using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsSc_PPBom_K3:DBUtility.ClsXt_BaseBill { public Model.ClsSc_PPBomMain_K3 omodel = new Model.ClsSc_PPBomMain_K3(); public List DetailColl = new List(); public ClsSc_PPBom_K3() { base.MvarItemKeySub = "PPBomEntry"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey="PPBom"; base.MvarReportTitle="生产投料单"; base.BillType="88"; } #region 固定代码 ~ClsSc_PPBom_K3() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { //try //{ // // // oCn.BeginTran(); // //更新主表 // oCn.RunProc("UpDate Sc_PPBomMain set " + // " HBillNo='" + omodel.HBillNo + "'" + // ",HSeOrderBillNo='" + omodel.HSeOrderBillNo + "'" + // ",HSeOrderInterID=" + omodel.HSeOrderInterID.ToString() + // ",HSeOrderEntryID=" + omodel.HSeOrderEntryID.ToString() + // ",HDeptID=" + omodel.HDeptID.ToString() + // ",HDeptNumber='" + omodel.HDeptNumber + "'" + // ",HEmpID=" + omodel.HEmpID.ToString() + // ",HEmpNumber='" + omodel.HEmpNumber + "'" + // ",HCusID=" + omodel.HCusID.ToString() + // ",HCusNumber='" + omodel.HCusNumber + "'" + // ",HCenterID=" + omodel.HCenterID.ToString() + // ",HCenterNumber='" + omodel.HCenterNumber + "'" + // ",HMaterID=" + omodel.HMaterID.ToString() + // ",HMaterNumber='" + omodel.HMaterNumber + "'" + // ",HUnitID=" + omodel.HUnitID.ToString() + // ",HUnitNumber='" + omodel.HUnitNumber + "'" + // ",HBomID=" + omodel.HBomID.ToString() + // ",HRoutingInterID=" + omodel.HRoutingInterID.ToString() + // ",HBomNumber='" + omodel.HBomNumber + "'" + // ",HDate='" + omodel.HDate + "'" + // ",HPlanBeginDate='" + omodel.HPlanBeginDate + "'" + // ",HPlanEndDate='" + omodel.HPlanEndDate + "'" + // ",HBeginDate='" + omodel.HBeginDate + "'" + // ",HEndDate='" + omodel.HEndDate + "'" + // ",HLevNum=" + omodel.HLevNum.ToString() + // ",HReadyQty=" + omodel.HReadyQty.ToString() + // ",HPlanQty=" + omodel.HPlanQty.ToString() + // ",HYear='" + omodel.HYear.ToString() + "'" + // ",HPeriod='" + omodel.HPeriod.ToString() + "'" + // ",HRemark='" + omodel.HRemark + "'" + // ",HUpDater='" + omodel.HUpDater + "'" + // ",HUpDateDate='" + omodel.HUpDateDate + "'" + // " where HInterID=" + lngBillKey.ToString()); // //删除关联 // DeleteRelation(ref sReturn, lngBillKey); // ////删除子表 // //DeleteBillSub(lngBillKey); // ////插入子表 // //omodel.HInterID = lngBillKey; // //foreach (Model.ClsSc_PPBomSub_K3 oSub in DetailColl) // //{ // // oCn.RunProc("Insert into Sc_PPBomSub " + // // " (HInterID,HEntryID,HCloseMan,HCloseType," + // // "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + // // ") values(" // // + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + 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); //} } //新增单据 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_PPBomMain " + // "(HBillType,HInterID,HBillNo,HDate,HSeOrderBillNo" + // ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + // ",HSeOrderInterID,HSeOrderEntryID,HDeptID,HDeptNumber,HCusID,HCusNumber" + // ",HCenterID,HCenterNumber,HMaterID,HMaterNumber,HUnitID,HUnitNumber" + // ",HBomID,HBomNumber,HRoutingInterID,HPlanBeginDate,HPlanEndDate,HBeginDate" + // ",HEndDate,HLevNum,HReadyQty,HPlanQty" + // ") " + // " values('" + this.BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate.ToShortDateString() + "','" + omodel.HSeOrderBillNo + "'" + // "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "'," + omodel.HEmpID.ToString() + ",'" + omodel.HEmpNumber + "'" + // "," + omodel.HSeOrderInterID.ToString() + "," + omodel.HSeOrderEntryID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HDeptNumber + "'," + omodel.HCusID.ToString() + ",'" + omodel.HCusNumber +"'"+ // "," + omodel.HCenterID.ToString() + ",'" + omodel.HCenterNumber + "'," + omodel.HMaterID.ToString() + ",'" + omodel.HMaterNumber + "'," + omodel.HUnitID.ToString() + ",'" + omodel.HUnitNumber + "'" + // "," + omodel.HBomID.ToString() + ",'" + omodel.HBomNumber + "'," + omodel.HRoutingInterID.ToString() + ",'" + omodel.HPlanBeginDate.ToShortDateString() + "','" + omodel.HPlanEndDate.ToShortDateString() + "','" + omodel.HBeginDate.ToShortDateString() + "'" + // ",'" + omodel.HEndDate.ToShortDateString() + "'," + omodel.HLevNum.ToString() + "," + omodel.HReadyQty.ToString() + "," + omodel.HPlanQty.ToString() + // ") "); // ////插入子表 // //foreach (Model.ClsSc_PPBomSub_K3 oSub in DetailColl) // //{ // // oCn.RunProc("Insert into Sc_PPBomSub " + // // " (HInterID,HEntryID,HCloseMan,HCloseType," + // // "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + // // ") values(" // // + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + 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); //} } //显示单据 public override bool ShowBill(Int64 lngBillKey, ref string sReturn) { try { //查询主表 DataSet Ds ; SQLHelper.ClsCNK3 oCn = new SQLHelper.ClsCNK3(); Ds = oCn.RunProcReturn("Select * from PPBom Where FInterID=" + lngBillKey.ToString(), "PPBom"); if(Ds.Tables[0].Rows.Count==0) { sReturn = "单据未找到!"; return false; } //赋值 omodel.FICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FICMOInterID"]); omodel.FOrderBillNo = Ds.Tables[0].Rows[0]["FOrderBillNo"].ToString().Trim(); omodel.FBillNo = Ds.Tables[0].Rows[0]["FBillNo"].ToString().Trim(); omodel.FDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["FDate"]); omodel.FItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FItemID"]); omodel.FWorkShop = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FWorkShop"]); omodel.FUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FUnitID"]); omodel.FAuxQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["FAuxQty"]); //================= omodel.FBillerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FBillerID"]); omodel.FCheckerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FCheckerID"]); omodel.FCheckDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["FCheckDate"]); // //循环 DataSet DsSub; DsSub = oCn.RunProcReturn("Select * from PPBomEntry Where FInterID=" + lngBillKey.ToString() + " order by HEntryID ", "PPBomEntry"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsSc_PPBomSub_K3 oSub = new Model.ClsSc_PPBomSub_K3(); oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FInterID"].ToString()); oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FEntryID"].ToString()); // oSub.FItemID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FItemID"].ToString()); oSub.FMaterielType = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FMaterielType"].ToString()); oSub.FQtyScrap = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FQtyScrap"].ToString()); oSub.FUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FUnitID"].ToString()); oSub.FBOMInPutAuxQTY = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FBOMInPutAuxQTY"].ToString()); oSub.FScrap = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FScrap"].ToString()); oSub.FAuxQtyLoss = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxQtyLoss"].ToString()); //oSub.FRealScrap = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FRealScrap"].ToString()); oSub.FAuxQtyPick = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxQtyPick"].ToString()); oSub.FAuxQtyMust = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxQtyMust"].ToString()); oSub.FAuxStockQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxStockQty"].ToString()); oSub.FDisCardAuxQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FDisCardAuxQty"].ToString()); oSub.FSendItemDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["FSendItemDate"].ToString()); oSub.FStockID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FStockID"].ToString()); oSub.FSPID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSPID"].ToString()); oSub.FBatchNo = DsSub.Tables[0].Rows[i]["FBatchNo"].ToString().Trim(); oSub.FBackFlush = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FBackFlush"].ToString()); oSub.FOPerID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FOPerID"].ToString()); oSub.FMachinePos = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FMachinePos"].ToString()); oSub.FNote = DsSub.Tables[0].Rows[i]["FNote"].ToString().Trim(); oSub.FAuxQtySupply = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxQtySupply"].ToString()); oSub.FOperSN = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FOperSN"].ToString()); oSub.FBomInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FBomInterID"].ToString()); oSub.FPositionNo = DsSub.Tables[0].Rows[i]["FPositionNo"].ToString().Trim(); oSub.FItemSize = DsSub.Tables[0].Rows[i]["FItemSize"].ToString().Trim(); oSub.FItemSuite = DsSub.Tables[0].Rows[i]["FItemSuite"].ToString().Trim(); DetailColl.Add(oSub); } sReturn = "显示单据成功!"; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } } }