From 39ae42d5ea7c7bcd0d11156891a48e9a3fc917c4 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期二, 02 四月 2024 15:00:11 +0800
Subject: [PATCH] 出站单 计时

---
 WebAPI/Controllers/基础资料/工资基础资料/Gy_ProcPriceController.cs |  720 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 689 insertions(+), 31 deletions(-)

diff --git "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\267\245\350\265\204\345\237\272\347\241\200\350\265\204\346\226\231/Gy_ProcPriceController.cs" "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\267\245\350\265\204\345\237\272\347\241\200\350\265\204\346\226\231/Gy_ProcPriceController.cs"
index 37a8953..41c6377 100644
--- "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\267\245\350\265\204\345\237\272\347\241\200\350\265\204\346\226\231/Gy_ProcPriceController.cs"
+++ "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\267\245\350\265\204\345\237\272\347\241\200\350\265\204\346\226\231/Gy_ProcPriceController.cs"
@@ -1,11 +1,15 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
+using System.IO;
+using System.Web;
 using System.Web.Http;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
 using WebAPI.Models;
 namespace WebAPI.Controllers
 {
@@ -25,6 +29,7 @@
         {
             try
             {
+                List<object> columnNameList = new List<object>();
                 //鏌ョ湅鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log("Gy_ProcPriceList", 1, false, user))
                 {
@@ -35,7 +40,15 @@
                     return objJsonResult;
                 }
 
-                ds = oCN.RunProcReturn("select * from h_v_Gy_ProcPriceList where 1 = 1 " + sWhere, "h_v_Gy_ProcPriceList");
+                ds = oCN.RunProcReturn("select * from h_v_Gy_ProcPriceList where 1 = 1 " + sWhere + " order by 鍒跺崟鏃ユ湡 desc", "h_v_Gy_ProcPriceList");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
 
                 //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                 //{
@@ -43,6 +56,7 @@
                 objJsonResult.count = 1;
                 objJsonResult.Message = "Sucess锛�";
                 objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
                 return objJsonResult;
                 //}
                 //else
@@ -109,7 +123,7 @@
                         oSub.HMaterID = DBUtility.ClsPub.isLong(subList[i].HMaterIDCol);
                         oSub.HProcID = DBUtility.ClsPub.isLong(subList[i].HProcIDCol);
                         oSub.HSourceID = DBUtility.ClsPub.isLong(subList[i].HSourceIDCol);
-                        oSub.HPrice = DBUtility.ClsPub.isLong(subList[i].HPriceCol);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(subList[i].HPriceCol);
                         oSub.HBeginDate = DBUtility.ClsPub.isDate(subList[i].HBeginDateCol);
                         oSub.HEndDate = DBUtility.ClsPub.isDate(subList[i].HEndDateCol);
                         oSub.HCostFlag = DBUtility.ClsPub.GridToBool(subList[i].HCostFlagCol);
@@ -120,6 +134,17 @@
                         oSub.HMaker = DBUtility.ClsPub.isStrNull(mainList[0].HMaker);
                         oSub.HMakeDate = DateTime.Today.ToString();
                         oSub.HRemark = DBUtility.ClsPub.isStrNull(subList[i].HRemarkCol);
+                        oSub.HWorkCenterID = DBUtility.ClsPub.isLong(subList[i].HWorkCenterID);
+                        oSub.HWorkQty = DBUtility.ClsPub.isSingle(subList[i].HWorkQty); //灏忔椂浜ц兘
+                        oSub.HStdEmp = DBUtility.ClsPub.isSingle(subList[i].HStdEmp); //鏍囧噯浜哄姏
+                        oSub.HChangeTimes = DBUtility.ClsPub.isSingle(subList[i].HChangeTimes); //鎹㈢嚎鏃堕棿
+                        oSub.HChangeMoney = DBUtility.ClsPub.isSingle(subList[i].HChangeMoney); //鎹㈢嚎琛ヨ创
+                        oSub.HProcNo = DBUtility.ClsPub.isLong(subList[i].HProcNo); //宸ヨ壓璺嚎娴佹按鍙�
+                        oSub.HPieceTimes = DBUtility.ClsPub.isSingle(subList[i].HPieceTimes); //鍗曚欢鍔犲伐鏃堕棿锛堝瓧娈靛彲鑳藉凡缁忓瓨鍦ㄤ簡锛�
+                        oSub.HMouldQty = DBUtility.ClsPub.isSingle(subList[i].HMouldQty); //妯″叿鏁伴噺
+                        oSub.HChangeMouldMoney = DBUtility.ClsPub.isSingle(subList[i].HChangeMouldMoney); //鎹㈡ā琛ヨ创
+                        oSub.HRushQty = DBUtility.ClsPub.isSingle(subList[i].HRushQty); //鍗曚欢鍐叉娆℃暟
+
                         BillNew.DetailColl.Add(oSub);
                     }
                     else
@@ -177,36 +202,24 @@
         {
             try
             {
-                ds = oCN.RunProcReturn("select " +
-                    "a.HItemID,ltrim(a.HMaterID)+'-'+ltrim(a.HProcID) 宸ュ簭宸ヤ环璧勬枡浠g爜,a.HDeptID,b.HName HDeptName" +
-                    ",a.HMaterID HMaterIDCol,c.HNumber HMaterNumberCol,c.HName HMaterNameCol,c.HModel HMaterModelCol" +
-                    ",a.HProcID HProcIDCol,d.HNumber HProcNumberCol,d.HName HProcNameCol" +
-                    ",a.HSourceID HSourceIDCol,e.HNumber HSourceNumberCol,e.HName HSourceNameCol" +
-                    ",a.HPrice HPriceCol,a.HBeginDate HBeginDateCol,a.HEndDate HEndDateCol" +
-                    ",case when a.HCostFlag<>0 then 'true'else 'false'end HCostFlagCol" +
-                    ",case when a.HFlowFlag<>0 then 'true'else 'false'end HFlowFlagCol" +
-                    ",case when a.HPayFlag<>0 then 'true'else 'false'end HPayFlagCol,a.HRemark HRemarkCol " +
-                    " from Gy_ProcPrice a " +
-                    " left join Gy_Department b on a.HDeptID = b.HItemID " +
-                    " left join Gy_Material c on a.HMaterID = c.HItemID " +
-                    " left join Gy_Process d on a.HProcID = d.HItemID " +
-                    " left join Gy_Source e on a.HSourceID = e.HItemID where a.HItemID = " + HItemID, "Gy_ProcPrice");
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                List<object> columnNameList = new List<object>();
+
+                ds = oCN.RunProcReturn("select * from h_v_Gy_ProcPriceList where HItemID = " + HItemID, "h_v_Gy_ProcPriceList");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "false锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "Sucess锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
             }
             catch (Exception e)
             {
@@ -218,5 +231,650 @@
             }
         }
         #endregion
+
+        #region 宸ュ簭宸ヤ环 鍒犻櫎
+        [Route("Gy_ProcPrice/DelProcPrice")]
+        [HttpGet]
+        public object DelProcPrice(int HInterID, string User)
+        {
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_ProcPriceList_Delete", 1, false, User))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DAL.ClsGy_ProcPrice_Ctl BillNew = new DAL.ClsGy_ProcPrice_Ctl();
+                var sReturn = "";
+                if (BillNew.ShowBill(HInterID, ref sReturn))
+                {
+                    foreach (Model.ClsGy_ProcPrice_Model oSub in BillNew.DetailColl)
+                    {
+                        if (oSub.HChecker.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "褰撳墠鍗曟嵁涓嶈兘鍒犻櫎锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+
+
+                    bool flag = false;
+                    oCN.BeginTran();//寮�鍚簨鍔�
+
+                    flag= BillNew.DeleteByID(HInterID);
+
+                    oCN.Commit();//缁撴潫浜嬪姟
+
+                    if (flag)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎澶辫触锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                }
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "褰撳墠鍗曟嵁涓嶅瓨鍦�,鏃犳硶鍒犻櫎锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();//鍥炴粴浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region [宸ュ簭宸ヤ环瀹℃牳銆佸弽瀹℃牳]
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_ProcPrice/AuditGy_ProcPrice")]
+        [HttpGet]
+        public object AuditGy_ProcPrice(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_ProcPriceList_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                DBUtility.ClsPub.CurUserName = CurUserName;
+                DAL.ClsGy_ProcPrice_Ctl BillNew = new DAL.ClsGy_ProcPrice_Ctl();
+                var sReturn = "";
+                if (BillNew.ShowBill(HInterID, ref sReturn))
+                {
+                    foreach (Model.ClsGy_ProcPrice_Model oSub in BillNew.DetailColl)
+                    {
+                        if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                        {
+                            if (oSub.HChecker.Trim() != "")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+                        if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                        {
+                            if (oSub.HChecker.Trim() == "")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                foreach (Model.ClsGy_ProcPrice_Model oSub in BillNew.DetailColl)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        //瀹℃牳鎻愪氦
+                        if (BillNew.CheckBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                        {
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳鎴愬姛";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        //鍙嶅鏍告彁浜bandonCheck
+                        if (BillNew.AbandonCheck(HInterID, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                        {
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+        #region 缁存姢宸ヤ环鏃惰繑鍥炲伐鑹鸿矾绾夸俊鎭�
+        [Route("Gy_RoutingBill/EditPrice")]
+        [HttpGet]
+        public object EditPrice(string HMaterNumber)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                ds = oCN.RunProcReturn("exec Gy_RoutingBill_EditPrice '" + HMaterNumber + "'", "Gy_RoutingBill_EditPrice");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ュ簭宸ヤ环 鏂囦欢涓婁紶
+        [Route("Gy_ProcPrice/Gy_ProcPrice_Excel")]
+        [HttpPost]
+        public object Gy_ProcPrice_Excel()
+        {
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("HMaterID", typeof(Int32));//鐗╂枡ID
+                tb2.Columns.Add("HProcID", typeof(Int32));//宸ュ簭ID
+                tb2.Columns.Add("HSourceID", typeof(Int32));//鐢熶骇璧勬簮ID
+                tb2.Columns.Add("HWorkCenterID", typeof(Int32));//宸ヤ綔涓績ID
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {                       
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    //濡傛灉琛ㄦ牸绗琲琛岀殑绗竴鍒椾负绌猴紝鍒欏垽鏂负杩欎竴琛岀殑鏁版嵁涓虹┖锛岃烦鍑哄惊鐜苟涓斾笉鎶婃暟鎹啓鍏� tb2
+                    if (ExcelDs.Tables[0].Rows[i][0].ToString() == "")
+                    {
+                        continue;
+                    }
+                    else
+                    {
+                        tb2.Rows.Add(row);
+                    }                    
+                }
+
+                var error = "";
+
+                //鏌ヨ宸ュ簭宸ヤ环娌℃湁鐨勫垪
+                if (!tb2.Columns.Contains("鐗╂枡浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮墿鏂欎唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鐗╂枡鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愮墿鏂欏悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("瑙勬牸鍨嬪彿"))
+                    error += "娌℃湁鎵惧埌銆愯鏍煎瀷鍙枫�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ュ簭浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愬伐搴忎唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ュ簭鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愬伐搴忓悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鐢熶骇璧勬簮浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮敓浜ц祫婧愪唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鐢熶骇璧勬簮鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愮敓浜ц祫婧愬悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ヤ綔涓績浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愬伐浣滀腑蹇冧唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ヤ綔涓績鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愬伐浣滀腑蹇冨悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍗曚环"))
+                    error += "娌℃湁鎵惧埌銆愬崟浠枫�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("灏忔椂浜ц兘"))
+                    error += "娌℃湁鎵惧埌銆愬皬鏃朵骇鑳姐�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鏍囧噯浜哄姏"))
+                    error += "娌℃湁鎵惧埌銆愭爣鍑嗕汉鍔涖�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鎹㈢嚎鏃堕棿"))
+                    error += "娌℃湁鎵惧埌銆愭崲绾挎椂闂淬�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鎹㈢嚎琛ヨ创"))
+                    error += "娌℃湁鎵惧埌銆愭崲绾胯ˉ璐淬�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ヨ壓璺嚎娴佹按鍙�"))
+                    error += "娌℃湁鎵惧埌銆愬伐鑹鸿矾绾挎祦姘村彿銆戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍗曚欢鍔犲伐鏃堕棿"))
+                    error += "娌℃湁鎵惧埌銆愬崟浠跺姞宸ユ椂闂淬�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("妯″叿鏁伴噺"))
+                    error += "娌℃湁鎵惧埌銆愭ā鍏锋暟閲忋�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鎹㈡ā琛ヨ创"))
+                    error += "娌℃湁鎵惧埌銆愭崲妯¤ˉ璐淬�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍗曚欢鍐叉娆℃暟"))
+                    error += "娌℃湁鎵惧埌銆愬崟浠跺啿娆℃鏁般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("寮�濮嬫棩鏈�"))
+                    error += "娌℃湁鎵惧埌銆愬紑濮嬫棩鏈熴�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("缁撴潫鏃ユ湡"))
+                    error += "娌℃湁鎵惧埌銆愮粨鏉熸棩鏈熴�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鎴愭湰蹇呴��"))
+                    error += "娌℃湁鎵惧埌銆愭垚鏈繀閫夈�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("娴佽浆榛樿"))
+                    error += "娌℃湁鎵惧埌銆愭祦杞粯璁ゃ�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ヨ祫榛樿"))
+                    error += "娌℃湁鎵惧埌銆愬伐璧勯粯璁ゃ�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("澶囨敞"))
+                    error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string HMaterNumber = "";
+                    string HMaterName = "";
+                    string HMaterModel = "";
+                    string HProcNumber = "";
+                    string HProcName = "";
+                    string HSourceNumber = "";
+                    string HSourceName = "";
+                    decimal HPrice = 0;
+                    string HWorkCenterNumber = "";
+                    string HWorkCenterName = "";
+                    decimal HWorkQty = 0;
+                    decimal HStdEmp = 0;
+                    decimal HChangeTimes = 0;
+                    decimal HChangeMoney = 0;
+                    Int64 HProcNo = 0;
+                    decimal HPieceTimes = 0;
+                    decimal HMouldQty = 0;
+                    decimal HChangeMouldMoney = 0;
+                    decimal HRushQty = 0;
+                    string HBeginDate = System.DateTime.Now.ToString("G");
+                    string HEndDate = System.DateTime.Now.ToString("G");
+                    Int64 HCostFlag = 0;
+                    Int64 HFlowFlag = 0;
+                    Int64 HPayFlag = 0;
+                    string HRemark = "";
+
+                    HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString());
+                    HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString());
+                    HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勬牸鍨嬪彿"].ToString());
+                    HProcNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ュ簭浠g爜"].ToString());
+                    HProcName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ュ簭鍚嶇О"].ToString());
+                    HSourceNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢熶骇璧勬簮浠g爜"].ToString());
+                    HSourceName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢熶骇璧勬簮鍚嶇О"].ToString());
+                    HPrice = DBUtility.ClsPub.isLong(tb2.Rows[i]["鍗曚环"].ToString());
+                    HWorkCenterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ヤ綔涓績浠g爜"].ToString());
+                    HWorkCenterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ヤ綔涓績鍚嶇О"].ToString());
+                    HWorkQty = DBUtility.ClsPub.isLong(tb2.Rows[i]["灏忔椂浜ц兘"].ToString());
+                    HStdEmp = DBUtility.ClsPub.isLong(tb2.Rows[i]["鏍囧噯浜哄姏"].ToString());
+                    HChangeTimes = DBUtility.ClsPub.isLong(tb2.Rows[i]["鎹㈢嚎鏃堕棿"].ToString());
+                    HChangeMoney = DBUtility.ClsPub.isLong(tb2.Rows[i]["鎹㈢嚎琛ヨ创"].ToString());
+                    HProcNo = DBUtility.ClsPub.isLong(tb2.Rows[i]["宸ヨ壓璺嚎娴佹按鍙�"].ToString());
+                    HPieceTimes = DBUtility.ClsPub.isLong(tb2.Rows[i]["鍗曚欢鍔犲伐鏃堕棿"].ToString());
+                    HMouldQty = DBUtility.ClsPub.isLong(tb2.Rows[i]["妯″叿鏁伴噺"].ToString());
+                    HChangeMouldMoney = DBUtility.ClsPub.isLong(tb2.Rows[i]["鎹㈡ā琛ヨ创"].ToString());
+                    HRushQty = DBUtility.ClsPub.isLong(tb2.Rows[i]["鍗曚欢鍐叉娆℃暟"].ToString());
+                    HBeginDate = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["寮�濮嬫棩鏈�"].ToString());
+                    HEndDate = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁撴潫鏃ユ湡"].ToString());
+                    HCostFlag = DBUtility.ClsPub.isLong(tb2.Rows[i]["鎴愭湰蹇呴��"].ToString());
+                    HFlowFlag = DBUtility.ClsPub.isLong(tb2.Rows[i]["娴佽浆榛樿"].ToString());
+                    HPayFlag = DBUtility.ClsPub.isLong(tb2.Rows[i]["宸ヨ祫榛樿"].ToString());
+                    HRemark = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["澶囨敞"].ToString());                    
+
+                    //妫�鏌ヨ〃鏍兼暟鎹�
+                    int index = i + 1;
+
+                    if (HMaterNumber != "" && HMaterName != "")
+                    {
+
+
+                        //鏌ヨ鐗╂枡
+                        ds = oCN.RunProcReturn("select * from Gy_Material where  HNumber='" + HMaterNumber + "' and HName='" + HMaterName + "' and HModel ='" + HMaterModel + "'", "Gy_Material");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }                      
+
+                        //鏌ヨ宸ュ簭
+                        ds = oCN.RunProcReturn("select * from Gy_Process where  HNumber='" + HProcNumber + "'", "Gy_Process");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,宸ュ簭涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                        //鏌ヨ鐢熶骇璧勬簮
+                        ds = oCN.RunProcReturn("select * from Gy_Source where  HNumber='" + HSourceNumber + "'" , "Gy_Source");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐢熶骇璧勬簮涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                        //鏌ヨ宸ヤ綔涓績
+                        ds = oCN.RunProcReturn("select * from Gy_WorkCenter where  HNumber='" + HWorkCenterNumber + "'", "Gy_WorkCenter"); //
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,宸ヤ綔涓績涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HWorkCenterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                        //宸ュ簭浠g爜
+                        if (HProcNumber == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,宸ュ簭浠g爜涓嶈兘涓虹┖锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //鐢熶骇璧勬簮鍚嶇О
+                        if (HSourceName == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐢熶骇璧勬簮鍚嶇О涓嶈兘涓虹┖锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //宸ヤ綔涓績浠g爜
+                        if (HWorkCenterNumber == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,宸ヤ綔涓績浠g爜涓嶈兘涓虹┖锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡淇℃伅涓嶅叏锛堢墿鏂欎唬鐮侊紝鐗╂枡鍚嶇О锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ュ簭宸ヤ环 瀵煎叆(淇濆瓨)
+        [Route("Gy_ProcPrice/Gy_ProcPrice_btnSave")]
+        [HttpPost]
+        public object Gy_ProcPrice_btnSave([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_ProcPriceList_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                oCN.BeginTran();
+                int i = 1;
+                foreach (Dictionary<string, string> item in list)
+                {
+                    string HProcID = item["HProcID"].ToString();//宸ュ簭
+                    string HMaterID = item["HMaterID"].ToString();//鐗╂枡
+                    string HSourceID = item["HSourceID"].ToString();//鐢熶骇璧勬簮
+                    string HWorkCenterID = item["HWorkCenterID"].ToString();//宸ヤ綔涓績                    
+                    string HPrice = item["鍗曚环"].ToString();                  
+                    string HWorkQty = item["灏忔椂浜ц兘"].ToString();
+                    string HStdEmp = item["鏍囧噯浜哄姏"].ToString();
+                    string HChangeTimes = item["鎹㈢嚎鏃堕棿"].ToString();
+                    string HChangeMoney = item["鎹㈢嚎琛ヨ创"].ToString();
+                    string HProcNo = item["宸ヨ壓璺嚎娴佹按鍙�"].ToString();
+                    string HPieceTimes = item["鍗曚欢鍔犲伐鏃堕棿"].ToString();
+                    string HMouldQty = item["妯″叿鏁伴噺"].ToString();
+                    string HChangeMouldMoney = item["鎹㈡ā琛ヨ创"].ToString();
+                    string HRushQty = item["鍗曚欢鍐叉娆℃暟"].ToString();
+                    string HCostFlag = item["鎴愭湰蹇呴��"].ToString();
+                    string HFlowFlag = item["娴佽浆榛樿"].ToString();
+                    string HPayFlag = item["宸ヨ祫榛樿"].ToString();
+                    string HRemark = item["澶囨敞"].ToString();
+                    string HBeginDate = item["寮�濮嬫棩鏈�"].ToString();
+                    string HEndDate = item["缁撴潫鏃ユ湡"].ToString();
+
+                    string sql = "insert into Gy_ProcPrice(HMaterID,HProcID,HSourceID,HBeginDate,HEndDate,HCostFlag,HFlowFlag,HPayFlag,HDeptID,HWorkCenterID,HWorkQty,HStdEmp,HChangeTimes,HChangeMoney,HProcNo,HPieceTimes,HMouldQty,HChangeMouldMoney,HRushQty,HPrice,HStopflag,HRemark,HMaker,HMakeDate)" +
+                            $"values({HMaterID}, {HProcID},{HSourceID}, '{HBeginDate}', '{HEndDate}', '{(HCostFlag == "鏄�" ? 1 : 0)}', {(HFlowFlag == "鏄�" ? 1 : 0)},'{(HPayFlag == "鏄�" ? 1 : 0)}',{0},{HWorkCenterID},{HWorkQty},{HStdEmp},{HChangeTimes},{HChangeMoney},{HProcNo},{HPieceTimes},{HMouldQty},{HChangeMouldMoney},{HRushQty},{HPrice},{0},'{HRemark}','{user}','{System.DateTime.Now.ToString("G")}')";
+                    oCN.RunProc(sql);
+
+                    i++;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1