|  |  | 
 |  |  |  | 
 |  |  |                 if (ds.Tables[0].Rows.Count == 0)//新增 | 
 |  |  |                 { | 
 |  |  |                     //主表 | 
 |  |  |                     oCN.RunProc(@"Insert Into Sc_QualityReportBillMain    | 
 |  |  | (HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate | 
 |  |  | ,HYear,HPeriod,HRemark,HMaker,HMakeDate | 
 |  |  | ,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo) | 
 |  |  |                     if (HResult== "微瑕品") | 
 |  |  |                     { | 
 |  |  |                         //主表 | 
 |  |  |                         oCN.RunProc(@"Insert Into Sc_QualityReportBillMain    | 
 |  |  |                     (HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate | 
 |  |  |                     ,HYear,HPeriod,HRemark,HMaker,HMakeDate | 
 |  |  |                     ,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo) | 
 |  |  |                         values('3717','3717-1',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + | 
 |  |  |                         "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" + | 
 |  |  |                         ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') "); | 
 |  |  |                         //重新给HResult赋值 | 
 |  |  |                         HResult = ""; | 
 |  |  |                     } | 
 |  |  |                     else | 
 |  |  |                     { | 
 |  |  |                         //主表 | 
 |  |  |                         oCN.RunProc(@"Insert Into Sc_QualityReportBillMain    | 
 |  |  |                     (HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate | 
 |  |  |                     ,HYear,HPeriod,HRemark,HMaker,HMakeDate | 
 |  |  |                     ,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo) | 
 |  |  |                         values('3717','3717',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + | 
 |  |  |                     "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" + | 
 |  |  |                     ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') "); | 
 |  |  |                         "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" + | 
 |  |  |                         ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') "); | 
 |  |  |                     } | 
 |  |  |                      | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |                 | 
 |  |  | 
 |  |  | (HInterID,HENTRYID,HBillNo_bak,HEmpID,HBarCode,HBadReasonID,HAddr,HMaker,HMakeDate | 
 |  |  | ,HMaterID,HUnitID,HRemark,HSourceID,HICMOInterID,HICMOEntryID,HICMOBillNo,HReportType | 
 |  |  | ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney | 
 |  |  | ,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo)  | 
 |  |  | ,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HProcID)  | 
 |  |  | values({HInterID},1,'{oSub.HBillNo_bak}',{oSub.HEmpID},'{oSub.HBarCode}',{oSub.HBadReasonID},'','{oSub.HMaker}','{oSub.HMakeDate}' | 
 |  |  | ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HICMOInterID},{oSub.HICMOEntryID},'{oSub.HICMOBillNo}',{oSub.HReportType} | 
 |  |  | ,0,0,'','',0,0 | 
 |  |  | ,0,'{HResult}',{oSub.HProcExchInterID},{oSub.HProcExchEntryID},'{oSub.HProcExchBillNo}')"); | 
 |  |  | ,1,'{HResult}',{oSub.HProcExchInterID},{oSub.HProcExchEntryID},'{oSub.HProcExchBillNo}',{oSub.HProcID})"); | 
 |  |  |  | 
 |  |  |             //修改条码表的状态 | 
 |  |  |             oCN.RunProc("update Gy_BarCodeBill set HStatus='"+ HResult + "' where HBarCode='"+ oSub.HBarCode + "'"); | 
 |  |  |  | 
 |  |  |             //修改出站单的 不良 报废数量 | 
 |  |  |             if (HResult == "不良") { | 
 |  |  |                 oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid); | 
 |  |  |             if (HResult == "不良" && (oSub.HBadTypeID == 3 || oSub.HBadTypeID == 4 || oSub.HBadTypeID == 6)) | 
 |  |  |             { | 
 |  |  |                 //工废 | 
 |  |  |                 if (oSub.HBadTypeID == 3) | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HWasterQty_Work+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid); | 
 |  |  |                 }//料废 | 
 |  |  |                 else if (oSub.HBadTypeID == 4) | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HWasterQty_Mater+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid); | 
 |  |  |                 }//返工 | 
 |  |  |                 else if (oSub.HBadTypeID == 6) | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HBackWorkQty+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |             else if (HResult == "报废") | 
 |  |  |             { | 
 |  |  | 
 |  |  |                 sMainStr = "[" + sMainStr + "]"; | 
 |  |  |                 List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(sMainStr); | 
 |  |  |  | 
 |  |  |                 ds = oCN.RunProcReturn("select  HCenterID from Sc_ProcessExchangeBillSub WITH(NOLOCK) where HInterID=" + list[0].HProcExchInterID + " and HEntryID=" + list[0].HProcExchEntryID, "Sc_ProcessExchangeBillSub"); | 
 |  |  |                 ds = oCN.RunProcReturn("select HCenterID from Sc_ProcessExchangeBillSub WITH(NOLOCK) where HInterID=" + list[0].HProcExchInterID + " and HEntryID=" + list[0].HProcExchEntryID, "Sc_ProcessExchangeBillSub"); | 
 |  |  |                 if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                 { | 
 |  |  |                     list[0].HCenterID = long.Parse(ds.Tables[0].Rows[0]["HCenterID"].ToString()); | 
 |  |  | 
 |  |  |                     ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" + | 
 |  |  |                         ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HShiftsID" + | 
 |  |  |                     ") " + | 
 |  |  |                     " values('" + BillType + "','"+ HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" + | 
 |  |  |                     " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" + | 
 |  |  |                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL + | 
 |  |  |                     "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + | 
 |  |  |                     ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID + | 
 |  |  | 
 |  |  |                         if (dataSet.Tables[0].Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             string HOutInterID = dataSet.Tables[0].Rows[0][0].ToString(); | 
 |  |  |  | 
 |  |  |                             oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1 where HInterID='" + HOutInterID + "'"); | 
 |  |  |                             //斯莫尔的情况 分 工废料废 返工 | 
 |  |  |                             //工废 | 
 |  |  |                             if (subLsit[0].HBadTypeID == 3) | 
 |  |  |                             { | 
 |  |  |                                 oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1,HWasterQty_Work-=1  where HInterID='" + HOutInterID + "'"); | 
 |  |  |                             }//料废 | 
 |  |  |                             else if (subLsit[0].HBadTypeID == 4) | 
 |  |  |                             { | 
 |  |  |                                 oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1,HWasterQty_Mater-=1 where HInterID='" + HOutInterID + "'"); | 
 |  |  |                             }//返工 | 
 |  |  |                             else if (subLsit[0].HBadTypeID == 6) | 
 |  |  |                             { | 
 |  |  |                                 oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1,HBackWorkQty-=1 where HInterID='" + HOutInterID + "'"); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                         else | 
 |  |  |                         { |