using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsXs_SeQuotation_ccjgBill : DBUtility.ClsXt_BaseBill { public Model.ClsXs_SeQuotation_ccjgBillMain omodel = new Model.ClsXs_SeQuotation_ccjgBillMain(); public List DetailColl = new List(); public ClsXs_SeQuotation_ccjgBill() { base.MvarItemKeySub = "Xs_SeQuotation_ccjgBillSub"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "Xs_SeQuotation_ccjgBillMain"; base.MvarReportTitle = "报价单"; base.BillType = "1990"; } #region 固定代码 ~ClsXs_SeQuotation_ccjgBill() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { try { // oCn.BeginTran(); //更新主表 oCn.RunProc("UpDate Xs_SeQuotation_ccjgBillMain set " + " HDate = '" + omodel.HDate.ToShortDateString() + "'" + //============================================ ",HCusID ='" + omodel.HCusID + "'" + ",HEmpID ='" + omodel.HEmpID + "'" + ",HDeptID ='" + omodel.HDeptID + "'" + ",HQuotationDate ='" + omodel.HQuotationDate + "'" + ",HQuotationStatus ='" + omodel.HQuotationStatus + "'" + //============================================ ",HRemark='" + omodel.HRemark + "'" + ",HYear=" + omodel.HYear.ToString() + ",HPeriod=" + omodel.HPeriod.ToString() + ",HUpDater='" + omodel.HUpDater + "'" + ",HUpDateDate='" + omodel.HUpDateDate + "'" + " where HInterID=" + lngBillKey.ToString()); //删除关联 DeleteRelation(ref sReturn, lngBillKey); //删除子表 DeleteBillSub(lngBillKey); //插入子表 omodel.HInterID = lngBillKey; foreach (Model.ClsXs_SeQuotation_ccjgBillSub oSub in DetailColl) { oCn.RunProc("Insert into Xs_SeQuotation_ccjgBillSub " + " (HInterID,HEntryID"+ ",HMaterID,HProdQty,HRelMaterID,HNetProdPrice" + ",HBigPack,HColorMidPack,HWhiteMidPack,HColorSmlPack" + ",HWhiteSmlPack,HPaperCard,HPlasticBag,HPlasticCard" + ",HMantle,HPlasticShelves,HProdPrice,HProdMoney,HSellRate" + ",HSellPrice,HRemark" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + ") values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HProdQty.ToString() + "," + oSub.HRelMaterID.ToString() + "," + oSub.HNetProdPrice.ToString() + "," + oSub.HBigPack.ToString() + "," + oSub.HColorMidPack.ToString() + "," + oSub.HWhiteMidPack.ToString() + "," + oSub.HColorSmlPack.ToString() + "," + oSub.HWhiteSmlPack.ToString() + "," + oSub.HPaperCard.ToString() + "," + oSub.HPlasticBag.ToString() + "," + oSub.HPlasticCard.ToString() + "," + oSub.HMantle.ToString() + "," + oSub.HPlasticShelves.ToString() + "," + oSub.HProdPrice.ToString() + "," + oSub.HProdMoney.ToString() + "," + oSub.HSellRate.ToString() + "," + oSub.HSellPrice.ToString() + ",'" + 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 Xs_SeQuotation_ccjgBillMain " + "(HBillType,HInterID,HBillNo,HDate" + ",HYear,HPeriod,HMaker,HMakeDate" + ",HCusID,HEmpID,HDeptID,HQuotationDate,HQuotationStatus,HRemark" + ") " + " values('" + this.BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate.ToShortDateString() + "'" + "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "',getdate()" + ",'" + omodel.HCusID + "','" + omodel.HEmpID + "','" + omodel.HDeptID + "'" + ",'" + omodel.HQuotationDate + "','" + omodel.HQuotationStatus + "','" + omodel.HRemark + "'" + ") "); //插入子表 foreach (Model.ClsXs_SeQuotation_ccjgBillSub oSub in DetailColl) { oCn.RunProc("Insert into Xs_SeQuotation_ccjgBillSub " + " (HInterID,HEntryID" + ",HMaterID,HProdQty,HRelMaterID,HNetProdPrice" + ",HBigPack,HColorMidPack,HWhiteMidPack,HColorSmlPack" + ",HWhiteSmlPack,HPaperCard,HPlasticBag,HPlasticCard" + ",HMantle,HPlasticShelves,HProdPrice,HProdMoney,HSellRate" + ",HSellPrice,HRemark" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + ") values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HProdQty.ToString() + "," + oSub.HRelMaterID.ToString() + "," + oSub.HNetProdPrice.ToString() + "," + oSub.HBigPack.ToString() + "," + oSub.HColorMidPack.ToString() + "," + oSub.HWhiteMidPack.ToString() + "," + oSub.HColorSmlPack.ToString() + "," + oSub.HWhiteSmlPack.ToString() + "," + oSub.HPaperCard.ToString() + "," + oSub.HPlasticBag.ToString() + "," + oSub.HPlasticCard.ToString() + "," + oSub.HMantle.ToString() + "," + oSub.HPlasticShelves.ToString() + "," + oSub.HProdPrice.ToString() + "," + oSub.HProdMoney.ToString() + "," + oSub.HSellRate.ToString() + "," + oSub.HSellPrice.ToString() + ",'" + 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 Xs_SeQuotation_ccjgBillMain Where HInterID=" + lngBillKey.ToString(), "Xs_SeQuotation_ccjgBillMain"); if (Ds.Tables[0].Rows.Count == 0) { sReturn = "单据未找到!"; return false; } //赋值 omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]); omodel.HBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]); omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]); omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]); omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]); //================= omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]); omodel.HCusID = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCusID"]); omodel.HEmpID = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HEmpID"]); omodel.HDeptID = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeptID"]); omodel.HQuotationDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HQuotationDate"]); omodel.HQuotationStatus = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HQuotationStatus"]); // 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.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.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; DsSub = oCn.RunProcReturn("Select * from Xs_SeQuotation_ccjgBillSub Where HInterID=" + lngBillKey.ToString(), "Xs_SeQuotation_ccjgBillSub"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsXs_SeQuotation_ccjgBillSub oSub = new Model.ClsXs_SeQuotation_ccjgBillSub(); 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.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]); oSub.HProdQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProdQty"]); oSub.HRelMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HRelMaterID"]); oSub.HNetProdPrice = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HNetProdPrice"]); oSub.HBigPack = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HBigPack"]); oSub.HColorMidPack = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HColorMidPack"]); oSub.HWhiteMidPack = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HWhiteMidPack"]); oSub.HColorSmlPack = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HColorSmlPack"]); oSub.HWhiteSmlPack = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HWhiteSmlPack"]); oSub.HPaperCard = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPaperCard"]); oSub.HPlasticBag = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPlasticBag"]); oSub.HPlasticCard = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPlasticCard"]); oSub.HMantle = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMantle"]); oSub.HPlasticShelves = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPlasticShelves"]); oSub.HProdPrice = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProdPrice"]); oSub.HProdMoney = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProdMoney"]); oSub.HSellRate = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSellRate"]); oSub.HSellPrice = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSellPrice"]); oSub.HRemark = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRemark"]); // 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); } } } }