void IBLL.ISupSettle.Change(Model.rp_t_recpay_record_info ord, List <Model.rp_t_recpay_record_detail> lines) { string sql = "select * from rp_t_recpay_record_info 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_recpay_record_detail where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); sql = "delete from rp_t_recpay_record_info where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); // d.Insert(ord); foreach (Model.rp_t_recpay_record_detail line in lines) { sql = "select isnull(max(flow_id)+1,1) from rp_t_recpay_record_detail"; line.flow_no = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null)); d.Insert(line); } // db.CommitTran(); } catch (Exception ex) { db.RollBackTran(); throw; } finally { db.Close(); } }
void IBLL.ICusSettle.Add(Model.rp_t_recpay_record_info ord, List <Model.rp_t_recpay_record_detail> lines, out string sheet_no) { IBLL.ICusSettle ins = this; // var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); ord.sheet_no = sheet_no = ins.MaxCode(); // string sql = "select * from rp_t_recpay_record_info 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_recpay_record_detail line in lines) { sql = "select isnull(max(flow_id)+1,1) from rp_t_recpay_record_detail"; line.sheet_no = sheet_no; line.flow_no = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null)); d.Insert(line); } // db.CommitTran(); } catch (Exception ex) { db.RollBackTran(); throw; } finally { db.Close(); } }
void IBLL.ICusSettle.Change(Model.rp_t_recpay_record_info ord, List <Model.rp_t_recpay_record_detail> lines) { ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("sheet_no", ord.sheet_no); w.Append("supcust_no", ord.supcust_no); w.Append("supcust_flag", ord.supcust_flag); w.Append("flag_post", ord.flag_post); w.Append("total_amount", ord.total_amount.ToString()); w.Append("free_money", ord.free_money.ToString()); w.Append("coin_no", ord.coin_no); w.Append("coin_rate", ord.coin_rate.ToString()); w.Append("pay_way", ord.pay_way); w.Append("approve_flag", ord.approve_flag); w.Append("oper_id", ord.oper_id); w.Append("oper_date", ord.oper_date.ToString("yyyy-MM-dd HH:mm:ss")); w.Append("deal_man", ord.deal_man); w.Append("approve_man", ord.approve_man); w.Append("approve_date", ""); w.Append("other1", ord.other1); w.Append("other2", ord.other2); w.Append("other3", ord.other3); w.Append("visa_id", ord.visa_id); w.Append("num1", ord.num1.ToString()); w.Append("num2", ord.num2.ToString()); w.Append("num3", ord.num3.ToString()); w.Append("cm_branch", ord.cm_branch); w.Append("branch_no", ord.branch_no); w.Append("from_date", ""); w.Append("to_date", ""); w.Append("rc_sheet_no", ord.rc_sheet_no); var tb = new DataTable(); tb.Columns.Add("sheet_no"); tb.Columns.Add("voucher_no"); tb.Columns.Add("sheet_amount", typeof(decimal)); tb.Columns.Add("paid_amount", typeof(decimal)); tb.Columns.Add("paid_free", typeof(decimal)); tb.Columns.Add("pay_amount", typeof(decimal)); tb.Columns.Add("pay_free", typeof(decimal)); tb.Columns.Add("memo"); tb.Columns.Add("other1"); tb.Columns.Add("other2"); tb.Columns.Add("other3"); tb.Columns.Add("num1"); tb.Columns.Add("num2"); tb.Columns.Add("num3"); tb.Columns.Add("pay_date", typeof(DateTime)); tb.Columns.Add("item_no"); tb.Columns.Add("path"); tb.Columns.Add("select_flag"); tb.Columns.Add("voucher_type"); tb.Columns.Add("oper_date", typeof(DateTime)); tb.Columns.Add("voucher_other1"); tb.Columns.Add("voucher_other2"); tb.Columns.Add("order_no"); foreach (Model.rp_t_recpay_record_detail line in lines) { tb.Rows.Add( line.sheet_no, line.voucher_no, line.sheet_amount, line.paid_amount, line.paid_free, line.pay_amount, line.pay_free, line.memo, line.other1, line.other2, line.other3, line.num1, line.num2, line.num3, line.pay_date, line.item_no, line.path, line.select_flag, line.voucher_type, line.oper_date, line.voucher_other1, line.voucher_other2, line.order_no ); } w.Append("lines", tb); Helper.IRequest req = new Helper.Request(); var json = req.request("/cus_settle?t=change", w.ToString()); ReadWriteContext.IReadContext r = new ReadWriteContext.ReadContextByJson(json); if (r.Read("errId") != "0") { throw new Exception(r.Read("errMsg")); } }