using System; using CoreSavingLibrary; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Xml.Linq; using CoreSavingLibrary.WcfNCommon; using CoreSavingLibrary.WcfNShrlon; using System.Globalization; using Sybase.DataWindow; using DataLibrary; namespace Saving.Applications.shrlon { public partial class Convert_contstatement : PageWebSheet, WebSheet { // protected string outputProcess; [JsPostBack] public string outputProcess { get; set; } public void InitJsPostBack() { } //method แรกเมื่อ sheet ดังกล่าวถูกเปิดขึ้น public void WebSheetLoadBegin() { } //เป็นฟังก์ชันไว้สำหรับตรวจสอบ event ที่มีการ register ไว้ กรณีมีการเรียกใช้งาน event นั้นๆ public void CheckJsPostBack(string eventArg) { } //เป็น method สำหรับการบันทึกข้อมูลของ sheet นั้นๆ public void SaveWebSheet() { try { //Gen ปรับ ขาด Sdt d = WebUtil.QuerySdt(@"select bffine_arrear,interest_period,fine_payment,bfintarrear_amt,bfintyeararr_amt,interest_payment, bffineyear_amt,fine_period,loancontract_no,seq_no from lncontstatement where bffine_arrear>0 or interest_period >0 or fine_payment >0 or bfintarrear_amt >0 or bfintyeararr_amt >0 or interest_payment >0 or bffineyear_amt >0 or fine_period >0 and operate_date > to_date('15032017','ddmmyyyy') order by loancontract_no,seq_no"); while (d.Next()) { decimal bffine_arrear = d.GetDecimal("bffine_arrear"); decimal fine_payment = d.GetDecimal("fine_payment"); decimal bffineyear_amt = d.GetDecimal("bffineyear_amt"); decimal fine_period = d.GetDecimal("fine_period"); decimal bfintarrear_amt = d.GetDecimal("bfintarrear_amt"); decimal interest_payment = d.GetDecimal("interest_payment"); decimal bfintyeararr_amt = d.GetDecimal("bfintyeararr_amt"); decimal interest_period = d.GetDecimal("interest_period"); decimal fine_arrear = 0, fine_new = 0, int_arr = 0, int_new = 0; if (bffine_arrear <= 0) { fine_arrear = 0; } else { if (fine_payment > bffineyear_amt) { if (fine_payment > bffine_arrear) { fine_arrear = (bffine_arrear - bffineyear_amt); } else { fine_arrear = (fine_payment - bffineyear_amt); } } else { fine_arrear = 0; } } //end ปรับขาด //start ปรับใหม่ if (fine_period <= 0) { fine_new = 0; } else { if ((fine_payment - bffine_arrear) > 0) { fine_new = (fine_payment - bffine_arrear); } else { fine_new = 0; } } //end ปรับใหม่ //start ด/บ ขาด if (bfintarrear_amt <= 0) { int_arr = 0; } else { if (interest_payment > bfintyeararr_amt) { if (interest_payment > bfintarrear_amt) { int_arr = (bfintarrear_amt - bfintyeararr_amt); } else { int_arr = (interest_payment - bfintyeararr_amt); } } else { int_arr = 0; } } //end ด/บ ขาด //start ด/บ ใหม่ if (interest_period <= 0) { int_new = 0; } else { if ((interest_payment - bfintarrear_amt) > 0) { int_new = (interest_payment - bfintarrear_amt); } else { int_new = 0; } //end ด/บ ใหม่ } WebUtil.QuerySdt(" update lncontstatement set fine_arrear = " + fine_arrear + " , fine_period = " + fine_new + ",interest_period=" + int_new + ",interest_arrear=" + int_arr + " where loancontract_no='" + d.GetString("loancontract_no") + "' and seq_no = " + d.GetInt32("seq_no") + " "); //String xml = ""+d.Rows+""; //outputProcess = WebUtil.runProcessingCapp(state, "DPF20PROCESS", xml, "", ""); } } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } //เป็น method สุดท้ายของ web sheet นี้ public void WebSheetLoadEnd() { //DwUtil.RetrieveDDDW(dw_head, "moneytype_code", "sl_slipall.pbl", null); } protected void Button1_Click(object sender, EventArgs e) { //Gen ปรับ ขาด Sdt d = WebUtil.QuerySdt(@"select bffine_arrear,interest_period,fine_payment,bfintarrear_amt,bfintyeararr_amt,interest_payment, bffineyear_amt,fine_period,loancontract_no,seq_no from lncontstatement where bffine_arrear>0 or interest_period >0 or fine_payment >0 or bfintarrear_amt >0 or bfintyeararr_amt >0 or interest_payment >0 or bffineyear_amt >0 or fine_period >0 order by loancontract_no,seq_no"); while (d.Next()) { decimal bffine_arrear = d.GetDecimal("bffine_arrear"); decimal fine_payment = d.GetDecimal("fine_payment"); decimal bffineyear_amt = d.GetDecimal("bffineyear_amt"); decimal fine_period = d.GetDecimal("fine_period"); decimal bfintarrear_amt = d.GetDecimal("bfintarrear_amt"); decimal interest_payment = d.GetDecimal("interest_payment"); decimal bfintyeararr_amt = d.GetDecimal("bfintyeararr_amt"); decimal interest_period = d.GetDecimal("interest_period"); decimal fine_arrear = 0, fine_new = 0, int_arr = 0, int_new = 0; if ( bffine_arrear <= 0) { fine_arrear = 0; } else { if (fine_payment > bffineyear_amt) { if (fine_payment > bffine_arrear) { fine_arrear = (bffine_arrear - bffineyear_amt); } else { fine_arrear = (fine_payment - bffineyear_amt); } } else { fine_arrear = 0; } } //end ปรับขาด //start ปรับใหม่ if ( fine_period <= 0) { fine_new = 0; } else { if ((fine_payment - bffine_arrear) > 0) { fine_new = (fine_payment - bffine_arrear); } else { fine_new = 0; } } //end ปรับใหม่ //start ด/บ ขาด if ( bfintarrear_amt <= 0) { int_arr = 0; } else { if (interest_payment > bfintyeararr_amt) { if (interest_payment > bfintarrear_amt) { int_arr = (bfintarrear_amt - bfintyeararr_amt); } else { int_arr = (interest_payment - bfintyeararr_amt); } } else { int_arr = 0; } } //end ด/บ ขาด //start ด/บ ใหม่ if ( interest_period <= 0) { int_new = 0; } else { if ((interest_payment - bfintarrear_amt) > 0) { int_new = (interest_payment - bfintarrear_amt); } else { int_new = 0; } //end ด/บ ใหม่ } WebUtil.QuerySdt(" update lncontstatement set fine_arrear = " + fine_arrear + " , fine_period = " + fine_new + ",interest_period=" + int_new + ",interest_arrear=" + int_arr + " where loancontract_no='" + d.GetString("loancontract_no") + "' and seq_no = "+d.GetInt32("seq_no")+" "); } } } }