|  |  | 
 |  |  |                 omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                 //若MAINDI重复则重新获取 | 
 |  |  |                 oCn.BeginTran(); | 
 |  |  |                 //主表 | 
 |  |  |                 DataSet ds; | 
 |  |  |  | 
 |  |  |                 //保存前控制========================================= | 
 |  |  |                 ds = oCn.RunProcReturn("exec h_p_Sc_ICMOBillWorkQtyStatus_BeforeSaveCtrl " + omodel.HInterID + "," + omodel.HSourceInterID + "," + omodel.HSourceEntryID + ",'" + omodel.HSourceBillNo + "'", "h_p_Sc_ICMOBillWorkQtyStatus_BeforeSaveCtrl"); | 
 |  |  |  | 
 |  |  |                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "1") | 
 |  |  |                 { | 
 |  |  |                     sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); | 
 |  |  |                     oCn.RollBack(); | 
 |  |  |                     return false; | 
 |  |  |                 } | 
 |  |  |                 //========================================================= | 
 |  |  |  | 
 |  |  |                 //主表 | 
 |  |  |                 oCn.RunProc("Insert Into Sc_ICMOBillWorkQtyStatus_Tmp   " +    | 
 |  |  |                "(HInterID,HBillType,HSourceID,HReportType,HPieceQty" + | 
 |  |  |                ",HMaterID,HGroupID,HWorkManID,HWorkReportDate,HDate" + | 
 |  |  |                ",HBillSubType,HBillNo,HICMOInterID,HICMOEntryID,HICMOBillNo" + | 
 |  |  |                ",HQty,HBadQty,HWasterQty,HBarCode,HAddr,HMaker,HMakeDate" + | 
 |  |  |                ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSplitNO,HSourceBillType" + | 
 |  |  |                ",HRelationInterID,HRelationEntryID,HRelationBillNo,HReportEntryID" + | 
 |  |  |                ") " + | 
 |  |  |                ",HRelationInterID,HRelationEntryID,HRelationBillNo,HReportEntryID,HBillStatus" + | 
 |  |  |                ",HICMOReportInterID) " + | 
 |  |  |                 " values(" + omodel.HInterID.ToString() + ",'" + BillType + "'," + omodel.HSourceID.ToString() + "," + omodel.HReportType.ToString() + "," + omodel.HPieceQty.ToString() + | 
 |  |  |                 "," + omodel.HMaterID.ToString() + ",'" + omodel.HGroupID + "','" + omodel.HWorkManID + "','" + omodel.HWorkReportDate + "','" + omodel.HDate + "'" + | 
 |  |  |                 ",'" + omodel.HBillSubType.ToString() + "','" + omodel.HBillNo + "','" + omodel.HICMOInterID + "','" + omodel.HICMOEntryID + "','" + omodel.HICMOBillNo + "'" + | 
 |  |  |                 "," + omodel.HQty.ToString() + "," + omodel.HBadQty.ToString() + "," + omodel.HWasterQty.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HMaker+ "','" + omodel.HMakeDate + "'" + | 
 |  |  |                 "," + omodel.HSourceInterID.ToString() + "," + omodel.HSourceEntryID.ToString() + ",'" + omodel.HSourceBillNo + "','" + omodel.HSplitNO + "','" + omodel.HSourceBillType + "'" + | 
 |  |  |                 "," + omodel.HRelationInterID.ToString() + "," + omodel.HRelationEntryID.ToString() + ",'" + omodel.HRelationBillNo + "'," + omodel.HReportEntryID.ToString() +  | 
 |  |  |                 ") "); | 
 |  |  |                 "," + omodel.HRelationInterID.ToString() + "," + omodel.HRelationEntryID.ToString() + ",'" + omodel.HRelationBillNo + "'," + omodel.HReportEntryID.ToString() + "," + omodel.HBillStatus.ToString() + | 
 |  |  |                 ",'"+ omodel.HSourceInterID.ToString() + "') "); | 
 |  |  |                 double sumqty = omodel.HQty + omodel.HBadQty + omodel.HWasterQty;  //汇报数量+不良+报废 | 
 |  |  |                 //回写生产状态临时表Sc_ICMOBillStatus_Tmp拆分汇报数量 HSplitRelationQty | 
 |  |  |                 oCn.RunProc("update Sc_ICMOBillStatus_Tmp set HSplitRelationQty=HSplitRelationQty+"+ sumqty + "  where HICMOBillNo='"+omodel.HICMOBillNo+"'  and HSourceID='"+omodel.HSourceID+"' and  HICMOInterID='"+omodel.HICMOInterID+"' and HICMOEntryID='"+omodel.HICMOEntryID+"'"); | 
 |  |  |                 oCn.RunProc("update Sc_ICMOBillStatus_Tmp set HSplitRelationQty=HSplitRelationQty+" + sumqty + "  where HICMOBillNo='" + omodel.HICMOBillNo + "'  and HSourceID='" + omodel.HSourceID + "' and  HICMOInterID='" + omodel.HICMOInterID + "' and HICMOEntryID='" + omodel.HICMOEntryID + "' and HInterID="+ omodel.HSourceInterID.ToString()); | 
 |  |  |  | 
 |  |  |                 //再次验证 保存是否 合理 | 
 |  |  |                 DataSet ds = oCn.RunProcReturn("exec h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl @HInterId=" + omodel.HInterID + "", "h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl"); | 
 |  |  |                 ds = oCn.RunProcReturn("exec h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl @HInterId=" + omodel.HInterID + "", "h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl"); | 
 |  |  |                 if (ds == null || ds.Tables[0].Rows.Count <= 0) | 
 |  |  |                 { | 
 |  |  |                     sReturn = "无验证数据!"; | 
 |  |  | 
 |  |  |                     return false; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //保存后控制========================================= | 
 |  |  |                 ds = oCn.RunProcReturn("exec h_p_Sc_ICMOBillWorkQtyStatus_AfterSaveCtrl " + omodel.HInterID + "," + omodel.HSourceInterID + "," + omodel.HSourceEntryID + ",'" + omodel.HSourceBillNo + "'", "h_p_Sc_ICMOBillWorkQtyStatus_BeforeSaveCtrl"); | 
 |  |  |  | 
 |  |  |                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "1") | 
 |  |  |                 { | 
 |  |  |                     sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); | 
 |  |  |                     oCn.RollBack(); | 
 |  |  |                     return false; | 
 |  |  |                 } | 
 |  |  |                 //========================================================= | 
 |  |  |  | 
 |  |  |                 sReturn = omodel.HInterID.ToString(); | 
 |  |  |  | 
 |  |  | 
 |  |  |                 //更新生产状态临时状态表数量 | 
 |  |  |                 //oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToICMOReport_Qty " + HICMOInterID.ToString() + "," + HICMOEntryID.ToString() + ""); | 
 |  |  |                 //根据源单主内码 设置 生产状态表 完工状态(设置本单对应得源单 为完工状态) 更新生产状态临时状态表数量 | 
 |  |  |                 oCn.RunProc("exec h_p_JIT_ICMOBillWorkQtyStatus_AddRelation " + HSourceID.ToString() + "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "',"+ HICMOInterID.ToString() + ","+ HICMOEntryID.ToString()+ ""); | 
 |  |  |                 oCn.RunProc("exec h_p_JIT_ICMOBillWorkQtyStatus_AddRelation " + HSourceID.ToString() + "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "'," + HICMOInterID.ToString() + "," + HICMOEntryID.ToString() + ""); | 
 |  |  |                 sReturn = "审核单据成功!"; | 
 |  |  |                 oCn.Commit(); | 
 |  |  |                 //生成调拨单 |