public void add(WebHelper w, Dictionary <string, object> kv) { Model.rp_t_recpay_record_info ord = w.GetObject <Model.rp_t_recpay_record_info>(); ord.supcust_flag = "S"; ord.flag_post = "1"; ord.coin_no = "RMB"; ord.coin_rate = 1; ord.approve_flag = "0"; ord.approve_man = ""; ord.approve_date = System.DateTime.MinValue; ord.cm_branch = "00"; ord.from_date = System.DateTime.MinValue; ord.to_date = System.DateTime.MinValue; List <Model.rp_t_recpay_record_detail> lines = w.GetList <Model.rp_t_recpay_record_detail>("lines"); foreach (Model.rp_t_recpay_record_detail line in lines) { line.sheet_no = ord.sheet_no; } string sheet_no = ""; bll.Add(ord, lines, out sheet_no); w.Write("sheet_no", sheet_no); }
void IBLL.ISupSettle.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("/sup_settle?t=change", w.ToString()); ReadWriteContext.IReadContext r = new ReadWriteContext.ReadContextByJson(json); if (r.Read("errId") != "0") { throw new Exception(r.Read("errMsg")); } }
void IOrder.Save() { try { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; // if (txtsup.Text.Trim().Contains("/") == false) { throw new Exception("货商必填!"); } if (txtbranch.Text.Trim().Contains("/") == false) { throw new Exception("机构必填!"); } if (txtoper_date.Text.Trim() == "") { throw new Exception("单据日期必填!"); } if (txtpay_way.Text.Trim().Contains("/") == false) { throw new Exception("付款方式必填"); } if (txtvisa.Text.Trim().Contains("/") == false) { throw new Exception("账户必填"); } Model.rp_t_recpay_record_info ord = new Model.rp_t_recpay_record_info(); ord.sheet_no = txtsheet_no.Text.Trim(); ord.supcust_no = txtsup.Text.Split('/')[0]; ord.supcust_flag = "S"; ord.flag_post = "1"; ord.total_amount = Helper.Conv.ToDecimal(txttotal_amount.Text.Trim()); ord.free_money = Helper.Conv.ToDecimal(txtfree_money.Text.Trim()); ord.coin_no = "RMB"; ord.coin_rate = 1; ord.pay_way = txtpay_way.Text.Split('/')[0]; ord.approve_flag = "0"; ord.oper_id = txtoper_man.Text.Trim().Split('/')[0]; ord.oper_date = Helper.Conv.ToDateTime(txtoper_date.Text.Trim()); ord.deal_man = txtpeople.Text.Split('/')[0]; ord.approve_man = ""; ord.approve_date = DateTime.MinValue; ord.other1 = txtmemo.Text.Trim(); ord.other2 = ""; ord.other3 = ""; ord.visa_id = txtvisa.Text.Split('/')[0]; ord.num1 = 0; ord.num2 = 0; ord.num3 = 0; ord.cm_branch = "00"; ord.branch_no = txtbranch.Text.Split('/')[0]; ord.from_date = DateTime.MinValue; ord.to_date = DateTime.MinValue; ord.rc_sheet_no = ""; int flag = 0; List <Model.rp_t_recpay_record_detail> lines = new List <Model.rp_t_recpay_record_detail>(); int index = 0; decimal pay_amt = ord.total_amount; decimal free_money = ord.free_money; decimal get_amt = 0; //应还客户金额 foreach (DataRow row in editGrid1.DataSource.Rows) { if (row["voucher_no"].ToString() != "" && row["select_flag"].ToString() == "1" && row["path"].ToString() == "-1") { get_amt += Conv.ToDecimal(row["pay_amount"]); } } pay_amt += get_amt; foreach (DataRow row in editGrid1.DataSource.Rows) { index++; if (row["voucher_no"].ToString() != "" && pay_amt >= 0 && row["select_flag"].ToString() == "1") { /* * if (Helper.Conv.ToDecimal(row["pay_amount"].ToString()) < 0) * { * throw new Exception("第i行付款金额不正确!".Replace("i", index.ToString())); * } * if (Helper.Conv.ToDecimal(row["pay_free"].ToString()) < 0) * { * throw new Exception("第i行免付金额不正确!".Replace("i", index.ToString())); * } */ decimal need_pay = Conv.ToDecimal(row["pay_amount"]); decimal repay_amt = 0; decimal pay_fee = 0; if (row["path"].ToString() == "-1") { repay_amt = need_pay; pay_fee = 0; } else { if (free_money > need_pay) { pay_fee = need_pay; } else { pay_fee = free_money; if (pay_amt > need_pay - pay_fee) { repay_amt = need_pay - pay_fee; } else { repay_amt = pay_amt; } } free_money -= pay_fee; pay_amt -= repay_amt; } Model.rp_t_recpay_record_detail line = new Model.rp_t_recpay_record_detail(); lines.Add(line); line.sheet_no = ord.sheet_no; line.voucher_no = row["voucher_no"].ToString(); line.sheet_amount = Helper.Conv.ToDecimal(row["sheet_amount"].ToString()); line.pay_amount = repay_amt; // Helper.Conv.ToDecimal(row["pay_amount"].ToString()); line.pay_free = pay_fee; // Helper.Conv.ToDecimal(row["pay_free"].ToString()); line.memo = row["memo"].ToString(); line.other1 = ""; line.other2 = ""; line.other3 = ""; line.num1 = 0; line.num2 = 0; line.num3 = 0; line.pay_date = System.DateTime.Now; line.item_no = ""; line.path = ((row["path"].ToString() == "1" || row["path"].ToString() == "+") ? "+" : "-"); line.select_flag = row["select_flag"].ToString(); line.voucher_type = row["voucher_type"].ToString(); line.oper_date = DateTime.Now; line.voucher_other1 = ""; line.voucher_other2 = ""; line.order_no = ""; flag = 1; } } if (flag == 0) { throw new Exception("无可结算明细!"); } if (runType == 1) { IBLL.ISupSettle bll = new BLL.SupSettle(); string sheet_no = ""; bll.Add(ord, lines, out sheet_no); IOrder ins = this; ins.ShowOrder(sheet_no); } else if (runType == 2) { IBLL.ISupSettle bll = new BLL.SupSettle(); bll.Change(ord, lines); IOrder ins = this; ins.ShowOrder(ord.sheet_no); } Dictionary <string, object> dic = this.Tag as Dictionary <string, object>; this.Tag = Helper.Conv.ControlsAdds(this, dic); IBLL.ISys sys = new BLL.SysBLL(); string isApprove = sys.Read("approve_at_ones"); if ("1".Equals(isApprove)) { if (YesNoForm.ShowFrom("保存成功!是否立即审核") == DialogResult.Yes) { tsbCheck_Click(new object(), new EventArgs()); } } } catch (Exception ex) { MsgForm.ShowFrom(ex); } finally { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; } }
void IServiceBase.Request(string t, string pars, out string res) { try { ReadWriteContext.IReadContext r = new ReadWriteContext.ReadContextByJson(pars); var kv = r.ToDictionary(); IBLL.ISupSettle bll = new BLL.SupSettle(); if (t == "get_list") { DateTime date1 = Helper.Conv.ToDateTime(r.Read("date1")); DateTime date2 = Helper.Conv.ToDateTime(r.Read("date2")); string sup_no = r.Read("sup_no"); var tb = bll.GetList(date1, date2, sup_no); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); w.Append("data", tb); res = w.ToString(); } else if (t == "get_order") { string sheet_no = r.Read("sheet_no"); System.Data.DataTable tb1; System.Data.DataTable tb2; bll.GetOrder(sheet_no, out tb1, out tb2); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); w.Append("tb1", tb1); w.Append("tb2", tb2); res = w.ToString(); } else if (t == "max_code") { string code = bll.MaxCode(); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); w.Append("code", code); res = w.ToString(); } else if (t == "add") { Model.rp_t_recpay_record_info ord = new Model.rp_t_recpay_record_info(); ord.sheet_no = r.Read("sheet_no"); ord.supcust_no = r.Read("supcust_no"); ord.supcust_flag = "S"; ord.flag_post = "1"; ord.total_amount = Helper.Conv.ToDecimal(r.Read("total_amount")); ord.free_money = Helper.Conv.ToDecimal(r.Read("free_money")); ord.coin_no = "RMB"; ord.coin_rate = 1; ord.pay_way = r.Read("pay_way"); ord.approve_flag = "0"; ord.oper_id = r.Read("oper_id"); ord.oper_date = Helper.Conv.ToDateTime(r.Read("oper_date")); ord.deal_man = r.Read("deal_man"); ord.approve_man = ""; ord.approve_date = System.DateTime.MinValue; ord.other1 = r.Read("other1"); ord.other2 = r.Read("other2"); ord.other3 = r.Read("other3"); ord.visa_id = r.Read("visa_id"); ord.num1 = Helper.Conv.ToDecimal(r.Read("num1")); ord.num2 = Helper.Conv.ToDecimal(r.Read("num2")); ord.num3 = Helper.Conv.ToDecimal(r.Read("num3")); ord.cm_branch = "00"; ord.branch_no = r.Read("branch_no"); ord.from_date = System.DateTime.MinValue; ord.to_date = System.DateTime.MinValue; ord.rc_sheet_no = r.Read("rc_sheet_no"); List <Model.rp_t_recpay_record_detail> lines = new List <Model.rp_t_recpay_record_detail>(); foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines")) { Model.rp_t_recpay_record_detail line = new Model.rp_t_recpay_record_detail(); lines.Add(line); line.sheet_no = ord.sheet_no; line.voucher_no = r2.Read("voucher_no"); line.sheet_amount = Helper.Conv.ToDecimal(r2.Read("sheet_amount")); line.paid_amount = Helper.Conv.ToDecimal(r2.Read("paid_amount")); line.paid_free = Helper.Conv.ToDecimal(r2.Read("paid_free")); line.pay_amount = Helper.Conv.ToDecimal(r2.Read("pay_amount")); line.pay_free = Helper.Conv.ToDecimal(r2.Read("pay_free")); line.memo = r2.Read("memo"); line.other1 = r2.Read("other1"); line.other2 = r2.Read("other2"); line.other3 = r2.Read("other3"); line.num1 = Helper.Conv.ToDecimal(r2.Read("num1")); line.num2 = Helper.Conv.ToDecimal(r2.Read("num2")); line.num3 = Helper.Conv.ToDecimal(r2.Read("num3")); line.pay_date = Helper.Conv.ToDateTime(r2.Read("pay_date")); line.item_no = r2.Read("item_no"); line.path = r2.Read("path"); line.select_flag = r2.Read("select_flag"); line.voucher_type = r2.Read("voucher_type"); line.oper_date = Helper.Conv.ToDateTime(r2.Read("oper_date")); line.voucher_other1 = r2.Read("voucher_other1"); line.voucher_other2 = r2.Read("voucher_other2"); line.order_no = r2.Read("order_no"); } string sheet_no = ""; bll.Add(ord, lines, out sheet_no); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); w.Append("sheet_no", sheet_no); res = w.ToString(); } else if (t == "change") { Model.rp_t_recpay_record_info ord = new Model.rp_t_recpay_record_info(); ord.sheet_no = r.Read("sheet_no"); ord.supcust_no = r.Read("supcust_no"); ord.supcust_flag = "S"; ord.flag_post = "1"; ord.total_amount = Helper.Conv.ToDecimal(r.Read("total_amount")); ord.free_money = Helper.Conv.ToDecimal(r.Read("free_money")); ord.coin_no = "RMB"; ord.coin_rate = 1; ord.pay_way = r.Read("pay_way"); ord.approve_flag = "0"; ord.oper_id = r.Read("oper_id"); ord.oper_date = Helper.Conv.ToDateTime(r.Read("oper_date")); ord.deal_man = r.Read("deal_man"); ord.approve_man = ""; ord.approve_date = System.DateTime.MinValue; ord.other1 = r.Read("other1"); ord.other2 = r.Read("other2"); ord.other3 = r.Read("other3"); ord.visa_id = r.Read("visa_id"); ord.num1 = Helper.Conv.ToDecimal(r.Read("num1")); ord.num2 = Helper.Conv.ToDecimal(r.Read("num2")); ord.num3 = Helper.Conv.ToDecimal(r.Read("num3")); ord.cm_branch = "00"; ord.branch_no = r.Read("branch_no"); ord.from_date = System.DateTime.MinValue; ord.to_date = System.DateTime.MinValue; ord.rc_sheet_no = r.Read("rc_sheet_no"); List <Model.rp_t_recpay_record_detail> lines = new List <Model.rp_t_recpay_record_detail>(); foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines")) { Model.rp_t_recpay_record_detail line = new Model.rp_t_recpay_record_detail(); lines.Add(line); line.sheet_no = ord.sheet_no; line.voucher_no = r2.Read("voucher_no"); line.sheet_amount = Helper.Conv.ToDecimal(r2.Read("sheet_amount")); line.paid_amount = Helper.Conv.ToDecimal(r2.Read("paid_amount")); line.paid_free = Helper.Conv.ToDecimal(r2.Read("paid_free")); line.pay_amount = Helper.Conv.ToDecimal(r2.Read("pay_amount")); line.pay_free = Helper.Conv.ToDecimal(r2.Read("pay_free")); line.memo = r2.Read("memo"); line.other1 = r2.Read("other1"); line.other2 = r2.Read("other2"); line.other3 = r2.Read("other3"); line.num1 = Helper.Conv.ToDecimal(r2.Read("num1")); line.num2 = Helper.Conv.ToDecimal(r2.Read("num2")); line.num3 = Helper.Conv.ToDecimal(r2.Read("num3")); line.pay_date = Helper.Conv.ToDateTime(r2.Read("pay_date")); line.item_no = r2.Read("item_no"); line.path = r2.Read("path"); line.select_flag = r2.Read("select_flag"); line.voucher_type = r2.Read("voucher_type"); line.oper_date = Helper.Conv.ToDateTime(r2.Read("oper_date")); line.voucher_other1 = r2.Read("voucher_other1"); line.voucher_other2 = r2.Read("voucher_other2"); line.order_no = r2.Read("order_no"); } bll.Change(ord, lines); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); res = w.ToString(); } else if (t == "delete") { string sheet_no = r.Read("sheet_no"); bll.Delete(sheet_no); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); res = w.ToString(); } else if (t == "check") { string sheet_no = r.Read("sheet_no"); string approve_man = r.Read("approve_man"); bll.Check(sheet_no, approve_man); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); res = w.ToString(); } else { throw new Exception("未找到方法" + t); } } catch (Exception ex) { ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "-1"); w.Append("errMsg", ex.Message); LogHelper.writeLog("", ex.ToString()); res = w.ToString(); } }