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.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using CoreSavingLibrary.WcfNCommon; using Sybase.DataWindow; using CoreSavingLibrary.WcfFinance; using System.Web.Services.Protocols; namespace Saving.Applications.app_finance { public partial class w_sheet_reprint_chq : PageWebSheet, WebSheet { private CommonClient com; private FinanceClient fin; private DwThDate tDwCon; protected String postChqBook; protected String postBankBranch; protected String postChqlistRetrieve; protected String postPrint; #region WebSheet Members public void InitJsPostBack() { tDwCon = new DwThDate(DwCon, this); tDwCon.Add("adtm_date", "adtm_tdate"); postChqBook = WebUtil.JsPostBack(this, "postChqBook"); postBankBranch = WebUtil.JsPostBack(this, "postBankBranch"); postChqlistRetrieve = WebUtil.JsPostBack(this, "postChqlistRetrieve"); postPrint = WebUtil.JsPostBack(this, "postPrint"); } public void WebSheetLoadBegin() { com = wcf.Common; fin = wcf.Finance; if (!IsPostBack) { DwCon.InsertRow(0); DwChqSize.InsertRow(0); DwCon.SetItemDateTime(1, "adtm_date", state.SsWorkDate); DwUtil.RetrieveDDDW(DwCon, "as_bank", "reprint.pbl", null); } else { this.RestoreContextDw(DwCon); this.RestoreContextDw(DwChqSize); this.RestoreContextDw(DwChqList); } tDwCon.Eng2ThaiAllRow(); } public void CheckJsPostBack(string eventArg) { if (eventArg == "postBankBranch") { GetBankBranch(); } else if (eventArg == "postChqBook") { GetChqBook(); } else if (eventArg == "postChqlistRetrieve") { ChqlistRetrieve(); } else if (eventArg == "postPrint") { PostPrint(); } } public void SaveWebSheet() { } public void WebSheetLoadEnd() { DwChqList.SaveDataCache(); DwChqSize.SaveDataCache(); DwCon.SaveDataCache(); } #endregion private void GetChqBook() { String BankCode, BankBranch; BankCode = DwCon.GetItemString(1, "bank_code"); BankBranch = DwCon.GetItemString(1, "bank_branch"); DwUtil.RetrieveDDDW(DwCon, "as_chqstart_no", "reprint.pbl", state.SsCoopId, BankCode, BankBranch); //DataWindowChild DcChqBookNo = DwCon.GetChild("as_chqstart_no"); //String DddwName = DwCon.Describe("as_chqstart_no.dddw.name"); //String DddwChqBookNo = com.GetDDDWXml(state.SsWsPass, DddwName); //DcChqBookNo.ImportString(DddwChqBookNo, FileSaveAsType.Xml); //DcChqBookNo.SetFilter("bank_code='" + BankCode + "' and bank_branch ='" + BankBranch + "'"); //DcChqBookNo.Filter(); String AccId = fin.DefaultAccId(state.SsWsPass, "CHQ"); DwCon.SetItemString(1, "as_tofromaccid", AccId); DwCon.SetItemString(1, "frombank", BankCode); DwCon.SetItemString(1, "frombranch", BankBranch); } private void GetBankBranch() { String ls_bank; try { ls_bank = DwCon.GetItemString(1, "as_bank"); } catch { ls_bank = ""; } DataWindowChild DcBankBranch = DwCon.GetChild("as_bankbranch"); String BankBranchXml = fin.OfGetChildBankbranch(state.SsWsPass, ls_bank); DcBankBranch.ImportString(BankBranchXml, FileSaveAsType.Text); DcBankBranch.SetFilter("bank_code = '" + ls_bank + "'"); DcBankBranch.Filter(); } private void ChqlistRetrieve() { try { String ls_retrieve_xml = DwCon.Describe("DataWindow.Data.XML"); String resultXml = fin.OfRetrieveRePrintChq(state.SsWsPass, state.SsCoopId, ls_retrieve_xml); DwChqList.Reset(); DwChqList.ImportString(resultXml, FileSaveAsType.Xml); } catch (SoapException ex) { LtServerMessage.Text = WebUtil.ErrorMessage(WebUtil.SoapMessage(ex)); } } private void PostPrint() { try { String formSet = DdPrintSetProfile.SelectedValue.ToString().Trim(); DwChqList.SetFilter("ai_check=" + 1 + ""); DwChqList.Filter(); String ls_cond_xml = DwChqSize.Describe("DataWindow.Data.XML"); String ls_retrieve_xml = DwCon.Describe("DataWindow.Data.XML"); String ls_chqlist_xml = DwChqList.Describe("DataWindow.Data.XML"); String result = fin.OfPostRePrintChq(state.SsWsPass, state.SsCoopId, state.SsUsername, state.SsWorkDate, state.SsClientIp, formSet, ls_cond_xml, ls_retrieve_xml, ls_chqlist_xml); if (WebUtil.IsXML(result)) { LtServerMessage.Text = WebUtil.CompleteMessage("บันทึกเรียบร้อย กรุณากด New[F2]"); String as_bank = DwCon.GetItemString(1, "as_bank"); String as_printtype = DwChqSize.GetItemString(1, "as_printtype"); Printing.PrintApplet(this, "fin_cheque_" + as_bank + "_" + as_printtype, result); ChqlistRetrieve(); } } catch (SoapException ex) { LtServerMessage.Text = WebUtil.ErrorMessage(WebUtil.SoapMessage(ex)); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex.Message); } } } }