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.WcfNAccount; using Sybase.DataWindow; using System.Web.Services.Protocols; using System.Globalization; //using CoreSavingLibrary.WcfPrint; namespace Saving.Applications.account { public partial class w_acc_report_triblane : PageWebSheet, WebSheet { protected String postOpenReport; protected String postOpenPDF; protected String changeValue; protected String saveData; protected String onSetDate; private n_accountClient Accsrv; private accFunction accF; private DwThDate tDwMain; #region WebSheet Members public void InitJsPostBack() { changeValue = WebUtil.JsPostBack(this, "changeValue"); postOpenReport = WebUtil.JsPostBack(this, "postOpenReport"); postOpenPDF = WebUtil.JsPostBack(this, "postOpenPDF"); //onSetDate = WebUtil.JsPostBack(this, "onSetDate"); tDwMain = new DwThDate(dw_main,this); tDwMain.Add("start_date", "start_tdate"); tDwMain = new DwThDate(dw_main, this); tDwMain.Add("end_date", "end_tdate"); tDwMain.Eng2ThaiAllRow(); } public void WebSheetLoadBegin() { try { Accsrv = wcf.NAccount; } catch { LtServerMessage.Text = WebUtil.ErrorMessage("ติดต่อ Web Service ไม่ได้"); return; } try { accF = new accFunction(); } catch { LtServerMessage.Text = WebUtil.ErrorMessage("ติดต่อ Function ไม่ได้"); return; } //this.ConnectSQLCA(); //dw_rpt.SetTransaction(sqlca); if (IsPostBack) { this.RestoreContextDw(dw_main); this.RestoreContextDw(dw_rpt); } if (dw_main.RowCount < 1) { dw_main.Reset(); dw_main.InsertRow(0); dw_rpt.Reset(); } } public void CheckJsPostBack(string eventArg) { if (eventArg == "postOpenReport") { this.JspostOpenReport(); }else if (eventArg == "postOpenPDF") { this.PostOpenPDF(); } } private void PostOpenPDF() { String xmlpdf = dw_rpt.Describe("Datawindow.data.XML"); //ชื่อไฟล์ PDF = YYYYMMDDHHMMSS__.PDF String pdfFileName = DateTime.Now.ToString("yyyyMMddHHmmss", WebUtil.EN); pdfFileName += "_Triblane.pdf"; pdfFileName = pdfFileName.Trim(); //PrintClient wsPrint = wcf.Print; //int inV = wsPrint.PrintPDF(state.SsWsPass, xmlpdf, pdfFileName); //if (inV < 0) //{ // LtServerMessage.Text = WebUtil.ErrorMessage("เกิดข้อผิดพลาด " + xmlpdf); // return; //} //String pdfURL = wsPrint.GetPDFURL(state.SsWsPass) + pdfFileName; //String pop = "Gcoop.OpenPopup('" + pdfURL + "')"; //ClientScript.RegisterClientScriptBlock(this.GetType(), "Triblane", pop, true); } public void SaveWebSheet() { } public void WebSheetLoadEnd() { if (dw_main.RowCount > 1) { dw_main.DeleteRow(dw_main.RowCount); } dw_main.SaveDataCache(); dw_rpt.SaveDataCache(); } #endregion private void JspostOpenReport() { string str_tmp = ""; ChangeRpt(); String xmlChooseReport = dw_main.Describe("Datawindow.Data.Xml"); DateTime sdt = DateTime.ParseExact(HdSDateUS.Value, "dd/MM/yyyy", null); DateTime edt = DateTime.ParseExact(HdEDateUS.Value, "dd/MM/yyyy", null); try { Int32 BsXml = Accsrv.of_gen_trial_bs(state.SsWsPass, xmlChooseReport, state.SsCoopId,ref str_tmp); if (str_tmp != "") { dw_rpt.ImportString(str_tmp, FileSaveAsType.Xml);//ทำการ import string xml str_tmp = "t_head.text = '"; str_tmp += state.SsCoopName; str_tmp += "'"; dw_rpt.Modify(str_tmp); str_tmp = "t_name.text = '"; str_tmp += "กระดาษทำการงบทดลอง "; str_tmp += "'"; dw_rpt.Modify(str_tmp); str_tmp = "t_date.text = '"; str_tmp += "ประจำวันที่ "; str_tmp += accF.CnvStrDateToStrFDate(HdSDateTH.Value, "th"); str_tmp += "ถึงวันที่ "; str_tmp += accF.CnvStrDateToStrFDate(HdEDateTH.Value, "th"); str_tmp += "'"; dw_rpt.Modify(str_tmp); } } catch (SoapException ex) { LtServerMessage.Text = WebUtil.ErrorMessage("เกิดข้อผิดพลาด " + WebUtil.SoapMessage(ex)); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex.Message); } } private void SetDate() { //dw_main.SetItemString(1, "start_tdate", HdSDateTH.Value); //dw_main.SetItemString(1, "end_tdate", HdEDateTH.Value); } private void ChangeRpt() { switch (dw_main.GetItemString(1, "check_flag").ToString()) { case "01": dw_rpt.DataWindowObject = "r_mth20_trilebalance_day_detail_a4land_6"; break; case "02": dw_rpt.DataWindowObject = "r_mth20_trilebalance_day_detail_a4land_10"; break; case "03": dw_rpt.DataWindowObject = "r_mth20_trilebalance_day_detail_a4land_14"; break; } dw_rpt.Reset(); } } }