using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using DataLibrary; using CoreSavingLibrary; namespace Saving.CriteriaIReport.check_principal_coll { public partial class check_principal_coll : PageWebReport, WebReport { protected String app; protected String gid; protected String rid; public void InitJsPostBack() { dsMain.InitDsMain(this); dsMain.account_year(); } public void WebSheetLoadBegin() { //--- Page Arguments try { app = Request["app"].ToString(); } catch { } if (app == null || app == "") { app = state.SsApplication; } try { gid = Request["gid"].ToString(); } catch { } try { rid = Request["rid"].ToString(); } catch { } //Report Name. try { Sta ta = new Sta(state.SsConnectionString); String sql = ""; sql = @"SELECT REPORT_NAME FROM WEBREPORTDETAIL WHERE ( GROUP_ID = '" + gid + @"' ) AND ( REPORT_ID = '" + rid + @"' )"; Sdt dt = ta.Query(sql); ReportName.Text = dt.Rows[0]["REPORT_NAME"].ToString(); ta.Close(); } catch { ReportName.Text = "[" + rid + "]"; } if (!IsPostBack) { dsMain.DdCoopId(); dsMain.DATA[0].coop_id = state.SsCoopControl; // dsMain.DATA[0].adtm_sdate = state.SsWorkDate; setyear(); } } public void CheckJsPostBack(string eventArg) { } public void setyear() { string sql_date = @"select account_year from cmaccountyear where accsyscls_status =0 and divavgcls_status =0"; sql_date = WebUtil.SQLFormat(sql_date); Sdt ds2_date = WebUtil.QuerySdt(sql_date); if (ds2_date.Next()) { dsMain.DATA[0].adtm_sdate = ds2_date.GetString("account_year"); } } public void RunReport() { delete_from_report_interest_on_fines(); Insert_report_interest_on_fines(); } private void delete_from_report_interest_on_fines() { try { string delete = "delete from report_check_coll"; delete = WebUtil.SQLFormat(delete); WebUtil.QuerySdt(delete); } catch { } } private void Insert_report_interest_on_fines() { try{ DateTime start_datebf = DateTime.Today; string sql_date = @"select accstart_date from cmaccountyear where account_year={0}"; sql_date = WebUtil.SQLFormat(sql_date, dsMain.DATA[0].adtm_sdate); Sdt ds2_date = WebUtil.QuerySdt(sql_date); if (ds2_date.Next()) { start_datebf = ds2_date.GetDate("accstart_date"); } string sql = "select loancontract_no,principal_balance from lncontstatement where loanitemtype_code ='B/F' and slip_date = {0}"; sql = WebUtil.SQLFormat(sql, start_datebf); Sdt ds = WebUtil.QuerySdt(sql); while (ds.Next()) { decimal coll = 0; decimal person = 0; string sqlcoll = @"select * from lncontcoll where loancontract_no ={0}"; sqlcoll = WebUtil.SQLFormat(sqlcoll, ds.GetString("loancontract_no")); Sdt ds2 = WebUtil.QuerySdt(sqlcoll); while (ds2.Next()) { if (ds2.GetString("loancolltype_code") == "04") //คนค้ำ { person = 1; } else if (ds2.GetString("loancolltype_code") == "03") //หลักทรพย์ { coll = 1; } } string insert = @"INSERT INTO report_check_coll (loancontract_no,principal_balance,coll,person ) VALUES ({0},{1},{2},{3})"; insert = WebUtil.SQLFormat(insert, ds.GetString("loancontract_no"), ds.GetDecimal("principal_balance"), coll, person); WebUtil.QuerySdt(insert); } } catch { } int coll1 = 0; int person1 = 0; string value = dsMain.DATA[0].membgroup_start; if (value =="1") { coll1 = 0; person1 = 1; } else if (value == "2") { coll1 = 1; person1 = 0; } else if (value == "3") { coll1 = 1; person1 = 1; } try { iReportArgument arg = new iReportArgument(); arg.Add("coll", iReportArgumentType.Integer, coll1); arg.Add("person", iReportArgumentType.Integer, person1); iReportBuider report = new iReportBuider(this, arg); report.Retrieve(); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } public void WebSheetLoadEnd() { } } }