protected void btnPreview_Click(object sender, EventArgs e)
        {
            //http://lifereport/ReportServer/Pages/ReportViewer.aspx //url test report
            //ReportSearchParam reportParam = UCReportSearch1.GetSearchField();
            C004_Calculator calculator = new C004_Calculator();

            DateFrom = calculator.SetFormatdate(txtDateFrom.TextDate.ToString(), 0).ToString("yyyy-MM-dd");
            //where < จึงต้องใช้ DateTo + 1
            DateTo = calculator.SetFormatdateTo(txtDateTo.TextDate.ToString(), 0).ToString("yyyy-MM-dd");

            string reportName      = "CommissionFBIRate";
            string reportPath      = "BaaclifeReport";
            string ReportServerUrl = ConfigurationSettings.AppSettings["ServerUrl"].ToString();

            //string ReportServerUrl = "http://lifeuatdb/ReportServer";
            //string ReportServerUrl = "http://lifereport/reportserver";
            //lifereport/reportserver (url production) : must open soap webservice port

            ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(ReportServerUrl);


            //while (ReportViewer.ServerReport.IsDrillthroughReport)
            //{
            //    ReportViewer.PerformBack();
            //}

            //// Could also be set to the selection of a ListBox.
            string strReport = string.Format("/{0}/{1}", reportPath, reportName);

            ReportViewer1.ServerReport.ReportPath = strReport;

            //string userName = "******";
            //string password = "******";


            ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials();

            List <Microsoft.Reporting.WebForms.ReportParameter> parameters = new List <Microsoft.Reporting.WebForms.ReportParameter>();

            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("AreaCode", ddlRegion.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("UpperDivision", ddlProvince.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("Division", ddlBranch.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("AreaCodeName", ddlBranch.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("UpperDivisionName", ddlProvince.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCategory", ddlPlan.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCategoryName", ddlPlan.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCode", ddlCategory.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCodeName", ddlCategory.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("StartDate", DateFrom));
            DateTime endDate = DateTime.Now;//reportParam.EndDate.Value.AddDays(1).AddMilliseconds(-1);

            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("EndDate", DateTo));

            bool isBranch = true;//BaacLifeUtil.checkBranch(division);

            //if (isBranch)
            //{
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("DivisionName", "division.DivisionName"));
            //}
            //else
            //{
            //    parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("DivisionName", "reportParam.DivisionCodeName"));
            //}
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("IsBranch", isBranch.ToString()));

            ReportViewer1.ServerReport.SetParameters(parameters);
            ReportViewer1.ServerReport.Refresh();
        }
Beispiel #2
0
        protected void btnPreview_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture   = us;
            System.Threading.Thread.CurrentThread.CurrentUICulture = us;

            //ReportSearchParam reportParam = UCReportSearch1.GetSearchField();
            C004_Calculator calculator = new C004_Calculator();

            DateFrom = calculator.SetFormatdate(txtDateFrom.TextDate.ToString(), 0).ToString("yyyy-MM-dd");

            //WHERE < จึงต้องใช้ DATETO + 1
            DateTo = calculator.SetFormatdateTo(txtDateTo.TextDate.ToString(), 0).ToString("yyyy-MM-dd HH:mm:ss");

            string reportName      = WebConfigurationManager.AppSettings["reportName"].ToString();
            string reportPath      = WebConfigurationManager.AppSettings["reportPath"].ToString();
            string ReportServerUrl = WebConfigurationManager.AppSettings["ServerUrl"].ToString();

            ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(ReportServerUrl);

            //****------ REPORT NOTE :
            //1.http://lifereport/ReportServer/Pages/ReportViewer.aspx //url test report
            //2.string ReportServerUrl = "http://lifeuatdb/ReportServer";
            //3.string ReportServerUrl = "http://lifereport/reportserver";
            //4.lifereport/reportserver (url production) : MUST OPEN SOAP WEBSERVICE PORT

            //while (ReportViewer.ServerReport.IsDrillthroughReport)
            //{
            //    ReportViewer.PerformBack();
            //}

            // COULD ALSO BE SET TO THE SELECTION OF A LISTBOX.
            string strReport = string.Format("/{0}/{1}", reportPath, reportName);

            ReportViewer1.ServerReport.ReportPath = strReport;

            //string userName = "******";
            //string password = "******";


            ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials();

            List <Microsoft.Reporting.WebForms.ReportParameter> parameters = new List <Microsoft.Reporting.WebForms.ReportParameter>();

            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("AreaCode", ddlRegion.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("UpperDivision", ddlProvince.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("Division", ddlBranch.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("AreaCodeName", ddlBranch.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("UpperDivisionName", ddlProvince.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCategory", ddlPlan.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCategoryName", ddlPlan.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCode", ddlCategory.SelectedValue.ToString()));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("PlanCodeName", ddlCategory.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("StartDate", DateFrom));
            //DateTime endDate = DateTime.Now;//reportParam.EndDate.Value.AddDays(1).AddMilliseconds(-1);
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("EndDate", DateTo));

            bool isBranch = true;

            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("DivisionName", ddlBranch.SelectedItem.Text));
            parameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("IsBranch", isBranch.ToString()));

            ReportViewer1.ServerReport.SetParameters(parameters);
            ReportViewer1.ServerReport.Refresh();


            lblRemark.Visible = true;

            System.Threading.Thread.CurrentThread.CurrentCulture   = th;
            System.Threading.Thread.CurrentThread.CurrentUICulture = th;
        }