using System; 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 Saving.WcfCommon; //using Saving.WcfDeposit; using CoreSavingLibrary.WcfNDeposit; // new deposit using CoreSavingLibrary.WcfNCommon; //new common using System.Web.Services.Protocols; using System.ServiceModel.Channels; using System.Xml; using DataLibrary; using CoreSavingLibrary; using System.Globalization; namespace Saving.Applications.shrlon { public partial class w_sheet_sl_print_book : PageWebSheet, WebSheet { protected String postAccountNo; protected String jsPostPrintNewBook; protected String jsPostPrintNewBookin; protected String jsPostPrintNewBookout; protected String postAccountNo1; protected String jsPrintLnconNo; protected String jsPostUpBookno; protected String jsPostPrintBookin; protected String JsPrinBook_Kong; protected String JsPrinBook_Kong_Ireport; protected String JsPrinBook_Card; protected String jsPrinHeaderbook; protected String jsPostPrintLnColl; protected String jsPrintslip; protected String jsPostbookcard; protected String JsPrinBook_Card_head; protected String JsPrinBook_Card_details; protected String JsPrinBook_Card_BF; protected String statement_all; protected String JsPrinBook_Card_3; protected String JsPrinBook_head_year; protected String JsPrinBook_Card_4; protected String Jsfrom_card; CultureInfo th = System.Globalization.CultureInfo.GetCultureInfo("th-TH"); //private DepositClient DepService; private n_depositClient ndept; //new deposit private n_commonClient ncommon; //new common private String pbl = "sl_print_book.pbl"; private string coop_id_SSK = "000301"; private string coop_kong = "000401"; #region WebSheet Members public void InitJsPostBack() { postAccountNo = WebUtil.JsPostBack(this, "postAccountNo"); jsPostPrintNewBook = WebUtil.JsPostBack(this, "jsPostPrintNewBook"); jsPostPrintNewBookin = WebUtil.JsPostBack(this, "jsPostPrintNewBookin"); postAccountNo1 = WebUtil.JsPostBack(this, "postAccountNo1"); jsPrintLnconNo = WebUtil.JsPostBack(this, "jsPrintLnconNo"); jsPostUpBookno = WebUtil.JsPostBack(this, "jsPostUpBookno"); jsPostPrintBookin = WebUtil.JsPostBack(this, "jsPostPrintBookin"); jsPostPrintLnColl = WebUtil.JsPostBack(this, "jsPostPrintLnColl"); jsPostPrintNewBookout = WebUtil.JsPostBack(this, "jsPostPrintNewBookout"); JsPrinBook_Kong = WebUtil.JsPostBack(this, "JsPrinBook_Kong"); JsPrinBook_Kong_Ireport = WebUtil.JsPostBack(this, "JsPrinBook_Kong_Ireport"); jsPrinHeaderbook = WebUtil.JsPostBack(this, "jsPrinHeaderbook"); jsPrintslip = WebUtil.JsPostBack(this, "jsPrintslip"); jsPostbookcard = WebUtil.JsPostBack(this, "jsPostbookcard"); JsPrinBook_Card = WebUtil.JsPostBack(this, "JsPrinBook_Card"); JsPrinBook_Card_head = WebUtil.JsPostBack(this, "JsPrinBook_Card_head"); JsPrinBook_Card_details = WebUtil.JsPostBack(this, "JsPrinBook_Card_details"); JsPrinBook_Card_BF = WebUtil.JsPostBack(this, "JsPrinBook_Card_BF"); Jsfrom_card = WebUtil.JsPostBack(this, "Jsfrom_card"); statement_all = WebUtil.JsPostBack(this, "statement_all"); JsPrinBook_Card_3 = WebUtil.JsPostBack(this, "JsPrinBook_Card_3"); JsPrinBook_Card_4 = WebUtil.JsPostBack(this, "JsPrinBook_Card_4"); JsPrinBook_head_year = WebUtil.JsPostBack(this, "JsPrinBook_head_year"); if (state.SsCoopId != "000401" && state.SsCoopId != coop_id_SSK) { Bookin.Style["display"] = "none"; bookin2.Style["display"] = "none"; PrinBook_Kong.Style["display"] = "none"; Headerbook.Style["display"] = "none"; } if (state.SsCoopId == "000401" || state.SsCoopId == coop_id_SSK) { ShifF7.Style["display"] = "none"; ShifF5.Style["display"] = "none"; } } public void WebSheetLoadBegin() { ndept = wcf.NDeposit; this.ConnectSQLCA(); DwMain.SetTransaction(sqlca); DwDetail.SetTransaction(sqlca); Hloancheck.Value = "true"; if (!IsPostBack) { DwMain.InsertRow(0); DwMain.SetItemString(1, "coop_id", state.SsCoopControl); dw_data_1.InsertRow(0); dw_data_2.InsertRow(0); } else { this.RestoreContextDw(DwMain); this.RestoreContextDw(DwDetail); this.RestoreContextDw(dw_data_1); this.RestoreContextDw(dw_data_2); } } public void CheckJsPostBack(string eventArg) { if (eventArg == "postAccountNo") { JsPostAccountNo(); } else if (eventArg == "chkTrue") { JschkTrue(); } else if (eventArg == "chkFalse") { JschkFalse(); } else if (eventArg == "Jsfrom_card") { from_card(); } else if (eventArg == "statement_all") { statement_all_sub(Hdloancontract_no.Value); } else if (eventArg == "JsPrinBook_Card_BF") { PrinBook_Card_BF(Hdloancontract_no.Value); } else if (eventArg == "JsPrinBook_head_year") { PrinBook_head_year(Hdloancontract_no.Value); } else if (eventArg == "jsPostbookcard") { bookcard(DwMain.GetItemString(1, "loancontract_no")); //JsPrinBook_Card } else if (eventArg == "JsPrinBook_Card") { Prin_ireport_bookCard(Hdloancontract_no.Value); } else if (eventArg == "JsPrinBook_Card_3") { Prin_ireport_bookCard_3(Hdloancontract_no.Value); }else if (eventArg == "JsPrinBook_Card_4") { Prin_ireport_bookCard_4(Hdloancontract_no.Value); } else if (eventArg == "JsPrinBook_Card_head") { Prin_ireport_bookCard_head(Hdloancontract_no.Value); } else if (eventArg == "JsPrinBook_Card_details") { Prin_ireport_bookCard_details(Hdloancontract_no.Value); } else if (eventArg == "jsPrintslip") { string memno = DwMain.GetItemString(1, "member_no"); // string coopid = state.SsCoopControl; iReportBuider report = new iReportBuider(this, ""); string report_name2 = ""; report_name2 = "sl_slip_buyshare"; iReportArgument args = new iReportArgument(); args.Add("memno", iReportArgumentType.String, memno); args.Add("coopid", iReportArgumentType.String, state.SsCoopControl); report.AddCriteria("book_coll_new", "พิมพ์สมุดจำนอง", ReportType.pdf, args); report.AutoOpenPDF = true; report.Retrieve(); } else if (eventArg == "JsPrinBook_Kong_Ireport") { PrinBookIreport_Kong(); } else if (eventArg == "jsPostPrintNewBook") { PostPrintNewBook(); } else if (eventArg == "jsPostPrintNewBookin") { PostPrintNewBookin(); } else if (eventArg == "jsPrinHeaderbook") { PrinHeaderbook(); } else if (eventArg == "jsPostPrintNewBookout") { PostPrintNewBookout(); } else if (eventArg == "jsPostPrintBookin") { PostPrintBookin(); } else if (eventArg == "postAccountNo1") { JsPostAccountNo1(); } else if (eventArg == "jsPrintLnconNo") { PostPrintLnconNo(); } else if (eventArg == "JsPrinBook_Kong") { CallFuntion_PrintBook(); } else if (eventArg == "jsPostUpBookno") { PostUpBookno(); } } public void statement_all_sub(string loancontract_no) // ปริ้น statement ทั้งหมด { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='Book_card_details._stament' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); // ปริ้น statement ทั้งหมด } } catch { } report_label3 = "รายการเคลื่อนไหวทั้วหมด"; args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void from_card() { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='print_from_card' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); //หัวสมุดและต้นยกมาสิ้นปี } } catch { } report_label3 = "แบบฟรอมการ์ด"; args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void PrinBook_head_year(string loancontract_no) { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='PrintBookCard_head_year' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); //หัวสมุดและต้นยกมาสิ้นปี } } catch { } report_label3 = "หัวสมุดและต้นยกมาสิ้นปี"; args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void PrinBook_Card_BF(string loancontract_no) { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='PrintBookCard_BF' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด } } catch { } report_label3 = "ต้นยกมาสิ้นปี"; args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void Prin_ireport_bookCard(string loancontract_no) { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='print_book_card' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด } } catch { } report_label3 = "ปริ้นสมุดการ์ด"; args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void Prin_ireport_bookCard_4(string loancontract_no) { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='Book_card_kong_2' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); //รายการ พร้อม ปิดปี } } catch { } report_label3 = "ปริ้นสมุดการ์ด"; args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void Prin_ireport_bookCard_3(string loancontract_no) { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='print_book_card_3' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด } } catch { } report_label3 = "ปริ้นสมุดการ์ด"; args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void Prin_ireport_bookCard_head(string loancontract_no) { iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='print_book_card_head' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด report_label3 = Greport.GetString("ireport_description"); } } catch { } args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void Prin_ireport_bookCard_details(string loancontract_no) { DateTime payment_date = DateTime.Today; string loanconract_no2 = ""; string word = ""; try { string sql = @"select loancontract_no,lastpayment_date from lncontmaster where loancontract_no ={0} and contract_status=-1 and coop_id={1}"; sql = WebUtil.SQLFormat(sql, loancontract_no, state.SsCoopId); Sdt sqlreport = WebUtil.QuerySdt(sql); if (sqlreport.Next()) { payment_date = sqlreport.GetDate("lastpayment_date"); loanconract_no2 = sqlreport.GetString("loancontract_no"); } } catch { } if (loanconract_no2 != "") { word = "ชำระเสร็จวันที่" + payment_date.ToString("dd/MM/yyyy", th); } else { word = "ยังชำระไม่แล้วเสร็จ"; } iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; try { string sqlselect = @"select * from report_master where ireport_id ='print_book_card_details' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด report_label3 = Greport.GetString("ireport_description"); } } catch { } args3.Add("payment_date", iReportArgumentType.String, word); args3.Add("loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void SaveWebSheet() { } public void WebSheetLoadEnd() { try { bool isChecked = CbCheckLoan.Checked; String memberNo = DwMain.GetItemString(1, "member_no").Trim(); //WebUtil.MemberNoFormat(dw_main.GetItemString(1, "member_no")); if (!string.IsNullOrEmpty(memberNo)) { memberNo = WebUtil.MemberNoFormat(memberNo); DwUtil.RetrieveDataWindow(dw_data_2, pbl, null, state.SsCoopId, memberNo); if (dw_data_2.RowCount > 0) { if (isChecked) { dw_data_2.SetFilter("contract_status > 0"); dw_data_2.Filter(); } else { dw_data_2.SetFilter("contract_status < 0"); dw_data_2.Filter(); } } } } catch { } DwMain.SaveDataCache(); DwDetail.SaveDataCache(); dw_data_1.SaveDataCache(); dw_data_2.SaveDataCache(); } #endregion #region Function public void bookcard(string loancontract_no) { decimal principal_period = 0; decimal principal_payment = 0; decimal intreest_period = 0; decimal interest_payment = 0; decimal fine_period = 0; decimal fine_payment = 0; decimal bfprincipal_arrear = 0; decimal forward_principal = 0; decimal principal_payment2 =0 ; decimal pn_arr = 0; DateTime slip_date = state.SsWorkDate; string entry_id = ""; string loanitemtype_code = ""; decimal fineyear_arrear =0, intarr_payment =0; decimal bffineyear_amt = 0; decimal bfintyeararr_amt = 0; try { string statement = @"select * from lncontstatement where loancontract_no={0} and coop_id={1} and item_status = 1"; statement = WebUtil.SQLFormat(statement, loancontract_no, state.SsCoopId); Sdt dt1 = WebUtil.QuerySdt(statement); try { string delete_report_book_statement = @"delete from report_book_statement where coop_id={0}"; delete_report_book_statement = WebUtil.SQLFormat(delete_report_book_statement, state.SsCoopId); WebUtil.QuerySdt(delete_report_book_statement); } catch { } while (dt1.Next()) { loanitemtype_code = dt1.GetString("loanitemtype_code"); bfprincipal_arrear = dt1.GetDecimal("principal_arrear"); intreest_period = dt1.GetDecimal("bfint_preiod"); interest_payment = dt1.GetDecimal("interest_period"); slip_date = dt1.GetDate("slip_date"); entry_id = dt1.GetString("entry_id"); fine_period = dt1.GetDecimal("bffine_preiod"); fine_payment = dt1.GetDecimal("fine_period"); principal_period = dt1.GetDecimal("principalpay_period"); principal_payment = dt1.GetDecimal("principal_payment"); principal_payment2 = dt1.GetDecimal("principal_payment"); fineyear_arrear = dt1.GetDecimal("fineyear_arrear"); intarr_payment = dt1.GetDecimal("intarr_payment"); decimal seq_no = dt1.GetDecimal("seq_no"); bffineyear_amt = dt1.GetDecimal("bffineyear_amt"); bfintyeararr_amt = dt1.GetDecimal("bfintyeararr_amt"); if(seq_no == 11){ seq_no = 11; } if (loanitemtype_code != "LRC" && loanitemtype_code != "B/F") { //pn_balance if((principal_payment - principal_period) <= 0 ){ if((bfprincipal_arrear-principal_payment) >= 0){ principal_payment = 0; }else{ principal_payment -= bfprincipal_arrear; } }else{ if ((bfprincipal_arrear - principal_period) > 0) { principal_payment = bfprincipal_arrear - principal_period; } else { principal_payment = principal_period; } } // pn_arr /* ( ( $F{LOANITEMTYPE_CODE} == "LPN" || $F{LOANITEMTYPE_CODE} == "LPX" && $F{BFPRINCIPAL_ARREAR} > $F{PRINCIPAL_PAYMENT} ? $F{PRINCIPAL_PAYMENT} :$F{BFPRINCIPAL_ARREAR})) */ if (bfprincipal_arrear > principal_payment2) { pn_arr = principal_payment2; } else { pn_arr = bfprincipal_arrear; } //คำนวณต้นล่วงหน้า //( ( $F{LOANITEMTYPE_CODE} == "LPN" || // $F{LOANITEMTYPE_CODE} == "LPX" && // $F{PRINCIPAL_PAYMENT} - ($V{pn_arr}+$V{pn_balance}) > 0 ? // $F{PRINCIPAL_PAYMENT} - ($V{pn_arr}+$V{pn_balance}):0 // ) //) if (principal_payment2 - (pn_arr + principal_payment) > 0) { forward_principal = principal_payment2 - (pn_arr + principal_payment); } else { forward_principal = 0; } // -------> เงินต้น ลด ใช้ filed principal_arrear //ต้นค้าง if (bfprincipal_arrear>0) { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, 0, entry_id, "ชำระต้นค้าง", bfprincipal_arrear, 0, loanitemtype_code, 0, 0, 8, 0,0); WebUtil.QuerySdt(insert_principal_arrear); } //ต้นปกติ if (principal_payment > 0) { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, 0, entry_id, "ชำระต้นพึงชำระ", principal_payment, 0, loanitemtype_code, 0, 0, 9, 0, 0); WebUtil.QuerySdt(insert_principal_arrear); } //ต้นล่วงหน้า if (forward_principal > 0) { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, 0, entry_id, "ชำระต้นก่อนกำหนด", forward_principal, 0, loanitemtype_code, 0, 0, 10, 0, 0); WebUtil.QuerySdt(insert_principal_arrear); } //ต้นปกติ //if (principal_payment > 0) //{ // string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; // insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, 0, entry_id, "ชำระต้นพึงชำระ", principal_payment, 0, loanitemtype_code, 0, 0, 9, 0); // WebUtil.QuerySdt(insert_principal_arrear); //} //ต้นล่วงหน้า //if (forward_principal > 0) //{ // string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; // insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, 0, entry_id, "ชำระต้นก่อนกำหนด", 0, forward_principal, loanitemtype_code, 0, 0, 10, 0); // WebUtil.QuerySdt(insert_principal_arrear); //} // ดอกเบี้ยเพิ่ม ใช้ filed interest_period //ดิกเบี้ยพึง if (intreest_period > 0) { if (loanitemtype_code=="LTA") { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, intreest_period, 0, entry_id, "โอนเข้าดอกเบี้ยค้าง", 0, 0, loanitemtype_code, 0, 0, 2, 0, intreest_period); WebUtil.QuerySdt(insert_principal_arrear); }else{ string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, intreest_period, 0, entry_id, "ดอกเบี้ยพึงชำระ", 0, 0, loanitemtype_code, 0, 0, 2, 0, intreest_period); WebUtil.QuerySdt(insert_principal_arrear); } } // ดอกเบี้ยลดใช้ field interest_payment //ดอกเบี้ยใหม่ if (interest_payment > 0) { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, interest_payment, entry_id, "ชำระดอกเบี้ยพึงชำระ", 0, 0, loanitemtype_code, 0, 0, 3,0, intreest_period - interest_payment); WebUtil.QuerySdt(insert_principal_arrear); } // ดอกเบี้ยเพิ่ม ใช้ filed fine_period //ด่าปรับพึง if (fine_period > 0) { if (loanitemtype_code == "LTA") { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, fine_period, 0, 0, 0, entry_id, "โอนเข้าด่าปรับพึงค้าง", 0, 0, loanitemtype_code, 0, 0, 4, 0, fine_period); WebUtil.QuerySdt(insert_principal_arrear); } else { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, fine_period, 0, 0, 0, entry_id, "ด่าปรับพึง", 0, 0, loanitemtype_code, 0, 0, 4, 0, fine_period); WebUtil.QuerySdt(insert_principal_arrear); } } // ด่าปรับพึงลดใช้ field fine_payment if (fine_payment > 0) { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, fine_payment, 0, 0, entry_id, "ชำระด่าปรับพึงชำระ", 0, 0, loanitemtype_code, 0, 0, 5, 0,fine_period - fine_payment); WebUtil.QuerySdt(insert_principal_arrear); } // ปรับค้างปี if (fineyear_arrear > 0) { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, fineyear_arrear, 0, 0, entry_id, "ชำระด่าปรับค้างปี", 0, 0, loanitemtype_code, fine_payment, 0, 7, 0, bffineyear_amt - fineyear_arrear); WebUtil.QuerySdt(insert_principal_arrear); } // ดอกเบี้ยค้าง if (intarr_payment > 0) { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, intarr_payment, entry_id, "ชำระดอกเบี้ยค้างปี", 0, 0, loanitemtype_code, 0, 0, 6, 0, bfintyeararr_amt - intarr_payment); WebUtil.QuerySdt(insert_principal_arrear); } }else{ // เงินเพิ่มใช้ principal_payment if (loanitemtype_code == "B/F") // ต้นยกมา { string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; if (bfprincipal_arrear > 0) { insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, dt1.GetDecimal("bffineyear_amt"), 0, dt1.GetDecimal("bfintyeararr_amt"), 0, entry_id, "ยอดยกมา ค้าง", 0, 0, loanitemtype_code, 0, 0, 1, principal_payment, principal_payment); } else { insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, dt1.GetDecimal("bffineyear_amt"), 0, dt1.GetDecimal("bfintyeararr_amt"), 0, entry_id, "ยอดยกมา", 0, 0, loanitemtype_code, 0, 0, 1, principal_payment, principal_payment); } WebUtil.QuerySdt(insert_principal_arrear); } else { //จ่ายเงินกู้ string insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, 0, entry_id, "จ่ายเงินกู้", 0, 0, loanitemtype_code, 0, 0, 1, principal_payment, principal_payment); WebUtil.QuerySdt(insert_principal_arrear); if (intreest_period > 0) { insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, intreest_period, 0, entry_id, "ดอกเบี้ยพึงชำระ", 0, 0, loanitemtype_code, 0, 0, 2, 0, intreest_period); WebUtil.QuerySdt(insert_principal_arrear); insert_principal_arrear = @"insert into report_book_statement(coop_id ,loancontract_no,slip_date,principal_arrear,fine_period,fine_payment,interest_period,interest_payment,entry_id,description,principal_period,forward_principal,loanitemtype_code,fineyear_arrear,intyear_arrear,seq_no,principal_payment,balance) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17})"; insert_principal_arrear = WebUtil.SQLFormat(insert_principal_arrear, state.SsCoopId, loancontract_no, slip_date, 0, 0, 0, 0, interest_payment, entry_id, "ชำระดอกเบี้ยพึงชำระ", 0, 0, loanitemtype_code, 0, 0, 3, 0, intreest_period - interest_payment); WebUtil.QuerySdt(insert_principal_arrear); } } } } } catch { } Page.ClientScript.RegisterStartupScript(this.GetType(), "Print_Card", "Print_Card('" + loancontract_no + "')", true); } public void JsPostAccountNo() { String loancontract_no = DwMain.GetItemString(1, "loancontract_no"); String sql1 = @"select loanpassbook_no,loanpassbook_no from lncontmaster where loancontract_no = '" + loancontract_no + "'"; Sdt dt1 = WebUtil.QuerySdt(sql1); if (dt1.Next()) { DwUtil.RetrieveDataWindow(DwMain, pbl, null, state.SsCoopControl, loancontract_no); DwUtil.RetrieveDataWindow(DwPeriod, pbl, null, state.SsCoopControl, loancontract_no); DwUtil.RetrieveDataWindow(DwDetail, pbl, null, state.SsCoopControl, loancontract_no); DwMain.SetItemString(1, "check_no", dt1.GetString("loanpassbook_no")); CbCheckLoan.Checked = true; string member_no = DwMain.GetItemString(1, "member_no"); string coop_id = state.SsCoopId; DwUtil.RetrieveDataWindow(dw_data_1, pbl, null, coop_id, member_no); DwUtil.RetrieveDataWindow(dw_data_2, pbl, null, coop_id, member_no); } } private void JschkFalse() { try { Hloancheck.Value = "false"; dw_data_2.SetFilter("contract_status < 0"); dw_data_2.Filter(); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } private void JschkTrue() { try { Hloancheck.Value = "true"; dw_data_2.SetFilter("contract_status > 0"); dw_data_2.Filter(); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } public void PrinBookIreport_Kong() { iReportBuider report = new iReportBuider(this, ""); iReportArgument args3 = new iReportArgument(); string report_name3 = "", report_label3 = ""; report_name3 = "Book_ RepaymentMain"; try { string sqlselect = @"select * from report_master where ireport_id ='printbook_repayment' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { report_name3 = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด } } catch { } report_label3 = "ปริ้นสมุดชำระหนี้"; args3.Add("Loancontract_no", iReportArgumentType.String, Hdloancontract_no.Value); args3.Add("coop_id", iReportArgumentType.String, state.SsCoopId); iReportBuider report3 = new iReportBuider(this, ""); report.AddCriteria(report_name3, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } public void JsPostAccountNo1() { String check_no = DwMain.GetItemString(1, "check_no"); String sql = @"select loancontract_no,loanpassbook_no from lncontmaster where loanpassbook_no = '" + check_no + "'"; Sdt dt = WebUtil.QuerySdt(sql); if (dt.Next()) { DwUtil.RetrieveDataWindow(DwPeriod, pbl, null, state.SsCoopControl, dt.GetString("loancontract_no")); DwUtil.RetrieveDataWindow(DwMain, pbl, null, state.SsCoopControl, dt.GetString("loancontract_no")); DwUtil.RetrieveDataWindow(DwDetail, pbl, null, state.SsCoopControl, dt.GetString("loancontract_no")); DwMain.SetItemString(1, "check_no", dt.GetString("loanpassbook_no")); } } private void PostPrintNewBook() { try { string as_loan_no = DwMain.GetItemString(1, "loancontract_no"); DateTime adtm_date = state.SsWorkDate; String as_xml_return = ""; String as_entryid = ""; //short ai_reprint = 0 ; String as_newpassbook_no = ""; String as_reson = ""; int result = ndept.of_print_bookloan_firstpage(state.SsWsPass, as_loan_no, state.SsWorkDate, as_entryid, ref as_xml_return, 0, as_newpassbook_no, as_reson); //Printing.Loanprintbookfristpage(this, as_xml_return); Printing.PrintApplet(this, "loan_printbookfirst", as_xml_return); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } private void PostPrintNewBookin() { try { if (state.SsCoopId == "000401" || state.SsCoopId == coop_id_SSK) { iReportBuider report = new iReportBuider(this, ""); string report_label3 = "พิมพ์หัวสมุดชำระหนี้"; iReportArgument args3 = new iReportArgument(); args3.Add("loancontract_no", iReportArgumentType.String, DwMain.GetItemString(1, "loancontract_no")); report.AddCriteria("Book_cover", report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } } catch { } } private void PrinHeaderbook() { try { try { if (state.SsCoopId == "000401" || state.SsCoopId == coop_id_SSK) { string Book_cover2 = "Book_cover2"; try { string sqlselect = @"select * from report_master where ireport_id ='Book_cover2' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { Book_cover2 = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด } } catch { } iReportBuider report = new iReportBuider(this, ""); string report_label3 = "พิมพ์หัวสมุดชำระหนี้"; iReportArgument args3 = new iReportArgument(); args3.Add("loancontract_no", iReportArgumentType.String, DwMain.GetItemString(1, "loancontract_no")); report.AddCriteria(Book_cover2, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } } catch { } } catch { } } private void PostPrintNewBookout() { try { if (state.SsCoopId == "000401" || state.SsCoopId == coop_id_SSK) { string bookout = "bookout"; try { string sqlselect = @"select * from report_master where ireport_id ='bookout' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { bookout = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด } } catch { } iReportBuider report = new iReportBuider(this, ""); string report_label3 = "พิมพ์ปกนอก"; iReportArgument args3 = new iReportArgument(); args3.Add("member_no", iReportArgumentType.String, DwMain.GetItemString(1, "member_no")); report.AddCriteria(bookout, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } } catch { } } private void PostPrintBookin() { String loancontract_no = DwMain.GetItemString(1, "loancontract_no"); String sql1 = @"select * from amsecusers where user_name={0} and coop_id={1}"; sql1 = WebUtil.SQLFormat(sql1,state.SsUsername,state.SsCoopId); Sdt dt1 = WebUtil.QuerySdt(sql1); string full_name = ""; string position = ""; if (dt1.Next()) { full_name = dt1.GetString("full_name"); position = dt1.GetString("description"); } try { if (state.SsCoopId == "000401" || state.SsCoopId == coop_id_SSK) { string bookin = "bookin"; try { string sqlselect = @"select * from report_master where ireport_id ='bookin' and coop_id={0}"; sqlselect = WebUtil.SQLFormat(sqlselect, state.SsCoopId); Sdt Greport = WebUtil.QuerySdt(sqlselect); if (Greport.Next()) { bookin = Greport.GetString("ireport_name"); // พิมพ์สมุดจ่ายเงินกู้ พร้อม หัวสมุด } } catch { } iReportBuider report = new iReportBuider(this, ""); string report_label3 = "พิมพ์ปกสมุดใน"; iReportArgument args3 = new iReportArgument(); args3.Add("member_no", iReportArgumentType.String, DwMain.GetItemString(1, "member_no")); args3.Add("full_name", iReportArgumentType.String, full_name); args3.Add("position", iReportArgumentType.String, position); report.AddCriteria(bookin, report_label3, ReportType.pdf, args3); report.AutoOpenPDF = true; report.Retrieve(); } } catch { } } private void PostPrintLnconNo() { String sl_xml_lnconno = ""; if (DwMain.RowCount > 0) { sl_xml_lnconno = DwPeriod.Describe("DataWindow.Data.XML"); // Printing.LoanPrintCont(this, sl_xml_lnconno); Printing.PrintApplet(this, "loan_printcontract", sl_xml_lnconno); } } private void CallFuntion_PrintBook() { if (state.SsCoopId == coop_kong) { String loancontract_no = DwMain.GetItemString(1, "loancontract_no"); Page.ClientScript.RegisterStartupScript(this.GetType(), "CallPrintBook_kong", "CallPrintBook_kong('" + loancontract_no + "')", true); } else { String loancontract_no = DwMain.GetItemString(1, "loancontract_no"); Page.ClientScript.RegisterStartupScript(this.GetType(), "CallPrintBook", "CallPrintBook('" + loancontract_no + "')", true); } } private void PostUpBookno() { try { LtServerMessage.Text = WebUtil.CompleteMessage("บันทึกข้อมูลสำเร็จ"); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage("บันทึกข้อมูลไม่สำเร็จ" + ex); } } #endregion } }