public int Add(Models.Bill_Main modelMainBill) { int iRel = dalMain.DeleteMain(modelMainBill.BillCode); int iMainRel = dalMain.InsertMain(modelMainBill); if (iMainRel < 1) { throw new Exception("未知错误!"); } else { return(1); } }
public bool Edit(Bill_Main main, ZiChan_ChuZhiDan sqmodel) { using (SqlConnection conn = new SqlConnection(DataHelper.constr)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { MainDal maindal = new MainDal(); maindal.DeleteMain(main.BillCode, tran); Delete(main.BillCode, tran); maindal.InsertMain(main, tran); Add(sqmodel, tran); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } } }
/// <summary> /// 添加 /// </summary> /// <param name="mainModel"></param> /// <param name="model"></param> /// <returns></returns> public int Add(Bill_Main mainModel, dz_yksqd model) { using (SqlConnection conn = new SqlConnection(DataHelper.constr)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { Delete(model.sqbh, tran); MainDal maindal = new MainDal(); maindal.DeleteMain(mainModel.BillCode); maindal.InsertMain(mainModel); int iRel = Add(model, tran); tran.Commit(); return(iRel); } catch { tran.Rollback(); throw; } } }
public bool Add(Bill_Main main, IList <ZiChan_ChuZhiDan> czLists) { using (SqlConnection conn = new SqlConnection(DataHelper.constr)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { MainDal maindal = new MainDal(); maindal.InsertMain(main, tran); foreach (var i in czLists) { Add(i, tran); } tran.Commit(); return(true); } catch { tran.Rollback(); throw; } } }