|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 == "报废") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HShiftsID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  * from Sc_StationOutBillMain a WITH(NOLOCK) left join  Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID where a.HInterID=" + HInterID + " and HBillNo='" + HBillNo + "' and CONVERT(varchar(10),HDate,20) ='" + DateTime.Now.ToString("yyyy-MM-dd") + "' ", "Sc_StationOutBillMain"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | { | 
|---|