| | |
| | | using DBUtility; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | { |
| | | try |
| | | { |
| | | List<object> a = new List<object>(); |
| | | //æ¥è¯¢æé |
| | | if (!DBUtility.ClsPub.Security_Log_second("JIT_ComplementGoodBill_Query", 1, false, user)) |
| | | { |
| | |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Gy_WorkWarehouseBillList where 1=1 " + sWhere + " order by hmainid desc ", "h_v_JIT_Gy_WorkWarehouseBillList"); |
| | | |
| | | foreach (DataColumn col in ds.Tables[0].Columns)//éådsä¸ç¬¬ä¸ä¸ªè¡¨ï¼Tables[0]ï¼çææåï¼Columnsï¼æ¯æ¬¡å¾ªç¯ä¸ï¼colåé伿æå½ååçå¼ç¨ |
| | | { |
| | | Type dataType = col.DataType; //è·åå½åæ°æ®ç±»åä¼ å
¥ èªå®ä¹åédatadataType |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //åç¬¦ä¸²æ¼æ¥ // å°åååæ°æ®ç±»åä¿¡æ¯æ¼æ¥æä¸ä¸ªJSONæ ¼å¼çå符串 |
| | | a.Add(JsonConvert.DeserializeObject(ColmString));//è·åå°DataColumnå对象çåå |
| | | } |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = a; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | |
| | | { |
| | | try |
| | | { |
| | | List<object> A = new List<object>(); |
| | | //æ¥è¯¢æé |
| | | if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanConfigBill_Query", 1, false, user)) |
| | | { |
| | |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanConfigBillList where 1=1 " + sWhere + " order by hmainid desc ", "h_v_JIT_Cg_PODemandPlanConfigBillList"); |
| | | |
| | | foreach (DataColumn col in ds.Tables[0].Columns)//éådsä¸ç¬¬ä¸ä¸ªè¡¨ï¼Tables[0]ï¼çææåï¼Columnsï¼æ¯æ¬¡å¾ªç¯ä¸ï¼colåé伿æå½ååçå¼ç¨ |
| | | { |
| | | Type dataType = col.DataType; //è·åå½åæ°æ®ç±»åä¼ å
¥ èªå®ä¹åédatadataType |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //åç¬¦ä¸²æ¼æ¥ // å°åååæ°æ®ç±»åä¿¡æ¯æ¼æ¥æä¸ä¸ªJSONæ ¼å¼çå符串 |
| | | A.Add(JsonConvert.DeserializeObject(ColmString));//è·åå°DataColumnå对象çåå |
| | | } |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = A; |
| | | |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (oSystemParameter.omodel.WMS_CampanyName != "å¸
å¨") |
| | | if (oSystemParameter.omodel.WMS_CampanyName != "å¸
å¨"&& oSystemParameter.omodel.WMS_CampanyName != "å®å·¥" && oSystemParameter.omodel.WMS_CampanyName != "ä¸å") |
| | | { |
| | | if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null) |
| | | { |
| | |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | //å¦æè¡¨æ ¼ç¬¬iè¡ç第ä¸å为空ï¼åå¤æä¸ºè¿ä¸è¡çæ°æ®ä¸ºç©ºï¼è·³åºå¾ªç¯å¹¶ä¸ä¸ææ°æ®åå
¥ tb2 |
| | | if (ExcelDs.Tables[0].Rows[i][0].ToString() == "") |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows.Add(row); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | string JIDLT = ""; //JITå°è´§åç½®æï¼å¤©ï¼ |
| | | string JIMLC = ""; //JITæå°èµ·éé |
| | | |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç»ç»ç¼ç "].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç»ç»ç¼ç "].ToString()).Replace("'", ""); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç»ç»"].ToString()); |
| | | HSupNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ä¾åºå代ç "].ToString()); |
| | | HSupNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ä¾åºå代ç "].ToString()).Replace("'", ""); |
| | | HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ä¾åºå"].ToString()); |
| | | HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString()); |
| | | HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString()).Replace("'", ""); |
| | | HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æåç§°"].ToString()); |
| | | HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["è§æ ¼åå·"].ToString()); |
| | | HUntilName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["计éåä½"].ToString()); |
| | |
| | | tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | //JITç©æåç±» |
| | | if (JITType == "") |
| | | string msg = ""; |
| | | oSystemParameter.ShowBill(ref msg); |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "å®å·¥"|| oSystemParameter.omodel.WMS_CampanyName == "ä¸å") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITç©æå类为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | //JITä¾è´§æåæï¼å¤©ï¼ |
| | | if (JISLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITä¾è´§æåæï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //JITæè´§ç»æµæ¹é |
| | | if (JIPEB == "") |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITæè´§ç»æµæ¹é为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //JITç©æåç±» |
| | | if (JITType == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITç©æå类为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITä¾è´§æåæï¼å¤©ï¼ |
| | | if (JISLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITä¾è´§æåæï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //JITæè´§ç»æµæ¹é |
| | | if (JIPEB == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITæè´§ç»æµæ¹é为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITå°è´§åç½®æï¼å¤©ï¼ |
| | | if (JIDLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITå°è´§åç½®æï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //JITä¾è´§æåæï¼å¤©ï¼ |
| | | if (JISLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITä¾è´§æåæï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITæå°èµ·éé |
| | | if (JIMLC == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITæå°èµ·éé为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //JITå°è´§åç½®æï¼å¤©ï¼ |
| | | if (JIDLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITå°è´§åç½®æï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //å®¡æ ¸ä»£ç æ¯å¦åç |
| | | if (!DBUtility.ClsPub.AllowNumber(HMaterNumer)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,ç©æä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //JITæå°èµ·éé |
| | | if (JIMLC == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITæå°èµ·éé为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //å®¡æ ¸ä»£ç æ¯å¦åç |
| | | if (!DBUtility.ClsPub.AllowNumber(HMaterNumer)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,ç©æä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,ç»ç»ä»£ç 为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo);//è·å¾ä¸ä¸ªæ°çid |
| | | string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo, true);//è·å¾ä¸ä¸ªæ°çåæ®å· |
| | | string HOrgID = item["HOrgID"].ToString();//ç»ç»ID |
| | | string HSupID = item["HSupID"].ToString();//ä¾åºå |
| | | string HSupplierName = item["ä¾åºå"].ToString(); |
| | | string HMaterID = item["HMaterID"].ToString();//ç©æID |
| | | string HOrgID = item["HOrgID"].ToString();//ç»ç»ID |
| | | string HSupplierName = item["ä¾åºå"].ToString(); |
| | | string HMaterName = item["ç©æåç§°"].ToString(); |
| | | string HMaterModel = item["è§æ ¼åå·"].ToString(); |
| | | string HUnitID = item["HUnitID"].ToString();//计éåä½ |
| | |
| | | string JIMLC = item["JITæå°èµ·éé"].ToString(); |
| | | string HRemark = item["夿³¨"].ToString(); |
| | | |
| | | |
| | | string sql = "insert into Cg_PODemandPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + |
| | | $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4611', '4611', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})"; |
| | | string sql1 = "insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," + |
| | | "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " + |
| | | "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl,HUnitID,HJITMinDeliveryQty)values" + |
| | | $"({HInterID}, 1, '{HRemark}', {(HSupID == "" ? "0" : HSupID)}, '{HSupplierName}', {(HMaterID == "" ? "0" : HMaterID)}," + |
| | | $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},{(JIPEB == "" ? "0" : JIPEB)},{(JITPBCC == "" ? "0" : JITPBCC)}," + |
| | | $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, '', {(JITDCD == "" ? "0" : JITDCD)} ,{HUnitID},{JIMLC})"; |
| | | LogService.Write("sql" + i + ":" + sql); |
| | | LogService.Write("sql1" + i + ":" + sql1); |
| | | //主表 |
| | | oCN.RunProc(sql); |
| | | //å表 |
| | | oCN.RunProc(sql1); |
| | | ds = oCN.RunProcReturn("select * from Cg_PODemandPlanConfigBillSub where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID, "Cg_PODemandPlanConfigBillSub"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | |
| | | long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo);//è·å¾ä¸ä¸ªæ°çid |
| | | string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo, true);//è·å¾ä¸ä¸ªæ°çåæ®å· |
| | | |
| | | |
| | | string sql = "insert into Cg_PODemandPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + |
| | | $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4611', '4611', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})"; |
| | | string sql1 = "insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," + |
| | | "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " + |
| | | "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl,HUnitID,HJITMinDeliveryQty)values" + |
| | | $"({HInterID}, 1, '{HRemark}', {(HSupID == "" ? "0" : HSupID)}, '{HSupplierName}', {(HMaterID == "" ? "0" : HMaterID)}," + |
| | | $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},{(JIPEB == "" ? "0" : JIPEB)},{(JITPBCC == "" ? "0" : JITPBCC)}," + |
| | | $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, '', {(JITDCD == "" ? "0" : JITDCD)} ,{HUnitID},{(JIMLC==""?"0": JIMLC)})"; |
| | | //主表 |
| | | oCN.RunProc(sql); |
| | | //å表 |
| | | oCN.RunProc(sql1); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc(" update Cg_PODemandPlanConfigBillSub set HLeadTime=" + JISLT + " where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | |
| | | |
| | | public json AddNeedBillSub(string msg3) |
| | | { |
| | | string Ret = ""; |
| | | omodelNeedsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JIT_NeedMaterPlanConfigBillSub>>(msg3); |
| | | |
| | | oSystemParameter.ShowBill(ref Ret); |
| | | foreach (Models.JIT_NeedMaterPlanConfigBillSub oSub in omodelNeedsub) |
| | | { |
| | | if (oSub.HWorkShopID == 0 || oSub.HWorkShopID == null) |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null) |
| | | if (oSystemParameter.omodel.WMS_CampanyName != "å®å·¥"&& oSystemParameter.omodel.WMS_CampanyName != "ä¸å") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = " JITéè´§æ§å¶å¤©æ°ä¸è½ä¸ºç©º"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = " JITéè´§æ§å¶å¤©æ°ä¸è½ä¸ºç©º"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | //å é¤å表 |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region ææè®¡åä¿¡æ¯ æä»¶ä¸ä¼ |
| | | [Route("Sc_JIT_ComplementGoodBill/Sc_JIT_ComplementGoodBill_Excel")] |
| | | [HttpPost] |
| | | public object Sc_JIT_ComplementGoodBill_Excel() |
| | | { |
| | | try |
| | | { |
| | | //var WorkBookName = HttpContext.Current.Request["WorkBookName"]; |
| | | //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]); |
| | | //è·åæä»¶åç§° |
| | | 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("HOrgID", typeof(Int32));//ç»ç»ID |
| | | tb2.Columns.Add("HWorkShopID", typeof(Int32));//ä¾åºå |
| | | tb2.Columns.Add("HMaterID", 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(); |
| | | } |
| | | //å¦æè¡¨æ ¼ç¬¬iè¡ç第ä¸å为空ï¼åå¤æä¸ºè¿ä¸è¡çæ°æ®ä¸ºç©ºï¼è·³åºå¾ªç¯å¹¶ä¸ä¸ææ°æ®åå
¥ tb2 |
| | | if (ExcelDs.Tables[0].Rows[i][0].ToString() == "") |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows.Add(row); |
| | | } |
| | | } |
| | | |
| | | |
| | | var 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("JITç©æåç±»")) |
| | | error += "æ²¡ææ¾å°ãJITç©æåç±»ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITæå¨å®å
¨åºåé")) |
| | | error += "æ²¡ææ¾å°ãJITæå¨å®å
¨åºåéãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITç©æéæ±ä¾è´§å¨æ")) |
| | | error += "æ²¡ææ¾å°ãJITç©æéæ±ä¾è´§å¨æãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITæè´§æ¹é")) |
| | | error += "æ²¡ææ¾å°ãJITæè´§æ¹éãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITæè´§æ¹é对åºå¨æï¼å¤©ï¼")) |
| | | error += "æ²¡ææ¾å°ãJITæè´§æ¹é对åºå¨æï¼å¤©ï¼ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITä¾è´§æåæï¼å¤©ï¼")) |
| | | error += "æ²¡ææ¾å°ãJITä¾è´§æåæï¼å¤©ï¼ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITå°è´§åç½®æï¼å¤©ï¼")) |
| | | error += "æ²¡ææ¾å°ãJITå°è´§åç½®æï¼å¤©ï¼ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITéè´§æ§å¶å¤©æ°")) |
| | | error += "æ²¡ææ¾å°ãJITéè´§æ§å¶å¤©æ°ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("JITéè´§æ¹å¼")) |
| | | error += "æ²¡ææ¾å°ãJITéè´§æ¹å¼ãçæ é¢,"; |
| | | |
| | | 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 HORGNumber = ""; |
| | | string HORGName = ""; |
| | | string HWorkShopNumer = ""; |
| | | string HWorkShopName = ""; |
| | | string HMaterNumer = ""; |
| | | string HMaterName = ""; |
| | | string HMaterModel = ""; |
| | | string HUntilName = ""; |
| | | |
| | | string JITType = "";//JITç©æåç±» |
| | | string JIPEB = ""; //JITæè´§ç»æµæ¹é |
| | | string JISLT = ""; //JITä¾è´§æåæï¼å¤©ï¼ |
| | | string JIDLT = ""; //JITå°è´§åç½®æï¼å¤©ï¼ |
| | | string JIMLC = ""; //JITæå°èµ·éé |
| | | |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç»ç»ç¼ç "].ToString()).Replace("'",""); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç»ç»"].ToString()); |
| | | HWorkShopNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["车é´ä»£ç "].ToString()).Replace("'", ""); |
| | | HWorkShopName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["车é´"].ToString()); |
| | | HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString()).Replace("'", ""); |
| | | HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æåç§°"].ToString()); |
| | | HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["è§æ ¼åå·"].ToString()); |
| | | |
| | | JITType = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JITç©æåç±»"].ToString()); |
| | | JIPEB = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JITæè´§æ¹é"].ToString()); |
| | | JISLT = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JITä¾è´§æåæï¼å¤©ï¼"].ToString()); |
| | | JIDLT = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JITå°è´§åç½®æï¼å¤©ï¼"].ToString()); |
| | | JIMLC = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JITéè´§æ¹å¼"].ToString()); |
| | | |
| | | //æ£æ¥ç©æ |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | |
| | | //æ¥è¯¢ç»ç» |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | 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]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | |
| | | |
| | | //æ¥è¯¢ä¾åºå |
| | | ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + HWorkShopNumer + "' and HUSEORGID=" + HORGid + "", "Gy_Department"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,该" + HORGName + "ç»ç»,车é´:" + HWorkShopName + ",ä¸åå¨ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HWorkShopID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | //æ¥è¯¢ç©æ |
| | | ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumer + "' and HUSEORGID=" + HORGid + "", "Gy_Material"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,该" + HORGName + "ç»ç»,ç©æ:" + HMaterName + ",ç©æä»£ç :" + HMaterNumer + ",ä¸åå¨ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | string msg = ""; |
| | | oSystemParameter.ShowBill(ref msg); |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "å®å·¥") |
| | | { |
| | | //JITä¾è´§æåæï¼å¤©ï¼ |
| | | if (JISLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITä¾è´§æåæï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITå°è´§åç½®æï¼å¤©ï¼ |
| | | if (JIDLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITå°è´§åç½®æï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //JITç©æåç±» |
| | | if (JITType == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITç©æå类为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITæè´§æ¹é |
| | | if (JIPEB == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITæè´§æ¹é为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITä¾è´§æåæï¼å¤©ï¼ |
| | | if (JISLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITä¾è´§æåæï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITå°è´§åç½®æï¼å¤©ï¼ |
| | | if (JIDLT == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITå°è´§åç½®æï¼å¤©ï¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //JITæå°èµ·éé |
| | | if (JIMLC == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,JITéè´§æ¹å¼ä¸ºç©ºï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //å®¡æ ¸ä»£ç æ¯å¦åç |
| | | if (!DBUtility.ClsPub.AllowNumber(HMaterNumer)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡,ç©æä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | 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("Sc_JIT_ComplementGoodBill/Sc_JIT_ComplementGoodBill_btnSave")] |
| | | [HttpPost] |
| | | public object Sc_JIT_ComplementGoodBill_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("JIT_NeedMaterPlanConfigBill_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 HWorkShopID = item["HWorkShopID"].ToString();//è½¦é´ |
| | | string HMaterID = item["HMaterID"].ToString();//ç©æID |
| | | string HOrgID = item["HOrgID"].ToString();//ç»ç»ID |
| | | string HWorkShopName = item["车é´"].ToString(); |
| | | string HMaterName = item["ç©æåç§°"].ToString(); |
| | | string HMaterModel = item["è§æ ¼åå·"].ToString(); |
| | | string JITType = item["JITç©æåç±»"].ToString(); |
| | | string JITPSL = item["JITæå¨å®å
¨åºåé"].ToString(); |
| | | string JITMDSC = item["JITç©æéæ±ä¾è´§å¨æ"].ToString(); |
| | | string JIPEB = item["JITæè´§æ¹é"].ToString(); |
| | | string JITPBCC = item["JITæè´§æ¹é对åºå¨æï¼å¤©ï¼"].ToString(); |
| | | string JISLT = item["JITä¾è´§æåæï¼å¤©ï¼"].ToString(); |
| | | string JIDLT = item["JITå°è´§åç½®æï¼å¤©ï¼"].ToString(); |
| | | string JITDCD = item["JITéè´§æ§å¶å¤©æ°"].ToString(); |
| | | string JIMLC = item["JITéè´§æ¹å¼"].ToString(); |
| | | string HRemark = item["夿³¨"].ToString(); |
| | | |
| | | ds = oCN.RunProcReturn("select * from JIT_NeedMaterPlanConfigBillSub where HMaterID=" + HMaterID + " and HWorkShopID=" + HWorkShopID, "JIT_NeedMaterPlanConfigBillSub"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | |
| | | long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4615", ref DBUtility.ClsPub.sExeReturnInfo);//è·å¾ä¸ä¸ªæ°çid |
| | | string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4615", ref DBUtility.ClsPub.sExeReturnInfo, true);//è·å¾ä¸ä¸ªæ°çåæ®å· |
| | | |
| | | |
| | | string sql = "insert into JIT_NeedMaterPlanConfigBillMain" + |
| | | "(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + |
| | | $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4615', '4615', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})"; |
| | | string sql1 = "insert into JIT_NeedMaterPlanConfigBillSub(HInterID,HEntryID,HRemark,HWorkShopID,HWorkShopName,HMaterID," + |
| | | "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " + |
| | | "HLeadTime, HLeadTime_Sec, HDeliveryDaysCtrl, HDeliveryMode) values" + |
| | | $"({HInterID}, 1, '{HRemark}', {(HWorkShopID == "" ? "0" : HWorkShopID)}, '{HWorkShopName}', {(HMaterID == "" ? "0" : HMaterID)}," + |
| | | $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},{(JIPEB == "" ? "0" : JIPEB)},{(JITPBCC == "" ? "0" : JITPBCC)}," + |
| | | $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, {(JITDCD == "" ? "0" : JITDCD)}, '{(JIMLC == "" ? "" : JIMLC)}')"; |
| | | |
| | | //主表 |
| | | oCN.RunProc(sql); |
| | | //å表 |
| | | oCN.RunProc(sql1); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc(" update JIT_NeedMaterPlanConfigBillMain set HLeadTime=" + JISLT + ",HLeadTime_Sec=" + JIDLT + " where HMaterID=" + HMaterID + " and HWorkShopID = " + HWorkShopID); |
| | | } |
| | | |
| | | 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 |
| | | #endregion |
| | | |
| | | |