using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsSc_ProcessBackPlan : DBUtility.ClsXt_BaseBill { public Model.ClsSc_ProcessBackPlanMain omodel = new Model.ClsSc_ProcessBackPlanMain(); public List DetailColl = new List(); public ClsSc_ProcessBackPlan() { base.MvarItemKeySub = "Sc_ProcessBackPlanSub"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "Sc_ProcessBackPlanMain"; base.MvarReportTitle = "返工工序"; base.BillType = "3718"; base.HBillSubType = "3718"; } #region 固定代码 ~ClsSc_ProcessBackPlan() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { try { // oCn.BeginTran(); //更新主表 oCn.RunProc("UpDate Sc_ProcessBackPlanMain set " + " HBillNo='" + omodel.HBillNo + "'" + //固定赋值=============== ",HDate='" + omodel.HDate + "'" + ",HYear='" + omodel.HYear.ToString() + "'" + ",HPeriod='" + omodel.HPeriod.ToString() + "'" + ",HRemark='" + omodel.HRemark + "'" + ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" + ",HUpDateDate=getdate()" + //======================================== ",HICMOInterID=" + omodel.HICMOInterID.ToString() + ",HMaterID=" + omodel.HMaterID.ToString() + ",HUnitID=" + omodel.HUnitID.ToString() + ",HPlanQty=" + omodel.HPlanQty.ToString() + ",HPlanEndDate='" + omodel.HPlanEndDate + "'" + ",HPlanBeginDate='" + omodel.HPlanBeginDate + "'" + ",HICMOBillNo='" + omodel.HICMOBillNo + "'" + ",HMaterNumber='" + omodel.HMaterNumber + "'" + ",HUnitNumber='" + omodel.HUnitNumber + "'" + ",HExplanation='" + omodel.HExplanation + "'" + ",HInnerBillNo='" + omodel.HInnerBillNo + "'" + " where HInterID=" + lngBillKey.ToString()); //删除关联 DeleteRelation(ref sReturn, lngBillKey); //删除子表 DeleteBillSub(lngBillKey); oCn.RunProc("exec h_p_Sc_ProcessPlanUpdateToPlanDelete " + lngBillKey.ToString()); //插入子表 omodel.HInterID = lngBillKey; foreach (Model.ClsSc_ProcessBackPlanSub oSub in DetailColl) { oCn.RunProc("Insert into Sc_ProcessBackPlanSub " + " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + ",HBillNo,HMaterID,HProcNo,HProcID,HProcNumber,HWorkRemark,HCenterID,HDeptID" + ",HDeptNumber,HGroupID,HGroupNumber,HWorkerID,HWorkerNumber,HSourceID,HQty" + ",HTimeUnit,HPlanWorkTimes,HPlanBeginDate,HPlanEndDate,HICMOInterID" + ",HICMOBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + ") values(" + omodel.HInterID.ToString() + "," + 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.HBillNo + "'," + oSub.HMaterID.ToString() + "," + oSub.HProcNo.ToString() + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNumber + "','" + oSub.HWorkRemark + "'," + oSub.HCenterID.ToString() + "," + oSub.HDeptID.ToString() + ",'" + oSub.HDeptNumber + "'," + oSub.HGroupID.ToString() + ",'" + oSub.HGroupNumber + "'," + oSub.HWorkerID.ToString() + ",'" + oSub.HWorkerNumber + "'," + oSub.HSourceID.ToString() + "," + oSub.HQty.ToString() + ",'" + oSub.HTimeUnit + "'," + oSub.HPlanWorkTimes.ToString() + ",'" + oSub.HPlanBeginDate + "','" + oSub.HPlanEndDate + "'," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "'," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" + ") "); } // //foreach (Model.ClsSc_ProcessBackPlanSub oSub in DetailColl) //{ // Ds = oCn.RunProcReturn("exec h_p_Sc_ProcessBackPlan_Qty " + oSub.HICMOInterID, ""); // if (Ds.Tables[0].Rows.Count == 0) // return; // if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y") // { // sReturn = "汇报数量超过计划数量!不允许保存"; // return false; // } //} oCn.RunProc("exec h_p_Sc_ReportUpdateToPlanAdd " + omodel.HInterID.ToString()); 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_ProcessBackPlanMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HYear,HPeriod,HRemark,HMaker,HMakeDate" + ",HICMOInterID,HICMOBillNo,HMaterID,HMaterNumber,HUnitID,HUnitNumber" + ",HPlanQty,HPlanBeginDate,HPlanEndDate,HExplanation,HInnerBillNo" + ") " + " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" + ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" + ", " + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "'," + omodel.HMaterID.ToString() + ",'" + omodel.HMaterNumber + "'," + omodel.HUnitID.ToString() + ",'" + omodel.HUnitNumber + "'" + ", " + omodel.HPlanQty.ToString() + ", '" + omodel.HPlanBeginDate + "','" + omodel.HPlanEndDate + "', '" + omodel.HExplanation + "', '" + omodel.HInnerBillNo + "'" + ") "); //插入子表 foreach (Model.ClsSc_ProcessBackPlanSub oSub in DetailColl) { oCn.RunProc("Insert into Sc_ProcessBackPlanSub " + " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + ",HBillNo,HMaterID,HProcNo,HProcID,HProcNumber,HWorkRemark,HCenterID,HDeptID" + ",HDeptNumber,HGroupID,HGroupNumber,HWorkerID,HWorkerNumber,HSourceID,HQty" + ",HTimeUnit,HPlanWorkTimes,HPlanBeginDate,HPlanEndDate,HICMOInterID" + ",HICMOBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + ") values(" + omodel.HInterID.ToString() + "," + 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.HBillNo + "'," + oSub.HMaterID.ToString() + "," + oSub.HProcNo.ToString() + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNumber + "','" + oSub.HWorkRemark + "'," + oSub.HCenterID.ToString() + "," + oSub.HDeptID.ToString() + ",'" + oSub.HDeptNumber + "'," + oSub.HGroupID.ToString() + ",'" + oSub.HGroupNumber + "'," + oSub.HWorkerID.ToString() + ",'" + oSub.HWorkerNumber + "'," + oSub.HSourceID.ToString() + "," + oSub.HQty.ToString() + ",'" + oSub.HTimeUnit + "'," + oSub.HPlanWorkTimes.ToString() + ",'" + oSub.HPlanBeginDate + "','" + oSub.HPlanEndDate + "'," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "'," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" + ") "); } // //foreach (Model.ClsSc_ProcessBackPlanSub oSub in DetailColl) //{ // Ds = oCn.RunProcReturn("exec h_p_Sc_ProcessBackPlan_Qty " + oSub.HICMOInterID, ""); // if (Ds.Tables[0].Rows.Count == 0) // return; // if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y") // { // sReturn = "汇报数量超过计划数量!不允许保存"; // return false; // } //} oCn.RunProc("exec h_p_Sc_ProcessPlanUpdateToPlanAdd " + omodel.HInterID.ToString()); // sReturn = "新增单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } //删除单据 public virtual bool DeleteBill(Int64 lngBillKey, ref string sReturn) { try { oCn.BeginTran(); oCn.RunProc("exec h_p_Sc_ProcessPlanUpdateToPlanDelete " + lngBillKey.ToString()); DeleteBillMain(lngBillKey); DeleteBillSub(lngBillKey); 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 Sc_ProcessBackPlanMain Where HInterID=" + lngBillKey.ToString(), "Sc_ProcessBackPlanMain"); 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 = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim(); 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.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]); omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim(); omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim(); omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim(); omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim(); omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim(); omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim(); omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim(); omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim(); omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim(); omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim(); omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim(); omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]); omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim(); omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim(); //======================================================== omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]); omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"]); 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.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HPlanBeginDate"]); omodel.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HPlanEndDate"]); omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]); omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]); // //循环 DataSet DsSub; DsSub = oCn.RunProcReturn("Select * from Sc_ProcessBackPlanSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sc_ProcessBackPlanSub"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsSc_ProcessBackPlanSub oSub = new Model.ClsSc_ProcessBackPlanSub(); // 固定赋值=============================================== oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]); oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]); oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]); oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]); oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim(); oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim(); oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]); oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]); oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]); oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]); oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]); oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim(); //=================================================== oSub.HBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HBillNo"]); oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]); oSub.HProcNo = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcNo"]); oSub.HProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcID"]); oSub.HProcNumber = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HProcNumber"]); oSub.HWorkRemark = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HWorkRemark"]); oSub.HCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCenterID"]); oSub.HDeptID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HDeptID"]); oSub.HDeptNumber = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HDeptNumber"]); oSub.HGroupID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HGroupID"]); oSub.HGroupNumber = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HGroupNumber"]); oSub.HWorkerID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HWorkerID"]); oSub.HWorkerNumber = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HWorkerNumber"]); oSub.HSourceID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceID"]); oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]); oSub.HTimeUnit = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HTimeUnit"]); oSub.HPlanWorkTimes = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPlanWorkTimes"]); oSub.HPlanBeginDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HPlanBeginDate"]); oSub.HPlanEndDate = DBUtility.ClsPub.isDate (DsSub.Tables[0].Rows[i]["HPlanEndDate"]); 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"]); DetailColl.Add(oSub); } sReturn = "显示单据成功!"; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } } }