using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsCB_WIPChangeMoneyBill : DBUtility.ClsXt_BaseBill { public Model.ClsCB_WIPChangeMoneyBillMain omodel = new Model.ClsCB_WIPChangeMoneyBillMain(); public List DetailColl = new List(); public ClsCB_WIPChangeMoneyBill() { base.MvarItemKeySub = "CB_WIPChangeMoneyBillSub"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "CB_WIPChangeMoneyBillMain"; base.MvarReportTitle = "CB_WIPChangeMoneyBill"; base.BillType = "1824"; base.HBillSubType = "1824"; } #region 固定代码 ~ClsCB_WIPChangeMoneyBill() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { try { oCn.BeginTran(); //更新主表 oCn.RunProc("UpDate CB_WIPChangeMoneyBillMain set " + " HBillNo='" + omodel.HBillNo + "'" + ",HDeptID=" + omodel.HDeptID.ToString() + ",HCostCenterID=" + omodel.HCostCenterID.ToString() + ",HExplanation='" + omodel.HExplanation + "'" + ",HInnerBillNo='" + omodel.HInnerBillNo + "'" + ",HDate='" + omodel.HDate + "'" + ",HYear='" + omodel.HYear.ToString() + "'" + ",HPeriod='" + omodel.HPeriod.ToString() + "'" + ",HRemark='" + omodel.HRemark + "'" + ",HUpdater='" + DBUtility.ClsPub.CurUserName + "'" + ",HUpdateDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" + " where HInterID=" + lngBillKey.ToString()); //删除关联 DeleteRelation(ref sReturn, lngBillKey); //删除子表 DeleteBillSub(lngBillKey); //插入子表 foreach (Model.ClsCB_WIPChangeMoneyBillSub oSub in DetailColl) { oCn.RunProc("Insert into CB_WIPChangeMoneyBillSub " + " (HInterID,HEntryID" + ",HCostObjID,HMaterID,HUnitID,HQty,HPrice,HMoney" + ",HBatchNo" + ",HCloseMan,HCloseType,HRemark" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" + ",HRelationQty,HRelationMoney" + ") values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HCostObjID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + ",'" + oSub.HBatchNo + "'"+ ",'" + 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 CB_WIPChangeMoneyBillMain " + "(HBillType,HInterID,HBillNo,HDate" + ",HYear,HPeriod,HRemark,HMaker" + ",HMakeDate,HDeptID,HCostCenterID,HExplanation,HInnerBillNo" + ") " + " values('" + this.BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" + "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.GetServerDate(-1) + "'"+ "," + omodel.HDeptID.ToString() + "," + omodel.HCostCenterID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'" + ") "); //插入子表 foreach (Model.ClsCB_WIPChangeMoneyBillSub oSub in DetailColl) { oCn.RunProc("Insert into CB_WIPChangeMoneyBillSub " + " (HInterID,HEntryID" + ",HCostObjID,HMaterID,HUnitID,HQty,HPrice,HMoney" + ",HBatchNo" + ",HCloseMan,HCloseType,HRemark" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" + ",HRelationQty,HRelationMoney" + ") values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HCostObjID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + ",'" + oSub.HBatchNo + "'" + ",'" + 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; Ds = oCn.RunProcReturn("Select * from CB_WIPChangeMoneyBillMain Where HInterID=" + lngBillKey.ToString(), "CB_WIPChangeMoneyBillMain"); if (Ds.Tables[0].Rows.Count == 0) { sReturn = "单据未找到!"; return false; } omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()); omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim(); omodel.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["HDate"].ToString().Trim()); omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"].ToString()); omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"].ToString()); omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim(); omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"].ToString()); omodel.HCostCenterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCostCenterID"].ToString()); omodel.HExplanation = Ds.Tables[0].Rows[0]["HExplanation"].ToString().Trim(); omodel.HInnerBillNo = Ds.Tables[0].Rows[0]["HInnerBillNo"].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.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim(); omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim(); omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim(); omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim(); omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim(); omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim(); //循环 DataSet DsSub = new DataSet(); DsSub = oCn.RunProcReturn("Select * from CB_WIPChangeMoneyBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "CB_WIPChangeMoneyBillSub"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsCB_WIPChangeMoneyBillSub oSub = new Model.ClsCB_WIPChangeMoneyBillSub(); oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"].ToString()); oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"].ToString()); oSub.HCostObjID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCostObjID"].ToString()); oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"].ToString()); oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"].ToString()); oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"].ToString()); oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"].ToString()); oSub.HMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HMoney"].ToString()); oSub.HBatchNo = DsSub.Tables[0].Rows[i]["HBatchNo"].ToString().Trim(); oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim(); oSub.HCloseMan = DsSub.Tables[0].Rows[i]["HCloseMan"].ToString().Trim(); oSub.HCloseType = (bool)DsSub.Tables[0].Rows[i]["HCloseType"]; // oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"].ToString()); oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"].ToString()); 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"].ToString()); oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"].ToString()); DetailColl.Add(oSub); } sReturn = "显示单据成功!"; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } /// /// 得到回收金额 料工费 /// /// /// /// //public bool GetPriceCostByHMaterID(long HMaterID, ref double CLMoney, ref double SumMoney) //{ // DataSet Ds; // // // //增加主表 // Ds = oCn.RunProcReturn("exec h_p_CB_GetMaterPriceCost " + HMaterID.ToString(), "h_p_CB_GetMaterPriceCost"); // if (Ds == null || Ds.Tables[0].Rows.Count == 0) // { // CLMoney = 0; // SumMoney = 0; // return false; // } // else // { // CLMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["材料成本"]); // SumMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["料工费"]); // return true; // } //} } }