using System; using CoreSavingLibrary; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; //using CoreSavingLibrary.WcfNShrlon; using CoreSavingLibrary.WcfNShrlon; using Sybase.DataWindow; using System.Web.Services.Protocols; using DataLibrary; using System.Data; using System.Globalization; namespace Saving.Applications.shrlon { public partial class w_sheet_gen_mbclass_crmja : PageWebSheet, WebSheet { Sta ta; public void InitJsPostBack() { } public void WebSheetLoadBegin() { try { this.ConnectSQLCA(); ta = new Sta(sqlca.ConnectionString); sqlca = new DwTrans(); sqlca.Connect(); if (IsPostBack) { } else { } } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex.ToString()); } } public void WebSheetLoadEnd() { } public void SaveWebSheet() { } public void CheckJsPostBack(string eventArg) { } protected void Button1_Click(object sender, EventArgs e) { try { Sdt ds = WebUtil.QuerySdt(@"select loancontract_no from lncontmaster where loancontract_no not in ( select loancontract_no from mbmembclass) and principal_balance>0"); while (ds.Next()) { Sdt d = WebUtil.QuerySdt(@"select mb.member_no,mb.mblntype_level,ln.loancontract_no from mbmembmaster mb inner join lncontmaster ln on mb.member_no=ln.member_no where ln.loancontract_no ='" + ds.GetString("loancontract_no") + "' "); if (d.Next()) { decimal point = 0, int_rate = 0; if (d.GetDecimal("mblntype_level") == 1) { point = 80; } else if (d.GetDecimal("mblntype_level") == 2) { point = 70; } else if (d.GetDecimal("mblntype_level") == 3) { point = 60; } else { point = 90; } //อัตราดอกเบี้ย string loancontract = d.GetString("loancontract_no"); // get yaer จาก ค่าคงที่ decimal INTROUNDSUM_TYPE = 0; string sql3 = @" select contract_interest from lncontmaster where loancontract_no={0}"; sql3 = WebUtil.SQLFormat(sql3, loancontract); Sdt dt3 = WebUtil.QuerySdt(sql3); if (dt3.Next()) { int_rate = dt3.GetDecimal("contract_interest"); } if (int_rate == -1)// ถ้ามากกว่า 0 ให้ไปดึงดอกเบี้ยจาก lncontmaster { if (INTROUNDSUM_TYPE == 0) { //คิดแบบ ไม่จัดชั้น string sql2 = @" select lncfloanintratedet.interest_rate from lncfloanintratedet left join lnloantype on lnloantype.inttabfix_code = lncfloanintratedet.loanintrate_code left join lncontmaster on lncontmaster.loantype_code=lnloantype.loantype_code where lncontmaster.loancontract_no= {0}"; sql2 = WebUtil.SQLFormat(sql2, loancontract); Sdt dt2 = WebUtil.QuerySdt(sql2); if (dt2.Next()) { int_rate = dt2.GetDecimal("interest_rate"); } } else {//คิดแบบ จัดชั้น string sql2 = @" select lir.int_rate from lncontmaster lc inner join lnloantypeintrate lir on lir.loantype_code = lc.loantype_code inner join mbmembmaster mb on mb.member_no = lc.member_no and mb.mblntype_level = lir.mblntype_level where lc.loancontract_no= {0}"; sql2 = WebUtil.SQLFormat(sql2, loancontract); Sdt dt2 = WebUtil.QuerySdt(sql2); if (dt2.Next()) { int_rate = dt2.GetDecimal("int_rate"); } } } WebUtil.QuerySdt("insert into mbmembclass(coop_id,year_no,memb_level,member_no,int_rate,points,seq_no,loancontract_no) values('000501','" + TextBox1.Text + "'," + d.GetDecimal("mblntype_level") + ",'" + d.GetString("member_no") + "'," + int_rate + "," + point + ",1,'" + d.GetString("loancontract_no") + "')"); } } } catch (Exception ex) { LtServerMessage.Text = " ผิดพลาด" + ex.ToString(); } } } }