using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsGy_CostItemAverageType:DBUtility.ClsXt_BaseBill { //public Model.ClsGy_CostItemAverageType_Model omodel = new Model.ClsGy_CostItemAverageType_Model(); public DBUtility.ClsXt_BaseBillMain omodel = new DBUtility.ClsXt_BaseBillMain(); public List DetailColl = new List(); public ClsGy_CostItemAverageType() { base.MvarItemKeySub = "Gy_CostItemAverageType"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "Gy_CostItemAverageType"; base.MvarReportTitle = "成本项目分配标准"; base.BillType="0"; } #region 固定代码 ~ClsGy_CostItemAverageType() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { try { // oCn.BeginTran(); // //DeleteRelation(ref sReturn, lngBillKey); //删除子表 //DeleteBillSub(lngBillKey); oCn.RunProc("delete from Gy_CostItemAverageType where Hitemid=" + lngBillKey.ToString()); //插入子表 omodel.HInterID = lngBillKey; foreach (Model.ClsGy_CostItemAverageType_Model oSub in DetailColl) { oCn.RunProc("Insert into Gy_CostItemAverageType " + " (HCostItemID,HAverageTypeID,HWIPFlag,HProcName" + ") values(" + oSub.HCostItemID.ToString() + "," + oSub.HAverageTypeID.ToString() + ",'" + oSub.HWIPFlag.ToString() + "','" + oSub.HProcName + "'" + ") "); } 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(); //插入子表 foreach (Model.ClsGy_CostItemAverageType_Model oSub in DetailColl) { oCn.RunProc("Insert into Gy_CostItemAverageType " + " (HCostItemID,HAverageTypeID,HWIPFlag,HProcName" + ") values(" + oSub.HCostItemID.ToString() + "," + oSub.HAverageTypeID.ToString() + ",'" + oSub.HWIPFlag.ToString() + "','" + oSub.HProcName + "'" + ") "); } 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 DsSub ; omodel.HInterID = lngBillKey; DsSub = oCn.RunProcReturn("Select * from Gy_CostItemAverageType Where HItemID=" + lngBillKey.ToString(), "Gy_CostItemAverageType"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsGy_CostItemAverageType_Model oSub = new Model.ClsGy_CostItemAverageType_Model(); oSub.HCostItemID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCostItemID"]); oSub.HAverageTypeID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HAverageTypeID"]); oSub.HWIPFlag = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HWIPFlag"]); oSub.HProcName = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HProcName"]); // DetailColl.Add(oSub); } sReturn = "显示成功!"; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //delete public override bool DeleteBill(long lngBillKey, ref string sReturn) { try { // oCn.BeginTran(); // //DeleteRelation(ref sReturn, lngBillKey); //删除子表 //DeleteBillSub(lngBillKey); oCn.RunProc("delete from Gy_CostItemAverageType where Hitemid=" + lngBillKey.ToString()); sReturn = "删除成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } } }