void IBLL.ICusFY.Change(Model.rp_t_supcust_fy_master ord, List <Model.rp_t_supcust_fy_detail> lines) { string sql = "select * from rp_t_supcust_fy_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 rp_t_supcust_fy_detail where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); sql = "delete from rp_t_supcust_fy_master where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); // d.Insert(ord); foreach (Model.rp_t_supcust_fy_detail line in lines) { sql = "select isnull(max(flow_id)+1,1) from rp_t_supcust_fy_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.ISupFY.Add(Model.rp_t_supcust_fy_master ord, List <Model.rp_t_supcust_fy_detail> lines, out string sheet_no) { ISupFY supfy = this; var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); // ord.sheet_no = supfy.MaxCode(); sheet_no = ord.sheet_no; string sql = "select * from rp_t_supcust_fy_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.rp_t_supcust_fy_detail line in lines) { sql = "select isnull(max(flow_id)+1,1) from rp_t_supcust_fy_detail"; line.flow_id = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null)); line.sheet_no = ord.sheet_no; d.Insert(line); } // db.CommitTran(); } catch (Exception ex) { db.RollBackTran(); throw; } finally { db.Close(); } }