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 DataLibrary; using CoreSavingLibrary.WcfNCommon; using CoreSavingLibrary.WcfNShrlon; using System.Globalization; namespace Saving.Criteria { public partial class u_cri_process_loanpayment_summary_rs : PageWebSheet, WebSheet { protected String app; protected String gid; protected String rid; protected String pdf; protected String runProcess; protected String popupReport; private n_shrlonClient shrlonService; private n_commonClient commonService; private DwThDate tdw_criteria; public String outputProcess = ""; #region WebSheet Members public void InitJsPostBack() { HdOpenIFrame.Value = "False"; runProcess = WebUtil.JsPostBack(this, "runProcess"); tdw_criteria = new DwThDate(dw_criteria, this); tdw_criteria.Add("s_date", "s_tdate"); tdw_criteria.Add("e_date", "e_tdate"); tdw_criteria.Add("sbfyear_date", "sbfyear_tdate"); tdw_criteria.Add("process_date", "process_tdate"); } //protected void Page_Load(object sender, EventArgs e) public void WebSheetLoadBegin() { InitJsPostBack(); try { shrlonService = wcf.NShrlon; commonService = wcf.NCommon; } catch { LtServerMessage.Text = WebUtil.ErrorMessage("ติดต่อ Web Service ไม่ได้"); return; } this.ConnectSQLCA(); if (IsPostBack) { dw_criteria.RestoreContext(); } else { CultureInfo th = System.Globalization.CultureInfo.GetCultureInfo("th-TH"); DateTime today = Convert.ToDateTime(state.SsWorkDate); //DateTime day = state.SsWorkDate; String dayss = "31/03/" + today.Year; today = DateTime.ParseExact(dayss, "dd/MM/yyyy", CultureInfo.InvariantCulture); //default values. dw_criteria.InsertRow(0); dw_criteria.SetItemDateTime(1, "s_date", state.SsWorkDate); dw_criteria.SetItemDateTime(1, "e_date", state.SsWorkDate); dw_criteria.SetItemString(1, "s_tdate", (today).ToString("ddMMyyyy", th)); dw_criteria.SetItemString(1, "e_tdate", (today).ToString("ddMMyyyy", th)); dw_criteria.SetItemDateTime(1, "sbfyear_date", state.SsWorkDate); dw_criteria.SetItemDateTime(1, "process_date", state.SsWorkDate); dw_criteria.SetItemString(1, "sbfyear_tdate", (today).ToString("ddMMyyyy", th)); dw_criteria.SetItemString(1, "process_tdate", (today).ToString("ddMMyyyy", th)); dw_criteria.SetItemDecimal(1, "year_no",Convert.ToDecimal( state.SsWorkDate.Year)); dw_criteria.SetItemDecimal(1, "month_no", Convert.ToDecimal(state.SsWorkDate.Month)); //DwUtil.RetrieveDDDW(dw_criteria, "select_coop", "criteria.pbl", state.SsCoopControl); //dw_criteria.SetItemString(1, "select_coop", state.SsCoopId); //tdw_criteria.Eng2ThaiAllRow(); DwUtil.RetrieveDDDW(dw_criteria, "printer", "criteria.pbl", state.SsCoopControl); } //--- Page Arguments try { app = Request["app"].ToString(); } catch { } if (app == null || app == "") { app = state.SsApplication; } try { gid = Request["gid"].ToString(); } catch { } try { rid = Request["rid"].ToString(); } catch { } //Report Name. try { Sta ta = new Sta(state.SsConnectionString); String sql = ""; sql = @"SELECT REPORT_NAME FROM WEBREPORTDETAIL WHERE ( GROUP_ID = '" + gid + @"' ) AND ( REPORT_ID = '" + rid + @"' )"; Sdt dt = ta.Query(sql); ReportName.Text = dt.Rows[0]["REPORT_NAME"].ToString(); ta.Close(); } catch { ReportName.Text = "[" + rid + "]"; } //Link back to the report menu. LinkBack.PostBackUrl = String.Format("~/ReportDefault.aspx?app={0}&gid={1}", app, gid); } public void CheckJsPostBack(string eventArg) { if (eventArg == "runProcess") { RunProcess(); } else if (eventArg == "popupReport") { PopupReport(); } } public void SaveWebSheet() { } public void WebSheetLoadEnd() { } #endregion #region Report Process private void RunProcess() { //อ่านค่าจากหน้าจอใส่ตัวแปรรอไว้ก่อน. //String coop_id = dw_criteria.GetItemString(1, "select_coop"); // int result = wcf.NShrlon.of.of_getnextworkday(state.SsWsPass, state.SsWorkDate, ref adtm_nextworkdate); String dwMain_XML = dw_criteria.Describe("DataWindow.Data.XML"); // int i = wcf.NShrlon.of_proc_loanpayment_summary(state.SsWsPass, state.SsCoopControl, dwMain_XML); DateTime s_date = dw_criteria.GetItemDateTime(1, "s_date"); DateTime e_date = dw_criteria.GetItemDateTime(1, "e_date"); DateTime sbfyear_date = dw_criteria.GetItemDateTime(1, "sbfyear_date"); DateTime process_date = dw_criteria.GetItemDateTime(1, "process_date"); short year_no = Convert.ToInt16(dw_criteria.GetItemDecimal(1, "year_no")); short month_no = Convert.ToInt16(dw_criteria.GetItemDecimal(1, "month_no")); short intfine_status = Convert.ToInt16( dw_criteria.GetItemDecimal (1, "month_no")); short intcom_flag = Convert.ToInt16(dw_criteria.GetItemDecimal(1, "month_no")); short bf_flag = Convert.ToInt16(dw_criteria.GetItemDecimal(1, "month_no")); int i = wcf.NShrlon.of_loanpayment_summary(state.SsWsPass,state.SsCoopControl,"001","002",dwMain_XML); if (i > 0) { LtServerMessage.Text = WebUtil.ErrorMessage("สำเร็จ"); } else { LtServerMessage.Text = WebUtil.ErrorMessage("ไม่ผ่าน"); } /* String start_date = WebUtil.ConvertDateThaiToEng(dw_criteria, "s_tdate", null); String end_date = WebUtil.ConvertDateThaiToEng(dw_criteria, "e_tdate", null); String sbfyear_date = WebUtil.ConvertDateThaiToEng(dw_criteria, "sbfyear_tdate", null); String process_date = WebUtil.ConvertDateThaiToEng(dw_criteria, "process_tdate", null); String reqstatus = dw_criteria.GetItemString(1, "reqstatus"); //แปลง Criteria ให้อยู่ในรูปแบบมาตรฐาน. ReportHelper lnv_helper = new ReportHelper(); lnv_helper.AddArgument(start_date, ArgumentType.DateTime); //lnv_helper.AddArgument(end_date, ArgumentType.DateTime); //lnv_helper.AddArgument(reqstatus, ArgumentType.String); //lnv_helper.AddArgument(coop_id, ArgumentType.String); //ชื่อไฟล์ PDF = YYYYMMDDHHMMSS__.PDF String pdfFileName = DateTime.Now.ToString("yyyyMMddHHmmss", WebUtil.EN); pdfFileName += "_" + gid + "_" + rid + ".pdf"; pdfFileName = pdfFileName.Trim(); //ส่งให้ ReportService สร้าง PDF ให้ {โดยปกติจะอยู่ใน C:\GCOOP\Saving\PDF\}. try { string printer = dw_criteria.GetItemString(1, "printer"); String criteriaXML = lnv_helper.PopArgumentsXML(); outputProcess = WebUtil.runProcessingReport(state, app, gid, rid, criteriaXML, pdfFileName, printer); } catch (Exception ex) { LtServerMessage.Text = WebUtil.ErrorMessage(ex); return; } * */ } public void PopupReport() { //เด้ง Popup ออกรายงานเป็น PDF. String pop = "Gcoop.OpenPopup('" + pdf + "')"; ClientScript.RegisterClientScriptBlock(this.GetType(), "DsReport", pop, true); } #endregion } }