|  |  | 
 |  |  |                 tb2.Columns.Add("åæ®å·", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("HWorkShopID", typeof(Int32));//çäº§è½¦é´ | 
 |  |  |                 tb2.Columns.Add("HEmpID", typeof(Int32));//èå | 
 |  |  |                 tb2.Columns.Add("åå·¥", typeof(string));//èå | 
 |  |  |                 tb2.Columns.Add("HUnitID", typeof(Int32));//计éåä½ | 
 |  |  |                 tb2.Columns.Add("HSourceID", typeof(Int32));//çäº§èµæºid | 
 |  |  |                 tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));//ç产订å主id | 
 |  |  |                 tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));//ç产订ååid | 
 |  |  |                 tb2.Columns.Add("HProdORGID", typeof(Int32));//ç»ç»id | 
 |  |  |                 tb2.Columns.Add("HSeOrderBillNo", typeof(string));//éå®è®¢åå· | 
 |  |  |  | 
 |  |  |                 //æ·»å æ°æ® | 
 |  |  |                 for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) | 
 |  |  | 
 |  |  |                     ds = oCN.RunProcReturn(sql1, "h_v_IF_ICMOBillList"); | 
 |  |  |  | 
 |  |  |                     if (ds.Tables[0].Rows.Count == 0) | 
 |  |  |                     { | 
 |  |  |                         error += $"没æç产订åä¿¡æ¯ï¼ç产订åå·:{ tb2.Rows[i]["ç产订åå·*"].ToString()},ç产车é´ç¼ç :{tb2.Rows[i]["ç产车é´ç¼ç *"].ToString()}" + | 
 |  |  |                             $",ç产订åæç»è¡å·:{ tb2.Rows[i]["ç产订åæç»è¡å·*"].ToString()},ç©æç¼ç :{ tb2.Rows[i]["ç©æç¼ç *"].ToString()}"; | 
 |  |  |                                $",ç产订åæç»è¡å·:{ tb2.Rows[i]["ç产订åæç»è¡å·*"].ToString()},ç©æç¼ç :{ tb2.Rows[i]["ç©æç¼ç *"].ToString()}"; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (error.Length > 0) | 
 |  |  |                     { | 
 |  |  | 
 |  |  |                         tb2.Rows[i]["ICMOBillHInterID"] = ds.Tables[0].Rows[0]["hmainid"].ToString();//ç产订å主id | 
 |  |  |                         tb2.Rows[i]["ICMOBillHEntryID"] = ds.Tables[0].Rows[0]["HEntryID"].ToString();//ç产订ååid | 
 |  |  |                         tb2.Rows[i]["çäº§è®¢åæ°é"] = ds.Tables[0].Rows[0]["ç产任å¡åæ°é"].ToString();//çäº§è®¢åæ°é | 
 |  |  |                         tb2.Rows[i]["HSeOrderBillNo"] = ds.Tables[0].Rows[0]["éå®è®¢åå·"].ToString();//éå®è®¢åå· | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     ds = oCN.RunProcReturn("select * from h_v_JIT_Sc_WorkBillSortBillList " + | 
 |  |  | 
 |  |  |                         tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HSourceID"].ToString(); | 
 |  |  |                         tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HEmpID"].ToString(); | 
 |  |  |                         tb2.Rows[i]["åå·¥ç¼ç "] = ds.Tables[0].Rows[0]["èå代ç "].ToString(); | 
 |  |  |                         tb2.Rows[i]["åå·¥"] = ds.Tables[0].Rows[0]["èå"].ToString(); | 
 |  |  |                         tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HUnitID"].ToString(); | 
 |  |  |                         tb2.Rows[i]["计éåä½"] = ds.Tables[0].Rows[0]["计éåä½"].ToString(); | 
 |  |  |                         tb2.Rows[i]["æ¹æ¬¡å·"] = ds.Tables[0].Rows[0]["æ¹æ¬¡"].ToString(); | 
 |  |  | 
 |  |  |                     { | 
 |  |  |                         //åå·¥ | 
 |  |  |                         ds = oCN.RunProcReturn($"select * from Gy_Employee  where HNumber='{tb2.Rows[i]["åå·¥ç¼ç "].ToString()}'", "Gy_Employee"); | 
 |  |  |                         if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                             tb2.Rows[i]["åå·¥ç¼ç "] = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
 |  |  |                         if (ds.Tables[0].Rows.Count > 0) { | 
 |  |  |                             tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
 |  |  |                             tb2.Rows[i]["åå·¥"] = ds.Tables[0].Rows[0]["HName"].ToString(); | 
 |  |  |                         } | 
 |  |  |                         else | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = $"第{i + 1}è¡,åå·¥æ¥æ æ°æ®!"; | 
 |  |  |                             objJsonResult.data = tb2; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         //计éåä½ | 
 |  |  |                         ds = oCN.RunProcReturn($"select * from Gy_Unit  where HNumber='{tb2.Rows[i]["计éåä½"].ToString()}'", "Gy_Unit"); | 
 |  |  |                         if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
 |  |  |                         } | 
 |  |  |                         else | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = $"第{i + 1}è¡,计éå使¥æ æ°æ®!"; | 
 |  |  |                             objJsonResult.data = tb2; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         //çäº§èµæº | 
 |  |  |                         ds = oCN.RunProcReturn($"select * from Gy_Source  where HNumber='{tb2.Rows[i]["çäº§èµæºç¼ç *"].ToString()}'", "Gy_Source"); | 
 |  |  |                         if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
 |  |  |                         } | 
 |  |  |                         else { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = $"第{i+1}è¡,çäº§èµæºæ¥æ æ°æ®!"; | 
 |  |  |                             objJsonResult.data = tb2; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     //ç»ç» | 
 |  |  |                     ds = oCN.RunProcReturn($"select * from Xt_ORGANIZATIONS  where HNumber='{tb2.Rows[i]["ç»ç»ç¼ç *"].ToString()}'", "Xt_ORGANIZATIONS"); | 
 |  |  |                     if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                     { | 
 |  |  |                         tb2.Rows[i]["HProdORGID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
 |  |  |                     } | 
 |  |  |                     else | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = $"第{i + 1}è¡,ç»ç»æ¥æ æ°æ®!"; | 
 |  |  |                         objJsonResult.data = tb2; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                | 
 |  |  |                 int TrueCount = 0, SumCount = 0; | 
 |  |  |                  | 
 |  |  |  | 
 |  |  |                 for (int i = 0; i < list.Count; i++) | 
 |  |  |                 { | 
 |  |  |                     int TrueCount = 0, SumCount = 0; | 
 |  |  |                     long HInterID = 0; | 
 |  |  |                     var HBillNo = ""; | 
 |  |  |                     if (list[i]["åæ®å·"].ToString() == "" && list[i]["hmainid"].ToString() == "") | 
 |  |  | 
 |  |  |                         HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//è·å¾ä¸ä¸ªæ°çid | 
 |  |  |                         var HICMOBillNo = list[i]["ç产订åå·*"].ToString(); | 
 |  |  |                         var HICMOEntrySEQ = list[i]["ç产订åæç»è¡å·*"].ToString(); | 
 |  |  |                         var HProdORGID = list[i]["ç»ç»ç¼ç *"].ToString(); | 
 |  |  |                         var HProdORGID = list[i]["HProdORGID"].ToString(); | 
 |  |  |                         var HWorkShopID = list[i]["HWorkShopID"].ToString(); | 
 |  |  |                         var HSourceID = list[i]["HSourceID"].ToString(); | 
 |  |  |                         var HYX = list[i]["ä¼å
级"].ToString(); | 
 |  |  | 
 |  |  |                         var HDate = omdelMian.HDate; | 
 |  |  |                         var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString(); | 
 |  |  |                         var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString(); | 
 |  |  |                         var HSeOrderBillNo = list[i]["HSeOrderBillNo"].ToString(); | 
 |  |  |  | 
 |  |  |                         ds = oCN.RunProcReturn($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" + | 
 |  |  |                           $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain"); | 
 |  |  |                         string sql = $"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" + | 
 |  |  |                           $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}"; | 
 |  |  |                         LogService.Write("sql:" + sql); | 
 |  |  |                         ds = oCN.RunProcReturn(sql, "Sc_WorkBillSortBillMain"); | 
 |  |  |                         if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  | 
 |  |  |                             "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX, HEmpID," + | 
 |  |  |                             " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," + | 
 |  |  |                             " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," + | 
 |  |  |                             "HMainSourceInterID,HMainSourceEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec)values" + | 
 |  |  |                             "HMainSourceInterID,HMainSourceEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" + | 
 |  |  |                             ",HSeOrderBillNo)values" + | 
 |  |  |                             $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," + | 
 |  |  |                             $"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," + | 
 |  |  |                             $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," + | 
 |  |  |                             $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," + | 
 |  |  |                             $" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," + | 
 |  |  |                             $" {HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID})"); | 
 |  |  |                             $" {HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" + | 
 |  |  |                             $",'{HSeOrderBillNo}')"); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     int SumDay = 31; //卿䏤æä¹å·® DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days; | 
 |  |  |  | 
 |  |  |                     for (int j = 0; j < SumDay; j++) | 
 |  |  |                     { | 
 |  |  |                         LogService.Write("1:" + list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString()); | 
 |  |  |                         LogService.Write("2:" + DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")); | 
 |  |  |                         //主表åè¡¨é½ææ°æ® | 
 |  |  |                         if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "") | 
 |  |  |                         { | 
 |  |  | 
 |  |  |                             objJsonResult = AddBillSub(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     if (TrueCount != SumCount) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = objJsonResult.Message; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (TrueCount != SumCount) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = objJsonResult.Message; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  | 
 |  |  |         { | 
 |  |  |             //è·åè¡¨æ ¼æ°æ® | 
 |  |  |             ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList where åæ®å·='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList"); | 
 |  |  |  | 
 |  |  |             int count = 0; | 
 |  |  |             if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |             { |