using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsK3_PrjGroup_Extend : DBUtility.ClsXt_BaseBill { public Model.ClsK3_PrjGroupMain_Extend omodel = new Model.ClsK3_PrjGroupMain_Extend(); public List DetailColl = new List(); public ClsK3_PrjGroup_Extend() { base.MvarItemKeySub = "K3_PrjGroupMain_Extend"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "K3_PrjGroupSub_Extend"; base.MvarReportTitle = "方案组"; base.BillType = ""; } #region 固定代码 ~ClsK3_PrjGroup_Extend() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { try { // oCn.BeginTran(); //删除主表 DeleteBillMain(lngBillKey); //删除子表 DeleteBillSub(lngBillKey); //主表 oCn.RunProc("INSERT INTO K3_PrjGroupMain_Extend " + "(HInterID,HName,HRemark)" + " VALUES " + "(" + omodel.HInterID.ToString() + ",'" + omodel.HName + "','" + omodel.HRemark + "') "); //删除关联 DeleteRelation(ref sReturn, lngBillKey); //插入子表 omodel.HInterID = lngBillKey; foreach (Model.ClsK3_PrjGroupSub_Extend oSub in DetailColl) { oCn.RunProc("INSERT INTO K3_PrjGroupSub_Extend " + "(HInterID,HEntryID,HBQty,HEQty,HPrjID,HPrjName)" + " VALUES " + "(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HBQty.ToString() + "," + oSub.HEQty.ToString() + "," + oSub.HPrjID.ToString() + ",'" + oSub.HPrjName + "')"); } sReturn = "修改单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } //新增单据 public override bool AddBill(ref string sReturn) { try { //得到mainid //若MAINDI重复则重新获取 oCn.BeginTran(); //主表 oCn.RunProc("INSERT INTO K3_PrjGroupMain_Extend " + "(HInterID,HName,HRemark)" + " VALUES " + "(" + omodel.HInterID.ToString() + ",'" + omodel.HName + "','" + omodel.HRemark + "') "); //插入子表 foreach (Model.ClsK3_PrjGroupSub_Extend oSub in DetailColl) { oCn.RunProc("INSERT INTO K3_PrjGroupSub_Extend " + "(HInterID,HEntryID,HBQty,HEQty,HPrjID,HPrjName)" + " VALUES " + "(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HBQty.ToString() + "," + oSub.HEQty.ToString() + "," + oSub.HPrjID.ToString() + ",'" + oSub.HPrjName + "')"); } 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 h_v_K3_PrjGroup_ExtendList Where HMainID=" + lngBillKey.ToString(), "h_v_K3_PrjGroup_ExtendList"); if (Ds.Tables[0].Rows.Count == 0) { sReturn = "单据未找到!"; return false; } //固定赋值=========================================== omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainID"]); omodel.HName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["方案组"]); omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["备注"]); // //循环 DataSet DsSub; DsSub = oCn.RunProcReturn("Select * from h_v_K3_PrjGroup_ExtendList Where HMainID=" + lngBillKey.ToString(), "h_v_K3_PrjGroup_ExtendList"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsK3_PrjGroupSub_Extend oSub = new Model.ClsK3_PrjGroupSub_Extend(); // 固定赋值=============================================== oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMainID"]); oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSubID"]); oSub.HBQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["起始数量"]); oSub.HEQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["截至数量"]); oSub.HPrjID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["方案编号"]); oSub.HPrjName = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["计算方式"]); DetailColl.Add(oSub); } sReturn = "显示单据成功!"; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } } }