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.WcfCommon; using CoreSavingLibrary.WcfKeeping; using Sybase.DataWindow; namespace Saving.Applications.keeping { public partial class w_sheet_kp_mrc_receive_store_pea : PageWebSheet, WebSheet { protected String postProcStatus; protected String getXml; protected String getAccid; protected String postSetProtype; private KeepingClient kpService; private DwThDate tDwMain; private CommonClient commonService; protected String chgProcDate; #region WebSheet Members public void InitJsPostBack() { postProcStatus = WebUtil.JsPostBack(this, "postProcStatus"); getAccid = WebUtil.JsPostBack(this, "getAccid"); getXml = WebUtil.JsPostBack(this, "getXml"); chgProcDate = WebUtil.JsPostBack(this, "chgProcDate"); postSetProtype = WebUtil.JsPostBack(this, "postSetProtype"); //==================== tDwMain = new DwThDate(DwMain, this); tDwMain.Add("receipt_date", "receipt_tdate"); tDwMain.Add("calint_date", "calint_tdate"); tDwMain.Add("startcont_date", "startcont_tdate"); } public void WebSheetLoadBegin() { HdRunProcess.Value = "false"; kpService = wcf.Keeping; commonService = wcf.Common; if (!IsPostBack) { if (DwMain.RowCount < 1) { DwMain.InsertRow(0); } DateTime last = commonService.LastDayOfmonth(state.SsWsPass, state.SsWorkDate); DwMain.SetItemDecimal(1, "receive_year", last.Year + 543); DwMain.SetItemDateTime(1, "receipt_date", last); DwMain.SetItemDateTime(1, "calint_date", last); DwMain.SetItemDecimal(1, "receive_month", last.Month); DwMain.SetItemString(1, "coop_id", state.SsCoopId); DwMain.SetItemString(1, "entry_id", state.SsUsername); DwMain.SetItemDateTime(1, "startcont_date", state.SsWorkDate); tDwMain.Eng2ThaiAllRow(); } else { this.RestoreContextDw(DwMain, tDwMain); } } public void CheckJsPostBack(string eventArg) { if (eventArg == "postProcStatus") { Decimal recpno_status = DwMain.GetItemDecimal(1, "recpno_status"); if (recpno_status == 0) { DwMain.SetItemString(1, "recpno_startnum", ""); } } if (eventArg == "getXml") { String xml_tmp = DwMain.Describe("DataWindow.Data.Xml"); //เรียกเว็บเซอร์วิสประมวลผลและจัดเก็บ CallWSRunRcvProcess(xml_tmp); } if (eventArg == "getAccid") { GetAccidToFrom(); } if (eventArg == "chgProcDate") { JsChgProcDate(); } if (eventArg == "postSetProtype") { JspostSetProtype(); } } private void GetAccidToFrom() { // DwUtil.RetrieveDDDW(DwMain, "moneytype_code", "kp_recieve_store.pbl", null); // DwUtil.RetrieveDDDW(DwMain, "tofrom_accid", "kp_recieve_store.pbl", null); // DataWindowChild dc = DwMain.GetChild("tofrom_accid"); // String moneyType_code = DwMain.GetItemString(1, "moneytype_code"); // dc.SetFilter("moneytype_code ='" + moneyType_code + "'"); // dc.Filter(); } public void SaveWebSheet() { } public void WebSheetLoadEnd() { DwMain.SaveDataCache(); try { GetAccidToFrom(); } catch (Exception ex) { } } #endregion private void CallWSRunRcvProcess(string xml) { try { //kpService.RunRcvProcess(state.SsWsPass, xml, state.SsApplication, state.CurrentPage); str_keep_proc str = new str_keep_proc(); WcfCallingExtend wcfextend = new WcfCallingExtend(this.xmlconfig); str.xml_option = xml; str.sqlrpt_desc = ""; try { wcfextend.Keeping.of_rcvprocess(state.SsWsPass, str); //HdRunProcess.Value = "true"; } catch (Exception e) { LtServerMessage.Text = WebUtil.ErrorMessage(e); } wcfextend.Close(); } catch (Exception e) { LtServerMessage.Text = WebUtil.ErrorMessage(e); } } protected void cb_process_Click(object sender, EventArgs e) { //String calint_date = WebUtil.ConvertDateThaiToEng(DwMain, "calint_tdate", null); //DateTime calint = Convert.ToDateTime(calint_date); //DwMain.SetItemDateTime(1, "calint_date", calint); //String receipt_date = WebUtil.ConvertDateThaiToEng(DwMain, "receipt_tdate", null); //DateTime receipt = Convert.ToDateTime(receipt_date); //DwMain.SetItemDateTime(1, "receipt_date", receipt); String xml_tmp = DwMain.Describe("DataWindow.Data.Xml"); //เรียกเว็บเซอร์วิสประมวลผลและจัดเก็บ CallWSRunRcvProcess(xml_tmp); } private void JsChgProcDate() { String t_date = "01"; Decimal t_month = DwMain.GetItemDecimal(1, "receive_month"); Decimal t_year = (DwMain.GetItemDecimal(1, "receive_year") - 543); String t_receive = t_month.ToString() + "/" + t_date + "/" + t_year.ToString(); DateTime endate = DateTime.Parse(t_receive); try { DateTime newdate = commonService.LastDayOfmonth(state.SsWsPass, endate); DwMain.SetItemDate(1, "receipt_date", newdate); DwMain.SetItemDate(1, "calint_date", newdate); tDwMain.Eng2ThaiAllRow(); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); } } private void JspostSetProtype() { DwMain.SetItemString(1, "memb_text", ""); DwMain.SetItemString(1, "group_text", ""); DwMain.SetItemString(1, "mem_text", ""); } } }