Ejemplo n.º 1
0
        void btnDisplayReport_Click(object sender, EventArgs e)
        {
            int      clientID  = 0;
            DateTime startDate = new DateTime();
            DateTime endDate   = new DateTime();
            DataSet  ds        = null;

            Facade.IReferenceData facReferenceData = new Facade.ReferenceData();

            int.TryParse(cboClient.SelectedValue, out clientID);
            startDate = rdiStartDate.SelectedDate.Value;
            endDate   = rdiEndDate.SelectedDate.Value;

            ds = facReferenceData.GetExtrasRevenueReport(clientID, startDate, endDate);

            if (ds.Tables[1].Rows.Count == 0)
            {
                if (clientID > 0)
                {
                    lblError.Text = "No extras for client " + cboClient.Text + " for period " + startDate.ToString("dd/MM/yy") + " to " + endDate.ToString("dd/MM/yy");
                }
                else
                {
                    lblError.Text = "No extras for period " + startDate.ToString("dd/MM/yy") + " to " + endDate.ToString("dd/MM/yy");
                }

                lblError.Visible     = true;
                reportViewer.Visible = false;
            }
            else
            {
                lblError.Visible = false;

                NameValueCollection reportParams = new NameValueCollection();

                reportParams.Add("IdentityID", clientID.ToString());
                reportParams.Add("StartDate", startDate.ToString("dd/MM/yy"));
                reportParams.Add("EndDate", endDate.ToString("dd/MM/yy"));

                // Configure the Session variables used to pass data to the report
                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.ExtrasRevenue;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = ds;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = String.Empty;
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table1";
                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;

                if (cboClient.SelectedValue != "")
                {
                    reportViewer.IdentityId = int.Parse(cboClient.SelectedValue);
                }
                // Show the user control
                reportViewer.Visible = true;
            }
        }