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.WcfNShrlon; using CoreSavingLibrary.WcfNCommon; using Sybase.DataWindow; using DataLibrary; using System.Threading; namespace Saving.Applications.shrlon { public partial class w_sheet_sl_collateral_master_tks : PageWebSheet, WebSheet { public String app = ""; public String gid = ""; public String rid = ""; protected String pdf = ""; private DwThDate tdwhead; private DwThDate tdwreview; private n_shrlonClient shrlonService; private n_commonClient commonService; protected String jsPostMember; protected String PostMember1; protected String jsPostCollmast; protected String newClear; protected String jsRefresh; protected String postInsertRow; protected String jsgetmember; protected String jsDeleteRow; protected String jspostPorvince; protected String jsprintColl; protected String jsInsertRowReview; protected String jsDeleteRowCollprop; protected String jsDeleteRowReview; protected String jsInsertRowDetail; public String outputProcess = ""; //============== //=============== public void InitJsPostBack() { jsPostMember = WebUtil.JsPostBack(this, "jsPostMember"); PostMember1 = WebUtil.JsPostBack(this, "PostMember1"); jsPostCollmast = WebUtil.JsPostBack(this, "jsPostCollmast"); jsRefresh = WebUtil.JsPostBack(this, "jsRefresh"); postInsertRow = WebUtil.JsPostBack(this, "postInsertRow"); jsgetmember = WebUtil.JsPostBack(this, "jsgetmember"); jsDeleteRow = WebUtil.JsPostBack(this, "jsDeleteRow"); jspostPorvince = WebUtil.JsPostBack(this, "jspostPorvince"); jsprintColl = WebUtil.JsPostBack(this, "jsprintColl"); newClear = WebUtil.JsPostBack(this, "newClear"); jsInsertRowReview = WebUtil.JsPostBack(this, "jsInsertRowReview"); jsInsertRowDetail = WebUtil.JsPostBack(this, "jsInsertRowDetail"); jsDeleteRowCollprop = WebUtil.JsPostBack(this, "jsDeleteRowCollprop"); jsDeleteRowReview = WebUtil.JsPostBack(this, "jsDeleteRowReview"); tdwhead = new DwThDate(dw_head, this); tdwreview = new DwThDate(dw_detail, this); tdwhead.Add("mortgage_date", "mortgage_tdate"); tdwhead.Add("redeem_date", "redeem_tdate"); tdwreview.Add("review_date", "review_tdate"); } public void WebSheetLoadBegin() { try { shrlonService = wcf.NShrlon; commonService = wcf.NCommon; } catch { LtServerMessage.Text = WebUtil.ErrorMessage("ติดต่อ Web Service ไม่ได้"); return; } //this.ConnectSQLCA(); //dw_collddetail.SetTransaction(sqlca); //dw_review.SetTransaction(sqlca); //dw_detail.SetTransaction(sqlca); if (IsPostBack) { try { this.RestoreContextDw(dw_main); //dw_main.RestoreContext(); this.RestoreContextDw(dw_list); //dw_list.RestoreContext(); this.RestoreContextDw(dw_head); //dw_head.RestoreContext(); this.RestoreContextDw(dw_detail1); //dw_colluse.RestoreContext(); this.RestoreContextDw(dw_detail); //dw_detail.RestoreContext(); this.RestoreContextDw(dw_collprop); //dw_collprop.RestoreContext(); this.RestoreContextDw(dw_detail2); //dw_review.RestoreContext(); } catch { } } else { dw_main.InsertRow(0); dw_list.InsertRow(0); dw_head.InsertRow(0); dw_collprop.InsertRow(0); dw_detail.InsertRow(0); dw_detail1.InsertRow(0); dw_detail2.InsertRow(0); tdwhead.Eng2ThaiAllRow(); tdwreview.Eng2ThaiAllRow(); // GetDDDW(); } } public void GetDDDW() { try { WebUtil.RetrieveDDDW(dw_list, "collmasttype_code", "sl_collateral_master.pbl", null); } catch { } } public void CheckJsPostBack(string eventArg) { if (eventArg == "jsPostMember") { JsPostMember(); } else if (eventArg == "PostMember1") { jsPostMember1(); } else if (eventArg == "jsPostCollmast") { JsPostCollmast(); } else if (eventArg == "newClear") { JsNewClear(); } else if (eventArg == "jsRefresh") { } else if (eventArg == "postInsertRow") { JsPostInsertRow(); } else if (eventArg == "jsgetmember") { Jsgetmember(); } else if (eventArg == "jsDeleteRow") { JsDeleteRow(); } else if (eventArg == "jsDeleteRowCollprop") { JsDeleteRowCollprop(); } else if (eventArg == "jspostPorvince") { JspostPorvince(); } else if (eventArg == "jsprintColl") { JsprintColl(); } else if (eventArg == "jsInsertRowDetail") { JsInsertRowDetail(); } } private void JsprintColl() { } private void JspostPorvince() { } public void SaveWebSheet() { } public void WebSheetLoadEnd() { //WebUtil.RetrieveDDDW(dw_head, "collmasttype_code", "sl_collateral_master.pbl", null); //WebUtil.RetrieveDDDW(dw_head, "collrelation_code", "sl_collateral_master.pbl", null); tdwhead.Eng2ThaiAllRow(); tdwreview.Eng2ThaiAllRow(); //dw_detail.SaveDataCache(); //dw_review.SaveDataCache(); dw_main.SaveDataCache(); dw_list.SaveDataCache(); dw_head.SaveDataCache(); dw_detail1.SaveDataCache(); dw_detail.SaveDataCache(); dw_collprop.SaveDataCache(); dw_detail2.SaveDataCache(); //ShowDistrict(); // GetDDDW(); } private void jsPostMember1() { Sta ta = new Sta(new DwTrans().ConnectionString); String memberno = Hmemno.Value; String sql = @"SELECT MBMEMBMASTER.MEMBER_NO, MBUCFPRENAME.PRENAME_DESC||MBMEMBMASTER.MEMB_NAME||' '||MBMEMBMASTER.MEMB_SURNAME AS name , MBMEMBMASTER.CARD_PERSON FROM MBMEMBMASTER, MBUCFPRENAME WHERE ( MBMEMBMASTER.PRENAME_CODE = MBUCFPRENAME.PRENAME_CODE ) and MBMEMBMASTER.MEMBER_NO = '" + memberno + "' "; Sdt dt = ta.Query(sql); String memno = dt.Rows[0]["member_no"].ToString(); String name = dt.Rows[0]["name"].ToString(); String CARD_PERSON = dt.Rows[0]["CARD_PERSON"].ToString(); } private void JsPostMember() { //JsNewClear(); //Hfredeemflag.Value = "0"; //dw_list.Reset(); try { // string membno = WebUtil.MemberNoFormat(Hfmember_no.Value); string membno = WebUtil.MemberNoFormat(dw_main.GetItemString(1,"member_no")); DwUtil.RetrieveDataWindow(dw_main, "sl_collateral_master_tks", null, state.SsCoopControl, membno); DwUtil.RetrieveDataWindow(dw_list, "sl_collateral_master_tks", null, state.SsCoopControl, membno); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } private void JsPostCollmast() { try { str_lncollmast strlncoll = new str_lncollmast(); strlncoll.collmast_no = HfSlipNo.Value; strlncoll.coop_id = state.SsCoopId; int li_row = dw_list.FindRow("collmast_no = '" + strlncoll.collmast_no.Trim() + "'", 0, dw_list.RowCount); //int li_row = 1; if (li_row > 0) { DwUtil.RetrieveDataWindow(dw_head, "sl_collateral_master_tks", null,HfSlipNo.Value, state.SsCoopControl); DwUtil.RetrieveDataWindow(dw_detail, "sl_collateral_master_tks", null, state.SsCoopControl, HfSlipNo.Value); DwUtil.RetrieveDataWindow(dw_collprop, "sl_collateral_master_tks", null, state.SsCoopControl, HfSlipNo.Value); DwUtil.RetrieveDataWindow(dw_detail1, "sl_collateral_master_tks", null, HfSlipNo.Value, state.SsCoopControl); DwUtil.RetrieveDataWindow(dw_detail2, "sl_collateral_master_tks", null, HfSlipNo.Value, state.SsCoopControl); try { string sql = @" select sum( tmp_coll.coll_use ) as sumcoll_use from ( select trunc(( ( ( b.principal_balance + b.withdrawable_amt ) * a.coll_percent ) ) / a.base_percent, 3) as coll_use from lncontcoll a, lncontmaster b where ( a.coop_id = b.coop_id ) and ( a.loancontract_no = b.loancontract_no ) and ( a.loancolltype_code = '04' ) and ( a.ref_collno = {0} ) and ( b.contract_status > 0 ) ) tmp_coll"; String collmast_no = dw_head.GetItemString(1, "collmast_no"); sql = WebUtil.SQLFormat(sql, collmast_no); Sdt dt = WebUtil.QuerySdt(sql); if (dt.Next()) { decimal colluse_amt = dt.GetDecimal("sumcoll_use"); dw_head.SetItemDecimal(1, "colluse_amt", colluse_amt); } } catch { } //ไถ่ถอน decimal flag = dw_head.GetItemDecimal(1, "redeem_flag"); Hfredeemflag.Value = Convert.ToString(flag); //if (flag == 1) //{ // dw_head.SetItemDecimal(1, "mortgage_price", 0); //} dw_list.SelectRow(0, false); dw_list.SelectRow(li_row, true); dw_list.SetRow(li_row); } } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } public void JsRefresh() { } private void JsInsertRowDetail() { dw_detail.InsertRow(0); dw_detail.SetItemDecimal(dw_detail.RowCount, "memco_no", dw_detail.RowCount); } //JS-EVENT private void JsPostInsertRow() { //dw_head.SetItemDate(1, "mortgage_date", state.SsWorkDate); //dw_head.SetItemDate(1, "redeem_date", state.SsWorkDate); if (dw_head.RowCount > 1) { dw_head.DeleteRow(dw_head.RowCount); } GetDDDW(); } private void Jsgetmember() { String member_no = WebUtil.MemberNoFormat(Hmemco_no.Value); int row = dw_detail.RowCount; String sql = @" SELECT MEMBER_NO, ( MBMEMBMASTER.MEMB_NAME||' '|| MBMEMBMASTER.MEMB_SURNAME)as MEMB_NAME FROM MBMEMBMASTER WHERE MBMEMBMASTER.MEMBER_NO='" + member_no + "' "; DataTable dt = WebUtil.Query(sql); if (dt.Rows.Count > 0) { dw_detail.SetItemString(row, "memco_no", dt.Rows[0]["MEMBER_NO"].ToString()); dw_detail.SetItemString(row, "mem_name", dt.Rows[0]["MEMB_NAME"].ToString()); } } private void JsDeleteRow() { try { Int32 row = Convert.ToInt32(HDeleteRow.Value); dw_detail.DeleteRow(row); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } private void JsDeleteRowCollprop() { try { Int32 row = Convert.ToInt32(HDeleteRow.Value); dw_collprop.DeleteRow(row); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } //JS-EVENT private void JsNewClear() { dw_main.Reset(); dw_list.Reset(); dw_head.Reset(); dw_detail1.Reset(); dw_detail.Reset(); dw_collprop.Reset(); dw_detail2.Reset(); dw_main.InsertRow(0); dw_list.InsertRow(0); dw_head.InsertRow(1); dw_collprop.InsertRow(0); dw_detail1.InsertRow(0); dw_detail2.InsertRow(0); //dw_head.SetItemDate(1, "mortgage_date", state.SsWorkDate); //dw_head.SetItemDate(1, "redeem_date", state.SsWorkDate); tdwhead.Eng2ThaiAllRow(); tdwreview.Eng2ThaiAllRow(); GetDDDW(); } private void ShowDistrict() { //แสดงอำเภอ try { //String province = dw_collddetail.GetItemString(1, "pos_province").Trim(); //String mrtgProv = dw_detail_01.GetItemString(1, "mrtg_province").Trim(); //String autrzProv = dw_detail_01.GetItemString(1, "autrz_province").Trim(); //String posDist, mrtgDist, autrzDist = ""; //try { posDist = dw_collddetail.GetItemString(1, "pos_district"); } //catch { posDist = ""; } //try { mrtgDist = dw_detail_01.GetItemString(1, "mrtg_district"); } //catch { mrtgDist = ""; } //try { autrzDist = dw_detail_01.GetItemString(1, "autrz_district"); } //catch { autrzDist = ""; } //if (province != "") //{ // //dw_collddetail.SetItemString(1, "pos_district", ""); // DwUtil.RetrieveDDDW(dw_collddetail, "pos_district", "sl_collateral_master.pbl", province); //} //if (mrtgProv != "") //{ // //dw_detail_01.SetItemString(1, "mrtg_district", ""); // DwUtil.RetrieveDDDW(dw_detail_01, "mrtg_district", "sl_collateral_master.pbl", mrtgProv); //} //if (autrzProv != "") //{ // //dw_detail_01.SetItemString(1, "autrz_district", ""); // DwUtil.RetrieveDDDW(dw_detail_01, "autrz_district", "sl_collateral_master.pbl", autrzProv); //} } catch { } } } }