using System; using CoreSavingLibrary; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Sybase.DataWindow; using System.Web.Services.Protocols; using DataLibrary; namespace Saving.Applications.shrlon.dlg { public partial class w_dlg_sl_loanrequest_monthpay : PageWebDialog, WebDialog { protected String closeWebDialog; public void InitJsPostBack() { closeWebDialog = WebUtil.JsPostBack(this, "closeWebDialog"); } public void WebDialogLoadBegin() { if (IsPostBack) { } else { Decimal income = Convert.ToDecimal(Request["income"].ToString()); Decimal paymonth = Convert.ToDecimal(Request["paymonth"].ToString()); Decimal salary_amt = Convert.ToDecimal(Request["salary_amt"].ToString()); dw_head.InsertRow(0); dw_head.SetItemDecimal(1, "salary_amt", salary_amt); dw_head.SetItemDecimal(1, "itemincome_other", income); dw_head.SetItemDecimal(1, "itempayment_amt", paymonth); string member_no = Request["member_no"].ToString(); try { decimal ldc_shrperiod = 0, ldc_intestm = 0, ldc_payment = 0, ldc_sumpay = 0, ldc_intpay = 0, ldc_pay = 0; int li_row = 0, li_paytype = 0, li_clrstatus = 0; string ls_loantype, ls_loanpaycode = "", ls_contno = "", ls_loanclr= "", ls_mthexp = ""; // ดึงรายการหุ้น ldc_shrperiod = Convert.ToDecimal(Request["share_periodvalue"].ToString()); // ถ้างดเก็บค่าหุ้นให้หุ้นต่อเดือนเป็นศูนย์ li_row = dw_detail.InsertRow(0); dw_detail.SetItemString(li_row, "operate_type", "SHR"); dw_detail.SetItemString(li_row, "description", "หุ้นสามัญรายเดือน"); dw_detail.SetItemDecimal(li_row, "period_payment", ldc_shrperiod); dw_detail.SetItemDecimal(li_row, "itempayment_amt", ldc_shrperiod); string x = Request.QueryString["loanpayment_type"].ToString(); string xx = Request.QueryString["period_payment"].ToString(); string xxx = Request.QueryString["intestimate_amt"].ToString(); // ดึงยอดเงินชำระต่อเดือนใบขอกู้ ls_loantype = Request["loantype_code"].ToString(); li_paytype = Convert.ToInt32(x); ldc_intestm = Convert.ToDecimal(xxx); ldc_payment = Convert.ToDecimal(xx); if (li_paytype == 0) { ldc_sumpay = 0; ldc_intpay = ldc_intestm; ldc_pay = ldc_payment - ldc_intestm; } else if (li_paytype == 1) { ldc_sumpay += ldc_payment + ldc_intestm; ldc_intpay = ldc_intestm; ldc_pay = ldc_payment - ldc_intestm; } else if (li_paytype == 2) { ldc_sumpay += ldc_payment; ldc_intpay = ldc_intestm; ldc_pay = ldc_payment - ldc_intestm; } else if (li_paytype == 3) { ldc_sumpay += ldc_intestm; ldc_intpay = ldc_intestm; ldc_pay = ldc_payment - ldc_intestm; } li_row = dw_detail.InsertRow(0); dw_detail.SetItemString(li_row, "operate_type", "REQ"); dw_detail.SetItemString(li_row, "description", "คำขอกู้เงิน "); dw_detail.SetItemDecimal(li_row, "period_payment", ldc_payment); dw_detail.SetItemDecimal(li_row, "intestimate_amt", ldc_intestm); dw_detail.SetItemDecimal(li_row, "itempayment_amt", ldc_sumpay); dw_detail.SetItemDecimal(li_row, "intestimate_pay", ldc_intpay); dw_detail.SetItemDecimal(li_row, "period_pay", ldc_pay); // ดึงรายการหนี้ ls_loanclr = Request["loanclr"].ToString(); if (ls_loanclr != "") { string[] larr_loanclr = ls_loanclr.Split(';').ToArray(); for (int i = 0; i < larr_loanclr.Length; i++) { string[] larr_loanclrtemp = larr_loanclr[i].Split(',').ToArray(); ls_contno = larr_loanclrtemp[0];//loancontract_no li_clrstatus = Convert.ToInt32(larr_loanclrtemp[1]);//Cclear_status li_paytype = Convert.ToInt32(larr_loanclrtemp[2]);//loanpayment_type ldc_payment = Convert.ToDecimal(larr_loanclrtemp[3]);//period_payment ldc_intestm = Convert.ToDecimal(larr_loanclrtemp[4]);//intestimate_amt ls_loanpaycode = larr_loanclrtemp[5];//loanpay_code if (ls_loanpaycode != "KEP" || li_paytype == 0) { continue; } if (li_clrstatus == 1) { continue; } ldc_sumpay = 0; switch (li_paytype) { case 0: ldc_sumpay = 0; break; case 1: ldc_sumpay = (ldc_payment + ldc_intestm); break; case 2: ldc_sumpay = ldc_payment; break; case 3: ldc_sumpay = ldc_intestm; break; } li_row = dw_detail.InsertRow(0); dw_detail.SetItemString(li_row, "operate_type", "LON"); dw_detail.SetItemString(li_row, "description", ls_contno); dw_detail.SetItemDecimal(li_row, "period_payment", ldc_payment); dw_detail.SetItemDecimal(li_row, "intestimate_amt", ldc_intestm); dw_detail.SetItemDecimal(li_row, "itempayment_amt", ldc_sumpay); } } // ดึงรายการหักจากเงินเดือน string ls_mthexpcode = "", ls_mthexpdesc = ""; decimal ldc_mthexpamt = 0; ls_mthexp = Request.QueryString["mthexp"].ToString(); if (ls_mthexp != "") { string[] larr_mthexp = ls_mthexp.Split(';').ToArray(); for (int i = 0; i < larr_mthexp.Length; i++) { string[] larr_mthexptemp = larr_mthexp[i].Split(',').ToArray(); ls_mthexpcode = larr_mthexptemp[0];//mthexp_code ls_mthexpdesc = larr_mthexptemp[1];//mthexp_desc ldc_mthexpamt = Convert.ToDecimal(larr_mthexptemp[2]);//mthexp_amt li_row = dw_detail.InsertRow(0); dw_detail.SetItemString(li_row, "operate_type", ls_mthexpcode); dw_detail.SetItemString(li_row, "description", ls_mthexpdesc); dw_detail.SetItemDecimal(li_row, "period_payment", ldc_mthexpamt); dw_detail.SetItemDecimal(li_row, "intestimate_amt", 0); dw_detail.SetItemDecimal(li_row, "itempayment_amt", ldc_mthexpamt); } } // ดึงรายการหักอื่นๆ ที่บันทึกเอาไว้ string sqlStr = @"select mthexpense_desc, mthexpense_amt from mbmembmthexpense where ( coop_id = {0} ) and ( member_no = {1} ) and ( sign_flag = -1 )"; sqlStr = WebUtil.SQLFormat(sqlStr, state.SsCoopControl, member_no); Sdt dt = WebUtil.QuerySdt(sqlStr); while (dt.Next()) { ldc_payment = dt.GetDecimal("mthexpense_amt"); li_row = dw_detail.InsertRow(0); dw_detail.SetItemString(li_row, "operate_type", "EXP"); dw_detail.SetItemString(li_row, "description", dt.GetString("mthexpense_desc")); dw_detail.SetItemDecimal(li_row, "period_payment", ldc_payment); dw_detail.SetItemDecimal(li_row, "itempayment_amt", ldc_payment); } } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } } public void CheckJsPostBack(string eventArg) { if (eventArg == "closeWebDialog") { OnCloseClick(); } } public void WebDialogLoadEnd() { dw_head.SaveDataCache(); } protected void OnCloseClick() { HfChkStatus.Value = "1"; } } }