using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CoreSavingLibrary; using System.Data; using DataLibrary; namespace Saving.Applications.trading.ws_td_creditor_ctrl { public partial class DsMain : DataSourceFormView { public DataSet1.STDEBTMASTERDataTable DATA { get; set; } public void InitdsMain(PageWeb pw) { css1.Visible = false; css2.Visible = false; DataSet1 ds = new DataSet1(); this.DATA = ds.STDEBTMASTER; this.EventItemChanged = "OnDsMainChanged"; this.EventClicked = "OnDsMainClicked"; this.InitDataSource(pw, FormView1, this.DATA, "dsMain"); this.Button.Add("bt_search_debt_no"); this.Register(); } public void RetrieveMain(string ls_debt_no, string ls_debtfromtypecode, string ls_debttypecode) { string sql = @" SELECT STDEBTMASTER.DEBT_NO, STDEBTMASTER.COOP_ID, trim(STDEBTMASTER.DEBTTYPE_CODE) DEBTTYPE_CODE, trim(STDEBTMASTER.DEBTFROMTYPE_CODE) DEBTFROMTYPE_CODE, case when trim(STDEBTMASTER.DEBTTYPE_CODE) = '002' then 'ลูกหนี้' else 'เจ้าหนี้' end as debttypecode, case when trim(STDEBTMASTER.DEBTFROMTYPE_CODE) = '002' then 'สมาชิกปกติ' else 'บุคคลทั่วไป' end as debtfromtypecode, STDEBTMASTER.DEBT_NAME, STDEBTMASTER.REFDEBT_NO, STDEBTMASTER.DEBT_AMT, STDEBTMASTER.CREDIT_AMT, STDEBTMASTER.ENTRY_ID, STDEBTMASTER.ENTRY_DATE, STDEBTMASTER.CREDITBALANCE_AMT, STDEBTMASTER.DEBT_ADDR, STDEBTMASTER.DEBT_TUMBON, STDEBTMASTER.DEBT_AMPHUR, STDEBTMASTER.DEBT_PROVINCE, STDEBTMASTER.DEBT_POSTCODE, STDEBTMASTER.DEBT_PHONE, STDEBTMASTER.DEBT_TAX_NO, STDEBTMASTER.DEBT_STATUS, STDEBTMASTER.BFDEBT_AMT, STDEBTMASTER.STORE_ID, STDEBTMASTER.BF_FEEAMT ,STDEBTMASTER.DEBT_MOO,STDEBTMASTER.DEBT_ROAD,STDEBTMASTER.Site_id,STDEBTMASTER.Site_desc FROM STDEBTMASTER WHERE ( STDEBTMASTER.DEBT_NO = {0} ) AND ( STDEBTMASTER.coop_id = {1} ) AND ( STDEBTMASTER.DEBTFROMTYPE_CODE = '001' ) AND ( STDEBTMASTER.DEBTTYPE_CODE = '001' ) "; sql = WebUtil.SQLFormat(sql, ls_debt_no, state.SsCoopId); DataTable dt = WebUtil.Query(sql); this.ImportData(dt); } public void DdDebtfromtype() { string sql = @" select trim(debtfromtype_code) debtfromtype_code,trim(debtfromtype_desc) debtfromtype_desc from stucfdebtfromtype where coop_id='" + state.SsCoopId + "' and item_status='1' order by debtfromtype_code"; DataTable dt = WebUtil.Query(sql); this.DropDownDataBind(dt, "debtfromtype_code", "debtfromtype_desc", "debtfromtype_code"); } public void DdDebtProvince() { string sql = @"select '000' as province_code,'กรุณาเลือก' as province_desc from dual union select province_code,province_desc from mbucfprovince order by province_code,province_desc"; DataTable dt = WebUtil.Query(sql); this.DropDownDataBind(dt, "debt_province", "province_desc", "province_code"); } public void DdDebtDistrict(string province_code) { string sql = @" select '0000' as district_code,'กรุณาเลือก' as district_desc from dual union select district_code,district_desc from mbucfdistrict where province_code={0} order by district_code"; sql = WebUtil.SQLFormat(sql, province_code); DataTable dt = WebUtil.Query(sql); this.DropDownDataBind(dt, "debt_amphur", "district_desc", "district_code"); } public void DdDebtTumbol(string debt_amphur) { string sql = @" select '000000' as tambol_code,'กรุณาเลือก' as tambol_desc from dual union select tambol_code,tambol_desc from mbucftambol where district_code = {0} order by tambol_code"; sql = WebUtil.SQLFormat(sql, debt_amphur); DataTable dt = WebUtil.Query(sql); this.DropDownDataBind(dt, "debt_tumbon", "tambol_desc", "tambol_code"); } public string DdDebtPostCode(string debt_amphur) { string postcode = string.Empty; string sql = @"select postcode from mbucfdistrict where district_code={0} "; sql = WebUtil.SQLFormat(sql, debt_amphur); Sdt dt = WebUtil.QuerySdt(sql); if (dt.Next()) { postcode = dt.GetString("postcode"); } return postcode; } public void DdDebtProvinceRetive(string debt_province) { string sql = string.Empty; if (debt_province == string.Empty) { sql = @" select '000' as province_code,'กรุณาเลือก' as province_desc from dual union select province_code,province_desc from mbucfprovince order by province_code,province_desc"; } else { sql = @"select province_code,province_desc from mbucfprovince where province_code ={0} union select province_code,province_desc from mbucfprovince order by province_code,province_desc"; } sql = WebUtil.SQLFormat(sql, debt_province); DataTable dt = WebUtil.Query(sql); this.DropDownDataBind(dt, "debt_province", "province_desc", "province_code"); } public void DdDebtDistrictRetive(string province_code, string district_code) { string sql = string.Empty; if (province_code == string.Empty && district_code == string.Empty) { sql = @" select '0000' as district_code,'กรุณาเลือก' as district_desc from dual union select district_code,district_desc from mbucfdistrict order by district_code"; } else if (province_code != string.Empty && district_code == string.Empty) { sql = @" select '0000' as district_code,'กรุณาเลือก' as district_desc from dual union select district_code,district_desc from mbucfdistrict where province_code={0} order by district_code"; } else if (province_code != string.Empty && district_code != string.Empty) { sql = @" select district_code,district_desc from mbucfdistrict where province_code ={0} and district_code = {1} union select district_code,district_desc from mbucfdistrict where province_code={0} order by district_code"; } sql = WebUtil.SQLFormat(sql, province_code, district_code); DataTable dt = WebUtil.Query(sql); this.DropDownDataBind(dt, "debt_amphur", "district_desc", "district_code"); } public void DdDebtTambolRetive(string district_code, string tambol_code) { string sql = string.Empty; if (district_code == string.Empty && tambol_code == string.Empty) { sql = @"select '000000' as tambol_code,'กรุณาเลือก' as tambol_desc from dual union select tambol_code,tambol_desc from mbucftambol order by tambol_code"; } else if (district_code != string.Empty && tambol_code == string.Empty) { sql = @"select tambol_code,tambol_desc from mbucftambol where district_code = {0} union select tambol_code,tambol_desc from mbucftambol where district_code not in ({0}) order by tambol_code"; } else if (district_code != string.Empty && tambol_code != string.Empty) { sql = @"select tambol_code,tambol_desc from mbucftambol where district_code = {0} and tambol_code={1} union select tambol_code,tambol_desc from mbucftambol where tambol_code not in ({0}) order by tambol_code"; } sql = WebUtil.SQLFormat(sql, district_code, tambol_code); DataTable dt = WebUtil.Query(sql); this.DropDownDataBind(dt, "debt_tumbon", "tambol_desc", "tambol_code"); } } }