Exemplo n.º 1
0
        protected void btnExportExcel_Click(object sender, EventArgs e)
        {
            try
            {
                if (tdAssignDateFrom.DateValue.Year == 1 || tdAssignDateTo.DateValue.Year == 1)
                {
                    AppUtil.ClientAlert(Page, "กรุณาระบุช่วงเวลาค้นหาให้ครบถ้วน");
                    return;
                }

                TimeSpan ts = tdAssignDateTo.DateValue.Subtract(tdAssignDateFrom.DateValue);
                if ((ts.TotalDays + 1) > AppConstant.SnapReportDateRange)
                {
                    AppUtil.ClientAlert(Page, "ไม่สามารถเลือกช่วงเวลาได้เกิน " + AppConstant.SnapReportDateRange + " วัน");
                    return;
                }

                string datefrom = tdAssignDateFrom.DateValue.Year.ToString() + tdAssignDateFrom.DateValue.ToString("-MM-dd");
                string dateto   = tdAssignDateTo.DateValue.Year.ToString() + tdAssignDateTo.DateValue.ToString("-MM-dd");
                Int64  countrow = 0;

                countrow = ReportBiz.CheckReportStaffWorkingExist(datefrom, dateto);
                if (countrow == 0)
                {
                    AppUtil.ClientAlert(Page, "ไม่พบข้อมูล");
                }
                else
                {
                    string script = "window.open('" + Page.ResolveUrl("~/ExportReport.aspx?reportflag=RPT_SNAP_MONITORING&teamlist=" + Server.UrlEncode(txtTeamList.Text.Trim()) + "&datefrom=" + datefrom + "&dateto=" + dateto) + "', 'reports', 'status=yes, toolbar=no, scrollbars=no, menubar=no, width=600, height=400, resizable=no');";
                    //string script = "window.open('" + Request.ApplicationPath + "ExportReport.aspx?reportflag=RPT_SNAP_MONITORING&teamlist=" + Server.UrlEncode(txtTeamList.Text.Trim()) + "&datefrom=" + datefrom + "&dateto=" + dateto + "', 'reports', 'status=yes, toolbar=no, scrollbars=no, menubar=no, width=800, height=600, resizable=no');";
                    ScriptManager.RegisterStartupScript(Page, GetType(), "reportsnapmonitoring", script, true);
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Debug(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Exemplo n.º 2
0
        protected void btnGenReport_Click(object sender, EventArgs e)
        {
            try
            {
                if (tdmStartDate.DateValue.Year.ToString() == "1" || tdmEndDate.DateValue.Year.ToString() == "1")
                {
                    AppUtil.ClientAlert(Page, "กรุณากรอกวันที่ให้ครบถ้วน");
                    return;
                }

                if (tdmStartDate.DateValue.Year.ToString() != "1" && tdmEndDate.DateValue.Year.ToString() != "1")
                {
                    if (tdmStartDate.DateValue > tdmEndDate.DateValue)
                    {
                        AppUtil.ClientAlert(Page, "วันที่เริ่มต้นต้องน้อยกว่าหรือเท่ากับวันที่สิ้นสุด");
                        return;
                    }
                }

                if (tdmStartDate.DateValue > DateTime.Today || tdmEndDate.DateValue > DateTime.Today)
                {
                    AppUtil.ClientAlert(Page, "ไม่สามารถเลือกช่วงเวลาเกินวันปัจจุบันได้");
                    return;
                }

                TimeSpan ts = tdmEndDate.DateValue.Subtract(tdmStartDate.DateValue);
                if ((ts.TotalDays + 1) > AppConstant.SnapReportDateRange)
                {
                    AppUtil.ClientAlert(Page, "ไม่สามารถเลือกช่วงเวลาได้เกิน " + AppConstant.SnapReportDateRange + " วัน");
                    return;
                }

                string datefrom = tdmStartDate.DateValue.Year.ToString() + tdmStartDate.DateValue.ToString("-MM-dd");
                string dateto   = tdmEndDate.DateValue.Year.ToString() + tdmEndDate.DateValue.ToString("-MM-dd");
                Int64  countrow = 0;

                if (rbAppReport.Checked == true)
                {
                    countrow = ReportBiz.CheckReportWorkDetailExist(datefrom, dateto);
                    if (countrow == 0)
                    {
                        AppUtil.ClientAlert(Page, "ไม่พบข้อมูล");
                        return;
                    }
                    else
                    {
                        string script = "window.open('" + Page.ResolveUrl("~/ExportReport.aspx?reportflag=RPT_WORKDETAIL&countrows=" + countrow + "&datefrom=" + datefrom + "&dateto=" + dateto) + "', 'reports', 'status=yes, toolbar=no, scrollbars=no, menubar=no, width=600, height=400, resizable=no');";
                        //string script = "window.open('" + (Request.ApplicationPath.EndsWith("/") ? Request.ApplicationPath : Request.ApplicationPath + "/") + "ExportReport.aspx?reportflag=RPT_WORKDETAIL&countrows=" + countrow + "&datefrom=" + datefrom + "&dateto=" + dateto + "', 'reports', 'status=yes, toolbar=no, scrollbars=no, menubar=no, width=800, height=600, resizable=no');";
                        ScriptManager.RegisterStartupScript(Page, GetType(), "reportgeneral", script, true);
                    }
                }
                else if (rbAccessReport.Checked == true)
                {
                    countrow = ReportBiz.CheckReportStaffWorkingExist(datefrom, dateto);
                    if (countrow == 0)
                    {
                        AppUtil.ClientAlert(Page, "ไม่พบข้อมูล");
                        return;
                    }
                    else
                    {
                        string script = "window.open('" + Page.ResolveUrl("~/ExportReport.aspx?reportflag=RPT_STAFF_WORKING&countrows=" + countrow + "&datefrom=" + datefrom + "&dateto=" + dateto) + "', 'reports', 'status=yes, toolbar=no, scrollbars=no, menubar=no, width=600, height=400, resizable=no');";
                        //string script = "window.open('" + (Request.ApplicationPath.EndsWith("/") ? Request.ApplicationPath : Request.ApplicationPath + "/") + "ExportReport.aspx?reportflag=RPT_STAFF_WORKING&countrows=" + countrow + "&datefrom=" + datefrom + "&dateto=" + dateto + "', 'reports', 'status=yes, toolbar=no, scrollbars=no, menubar=no, width=800, height=600, resizable=no');";
                        ScriptManager.RegisterStartupScript(Page, GetType(), "reportgeneral", script, true);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Debug(message);
                AppUtil.ClientAlert(Page, message);
            }
        }