using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; namespace WebAPI.DLL { public class ClsWW_EntrustProcessReportBill : DBUtility.ClsXt_BaseBill { public WebAPI.Models.ClsWW_EntrustProcessReportBillMain omodel = new WebAPI.Models.ClsWW_EntrustProcessReportBillMain(); public List DetailColl = new List(); public ClsWW_EntrustProcessReportBill() { base.MvarItemKeySub = "WW_EntrustProcessReportBillSub"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "WW_EntrustProcessReportBillMain"; base.MvarReportTitle = "委外工序计划汇报单"; base.BillType = "3742"; base.HBillSubType = "3742"; } #region 固定代码 ~ClsWW_EntrustProcessReportBill() { DetailColl = null; } #endregion 自定义方法 #region ////修改单据 //public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) //{ // try // { // // // oCn.BeginTran(); // //更新主表 // oCn.RunProc("UpDate Sc_ProcessSendWorkMain set " + // " HYear=" + omodel.HYear.ToString() + // ",HPeriod=" + omodel.HPeriod.ToString() + // ",HInterID=" + omodel.HInterID.ToString() + // ",HDate='" + omodel.HDate.ToShortDateString() + "'" + // ",HBillNo='" + omodel.HBillNo + "'" + // ",HBillStatus=" + omodel.HBillStatus.ToString() + // ",HCheckItemNowID=" + omodel.HCheckItemNowID.ToString() + // ",HCheckItemNextID=" + omodel.HCheckItemNextID.ToString() + // ",HCheckFlowID=" + omodel.HCheckFlowID.ToString() + // ",HICMOInterID=" + omodel.HICMOInterID.ToString() + // ",HICMOBillNo='" + omodel.HICMOBillNo + "'" + // ",HProcPlanBillNo='" + omodel.HProcPlanBillNo + "'" + // ",HPlanBeginDate='" + omodel.HPlanBeginDate.ToShortDateString() + "'" + // ",HPlanEndDate='" + omodel.HPlanEndDate.ToShortDateString() + "'" + // ",HBatchNo='" + omodel.HBatchNo + "'" + // ",HSeOrderInterID=" + omodel.HSeOrderInterID.ToString() + // ",HSeOrderEntryID=" + omodel.HSeOrderEntryID.ToString() + // ",HSeOrderBillNo='" + omodel.HSeOrderBillNo + "'" + // ",HProcID=" + omodel.HProcID.ToString() + // ",HProcNumber='" + omodel.HProcNumber + "'" + // ",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 + "'" + // ",HRoutingInterID=" + omodel.HRoutingInterID.ToString() + // ",HPlanQty=" + omodel.HPlanQty.ToString() + // ",HExplanation='" + omodel.HExplanation + "'" + // ",HRemark='" + omodel.HRemark + "'" + // ",HInnerBillNo='" + omodel.HInnerBillNo + "'" + // ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" + // ",HUpDateDate=getdate()" + // ",HSupID=" + omodel.HSupID.ToString() + // " where HInterID=" + lngBillKey.ToString()); // //删除关联 // DeleteRelation(ref sReturn, lngBillKey); // //删除子表 // DeleteBillSub(lngBillKey); // //插入子表 // omodel.HInterID = lngBillKey; // foreach (Model.ClsSc_ProcessSendWorkSub oSub in DetailColl) // { // oCn.RunProc("Insert into Sc_ProcessSendWorkSub " + // " (HInterID,HEntryID,HProcID,HProcNumber,HGroupID,HSourceID,HSourceNumber" + // ",HGroupNumber,HWorkerID,HWorkerNumber,HQty,HPlanBeginDate" + // ",HPlanEndDate,HPlanTimes,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + // ",HICMOBillNo,HICMOInterID,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo" + // ",HCloseMan,HCloseType,HRemark,HSourceInterID,HSourceEntryID" + // ",HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + // ") values(" // + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNumber + "'," + oSub.HGroupID.ToString() + "," + oSub.HSourceID.ToString() + ",'" + oSub.HSourceNumber + "'" + // ",'" + oSub.HGroupNumber + "'," + oSub.HWorkerID.ToString() + ",'" + oSub.HWorkerNumber + "'," + oSub.HQty.ToString() + ",'" + oSub.HPlanBeginDate + "'" + // ",'" + oSub.HPlanEndDate + "'," + oSub.HPlanTimes.ToString() + "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" + // ",'" + oSub.HICMOBillNo + "'," + oSub.HICMOInterID.ToString() + "," + oSub.HProcPlanInterID.ToString() + "," + oSub.HProcPlanEntryID.ToString() + ",'" + oSub.HProcPlanBillNo + "'" + // ",'" + 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() + // ") "); // } // sReturn = "修改单据成功!"; // oCn.Commit(); // return true; // } // catch (Exception e) // { // sReturn = e.Message; // oCn.RollBack(); // throw (e); // } //} #endregion //新增单据 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 WW_EntrustProcessReportBillMain " + "(HYear, HPeriod, HBillType, HBillSubType, HInterID" + ",HDate, HBillNo, HBillStatus, HCheckItemNowID, HCheckItemNextID" + ",HCheckFlowID, HRemark, HBacker, HBackDate, HBackRemark" + ",HChecker, HCheckDate, HMaker, HMakeDate, HUpDater" + ",HUpDateDate, HCloseMan, HCloseDate, HCloseType,HDeleteMan" + ",HDeleteDate,HMainSourceBillType, HMainSourceInterID, HMainSourceEntryID, HMainSourceBillNo" + ",[HPrintQty], [HDeptID], [HSupID], [HEmpID], [HExplanation], [HInnerBillNo]" + ") " + " values(" + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + this.BillType + "','" + omodel.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HDate.ToShortDateString() + "','" + omodel.HBillNo + "'," + omodel.HBillStatus + "," + omodel.HCheckItemNowID.ToString() + "," + omodel.HCheckItemNextID.ToString() + "," + omodel.HCheckFlowID.ToString() + ",'" + omodel.HRemark + "','" + omodel.HBacker + "','" + omodel.HBackDate + "','" + omodel.HBackRemark + "'" + ",'" + omodel.HChecker + "','" + omodel.HCheckDate + "','" + DBUtility.ClsPub.CurUserName + "',getdate(),'" + omodel.HUpDater + "'" + ",'" + omodel.HUpDateDate + "','" + omodel.HCloseMan + "','" + omodel.HCloseDate + "'," + Convert.ToString(omodel.HCloseType ? 1 : 0) + ",'" + omodel.HDeleteMan + "'" + ",'" + omodel.HDeleteDate + "','" + omodel.HMainSourceBillType + "'," + omodel.HMainSourceInterID.ToString() + "," + omodel.HMainSourceEntryID.ToString() + ",'" + omodel.HMainSourceBillNo + "'" + ",'" + omodel.HPrintQty + "','" + omodel.HDeptID + "','" + omodel.HSupID + "','" + omodel.HEmpID +"'"+ ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'" + ") "); //插入子表 foreach (Models.ClsWW_EntrustProcessReportBillSub oSub in DetailColl) { oCn.RunProc("Insert into WW_EntrustProcessReportBillSub " + "([HInterID], [HBillNo_bak], [HEntryID], [HCloseMan], [HEntryCloseDate], [HCloseType], [HRemark], [HSourceInterID]" + ",[HSourceEntryID], [HSourceBillNo], [HSourceBillType], [HRelationQty], [HRelationMoney], [HProcID]" + ", [HSupFlag], [HMaterID], [HTimes], [HQty],[HCheckQty], [HBadCount], [HWasterQty], [HWasterQty2], [HWeight]" + ", [HPrice], [HMoney], [HBatchNo], [HBadPrirce], [HBadMoney], [HWasterPrice], [HWasterMoney],[HQualityRate]" + ", [HUsingQty], [HSelfBadCount], [HPreBadCount], [HPayMentQty], [HPackType],[HCheckEmpID], [HProcPlanInterID]" + ", [HProcPlanEntryID], [HProcPlanBillNo], [HICMOInterID],[HICMOEntryID], [HICMOBillNo], [HSeOrderInterID]" + ", [HSeOrderEntryID], [HSeOrderBillNo]" + ") " + "values(" + omodel.HInterID.ToString() + ",'" + oSub.HBillNo_bak + "'," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "'," + oSub.HEntryCloseDate.ToShortDateString() + "," + 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.HProcID.ToString() + "," + Convert.ToString(oSub.HSupFlag ? 1 : 0) + "," + oSub.HMaterID.ToString() + "," + oSub.HTimes.ToString() + "," + oSub.HQty.ToString() + "," + oSub.HCheckQty.ToString() + "," + oSub.HBadCount.ToString() + "," + oSub.HWasterQty.ToString() + "," + oSub.HWasterQty2.ToString() + "," + oSub.HWeight.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HBadPrirce.ToString() + "," + oSub.HBadMoney.ToString() + "," + oSub.HWasterPrice.ToString() + "," + oSub.HWasterMoney.ToString() + "," + oSub.HQualityRate.ToString() + "," + oSub.HUsingQty + "," + oSub.HSelfBadCount + "," + oSub.HPreBadCount.ToString() + "," + oSub.HPayMentQty.ToString() + ",'" + oSub.HPackType + "'," + oSub.HCheckEmpID.ToString() + "," + oSub.HProcPlanInterID.ToString() + "," + oSub.HProcPlanEntryID.ToString() + ",'" + oSub.HProcPlanBillNo + "'," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo + "','" + oSub.HSeOrderInterID + "','" + oSub.HSeOrderEntryID + "','" + oSub.HSeOrderBillNo + "'" + ") "); } 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 WW_EntrustProcessReportBillMain Where HInterID=" + lngBillKey.ToString(), "WW_EntrustProcessReportBillMain"); 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.HSupID = (int)DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]); omodel.HDeptID = (int)DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]); 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.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.ClsWW_EntrustProcessReportBillSub oSub = new Models.ClsWW_EntrustProcessReportBillSub(); oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]); oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]); // oSub.HMaterID = (int)DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]); oSub.HProcID = (int)DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcID"]); oSub.HTimes = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HTimes"]); oSub.HQty = (decimal)DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]); oSub.HCheckQty = (decimal)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 = (decimal)DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]); oSub.HMoney = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HMoney"]); //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.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.HBatchNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HBatchNo"]); oSub.HPackType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HPackType"]); oSub.HCheckEmpID = (int)DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCheckEmpID"]); // oSub.HProcPlanInterID = (int)DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcPlanInterID"]); oSub.HProcPlanEntryID = (int)DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcPlanEntryID"]); oSub.HProcPlanBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HProcPlanBillNo"]); oSub.HICMOInterID = (int)DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HICMOInterID"]); oSub.HICMOBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HICMOBillNo"]); oSub.HSeOrderInterID = (int)DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderInterID"]); oSub.HSeOrderEntryID = (int)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); } } } }