| using System; | 
| using System.Collections.Generic; | 
| using System.Text; | 
| using System.Data; | 
|   | 
| namespace DAL | 
| { | 
|     public  class ClsSc_WorkBillMonthSortBill:DBUtility.ClsXt_BaseBill | 
|     { | 
|         public long HRelationInterID; | 
|         public Model.ClsSc_WorkBillMonthSortBillMain omodel = new Model.ClsSc_WorkBillMonthSortBillMain(); | 
|         public List<Model.ClsSc_WorkBillMonthSortBillMain> MainColl = new List<Model.ClsSc_WorkBillMonthSortBillMain>(); | 
|         public List<Model.ClsSc_WorkBillMonthSortBillSub> DetailColl = new List<Model.ClsSc_WorkBillMonthSortBillSub>(); | 
|         public List<Model.ClsSc_WorkBillMonthSortBillMain> MainICMOColl = new List<Model.ClsSc_WorkBillMonthSortBillMain>(); | 
|   | 
|         public ClsSc_WorkBillMonthSortBill() | 
|         { | 
|             base.MvarItemKeySub = "Sc_WorkBillMonthSortBillSub"; | 
|             base.MvarItemKeySub2 = ""; | 
|             base.MvarItemKeySub3 = ""; | 
|             base.MvarItemKeySub4 = ""; | 
|             base.MvarItemKey="Sc_WorkBillMonthSortBillMain"; | 
|             base.MvarReportTitle="主生产计划预测"; | 
|             base.BillType = "3703"; | 
|             base.HBillSubType = " "; | 
|   | 
|         } | 
|   | 
|         #region 固定代码 | 
|   | 
|         ~ClsSc_WorkBillMonthSortBill() | 
|         { | 
|             DetailColl = null; | 
|         } | 
|         | 
|         #endregion   自定义方法 | 
|         //修改单据 | 
|         public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             {  | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|         //新增单据 | 
|         public bool AddBill(Int64 sDeptID, Int64 HRelationInterID, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //得到mainid  | 
|                 //若MAINDI重复则重新获取 | 
|                 Int64 MainID = 0; | 
|                 oCn.BeginTran(); | 
|                 //按部门删除 | 
|                 //oCn.RunProc("update Sc_ICMOSortBillMain set HDeleteMan='System',HDeleteDate=getdate()  where HDeleteMan='' and  HDeptID=" + sDeptID.ToString()); | 
|                 // | 
|                 foreach (Model.ClsSc_WorkBillMonthSortBillMain oModel in MainColl) | 
|                 { | 
|                     //主表 | 
|                     oCn.RunProc("Insert Into Sc_WorkBillMonthSortBillMain   " + | 
|                     "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate" + | 
|                     ",HYear,HPeriod,HRemark,HICMOStatus,HDeptID,HDeptNumber" + | 
|                     ",HMaterID,HMaterNumber,HSourceID,HSourceNumber" + | 
|                     ",HUnitID,HUnitNumber,HWorkerID,HWorkerNumber" + | 
|                     ",HGroupID,HGroupNumber,HYX,HWorkQty,HWorkTimes,HReadyQty" + | 
|                     ",HPlanBeginDate,HPlanEndDate,HLastBeginDate,HLastEndDate" + | 
|                     ",HPlanQty,HProcID,HProdTimes,HRelationQty,HKTQ" + | 
|                     ",HOrderNeedQty,HReadyTimes,HSourceInterID,HSourceEntryID" + | 
|                     ",HSourceBillNo,HSourceBillType,HICMOInterID,HICMOBillNo" + | 
|                     ",HOrderCommitDate,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo" + | 
|                     ",HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HRelationInterID" + | 
|                     ",HSplitPlanQty,HSplitRelationQty,HSplitNO,HLocked,HSourceQty" + | 
|                     ") " + | 
|                     " values('" + this.BillType + "','" + this.HBillSubType + "'," + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HDate + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" + | 
|                     "," + oModel.HYear.ToString() + "," + oModel.HPeriod.ToString() + ",'" + oModel.HRemark + "'," + oModel.HICMOStatus.ToString() + "," + oModel.HDeptID.ToString() + ",'" + oModel.HDeptNumber + "'" + | 
|                     "," + oModel.HMaterID.ToString() + ",'" + oModel.HMaterNumber + "'," + oModel.HSourceID.ToString() + ",'" + oModel.HSourceNumber + "'" + | 
|                     "," + oModel.HUnitID.ToString() + ",'" + oModel.HUnitNumber + "'," + oModel.HWorkerID.ToString() + ",'" + oModel.HWorkerNumber + "'" + | 
|                     "," + oModel.HGroupID.ToString() + ",'" + oModel.HGroupNumber + "'," + oModel.HYX.ToString() + "," + oModel.HWorkQty.ToString() + "," + oModel.HWorkTimes.ToString() + "," + oModel.HReadyQty.ToString() + | 
|                     ",'" + oModel.HPlanBeginDate.ToShortDateString() + "','" + oModel.HPlanEndDate.ToShortDateString() + "','" + oModel.HLastBeginDate.ToShortDateString() + "','" + oModel.HLastEndDate.ToShortDateString() + "'" + | 
|                     "," + oModel.HPlanQty.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HProdTimes.ToString() + "," + oModel.HRelationQty.ToString() + "," + Convert.ToString(oModel.HKTQ ? 1 : 0) + | 
|                     "," + oModel.HOrderNeedQty.ToString() + "," + oModel.HReadyTimes.ToString() + "," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + | 
|                     ",'" + oModel.HSourceBillNo + "','" + oModel.HSourceBillType + "'," + oModel.HICMOInterID.ToString() + ",'" + oModel.HICMOBillNo + "'" + | 
|                     ",'" + oModel.HOrderCommitDate.ToShortDateString() + "'," + oModel.HProcPlanInterID.ToString() + "," + oModel.HProcPlanEntryID.ToString() + ",'" + oModel.HProcPlanBillNo + "'" + | 
|                     ",'" + oModel.HSeOrderBillNo + "'," + oModel.HSeOrderInterID.ToString() + "," + oModel.HSeOrderEntryID.ToString() + "," + HRelationInterID.ToString() + | 
|                     "," + oModel.HSplitPlanQty.ToString() + "," + oModel.HSplitRelationQty.ToString() + ",'" + oModel.HSplitNO + "'," + Convert.ToString(oModel.HLocked ? 1 : 0) + "," + oModel.HSourceQty.ToString() + | 
|                     ") "); | 
|                     MainID = oModel.HInterID; | 
|   | 
|                     //插入子表 | 
|                     foreach (Model.ClsSc_WorkBillMonthSortBillSub oSub in DetailColl) | 
|                     { | 
|                         oCn.RunProc("Insert into Sc_WorkBillMonthSortBillSub " + | 
|                           " (HInterID,HEntryID,HLocked,HMasterDate" + | 
|                           ",HDate,HQty,HTimes,HUseTimes,HStatusTag" + | 
|                           ",HiForeColor,HiBackColor,HRemark,HRelationInterID,HBTimes,HETimes" + | 
|                           ") values(" | 
|                           + oModel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + Convert.ToString(oSub.HLocked ? 1 : 0) + ",'" + oSub.HMasterDate.ToShortDateString() + "'" + | 
|                           ",'" + oSub.HDate.ToShortDateString() + "'," + oSub.HQty.ToString() + "," + oSub.HTimes.ToString() + "," + oSub.HUseTimes.ToString() + "," + oSub.HStatusTag.ToString() + | 
|                           "," + oSub.HiForeColor.ToString() + "," + oSub.HiBackColor.ToString() + ",'" + oSub.HRemark + "'," + HRelationInterID.ToString() +",'"+ DBUtility.ClsPub.isDate( oSub.HBTimes) + "','" +DBUtility.ClsPub.isDate( oSub.HETimes)+"'"+ | 
|                           ") "); | 
|                     } | 
|                 } | 
|                 // | 
|                 // | 
|                 sReturn = "新增单据成功!"; | 
|                 oCn.Commit(); | 
|                  | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|         //显示单据 | 
|         public override bool ShowBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //查询主表 | 
|                 DataSet Ds; | 
|                 Ds = oCn.RunProcReturn("Select * from h_v_Sc_WorkBillMonthSortBillMain Where HDeleteMan='' and HRelationInterID=" + lngBillKey.ToString(), "Sc_WorkBillMonthSortBillMain"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "单据未找到!"; | 
|                     return false; | 
|                 } | 
|                 MainColl.Clear(); | 
|                 for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) | 
|                 { | 
|                     Model.ClsSc_WorkBillMonthSortBillMain oMain = new Model.ClsSc_WorkBillMonthSortBillMain(); | 
|                     //固定赋值=========================================== | 
|                     oMain.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HInterID"]); | 
|                     oMain.HBillNo = Ds.Tables[0].Rows[i]["HBillNo"].ToString().Trim(); | 
|                     oMain.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HDate"]); | 
|                     oMain.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HYear"]); | 
|                     oMain.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HPeriod"]); | 
|                     oMain.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HCheckItemNowID"]); | 
|                     oMain.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HCheckItemNextID"]); | 
|                     oMain.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HCheckFlowID"]); | 
|                     oMain.HRemark = Ds.Tables[0].Rows[i]["HRemark"].ToString().Trim(); | 
|                     oMain.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[i]["HBillStatus"]); | 
|                     oMain.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillType"]); | 
|                     oMain.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillSubType"]); | 
|                     oMain.HMaker = Ds.Tables[0].Rows[i]["HMaker"].ToString().Trim(); | 
|                     oMain.HMakeDate = Ds.Tables[0].Rows[i]["HMakeDate"].ToString().Trim(); | 
|                     oMain.HUpDateDate = Ds.Tables[0].Rows[i]["HUpDateDate"].ToString().Trim(); | 
|                     oMain.HUpDater = Ds.Tables[0].Rows[i]["HUpDater"].ToString().Trim(); | 
|                     oMain.HBackDate = Ds.Tables[0].Rows[i]["HBackDate"].ToString().Trim(); | 
|                     oMain.HBacker = Ds.Tables[0].Rows[i]["HBacker"].ToString().Trim(); | 
|                     oMain.HCheckDate = Ds.Tables[0].Rows[i]["HCheckDate"].ToString().Trim(); | 
|                     oMain.HChecker = Ds.Tables[0].Rows[i]["HChecker"].ToString().Trim(); | 
|                     oMain.HCloseDate = Ds.Tables[0].Rows[i]["HCloseDate"].ToString().Trim(); | 
|                     oMain.HCloseMan = Ds.Tables[0].Rows[i]["HCloseMan"].ToString().Trim(); | 
|                     oMain.HDeleteDate = Ds.Tables[0].Rows[i]["HDeleteDate"].ToString().Trim(); | 
|                     oMain.HDeleteMan = Ds.Tables[0].Rows[i]["HDeleteMan"].ToString().Trim(); | 
|                     //======================================================== | 
|                     //== | 
|                     oMain.HICMOStatus = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOStatus"]); | 
|                     oMain.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HDeptID"]); | 
|                     oMain.HDeptNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HDeptNumber"]); | 
|                     oMain.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"]); | 
|                     oMain.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HMaterNumber"]); | 
|                     oMain.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceID"]); | 
|                     oMain.HSourceNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceNumber"]); | 
|                     oMain.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HUnitID"]); | 
|                     oMain.HUnitNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HUnitNumber"]); | 
|                     oMain.HWorkerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HWorkerID"]); | 
|                     oMain.HWorkerNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HWorkerNumber"]); | 
|                     oMain.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]); | 
|                     oMain.HGroupNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HGroupNumber"]); | 
|                     oMain.HYX = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HYX"]); | 
|                     oMain.HSourceQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSourceQty"]); | 
|                     oMain.HWorkQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HWorkQty"]); | 
|                     oMain.HWorkTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HWorkTimes"]); | 
|                     oMain.HReadyQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReadyQty"]); | 
|                     oMain.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanBeginDate"]); | 
|                     oMain.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanEndDate"]); | 
|                     oMain.HLastBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastBeginDate"]); | 
|                     oMain.HLastEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastEndDate"]); | 
|                     oMain.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPlanQty"]); | 
|                     oMain.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcID"]); | 
|                     oMain.HProdTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HProdTimes"]); | 
|                     oMain.HRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HRelationQty"]); | 
|                     oMain.HKTQ = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HKTQ"]); | 
|                     oMain.HReadyTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReadyTimes"]); | 
|                     oMain.HOrderNeedQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HOrderNeedQty"]); | 
|                     oMain.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceInterID"]); | 
|                     oMain.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceEntryID"]); | 
|                     oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillNo"]); | 
|                     oMain.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillType"]); | 
|                     oMain.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOInterID"]); | 
|                     oMain.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HICMOBillNo"]); | 
|                     oMain.HOrderCommitDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HOrderCommitDate"]); | 
|                     oMain.HProcPlanInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcPlanInterID"]); | 
|                     oMain.HProcPlanEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcPlanEntryID"]); | 
|                     oMain.HProcPlanBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HProcPlanBillNo"]); | 
|                     oMain.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSeOrderBillNo"]); | 
|                     oMain.HSeOrderInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSeOrderInterID"]); | 
|                     oMain.HSeOrderEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSeOrderEntryID"]); | 
|                     oMain.HRelationInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HRelationInterID"]); | 
|                     oMain.HSplitPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSplitPlanQty"]); | 
|                     oMain.HSplitRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSplitRelationQty"]); | 
|                     oMain.HSplitNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSplitNO"]); | 
|                     oMain.HLocked = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HLocked"]); | 
|                     // | 
|                     if (oMain.HLocked == true)      //显示锁定的排程计划 | 
|                     { | 
|                         //循环 | 
|                         DataSet DsSub; | 
|                         DsSub = oCn.RunProcReturn("Select * from Sc_WorkBillMonthSortBillSub Where HInterID=" + oMain.HInterID.ToString() + " order by HEntryID ", "Sc_WorkBillMonthSortBillSub"); | 
|                         DetailColl.Clear();//清空 | 
|                         for (int r = 0; r < DsSub.Tables[0].Rows.Count; r++) | 
|                         { | 
|                             Model.ClsSc_WorkBillMonthSortBillSub oSub = new Model.ClsSc_WorkBillMonthSortBillSub(); | 
|                             // 固定赋值=============================================== | 
|                             oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HInterID"]); | 
|                             oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HEntryID"]); | 
|                             //oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HSourceInterID"]); | 
|                             //oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HSourceEntryID"]); | 
|                             //oSub.HSourceBillType = DsSub.Tables[0].Rows[r]["HSourceBillType"].ToString().Trim(); | 
|                             //oSub.HSourceBillNo = DsSub.Tables[0].Rows[r]["HSourceBillNo"].ToString().Trim(); | 
|                             //oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[r]["HRelationQty"]); | 
|                             //oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[r]["HRelationMoney"]); | 
|                             oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[r]["HCloseMan"]); | 
|                             oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HCloseType"]); | 
|                             //oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HEntryCloseDate"]); | 
|                             oSub.HRemark = DsSub.Tables[0].Rows[r]["HRemark"].ToString().Trim(); | 
|                             //=================================================== | 
|                             oSub.HLocked = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HLocked"]); | 
|                             oSub.HMasterDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HMasterDate"]); | 
|                             oSub.HDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HDate"]); | 
|                             oSub.HQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HQty"]); | 
|                             oSub.HTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HTimes"]); | 
|                             oSub.HUseTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HUseTimes"]); | 
|                             oSub.HStatusTag = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HStatusTag"]); | 
|                             oSub.HiForeColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiForeColor"]); | 
|                             oSub.HiBackColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiBackColor"]); | 
|                             oSub.HRelationInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HRelationInterID"]); | 
|                             DetailColl.Add(oSub); | 
|                         } | 
|                     } | 
|                     MainColl.Add(oMain); | 
|                 } | 
|                 sReturn = "显示单据成功!"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 return false; | 
|                 //throw (e); | 
|             } | 
|         } | 
|   | 
|   | 
|         //显示单据 | 
|         public  bool ShowBillByICMO(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //查询主表 | 
|                 DataSet Ds; | 
|                 Ds = oCn.RunProcReturn("Select * from h_v_Sc_WorkBillMonthSortBillMain_ICMO Where HDeleteMan='' and HRelationInterID=" + lngBillKey.ToString(), "h_v_Sc_WorkBillMonthSortBillMain_ICMO"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "单据未找到!"; | 
|                     return false; | 
|                 } | 
|                 MainColl.Clear(); | 
|                 for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) | 
|                 { | 
|                     Model.ClsSc_WorkBillMonthSortBillMain oMain = new Model.ClsSc_WorkBillMonthSortBillMain(); | 
|                     //固定赋值=========================================== | 
|                     oMain.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HInterID"]); | 
|                     oMain.HBillNo = Ds.Tables[0].Rows[i]["HBillNo"].ToString().Trim(); | 
|                     oMain.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HDate"]); | 
|                     oMain.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HYear"]); | 
|                     oMain.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HPeriod"]); | 
|                     oMain.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HCheckItemNowID"]); | 
|                     oMain.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HCheckItemNextID"]); | 
|                     oMain.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HCheckFlowID"]); | 
|                     oMain.HRemark = Ds.Tables[0].Rows[i]["HRemark"].ToString().Trim(); | 
|                     oMain.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[i]["HBillStatus"]); | 
|                     oMain.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillType"]); | 
|                     oMain.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillSubType"]); | 
|                     oMain.HMaker = Ds.Tables[0].Rows[i]["HMaker"].ToString().Trim(); | 
|                     oMain.HMakeDate = Ds.Tables[0].Rows[i]["HMakeDate"].ToString().Trim(); | 
|                     oMain.HUpDateDate = Ds.Tables[0].Rows[i]["HUpDateDate"].ToString().Trim(); | 
|                     oMain.HUpDater = Ds.Tables[0].Rows[i]["HUpDater"].ToString().Trim(); | 
|                     oMain.HBackDate = Ds.Tables[0].Rows[i]["HBackDate"].ToString().Trim(); | 
|                     oMain.HBacker = Ds.Tables[0].Rows[i]["HBacker"].ToString().Trim(); | 
|                     oMain.HCheckDate = Ds.Tables[0].Rows[i]["HCheckDate"].ToString().Trim(); | 
|                     oMain.HChecker = Ds.Tables[0].Rows[i]["HChecker"].ToString().Trim(); | 
|                     oMain.HCloseDate = Ds.Tables[0].Rows[i]["HCloseDate"].ToString().Trim(); | 
|                     oMain.HCloseMan = Ds.Tables[0].Rows[i]["HCloseMan"].ToString().Trim(); | 
|                     oMain.HDeleteDate = Ds.Tables[0].Rows[i]["HDeleteDate"].ToString().Trim(); | 
|                     oMain.HDeleteMan = Ds.Tables[0].Rows[i]["HDeleteMan"].ToString().Trim(); | 
|                     //======================================================== | 
|                     //== | 
|                     oMain.HICMOStatus = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOStatus"]); | 
|                     oMain.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HDeptID"]); | 
|                     oMain.HDeptNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HDeptNumber"]); | 
|                     oMain.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"]); | 
|                     oMain.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HMaterNumber"]); | 
|                     oMain.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceID"]); | 
|                     oMain.HSourceNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceNumber"]); | 
|                     oMain.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HUnitID"]); | 
|                     oMain.HUnitNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HUnitNumber"]); | 
|                     oMain.HWorkerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HWorkerID"]); | 
|                     oMain.HWorkerNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HWorkerNumber"]); | 
|                     oMain.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]); | 
|                     oMain.HGroupNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HGroupNumber"]); | 
|                     oMain.HYX = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HYX"]); | 
|                     oMain.HWorkQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HWorkQty"]); | 
|                     oMain.HWorkTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HWorkTimes"]); | 
|                     oMain.HReadyQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReadyQty"]); | 
|                     oMain.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanBeginDate"]); | 
|                     oMain.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanEndDate"]); | 
|                     oMain.HLastBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastBeginDate"]); | 
|                     oMain.HLastEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastEndDate"]); | 
|                     oMain.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPlanQty"]); | 
|                     oMain.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcID"]); | 
|                     oMain.HProdTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HProdTimes"]); | 
|                     oMain.HRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HRelationQty"]); | 
|                     oMain.HKTQ = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HKTQ"]); | 
|                     oMain.HReadyTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReadyTimes"]); | 
|                     oMain.HOrderNeedQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HOrderNeedQty"]); | 
|                     oMain.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceInterID"]); | 
|                     oMain.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceEntryID"]); | 
|                     oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillNo"]); | 
|                     oMain.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillType"]); | 
|                     oMain.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOInterID"]); | 
|                     oMain.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HICMOBillNo"]); | 
|                     oMain.HOrderCommitDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HOrderCommitDate"]); | 
|                     oMain.HProcPlanInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcPlanInterID"]); | 
|                     oMain.HProcPlanEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcPlanEntryID"]); | 
|                     oMain.HProcPlanBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HProcPlanBillNo"]); | 
|                     oMain.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSeOrderBillNo"]); | 
|                     oMain.HSeOrderInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSeOrderInterID"]); | 
|                     oMain.HSeOrderEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSeOrderEntryID"]); | 
|                     oMain.HRelationInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HRelationInterID"]); | 
|                     oMain.HSplitPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSplitPlanQty"]); | 
|                     oMain.HSplitRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSplitRelationQty"]); | 
|                     oMain.HSplitNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSplitNO"]); | 
|                     oMain.HLocked = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HLocked"]); | 
|                     // | 
|                     if (oMain.HLocked == true)      //显示锁定的排程计划 | 
|                     { | 
|                         //循环 | 
|                         DataSet DsSub; | 
|                         DsSub = oCn.RunProcReturn("Select * from Sc_WorkBillMonthSortBillSub Where HInterID=" + oMain.HInterID.ToString() + " order by HEntryID ", "Sc_WorkBillMonthSortBillSub"); | 
|                         DetailColl.Clear();//清空 | 
|                         for (int r = 0; r < DsSub.Tables[0].Rows.Count; r++) | 
|                         { | 
|                             Model.ClsSc_WorkBillMonthSortBillSub oSub = new Model.ClsSc_WorkBillMonthSortBillSub(); | 
|                             // 固定赋值=============================================== | 
|                             oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HInterID"]); | 
|                             oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HEntryID"]); | 
|                             //oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HSourceInterID"]); | 
|                             //oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HSourceEntryID"]); | 
|                             //oSub.HSourceBillType = DsSub.Tables[0].Rows[r]["HSourceBillType"].ToString().Trim(); | 
|                             //oSub.HSourceBillNo = DsSub.Tables[0].Rows[r]["HSourceBillNo"].ToString().Trim(); | 
|                             //oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[r]["HRelationQty"]); | 
|                             //oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[r]["HRelationMoney"]); | 
|                             oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[r]["HCloseMan"]); | 
|                             oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HCloseType"]); | 
|                             //oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HEntryCloseDate"]); | 
|                             oSub.HRemark = DsSub.Tables[0].Rows[r]["HRemark"].ToString().Trim(); | 
|                             //=================================================== | 
|                             oSub.HLocked = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HLocked"]); | 
|                             oSub.HMasterDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HMasterDate"]); | 
|                             oSub.HDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HDate"]); | 
|                             oSub.HQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HQty"]); | 
|                             oSub.HTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HTimes"]); | 
|                             oSub.HUseTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HUseTimes"]); | 
|                             oSub.HStatusTag = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HStatusTag"]); | 
|                             oSub.HiForeColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiForeColor"]); | 
|                             oSub.HiBackColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiBackColor"]); | 
|                             oSub.HRelationInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HRelationInterID"]); | 
|   | 
|                             DetailColl.Add(oSub); | 
|                         } | 
|                     } | 
|                     MainColl.Add(oMain); | 
|                 } | 
|                 sReturn = "显示单据成功!"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //显示单据 工序排程 | 
|         public bool ShowBillByProc(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //查询主表 | 
|                 DataSet Ds; | 
|                 Ds = oCn.RunProcReturn("Select distinct hicmointerid,hicmobillno,hmaterid,hunitid,hplanqty,hprodtimes,HYX,hreadyqty,hplanbegindate,hplanenddate,hlastbegindate,hlastenddate,horderneedqty ,hseorderbillno,HOrderCommitDate,HSourceBillNo,HSourceBillType,HLocked,HRemark,HHangUp,Horderlev from h_v_Sc_WorkBillMonthSortBillMain Where HDeleteMan='' and HRelationInterID=" + lngBillKey.ToString(), "Sc_WorkBillMonthSortBillMain"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "单据未找到!"; | 
|                     return false; | 
|                 } | 
|                 MainColl.Clear(); | 
|                 for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) | 
|                 { | 
|                     Model.ClsSc_WorkBillMonthSortBillMain oMain = new Model.ClsSc_WorkBillMonthSortBillMain(); | 
|                     //固定赋值=========================================== | 
|                     //oMain.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HInterID"]); | 
|                     oMain.HRemark = Ds.Tables[0].Rows[i]["HRemark"].ToString().Trim(); | 
|                     oMain.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"]); | 
|                     oMain.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HUnitID"]); | 
|                     oMain.HYX = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HYX"]); | 
|                     oMain.HReadyQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReadyQty"]); | 
|                     oMain.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanBeginDate"]); | 
|                     oMain.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanEndDate"]); | 
|                     oMain.HLastBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastBeginDate"]); | 
|                     oMain.HLastEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastEndDate"]); | 
|                     oMain.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPlanQty"]); | 
|                     oMain.HProdTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HProdTimes"]); | 
|                     oMain.HOrderNeedQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HOrderNeedQty"]); | 
|                     oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillNo"]); | 
|                     oMain.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillType"]); | 
|                     oMain.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HICMOBillNo"]); | 
|                     oMain.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOInterID"]); | 
|                     oMain.HOrderCommitDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HOrderCommitDate"]); | 
|                     oMain.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSeOrderBillNo"]); | 
|                     oMain.HLocked = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HLocked"]); | 
|                     oMain.HHangUp = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HHangUp"]); | 
|                     oMain.Horderlev = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["Horderlev"]); | 
|                     // | 
|                     if (oMain.HLocked == true)      //显示锁定的排程计划 | 
|                     { | 
|                         //循环 | 
|                         DataSet DsSub; | 
|                         DsSub = oCn.RunProcReturn("Select * from Sc_WorkBillMonthSortBillSub Where HInterID=" + oMain.HInterID.ToString(), "Sc_WorkBillMonthSortBillSub"); | 
|                         DetailColl.Clear();//清空 | 
|                         for (int r = 0; r < DsSub.Tables[0].Rows.Count; r++) | 
|                         { | 
|                             Model.ClsSc_WorkBillMonthSortBillSub oSub = new Model.ClsSc_WorkBillMonthSortBillSub(); | 
|                             // 固定赋值=============================================== | 
|                             oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HInterID"]); | 
|                             oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HEntryID"]); | 
|                             oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[r]["HCloseMan"]); | 
|                             oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HCloseType"]); | 
|                             oSub.HRemark = DsSub.Tables[0].Rows[r]["HRemark"].ToString().Trim(); | 
|                             //=================================================== | 
|                             oSub.HLocked = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HLocked"]); | 
|                             oSub.HMasterDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HMasterDate"]); | 
|                             oSub.HDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HDate"]); | 
|                             oSub.HBTimes = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HBTimes"]); | 
|                             oSub.HETimes = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HETimes"]); | 
|                             oSub.HQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HQty"]); | 
|                             oSub.HTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HTimes"]); | 
|                             oSub.HUseTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HUseTimes"]); | 
|                             oSub.HStatusTag = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HStatusTag"]); | 
|                             oSub.HiForeColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiForeColor"]); | 
|                             oSub.HiBackColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiBackColor"]); | 
|                             oSub.HRelationInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HRelationInterID"]); | 
|                             DetailColl.Add(oSub); | 
|                         } | 
|                     } | 
|                     MainColl.Add(oMain); | 
|                 } | 
|                 sReturn = "显示单据成功!"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 return false;  | 
|             } | 
|         } | 
|   | 
|   | 
|         //显示单据 工序排程 | 
|         public bool ShowBillByProc_t(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //查询主表 | 
|                 DataSet Ds; | 
|                 Ds = oCn.RunProcReturn("Select  HinterID,hicmointerid,hicmobillno,hmaterid,hunitid,hplanqty,hprodtimes,HYX,hreadyqty,hplanbegindate,hplanenddate,hlastbegindate,hlastenddate,horderneedqty ,hseorderbillno,HOrderCommitDate,HSourceBillNo,HSourceBillType,HLocked,HRemark,HHangUp,Horderlev from h_v_Sc_WorkBillMonthSortBillMain Where HDeleteMan='' and HRelationInterID=" + lngBillKey.ToString(), "Sc_WorkBillMonthSortBillMain"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "单据未找到!"; | 
|                     return false; | 
|                 } | 
|                 MainColl.Clear(); | 
|                 DetailColl.Clear();//清空 | 
|                 for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) | 
|                 { | 
|                     Model.ClsSc_WorkBillMonthSortBillMain oMain = new Model.ClsSc_WorkBillMonthSortBillMain(); | 
|                     //固定赋值=========================================== | 
|                     oMain.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HInterID"]); | 
|                     oMain.HRemark = Ds.Tables[0].Rows[i]["HRemark"].ToString().Trim(); | 
|                     oMain.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"]); | 
|                     oMain.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HUnitID"]); | 
|                     oMain.HYX = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HYX"]); | 
|                     oMain.HReadyQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReadyQty"]); | 
|                     oMain.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanBeginDate"]); | 
|                     oMain.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HPlanEndDate"]); | 
|                     oMain.HLastBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastBeginDate"]); | 
|                     oMain.HLastEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HLastEndDate"]); | 
|                     oMain.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPlanQty"]); | 
|                     oMain.HProdTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HProdTimes"]); | 
|                     oMain.HOrderNeedQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HOrderNeedQty"]); | 
|                     oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillNo"]); | 
|                     oMain.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillType"]); | 
|                     oMain.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HICMOBillNo"]); | 
|                     oMain.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOInterID"]); | 
|                     oMain.HOrderCommitDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["HOrderCommitDate"]); | 
|                     oMain.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSeOrderBillNo"]); | 
|                     oMain.HLocked = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HLocked"]); | 
|                     oMain.HHangUp = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HHangUp"]); | 
|                     oMain.Horderlev = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["Horderlev"]); | 
|                     // | 
|                     //if (oMain.HLocked == true)      //显示锁定的排程计划 | 
|                     //{ | 
|                     //循环 | 
|                     DataSet DsSub; | 
|                     DsSub = oCn.RunProcReturn("Select * from Sc_WorkBillMonthSortBillSub Where HInterID=" + oMain.HInterID.ToString() + " order by HMakeDate", "Sc_WorkBillMonthSortBillSub"); | 
|                     for (int r = 0; r < DsSub.Tables[0].Rows.Count; r++) | 
|                     { | 
|                         Model.ClsSc_WorkBillMonthSortBillSub oSub = new Model.ClsSc_WorkBillMonthSortBillSub(); | 
|                         // 固定赋值=============================================== | 
|                         oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HInterID"]); | 
|                         oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HEntryID"]); | 
|                         oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[r]["HCloseMan"]); | 
|                         oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HCloseType"]); | 
|                         oSub.HRemark = DsSub.Tables[0].Rows[r]["HRemark"].ToString().Trim(); | 
|                         //=================================================== | 
|                         oSub.HLocked = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[r]["HLocked"]); | 
|                         oSub.HMasterDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HMasterDate"]); | 
|                         oSub.HDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HDate"]); | 
|                         oSub.HBTimes = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HBTimes"]); | 
|                         oSub.HETimes = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[r]["HETimes"]); | 
|                         oSub.HQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HQty"]); | 
|                         oSub.HTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HTimes"]); | 
|                         oSub.HUseTimes = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HUseTimes"]); | 
|                         oSub.HStatusTag = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HStatusTag"]); | 
|                         oSub.HiForeColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiForeColor"]); | 
|                         oSub.HiBackColor = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HiBackColor"]); | 
|                         oSub.HRelationInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[r]["HRelationInterID"]); | 
|                         DetailColl.Add(oSub); | 
|                     } | 
|                     //} | 
|                     MainColl.Add(oMain); | 
|                 } | 
|                 sReturn = "显示单据成功!"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 return false; | 
|             } | 
|         } | 
|   | 
|         public bool DeleteBillUnlock(Int64 sDeptID) | 
|         { | 
|             try | 
|             { | 
|                 oCn.RunProcReturn("exec h_p_Sc_DeleteWorkAutoBillList  '" + DBUtility.ClsPub.CurUserName + "'," + sDeptID.ToString(), "h_p_Sc_DeleteWorkAutoBillList"); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 return false; | 
|             } | 
|         } | 
|   | 
|   | 
|         //得到该部门HRelationInterID | 
|         public Int64 GetRelationInterIDByDept(Int64 sDeptID) | 
|         { | 
|             DataSet DS; | 
|             try | 
|             { | 
|                 DS = oCn.RunProcReturn("Select isnull(max(HRelationInterID),0) HRelationInterID  from Sc_WorkBillMonthSortBillMain Where HDeptID=" + sDeptID + "  and Hdeleteman='' ", "Sc_WorkBillMonthSortBillMain"); | 
|                 if (DS.Tables[0].Rows.Count == 0) | 
|                     return 0; | 
|                 else | 
|                 { | 
|   | 
|                     return DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HRelationInterID"]); | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 return 0; | 
|             } | 
|         } | 
|   | 
|   | 
|         //得到该部门该操作员 HRelationInterID | 
|         public Int64 GetRelationInterIDByDeptUser(Int64 sDeptID) | 
|         { | 
|             DataSet DS; | 
|             try | 
|             { | 
|                 DS = oCn.RunProcReturn("Select isnull(max(HRelationInterID),0) HRelationInterID  from Sc_WorkBillMonthSortBillMain Where HDeptID=" + sDeptID + " and HMaker='" + DBUtility.ClsPub.CurUserName + "' and Hdeleteman='' ", "Sc_WorkBillMonthSortBillMain"); | 
|                 if (DS.Tables[0].Rows.Count == 0) | 
|                     return 0; | 
|                 else | 
|                 { | 
|                     return DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HRelationInterID"]); | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 return 0; | 
|             } | 
|         } | 
|   | 
|   | 
|   | 
|         //设置本行 资源  ,拆分汇报数量 | 
|         public bool GetSourceRelationQty(Int64 ICMOInterID, Int64 sSourceID, ref Single RelationQty, ref Single SplitRelationQty) | 
|         { | 
|             DataSet DS; | 
|             try | 
|             { | 
|                 DS = oCn.RunProcReturn("exec h_p_Sc_SetSourceStockInQty " + ICMOInterID.ToString() + "," + sSourceID.ToString(), "xt_xtgnb"); | 
|                 if (DS.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     RelationQty = 0; | 
|                     SplitRelationQty = 0; | 
|                     return false; | 
|                 } | 
|                 else | 
|                 { | 
|                     RelationQty = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["RelationQty"]); | 
|                     SplitRelationQty = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["SplitRelationQty"]); | 
|                     return true; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 RelationQty = 0; | 
|                 SplitRelationQty = 0; | 
|                 return false; | 
|             } | 
|         } | 
|   | 
|         //设置本行 资源 产能,拆分汇报数量 | 
|         public Single GetSourceWorkQty(Int64 sMaterID, Int64 sProcID, Int64 sSourceID) | 
|         { | 
|             DataSet DS; | 
|             try | 
|             { | 
|                 DS = oCn.RunProcReturn("exec h_p_Sc_SetSourceWorkQty " + sMaterID.ToString() + "," + sProcID.ToString() + "," + sSourceID.ToString(), "xt_xtgnb"); | 
|                 if (DS.Tables[0].Rows.Count == 0) | 
|                     return 0; | 
|                 else | 
|                 { | 
|                     return DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HWorkQty"]); | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 return 0; | 
|             } | 
|         } | 
|   | 
|         //设置本行 资源 产能 | 
|         public Single GetSourceWorkQty(Int64 sMaterID, Int64 sProcID, Int64 sSourceID,bool IsNew) | 
|         { | 
|             DataSet DS; | 
|             try | 
|             { | 
|                 DS = oCn.RunProcReturn("exec h_p_Sc_SetSourceWorkQty_New " + sMaterID.ToString() + "," + sProcID.ToString() + "," + sSourceID.ToString(), "xt_xtgnb"); | 
|                 if (DS.Tables[0].Rows.Count == 0) | 
|                     return 0; | 
|                 else | 
|                 { | 
|                     return DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HWorkQty"]); | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 return 0; | 
|             } | 
|         } | 
|   | 
|   | 
|         //根据信息 设置---是否缺料,确认时间 | 
|         public bool Sub_SetStatusByInfo(Int64 lSourceID, Int64 lSourceInterID, DateTime dDate, Int64 HStatus, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 oCn.BeginTran(); | 
|                 // | 
|                 oCn.RunProc("exec h_p_Sc_SetICMOStatus_ReadyMater " + lSourceID.ToString() + "," + lSourceInterID.ToString() + ",'" + dDate.ToShortDateString() + "'," + HStatus.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "'"); | 
|                 // | 
|                 oCn.Commit(); | 
|                 // | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 return false; | 
|             } | 
|         } | 
|   | 
|         //根据信息 设置 计划执行 | 
|         public bool Sub_SetStartByInfo(Int64 lSourceID, Int64 lSourceInterID, DateTime dDate, Int64 HStatus, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 oCn.BeginTran(); | 
|                 // | 
|                 oCn.RunProc("exec h_p_Sc_SetICMOStatus_ReadyStart " + lSourceID.ToString() + "," + lSourceInterID.ToString() + ",'" + dDate.ToShortDateString() + "'," + HStatus.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "'"); | 
|                 // | 
|                 oCn.Commit(); | 
|                 // | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 return false; | 
|             } | 
|         } | 
|          | 
|         //挂起本任务单 | 
|         public bool SetICMOBill_HangUp(Int64 HICMOInterID) | 
|         { | 
|             DataSet DS; | 
|             try | 
|             { | 
|                 DataSet Ds; | 
|                 Ds = oCn.RunProcReturn("Select  * from Sc_WorkBillMonthSortBillMain Where  hicmointerid=" + HICMOInterID.ToString(), "Sc_WorkBillMonthSortBillMain"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     return false; | 
|                 } | 
|                 else | 
|                 { | 
|                     oCn.RunProcReturn("update Sc_WorkBillMonthSortBillMain set HHangUp=1 Where  hicmointerid=" + HICMOInterID.ToString(), "Sc_WorkBillMonthSortBillMain"); | 
|                     return true; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 return false; | 
|             } | 
|         } | 
|   | 
|         //反挂起本任务单 | 
|         public bool SetICMOBill_UnHangUp(Int64 HICMOInterID) | 
|         { | 
|             DataSet DS; | 
|             try | 
|             { | 
|                 DataSet Ds; | 
|                 Ds = oCn.RunProcReturn("Select  * from Sc_WorkBillMonthSortBillMain Where HHangUp=1 and hicmointerid=" + HICMOInterID.ToString(), "Sc_WorkBillMonthSortBillMain"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     return false; | 
|                 } | 
|                 else | 
|                 { | 
|                     oCn.RunProcReturn("update Sc_WorkBillMonthSortBillMain set HHangUp=0 Where  hicmointerid=" + HICMOInterID.ToString(), "Sc_WorkBillMonthSortBillMain"); | 
|                     return true; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 return false; | 
|             } | 
|         } | 
|   | 
|   | 
|   | 
|     } | 
| } |