| using System; | 
| using System.Collections.Generic; | 
| using System.Text; | 
| using System.Data; | 
|   | 
| namespace WebAPI.DLL | 
| { | 
|     public  class ClsSc_ProcessReport:DBUtility.ClsXt_BaseBill | 
|     { | 
|         public Models.ClsSc_ProcessReportMain omodel = new Models.ClsSc_ProcessReportMain(); | 
|         public List<Models.ClsSc_ProcessReportSub> DetailColl = new List<Models.ClsSc_ProcessReportSub>(); | 
|   | 
|         public ClsSc_ProcessReport() | 
|         { | 
|             base.MvarItemKeySub = "Sc_ProcessReportSub"; | 
|             base.MvarItemKeySub2 = ""; | 
|             base.MvarItemKeySub3 = ""; | 
|             base.MvarItemKeySub4 = ""; | 
|             base.MvarItemKey="Sc_ProcessReportMain"; | 
|             base.MvarReportTitle="工序汇报单"; | 
|             base.BillType="3714";  | 
|         } | 
|   | 
|         #region 固定代码 | 
|   | 
|         ~ClsSc_ProcessReport() | 
|         { | 
|             DetailColl = null; | 
|         } | 
|         | 
|         #endregion   自定义方法 | 
|         //修改单据 | 
|         public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 // | 
|                 oCn.BeginTran(); | 
|                 //更新主表 | 
|                 oCn.RunProc("UpDate Sc_ProcessReportMain set  " + | 
|                 " HYear=" + omodel.HYear.ToString() + | 
|                 ",HPeriod=" + omodel.HPeriod.ToString() + | 
|                 ",HDate='" + omodel.HDate.ToShortDateString() + "'" + | 
|                 ",HBillStatus=" + omodel.HBillStatus.ToString() + | 
|                 ",HCheckItemNowID=" + omodel.HCheckItemNowID.ToString() + | 
|                 ",HCheckItemNextID=" + omodel.HCheckItemNextID.ToString() + | 
|                 ",HICMOInterID=" + omodel.HICMOInterID.ToString() + | 
|                 ",HICMOBillNo='" + omodel.HICMOBillNo + "'" + | 
|                 ",HMarker='" + omodel.HMarker + "'" + | 
|                 ",HSupID=" + omodel.HSupID.ToString() + | 
|                 ",HDeptID=" + omodel.HDeptID.ToString() + | 
|                 ",HDeptNumber='" + omodel.HDeptNumber + "'" + | 
|                 ",HGroupID=" + omodel.HGroupID.ToString() + | 
|                 ",HGroupNumber='" + omodel.HGroupNumber + "'" + | 
|                 ",HMaterID=" + omodel.HMaterID.ToString() + | 
|                 ",HMaterNumber='" + omodel.HMaterNumber + "'" +  | 
|                 ",HUnitID=" + omodel.HUnitID.ToString() + | 
|                 ",HUnitNumber='" + omodel.HUnitNumber + "'" +  | 
|                 ",HPlanQty=" + omodel.HPlanQty.ToString() + | 
|                 ",HInStockQty=" + omodel.HInStockQty.ToString() + | 
|                 ",HSumTimes=" + omodel.HSumTimes.ToString() + | 
|                 ",HExplanation='" + omodel.HExplanation + "'" + | 
|                 ",HRemark='" + omodel.HRemark + "'" + | 
|                 ",HInnerBillNo='" + omodel.HInnerBillNo + "'" + | 
|                 ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" + | 
|                 ",HUpDateDate=getdate()" + | 
|                 " where HInterID=" + lngBillKey.ToString()); | 
|                 //删除关联 | 
|                 DeleteRelation(ref sReturn, lngBillKey); | 
|                 //删除子表 | 
|                 DeleteBillSub(lngBillKey); | 
|                 //插入子表 | 
|                 omodel.HInterID = lngBillKey; | 
|                 foreach (Models.ClsSc_ProcessReportSub oSub in DetailColl) | 
|                 { | 
|                     oCn.RunProc("Insert into Sc_ProcessReportSub " + | 
|                   " (HInterID,HEntryID,HProcID,HProcNumber,HEmpID" + | 
|                   ",HMaterID,HMaterNumber,HOutPrice,HOutMoney" + | 
|                   ",HEmpNumber,HSourceID,HRelBeginDate,HRelEndDate,HTimes" + | 
|                   ",HQty,HCheckQty,HBadCount,HWasterQty,HWasterQty2" + | 
|                   ",HPrice,HMoney,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo" + | 
|                   ",HICMOInterID,HICMOBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + | 
|                   ",HCloseMan,HCloseType,HRemark" + | 
|                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + | 
|                   ",HBadPrirce,HBadMoney,HWasterPrice,HWasterMoney,HQualityRate," + | 
|                   "HSecUnitQty1,HSecUnitRate1,HSecUnitQty2,HSecUnitRate2,HUsingQty," + | 
|                   "HSelfBadCount,HPreBadCount,HPayMentQty,HOtherDeduct,HRelPay," + | 
|                   "HOtherItem1,HOtherItem2,HOtherItem3,HOtherItem4,HOtherItem5," + | 
|                   "HPackType,HCheckEmpID,HBatchNo" + | 
|                   ") values(" | 
|                   + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNumber + "'," + oSub.HEmpID.ToString() + | 
|                   "," + oSub.HMaterID.ToString() + ",'" + oSub.HMaterNumber + "'," + oSub.HOutPrice.ToString() + "," + oSub.HOutMoney.ToString() +  | 
|                   ",'" + oSub.HEmpNumber + "'," + oSub.HSourceID.ToString() + ",'" + oSub.HRelBeginDate.ToShortDateString() + "','" + oSub.HRelEndDate.ToShortDateString() + "'," + oSub.HTimes.ToString() + | 
|                   "," + oSub.HQty.ToString() + "," + oSub.HCheckQty.ToString() + "," + oSub.HBadCount.ToString() + "," + oSub.HWasterQty.ToString() +"," + oSub.HWasterQty2.ToString() + | 
|                   "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HProcPlanInterID.ToString() + "," + oSub.HProcPlanEntryID.ToString() + ",'" + oSub.HProcPlanBillNo + "'" + | 
|                   "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "'," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" + | 
|                   ",'" + oSub.HCloseMan + "'," + 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.HBadPrirce.ToString() + "," + oSub.HBadMoney.ToString() + "," + oSub.HWasterPrice.ToString() + "," + oSub.HWasterMoney.ToString() + "," + oSub.HQualityRate.ToString() + | 
|                   "," + oSub.HSecUnitQty1.ToString() + "," + oSub.HSecUnitRate1.ToString() + "," + oSub.HSecUnitQty2.ToString() + "," + oSub.HSecUnitRate2.ToString() + "," + oSub.HUsingQty.ToString() + | 
|                   "," + oSub.HSelfBadCount.ToString() + "," + oSub.HPreBadCount.ToString() + "," + oSub.HPayMentQty.ToString() + "," + oSub.HOtherDeduct.ToString() + "," + oSub.HRelPay.ToString() + | 
|                   ",'" + oSub.HOtherItem1.ToString() + "','" + oSub.HOtherItem2.ToString() + "','" + oSub.HOtherItem3.ToString() + "','" + oSub.HOtherItem4.ToString() + "','" + oSub.HOtherItem5.ToString() + | 
|                   "','" + oSub.HPackType.ToString() + "'," + oSub.HCheckEmpID.ToString() + ",'" + oSub.HBatchNo + "'" +  | 
|                   ") "); | 
|                 } | 
|                 //更新关联数量 | 
|                 AddNewRelation(ref sReturn, omodel.HInterID); | 
|                 // | 
|                 sReturn = "修改单据成功!"; | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|         //新增单据 | 
|         public override bool AddBill(ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //得到mainid | 
|                 omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
|                 //若MAINDI重复则重新获取 | 
|                 oCn.BeginTran(); | 
|                 //主表 | 
|                 oCn.RunProc("Insert Into Sc_ProcessReportMain   " + | 
|                 "(HYear,HPeriod,HBillType,HBillSubType,HInterID" + | 
|                 ",HDate,HBillNo,HBillStatus,HCheckItemNowID,HCheckItemNextID" + | 
|                 ",HICMOInterID,HICMOBillNo ,HDeptID ,HDeptNumber,HGroupID" + | 
|                 ",HGroupNumber,HMaterID,HMaterNumber,HUnitID,HUnitNumber" + | 
|                 ",HPlanQty,HInStockQty,HSumTimes,HExplanation,HRemark" + | 
|                 ",HInnerBillNo,HMaker,HMakeDate,HSupID,HMarker" + | 
|                 ") " + | 
|                 " values(" + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + this.BillType +"','"+ omodel.HBillSubType + "'," + omodel.HInterID.ToString() + | 
|                 ",'" + omodel.HDate.ToShortDateString() + "','" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + "," + omodel.HCheckItemNowID.ToString() + "," + omodel.HCheckItemNextID.ToString() + | 
|                 "," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "'," + omodel.HDeptID.ToString() + ",'" + omodel.HDeptNumber + "'," + omodel.HGroupID.ToString() + | 
|                 ",'" + omodel.HGroupNumber + "'," + omodel.HMaterID.ToString() + ",'" + omodel.HMaterNumber + "'," + omodel.HUnitID.ToString() + ",'" + omodel.HUnitNumber + "'" + | 
|                 ", " + omodel.HPlanQty.ToString() + "," + omodel.HInStockQty.ToString() + "," + omodel.HSumTimes.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HRemark + "'" + | 
|                 ",'" + omodel.HInnerBillNo  + "','" + omodel.HMaker.ToString() + "',getdate()," + omodel.HSupID.ToString() + ",'" + omodel.HMarker + "'" + | 
|                 ") "); | 
|                 //插入子表 | 
|                 foreach (Models.ClsSc_ProcessReportSub oSub in DetailColl) | 
|                 { | 
|                    | 
|   | 
|                     oCn.RunProc("Insert into Sc_ProcessReportSub " + | 
|                   " (HInterID,HEntryID,HProcID,HProcNumber,HEmpID" + | 
|                   ",HMaterID,HMaterNumber,HOutPrice,HOutMoney" + | 
|                   ",HEmpNumber,HSourceID,HRelBeginDate,HRelEndDate,HTimes" + | 
|                   ",HQty,HCheckQty,HBadCount,HWasterQty,HWasterQty2" + | 
|                   ",HPrice,HMoney,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo" + | 
|                   ",HICMOInterID,HICMOBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + | 
|                   ",HCloseMan,HCloseType,HRemark" + | 
|                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + | 
|                   ",HBadPrirce,HBadMoney,HWasterPrice,HWasterMoney,HQualityRate,"+ | 
|                   "HSecUnitQty1,HSecUnitRate1,HSecUnitQty2,HSecUnitRate2,HUsingQty,"+ | 
|                   "HSelfBadCount,HPreBadCount,HPayMentQty,HOtherDeduct,HRelPay,"+ | 
|                   "HOtherItem1,HOtherItem2,HOtherItem3,HOtherItem4,HOtherItem5,"+ | 
|                   "HPackType,HCheckEmpID,HWeight,HBatchNo,HRelationInterID" + | 
|                   ") values(" | 
|                   + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNumber + "'," + oSub.HEmpID.ToString() + | 
|                   "," + oSub.HMaterID.ToString() + ",'" + oSub.HMaterNumber + "'," + oSub.HOutPrice.ToString() + "," + oSub.HOutMoney.ToString() +  | 
|                   ",'" + oSub.HEmpNumber + "'," + oSub.HSourceID.ToString() + ",'" + oSub.HRelBeginDate.ToShortDateString() + "','" + oSub.HRelEndDate.ToShortDateString() + "'," + oSub.HTimes.ToString() + | 
|                   "," + oSub.HQty.ToString() + "," + oSub.HCheckQty.ToString() + "," + oSub.HBadCount.ToString() + "," + oSub.HWasterQty.ToString() + "," + oSub.HWasterQty2.ToString() + | 
|                   "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HProcPlanInterID.ToString() + "," + oSub.HProcPlanEntryID.ToString() + ",'" + oSub.HProcPlanBillNo + "'" + | 
|                   "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "'," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" + | 
|                   ",'" + oSub.HCloseMan + "'," + 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.HBadPrirce.ToString() + "," + oSub.HBadMoney.ToString() + "," + oSub.HWasterPrice.ToString() + "," + oSub.HWasterMoney.ToString() + "," + oSub.HQualityRate.ToString() + | 
|                   "," + oSub.HSecUnitQty1.ToString() + "," + oSub.HSecUnitRate1.ToString() + "," + oSub.HSecUnitQty2.ToString() + "," + oSub.HSecUnitRate2.ToString() + "," + oSub.HUsingQty.ToString() + | 
|                   "," + oSub.HSelfBadCount.ToString() + "," + oSub.HPreBadCount.ToString() + "," + oSub.HPayMentQty.ToString() + "," + oSub.HOtherDeduct.ToString() + "," + oSub.HRelPay.ToString() + | 
|                   ",'" + oSub.HOtherItem1.ToString() + "','" + oSub.HOtherItem2.ToString() + "','" + oSub.HOtherItem3.ToString() + "','" + oSub.HOtherItem4.ToString() + "','" + oSub.HOtherItem5.ToString() + | 
|                   "','" + oSub.HPackType.ToString() + "'," + oSub.HCheckEmpID.ToString() + "," + oSub.HWeight.ToString() + ",'" + oSub.HBatchNo + "','0'" + | 
|                   ") "); | 
|                 } | 
|                 //更新关联数量 | 
|                 //AddNewRelation(ref sReturn, omodel.HInterID); | 
|                 //更新关联数量 | 
|                  oCn.RunProc("exec h_p_Sc_UpDateICMOBillStepStatusRelation_Add " + omodel.HInterID); | 
|                 //回填 生产状态表  日计划  为 已完工 状态 | 
|                 //oCn.RunProc("exec h_p_Sc_UpDateICMOBillQualityStatus " + omodel.HICMOStatusInterID.ToString() + ",3"); | 
|                 //默认变为 申请检验状态 | 
|                 oCn.RunProc("exec h_p_Sc_UpDateProcessReportStatus " + omodel.HInterID.ToString() + ",15"); | 
|                 // | 
|                 sReturn = omodel.HInterID.ToString(); | 
|                 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 Sc_ProcessReportMain Where HInterID=" + lngBillKey.ToString(), "Sc_ProcessReportMain"); | 
|                 if(Ds.Tables[0].Rows.Count==0) | 
|                 { | 
|                     sReturn = "单据未找到!"; | 
|                     return false; | 
|                 } | 
|                 //赋值 | 
|                 omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]); | 
|                 omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]); | 
|                 omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]); | 
|                 omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]); | 
|                 omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]); | 
|                 omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]); | 
|                 omodel.HBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]); | 
|                 omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]); | 
|                 omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]); | 
|                 omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]); | 
|                 // | 
|                 omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]); | 
|                 omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"]); | 
|                 omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]); | 
|                 omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]); | 
|                 omodel.HDeptNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeptNumber"]); | 
|                 omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]); | 
|                 omodel.HGroupNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HGroupNumber"]); | 
|                 omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]); | 
|                 omodel.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterNumber"]); | 
|                 omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]); | 
|                 omodel.HUnitNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUnitNumber"]); | 
|                 omodel.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPlanQty"]); | 
|                 omodel.HInStockQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HInStockQty"]); | 
|                 omodel.HSumTimes = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[0]["HSumTimes"]); | 
|                 omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]); | 
|                 omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]); | 
|                 omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]); | 
|                 omodel.HMarker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMarker"]); | 
|                 // | 
|                  omodel.HBacker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBacker"]); | 
|                 omodel.HBackDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBackDate"]); | 
|                 omodel.HChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HChecker"]); | 
|                 omodel.HCheckDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCheckDate"]); | 
|                 omodel.HMaker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaker"]); | 
|                 omodel.HMakeDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMakeDate"]); | 
|                 omodel.HUpDater = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDater"]); | 
|                 omodel.HUpDateDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDateDate"]); | 
|                 omodel.HCloseMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCloseMan"]); | 
|                 omodel.HCloseDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCloseDate"]); | 
|                 omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]); | 
|                 omodel.HDeleteMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeleteMan"]); | 
|                 omodel.HDeleteDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeleteDate"]); | 
|                 //循环 | 
|                 DataSet DsSub ; | 
|                 DsSub = oCn.RunProcReturn("Select * from Sc_ProcessReportSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sc_ProcessReportSub"); | 
|                 DetailColl.Clear();//清空 | 
|                 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) | 
|                 { | 
|                     Models.ClsSc_ProcessReportSub oSub = new Models.ClsSc_ProcessReportSub(); | 
|                     oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]); | 
|                     oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]); | 
|                     // | 
|                     oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]); | 
|                     oSub.HMaterNumber = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HMaterNumber"]); | 
|                     oSub.HProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcID"]); | 
|                     oSub.HProcNumber = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HProcNumber"]); | 
|                     oSub.HEmpID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEmpID"]); | 
|                     oSub.HEmpNumber = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HEmpNumber"]); | 
|                     oSub.HSourceID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceID"]); | 
|                     oSub.HRelBeginDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HRelBeginDate"]); | 
|                     oSub.HRelEndDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HRelEndDate"]); | 
|                     oSub.HTimes = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HTimes"]); | 
|                     oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]); | 
|                     oSub.HCheckQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HCheckQty"]); | 
|                     oSub.HBadCount = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HBadCount"]); | 
|                     oSub.HWasterQty = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HWasterQty"]); | 
|                     oSub.HWasterQty2 = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HWasterQty2"]); | 
|                     oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]); | 
|                     oSub.HMoney = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HMoney"]); | 
|                     oSub.HOutMoney = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HOutMoney"]); | 
|                     oSub.HOutPrice = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HOutPrice"]); | 
|                     //addnew | 
|                     oSub.HBadPrirce = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HBadPrirce"]); | 
|                     oSub.HBadMoney = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HBadMoney"]); | 
|                     oSub.HWasterPrice = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HWasterPrice"]); | 
|                     oSub.HWasterMoney = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HWasterMoney"]); | 
|                     oSub.HQualityRate = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HQualityRate"]); | 
|   | 
|                     oSub.HSecUnitQty1 = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HSecUnitQty1"]); | 
|                     oSub.HSecUnitRate1 = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HSecUnitRate1"]); | 
|                     oSub.HSecUnitQty2 = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HSecUnitQty2"]); | 
|                     oSub.HSecUnitRate2 = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HSecUnitRate2"]); | 
|                     oSub.HUsingQty = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HUsingQty"]); | 
|                     oSub.HSelfBadCount = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HSelfBadCount"]); | 
|                     oSub.HPreBadCount = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HPreBadCount"]); | 
|   | 
|                     oSub.HPayMentQty = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HPayMentQty"]); | 
|                     oSub.HOtherDeduct = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HOtherDeduct"]); | 
|                     oSub.HRelPay = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HRelPay"]); | 
|                     oSub.HBatchNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HBatchNo"]); | 
|   | 
|                     oSub.HOtherItem1 = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HOtherItem1"]); | 
|                     oSub.HOtherItem2 = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HOtherItem2"]); | 
|                     oSub.HOtherItem3 = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HOtherItem3"]); | 
|                     oSub.HOtherItem4 = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HOtherItem4"]); | 
|                     oSub.HOtherItem5 = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HOtherItem5"]); | 
|                     oSub.HPackType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HPackType"]); | 
|                     oSub.HCheckEmpID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCheckEmpID"]); | 
|   | 
|                     // | 
|                     oSub.HProcPlanInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcPlanInterID"]); | 
|                     oSub.HProcPlanEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcPlanEntryID"]); | 
|                     oSub.HProcPlanBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HProcPlanBillNo"]); | 
|                     oSub.HICMOInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HICMOInterID"]); | 
|                     oSub.HICMOBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HICMOBillNo"]); | 
|                     oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderInterID"]); | 
|                     oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderEntryID"]); | 
|                     oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSeOrderBillNo"]); | 
|                     // | 
|                     oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]); | 
|                     oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]); | 
|                     oSub.HRemark = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRemark"]); | 
|                     oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]); | 
|                     oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]); | 
|                     oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSourceBillNo"]); | 
|                     oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSourceBillType"]); | 
|                     oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]); | 
|                     oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]); | 
|                     DetailColl.Add(oSub); | 
|                 } | 
|                 sReturn = "显示单据成功!"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //审核 | 
|         public bool CheckBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             DataSet oDs = new DataSet(); | 
|             string sBillName = ""; | 
|             sReturn = ""; | 
|             try | 
|             { | 
|                 string HChecker = DBUtility.ClsPub.CurUserName; | 
|                 string HCheckDate = DBUtility.ClsPub.GetServerDate(-1); | 
|                 // | 
|                 oDs = oCn.RunProcReturn("select * from Sc_ProcessReportSub where HInterID=" + lngBillKey.ToString(), "Sc_ProcessReportSub"); | 
|                 if (oDs == null || oDs.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     return false; | 
|                 } | 
|                 for (int i = 0; i <= oDs.Tables[0].Rows.Count - 1; i++) | 
|                 { | 
|                     long ProdMoveInterID = DBUtility.ClsPub.CreateBillID("3771", ref DBUtility.ClsPub.sExeReturnInfo); | 
|                     string ProdMoveBillNo = DBUtility.ClsPub.CreateBillCode("3771", ref DBUtility.ClsPub.sExeReturnInfo, true); | 
|                     //oCn.RunProc("exec h_p_Sc_ProcProdMoveBill_Add " + lngBillKey.ToString() + "," + DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[i]["HEntryID"]).ToString() + "," + ProdMoveInterID.ToString() + ",'" + ProdMoveBillNo + "','" + HChecker + "'"); | 
|                     sBillName = sBillName + ProdMoveBillNo + ","; | 
|                 } | 
|                 oCn.RunProc(" Update " + MvarItemKey + " set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString()); | 
|   | 
|                 sReturn = sBillName; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|   | 
|         } | 
|         //反审核 | 
|         public bool AbandonCheck(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             DataSet oDs = new DataSet(); | 
|             string sBillName = ""; | 
|             sReturn = ""; | 
|             try | 
|             { | 
|                 string HChecker = DBUtility.ClsPub.CurUserName; | 
|                 string HCheckDate = DBUtility.ClsPub.GetServerDate(-1); | 
|                 // | 
|                 oDs = oCn.RunProcReturn("select * from Sc_ProcessReportSub where HInterID=" + lngBillKey.ToString(), "Sc_ProcessReportSub"); | 
|                 if (oDs == null || oDs.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     return false; | 
|                 } | 
|                 for (int i = 0; i <= oDs.Tables[0].Rows.Count - 1; i++) | 
|                 { | 
|                     long ProdMoveInterID = DBUtility.ClsPub.CreateBillID("3771", ref DBUtility.ClsPub.sExeReturnInfo); | 
|                     string ProdMoveBillNo = DBUtility.ClsPub.CreateBillCode("3771", ref DBUtility.ClsPub.sExeReturnInfo, true); | 
|                     //oCn.RunProc("exec h_p_Sc_ProcProdMoveBill_Add " + lngBillKey.ToString() + "," + DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[i]["HEntryID"]).ToString() + "," + ProdMoveInterID.ToString() + ",'" + ProdMoveBillNo + "','" + HChecker + "'"); | 
|                     sBillName = sBillName + ProdMoveBillNo + ","; | 
|                 } | 
|                 oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='1',HChecker='',HCheckDate='' Where HInterID=" + lngBillKey.ToString()); | 
|   | 
|                 sReturn = sBillName; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             }   | 
|         } | 
|   | 
|   | 
|         //删除关联 | 
|         public override void DeleteRelation(ref string sReturn, Int64 lngBillKey) | 
|         { | 
|             //增加 | 
|             try | 
|             { | 
|                 if (omodel.HMainSourceBillType == "工序计划单") | 
|                 { | 
|                     oCn.RunProc("exec h_p_Sc_UpDateProcessPlanRelation_Del " + lngBillKey.ToString()); | 
|                 } | 
|                 else | 
|                 { | 
|                     oCn.RunProc("exec h_p_Sc_UpDateICMOBillStatusRelation_Del " + lngBillKey.ToString()); | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //新增关联 | 
|         public override void AddNewRelation(ref string sReturn, Int64 lngBillKey) | 
|         { | 
|             //增加 | 
|             try | 
|             { | 
|                 if (omodel.HMainSourceBillType == "工序计划单") | 
|                 { | 
|                     oCn.RunProc("exec h_p_Sc_UpDateProcessPlanRelation_Add " + lngBillKey.ToString()); | 
|                 } | 
|                 else | 
|                 { | 
|                     oCn.RunProc("exec h_p_Sc_UpDateICMOBillStatusRelation_Add " + lngBillKey.ToString()); | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         public bool CheckStatus(long HMainID, long HSubID, ref string sReturn) | 
|         { | 
|             DataSet oDs = new DataSet(); | 
|             oDs = oCn.RunProcReturn("exec h_p_Sc_CheckProcessReportStatus " + HMainID.ToString() + "," + HSubID.ToString(), "h_p_Sc_CheckProcessReportStatus"); | 
|             if (oDs == null || oDs.Tables[0].Rows.Count == 0) | 
|             { | 
|                 sReturn = "未查询到记录!"; | 
|                 return false; | 
|             } | 
|             if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) != 99) | 
|             { | 
|                 sReturn = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][1]); | 
|                 return false; | 
|             } | 
|             else | 
|             { | 
|                 sReturn = "正常"; | 
|                 return true; | 
|             } | 
|         } | 
|   | 
|   | 
|         // | 
|     } | 
|   | 
| } |