void IBLL.IFYOrder.Change(Model.bank_t_cash_master ord, List <Model.bank_t_cash_detail> lines) { string sql = "select * from bank_t_cash_master where sheet_no='" + ord.sheet_no + "'"; var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); // var tb = d.ExecuteToTable(sql, null); if (tb.Rows.Count == 0) { throw new Exception("单据不存在" + ord.sheet_no); } else { var row = tb.Rows[0]; if (row["approve_flag"].ToString() == "1") { throw new Exception("单据已审核" + ord.sheet_no); } } sql = "delete from bank_t_cash_detail where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); sql = "delete from bank_t_cash_master where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); // d.Insert(ord); foreach (Model.bank_t_cash_detail line in lines) { sql = "select isnull(max(flow_id)+1,1) from bank_t_cash_detail"; line.flow_id = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null)); d.Insert(line); } // db.CommitTran(); } catch (Exception ex) { db.RollBackTran(); throw; } finally { db.Close(); } }
void IBLL.ICashOrder.Change(Model.bank_t_cash_master ord) { string sql = "select * from bank_t_cash_master where sheet_no='" + ord.sheet_no + "'"; var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); // var tb = d.ExecuteToTable(sql, null); if (tb.Rows.Count == 0) { throw new Exception("单据不存在" + ord.sheet_no); } else { var row = tb.Rows[0]; if (row["approve_flag"].ToString() == "1") { throw new Exception("单据已审核" + ord.sheet_no); } } sql = "delete from bank_t_cash_master where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); // d.Insert(ord); // db.CommitTran(); } catch (Exception ex) { db.RollBackTran(); LogHelper.writeLog("", ex.ToString()); throw; } finally { db.Close(); } }
void IBLL.IFYOrder.Add(Model.bank_t_cash_master ord, List <Model.bank_t_cash_detail> lines, out string sheet_no) { var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; IBLL.IFYOrder order = this; try { db.Open(); db.BeginTran(); // sheet_no = ord.sheet_no = order.MaxCode(); string sql = "select * from bank_t_cash_master where sheet_no='" + ord.sheet_no + "'"; var tb = d.ExecuteToTable(sql, null); if (tb.Rows.Count != 0) { throw new Exception("已存在单号" + ord.sheet_no); } d.Insert(ord); foreach (Model.bank_t_cash_detail line in lines) { sql = "select isnull(max(flow_id)+1,1) from bank_t_cash_detail"; line.flow_id = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null)); line.sheet_no = sheet_no; d.Insert(line); } // db.CommitTran(); } catch (Exception ex) { db.RollBackTran(); throw; } finally { db.Close(); } }
void IBLL.ICashOrder.Add(Model.bank_t_cash_master ord, out string sheet_no) { IBLL.ICashOrder ins = this; ord.sheet_no = ins.MaxCode(); // string sql = "select * from bank_t_cash_master where sheet_no='" + ord.sheet_no + "'"; var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); // var tb = d.ExecuteToTable(sql, null); if (tb.Rows.Count != 0) { throw new Exception("已存在单号" + ord.sheet_no); } d.Insert(ord); // db.CommitTran(); } catch (Exception ex) { db.RollBackTran(); LogHelper.writeLog("", ex.ToString()); throw; } finally { db.Close(); } sheet_no = ord.sheet_no; }