|  |  | 
 |  |  | { | 
 |  |  |     public  class ClsSc_MESBeginWorkBill:DBUtility.ClsXt_BaseBill | 
 |  |  |     { | 
 |  |  |         public Model.ClsSc_MESBeginWorkBillMain omodel = new Model.ClsSc_MESBeginWorkBillMain(); | 
 |  |  |         public List<Model.ClsSc_MESBeginWorkBillSub> DetailColl = new List<Model.ClsSc_MESBeginWorkBillSub>(); | 
 |  |  |         public Models.ClsSc_MESBeginWorkBillMain omodel = new Models.ClsSc_MESBeginWorkBillMain(); | 
 |  |  |         public List<Models.ClsSc_MESBeginWorkBillSub> DetailColl = new List<Models.ClsSc_MESBeginWorkBillSub>(); | 
 |  |  |         //public List<Model.ClsSc_MESBeginWorkBillSub_Item> DetailColl1 = new List<Model.ClsSc_MESBeginWorkBillSub_Item>(); | 
 |  |  |         //获取系统参数 | 
 |  |  |         Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
 |  |  |         public ClsSc_MESBeginWorkBill() | 
 |  |  |         { | 
 |  |  |             base.MvarItemKeySub = "Sc_MESBeginWorkBillSub"; | 
 |  |  | 
 |  |  |                 //",HCheckDate='" + omodel.HCheckDate + "'" + | 
 |  |  |                 //",HMaker='" + omodel.HMaker + "'" + | 
 |  |  |                 //",HMakeDate='" + omodel.HMakeDate + "'" + | 
 |  |  |                 ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" + | 
 |  |  |                 ",HUpDater='" +omodel.HMaker + "'" + | 
 |  |  |                 ",HUpDateDate=getdate()" + | 
 |  |  |                 //",HCloseMan='" + omodel.HCloseMan + "'" + | 
 |  |  |                 //",HCloseDate='" + omodel.HCloseDate + "'" + | 
 |  |  | 
 |  |  |                 DeleteBillSub(lngBillKey); | 
 |  |  |                 //插入子表 | 
 |  |  |                 omodel.HInterID = lngBillKey; | 
 |  |  |                 foreach (Model.ClsSc_MESBeginWorkBillSub oSub in DetailColl) | 
 |  |  |                 foreach (Models.ClsSc_MESBeginWorkBillSub oSub in DetailColl) | 
 |  |  |                 { | 
 |  |  |                     //oCn.RunProc("Insert into Sc_MESBeginWorkBillSub " + | 
 |  |  |                     //  " (HInterID,HBillNo_bak,HEntryID,HCloseMan" + | 
 |  |  | 
 |  |  |                 //若MAINDI重复则重新获取 | 
 |  |  |                 oCn.BeginTran(); | 
 |  |  |                 //主表 | 
 |  |  |                 | 
 |  |  |                 oCn.RunProc("Insert Into Sc_MESBeginWorkBillMain " + | 
 |  |  |                 "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" + | 
 |  |  |                 ",HYear,HPeriod,HRemark" + | 
 |  |  |                 ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + | 
 |  |  |                 ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + | 
 |  |  |                 ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HBeginWorkTime,HSourceID" + | 
 |  |  |                 ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + | 
 |  |  |                 ",HSourceInterID_Main,HSourceEntryID_Main,HSourceBillNo_Main,HSourceBillType_Main" + | 
 |  |  |                 ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" + | 
 |  |  |                  ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + | 
 |  |  |                 ") " + | 
 |  |  |                 " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + ",getdate(),'" + DBUtility.ClsPub.CurUserName + "',getdate()" + | 
 |  |  |                 " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + ",getdate(),'" + omodel.HMaker+ "',getdate()" + | 
 |  |  |                 "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "'" + | 
 |  |  |                 "," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "'," + omodel.HProcPlanInterID.ToString() + "," + omodel.HProcPlanEntryID.ToString() + ",'" + omodel.HProcPlanBillNo + "'," + omodel.HProcExchInterID.ToString() + "," + omodel.HProcExchEntryID.ToString() + | 
 |  |  |                 "," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOEntryID + "','" + omodel.HICMOBillNo + "'," + omodel.HProcPlanInterID.ToString() + "," + omodel.HProcPlanEntryID.ToString() + ",'" + omodel.HProcPlanBillNo + "'," + omodel.HProcExchInterID.ToString() + "," + omodel.HProcExchEntryID.ToString() + | 
 |  |  |                 ",'" + omodel.HProcExchBillNo + "'," + omodel.HMaterID.ToString() + "," + omodel.HProcID.ToString() + "," + omodel.HICMOQty.ToString() + "," + omodel.HPlanQty.ToString() + ",getdate()," + omodel.HSourceID.ToString() + | 
 |  |  |                 ",'" + omodel.HMainSourceInterID.ToString() + "'," + omodel.HMainSourceEntryID.ToString() + ",'" + omodel.HMainSourceBillNo.ToString() + "','" + omodel.HMainSourceBillType.ToString() + "'" + | 
 |  |  |                 ",'" + omodel.HMainSourceInterID.ToString() + "'," + omodel.HMainSourceEntryID.ToString() + ",'" + omodel.HMainSourceBillNo.ToString() + "','" + omodel.HMainSourceBillType.ToString() + "'" + | 
 |  |  |                 "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HBarCodeMaker + "',getdate()" + | 
 |  |  |               ") "); | 
 |  |  |                 //插入子表 | 
 |  |  |                 foreach (Model.ClsSc_MESBeginWorkBillSub oSub in DetailColl) | 
 |  |  |                 { | 
 |  |  |                     //oCn.RunProc("Insert into Sc_MESBeginWorkBillSub " + | 
 |  |  |                     //  " (HInterID,HBillNo_bak,HEntryID,HCloseMan" + | 
 |  |  |                     //  ",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" + | 
 |  |  |                     //  ",HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + | 
 |  |  |                     //  ",HDotCheckItemID,HDotCheckItem,HDotCheckPart,HClaim,HManagerID" + | 
 |  |  |  | 
 |  |  |                     //  ") values(" | 
 |  |  |                     //  + omodel.HInterID.ToString() + ",'" + oSub.HBillNo_bak + "'," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "'" + | 
 |  |  |                     //  ",getdate()," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'," + oSub.HSourceInterID.ToString() + | 
 |  |  |                     //  "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() + | 
 |  |  |                     //  "," + oSub.HDotCheckItemID.ToString() + ",'" + oSub.HDotCheckItem + "','" + oSub.HDotCheckPart + "','" + oSub.HClaim + "'," + oSub.HManagerID.ToString() + | 
 |  |  |                     //  ") "); | 
 |  |  |                 } | 
 |  |  |                 //foreach (Model.ClsSc_MESBeginWorkBillSub_Item oSub2 in DetailColl1) | 
 |  |  |                 //{ | 
 |  |  |                 //    oCn.RunProc("Insert into Sc_MESBeginWorkBillSub_Item " + | 
 |  |  |                 //      " (HInterID,HBillNo_bak,HEntryID,HCloseMan" + | 
 |  |  |                 //      ",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" + | 
 |  |  |                 //      ",HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + | 
 |  |  |                 //      ",HMaintainItemID,HMaintainItem,HMaintainPart,HClaim,HManagerID" + | 
 |  |  |  | 
 |  |  |                 //      ") values(" | 
 |  |  |                 //      + omodel.HInterID.ToString() + ",'" + oSub2.HBillNo_bak + "'," + oSub2.HEntryID.ToString() + ",'" + oSub2.HCloseMan + "'" + | 
 |  |  |                 //      ",getdate()," + Convert.ToString(oSub2.HCloseType ? 1 : 0) + ",'" + oSub2.HRemark + "'," + oSub2.HSourceInterID.ToString() + | 
 |  |  |                 //      "," + oSub2.HSourceEntryID.ToString() + ",'" + oSub2.HSourceBillNo + "','" + oSub2.HSourceBillType + "'," + oSub2.HRelationQty.ToString() + "," + oSub2.HRelationMoney.ToString() + | 
 |  |  |                 //      "," + oSub2.HMaintainItemID.ToString() + ",'" + oSub2.HMaintainItem + "','" + oSub2.HMaintainPart + "','" + oSub2.HClaim + "'," + oSub2.HManagerID.ToString() + | 
 |  |  |                 //      ") "); | 
 |  |  |                 //} | 
 |  |  |                 // | 
 |  |  |                 //foreach (Model.ClsSc_MESBeginWorkBillSub oSub in DetailColl) | 
 |  |  |                 //{ | 
 |  |  |                 //    Ds = oCn.RunProcReturn("exec h_p_Sc_MESBeginWorkBill_Qty " + oSub.HICMOInterID, ""); | 
 |  |  |                 //    if (Ds.Tables[0].Rows.Count == 0) | 
 |  |  |                 //        return; | 
 |  |  |                 //    if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y") | 
 |  |  |                 //    { | 
 |  |  |                 //        sReturn = "汇报数量超过计划数量!不允许保存"; | 
 |  |  |                 //        return false; | 
 |  |  |                 //    } | 
 |  |  |                 //} | 
 |  |  |                 // | 
 |  |  |                 //根据开工单内码 设置 生产状态表 开工状态(先把 本资源全部工单 设置为非开工状态,再设置本单对应得源单 为开工状态) | 
 |  |  |                 oCn.RunProcReturn("exec h_p_JIT_MESBeginWorkBill_BeginWork @HInterId=" + omodel.HInterID + ",@flag='开工'", "h_p_JIT_MESBeginWorkBill_BeginWork"); | 
 |  |  |                 sReturn = "新增单据成功!"; | 
 |  |  |                 //系统参数  自动审核  | 
 |  |  |                 string AutoCheck = oSystemParameter.GetSingleSystemParameter("Sc_MESBeginWorkBill_AutoCheck",ref sReturn); | 
 |  |  |                 if (AutoCheck=="Y")  | 
 |  |  |                 { | 
 |  |  |                     //审核单据 | 
 |  |  |                     oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='2', HChecker='" + omodel.HMaker + "',HCheckDate=getdate() Where HInterID=" + omodel.HInterID.ToString()); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 oCn.Commit(); | 
 |  |  |                 return true; | 
 |  |  |             } | 
 |  |  | 
 |  |  |                 DetailColl.Clear();//清空 | 
 |  |  |                 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) | 
 |  |  |                 { | 
 |  |  |                     Model.ClsSc_MESBeginWorkBillSub oSub = new Model.ClsSc_MESBeginWorkBillSub(); | 
 |  |  |                     Models.ClsSc_MESBeginWorkBillSub oSub = new Models.ClsSc_MESBeginWorkBillSub(); | 
 |  |  |                     // 固定赋值=============================================== | 
 |  |  |                     //oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]); | 
 |  |  |                     //oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]); | 
 |  |  | 
 |  |  |             { | 
 |  |  |                 string HChecker = DBUtility.ClsPub.CurUserName; | 
 |  |  |                 string HCheckDate = DBUtility.ClsPub.GetServerDate(-1); | 
 |  |  |                 oCn.RunProc(" Update " + MvarItemKey + " set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString()); | 
 |  |  |                 oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='2',HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString()); | 
 |  |  |                 //生成调拨单 | 
 |  |  |                 //得到调拨单 mainid 单据号 | 
 |  |  |                 //long NewInterID = DBUtility.ClsPub.CreateBillID("1207", ref DBUtility.ClsPub.sExeReturnInfo); |