using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsSb_EquipStockInCheckBill : DBUtility.ClsXt_BaseBill { public Model.ClsSb_EquipStockInCheckBillMain omodel = new Model.ClsSb_EquipStockInCheckBillMain(); public List DetailColl = new List(); public ClsSb_EquipStockInCheckBill() { base.MvarItemKeySub = "Sb_EquipStockInCheckBillSub"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey= "Sb_EquipStockInCheckBillMain"; base.MvarReportTitle= "设备入库检验验收单"; base.BillType = "3914"; base.HBillSubType = "3914"; } #region 固定代码 ~ClsSb_EquipStockInCheckBill() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { try { // oCn.BeginTran(); //更新主表 oCn.RunProc("UpDate Sb_EquipStockInCheckBillMain set " + " HBillNo='" + omodel.HBillNo + "'" + //固定赋值=============== //",HDate='" + omodel.HDate + "'" + ",HYear='" + omodel.HYear.ToString() + "'" + ",HPeriod='" + omodel.HPeriod.ToString() + "'" + ",HRemark='" + omodel.HRemark + "'" + ",HCheckerResult='" + omodel.HCheckerResult + "'" + ",HUpDater='" + omodel.HMaker + "'" + ",HUpDateDate=getdate()" + //======================================== ",HEquipID=" + omodel.HEquipID.ToString() + ",HSupID=" + omodel.HSupID.ToString() + ",HFirstCheckEmp=" + omodel.HFirstCheckEmp.ToString() + " where HInterID=" + lngBillKey.ToString()); //删除关联 DeleteRelation(ref sReturn, lngBillKey); //删除子表 DeleteBillSub(lngBillKey); //插入子表 omodel.HInterID = lngBillKey; foreach (Model.ClsSb_EquipStockInCheckBillSub oSub in DetailColl) { oCn.RunProc("Insert into Sb_EquipStockInCheckBillSub " + " (HInterID,HEntryID,HCloseMan, HEntryCloseDate, HCloseType" + ", HRemark, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType" + ", HRelationQty, HRelationMoney,HQCCheckClassID, HQCCheckItemID, HQCStd" + ", HQCRelValue, HResult, HProcCheckEmp, HProcCheckTime, HBillNo_bak) values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate + "'," + 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.HQCCheckClassID + "','" + oSub.HQCCheckItemID + "','" + oSub.HQCStd + "','" + oSub.HQCRelValue + "','" + oSub.HResult.ToString() + "','" + oSub.HProcCheckEmp + "','" + oSub.HProcCheckTime + "','') "); } 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 Sb_EquipStockInCheckBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo , HDate, HMaker, HMakeDate" + ", HYear, HPeriod , HRemark, HEquipID, HSupID, HFirstCheckEmp, HCheckerResult" + ", HBackRemark, HMainSourceBillType, HMainSourceInterID, HMainSourceEntryID, HMainSourceBillNo) " + " values('" + this.BillType + "','" + this.HBillSubType + "'," +omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "','" + omodel.HMaker + "',getdate()" + "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "'," + omodel.HEquipID.ToString() + ",'" + omodel.HSupID + "','" + omodel.HFirstCheckEmp + "','" + omodel.HCheckerResult + "'" + ",'','',0,0,'') "); //插入子表 foreach (Model.ClsSb_EquipStockInCheckBillSub oSub in DetailColl) { oCn.RunProc("Insert into Sb_EquipStockInCheckBillSub " + " (HInterID,HEntryID,HCloseMan, HEntryCloseDate, HCloseType" + ", HRemark, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType" + ", HRelationQty, HRelationMoney,HQCCheckClassID, HQCCheckItemID, HQCStd" + ", HQCRelValue, HResult, HProcCheckEmp, HProcCheckTime, HBillNo_bak) values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate + "'," + 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.HQCCheckClassID + "','" + oSub.HQCCheckItemID + "','" + oSub.HQCStd + "','" + oSub.HQCRelValue + "','" + oSub.HResult.ToString() + "','" + oSub.HProcCheckEmp + "','" + oSub.HProcCheckTime + "','') "); } sReturn = "新增单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } } }