private void LoadReport() { DateTime today = DateTime.UtcNow; today = today.Subtract(today.TimeOfDay); int identityId = int.Parse(cboClient.SelectedValue); Facade.IOrganisation facOrganisation = new Facade.Organisation(); Facade.IJob facJob = new Facade.Job(); DataSet dsClientReferences = facOrganisation.GetReferencesForIdentityId(identityId); DataSet dsLogColumns = facOrganisation.GetIncludedLogColumnsForIdentityId(identityId); DataSet dsDeliveryAndReturnsLog = facJob.GetDeliveryAndReturnsLogForClient(identityId, dteStartDate.SelectedDate.Value, dteEndDate.SelectedDate.Value); if (dsDeliveryAndReturnsLog.Tables[0].Rows.Count == 0) { lblError.Text = "No completed delivery and returns for client " + cboClient.Text + " for period " + dteStartDate.SelectedDate.Value.ToString("dd/MM/yy") + " to " + dteEndDate.SelectedDate.Value.ToString("dd/MM/yy"); lblError.Visible = true; reportViewer.Visible = false; } else { lblError.Visible = false; // Build a comma-delimited list of column names to pass to the report from the first two // (by sequence number) client references and the columns, as configured in the client section. StringBuilder sbLogColumns = new StringBuilder(); for (int refCounter = 0; refCounter < dsClientReferences.Tables[0].Rows.Count && refCounter < C_REFERENCE_COUNT_VS; refCounter++) { sbLogColumns.Append(Convert.ToString(dsClientReferences.Tables[0].Rows[refCounter]["Description"]) + ","); } for (int logCounter = 0; logCounter < dsLogColumns.Tables[0].Rows.Count; logCounter++) { if (logCounter == dsLogColumns.Tables[0].Rows.Count - 1) { sbLogColumns.Append(Convert.ToString(dsLogColumns.Tables[0].Rows[logCounter]["Description"])); } else { sbLogColumns.Append(Convert.ToString(dsLogColumns.Tables[0].Rows[logCounter]["Description"]) + ","); } } string columnNames = sbLogColumns.ToString(); NameValueCollection reportParams = new NameValueCollection(); reportParams.Add("Columns", columnNames); reportParams.Add("ClientId", cboClient.SelectedValue); reportParams.Add("Client", cboClient.Text); reportParams.Add("StartDate", dteStartDate.SelectedDate.Value.ToString("dd/MM/yy")); reportParams.Add("EndDate", dteEndDate.SelectedDate.Value.ToString("dd/MM/yy")); // Configure the Session variables used to pass data to the report Session["LogId"] = m_LogId; Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable] = eReportType.DeliveryAndReturnsLog; Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] = dsDeliveryAndReturnsLog; Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable] = String.Empty; Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table"; Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable] = reportParams; if (cboClient.SelectedValue != "") { reportViewer.IdentityId = int.Parse(cboClient.SelectedValue); } // Show the user control reportViewer.Visible = true; } }