using System; using System.Collections.Generic; using System.Text; using System.Data; namespace WebAPI.DLL { public class ClsGy_GroupEmpBill : DBUtility.ClsXt_BaseBill { public Models.ClsGy_GroupEmpListMain omodel = new Models.ClsGy_GroupEmpListMain(); public List DetailColl = new List(); public ClsGy_GroupEmpBill() { base.MvarItemKeySub = "Gy_GroupEmpListSub"; base.MvarItemKeySub2 = " "; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "Gy_GroupEmpListMain"; base.MvarReportTitle = "班组职员清单"; base.BillType = "9876"; base.HBillSubType = "9876"; } #region 固定代码 ~ClsGy_GroupEmpBill() { DetailColl = null; } #endregion 自定义方法 //修改单据 public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) { try { // oCn.BeginTran(); //更新主表 oCn.RunProc("UpDate Gy_GroupEmpListMain set " + " HBillNo='" + omodel.HBillNo + "'" + //固定赋值=============== ",HDate='" + omodel.HDate + "'" + ",HYear='" + omodel.HYear.ToString() + "'" + ",HPeriod='" + omodel.HPeriod.ToString() + "'" + ",HRemark='" + omodel.HRemark + "'" + ",HUpDater='" + omodel.HMaker+ "'" + ",HUpDateDate=getdate()" + //======================================== ",HGroupID=" + omodel.HGroupID.ToString() + " where HInterID=" + lngBillKey.ToString()); //删除关联 DeleteRelation(ref sReturn, lngBillKey); //删除子表 DeleteBillSub(lngBillKey); //插入子表 omodel.HInterID = lngBillKey; foreach (Models.ClsGy_GroupEmpListSub oSub in DetailColl) { oCn.RunProc("Insert into Gy_GroupEmpListSub (HInterID,HEntryID,HEmpID,HRemark ) values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HEmpID.ToString() + ",'" + oSub.HRemark.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(); string sql = string.Format(@"Insert Into Gy_GroupEmpListMain(HBillType,HBillSubType,HInterID,HBillNo,HDate,HYear,HPeriod,HRemark,HGroupID,HMaker,HMakeDate) values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" + ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HGroupID.ToString() + "','" + omodel.HMaker + "',getdate())"); oCn.RunProc(sql); //插入子表 foreach (Models.ClsGy_GroupEmpListSub oSub in DetailColl) { oCn.RunProc("Insert into Gy_GroupEmpListSub (HInterID,HEntryID,HEmpID,HRemark ) values(" + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HEmpID.ToString() + ",'" + oSub.HRemark.ToString() + "')"); } sReturn = "新增单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } } }