void btnGetJobs_Click(object sender, EventArgs e) { btnGetJobs.DisableServerSideValidation(); int resourceId = 0; int subContractorId = 0; pnlMatchedJobs.Visible = false; reportViewer.Visible = false; DataSet dsManifestData = null; Facade.IManifest facManifest = new Facade.Manifest(); DateTime startDateTime = GetStartDateTime(); lblLegCount.Text = string.Empty; if (int.TryParse(cboResource.SelectedValue, out resourceId)) { lblLegCount.Text = "Searching for matches for resource. "; dsManifestData = facManifest.GetManifestForResource(resourceId, startDateTime, chkIncludePlannedWork.Checked); } else if (int.TryParse(cboSubContractor.SelectedValue, out subContractorId)) { lblLegCount.Text = "Searching for matches for sub-contractor. "; dsManifestData = facManifest.GetManifestForSubContractor(subContractorId, startDateTime); } if (dsManifestData != null) { pnlMatchedJobs.Visible = true; gvManifest.DataSource = dsManifestData; gvManifest.DataBind(); lblLegCount.Text += dsManifestData.Tables[0].Rows.Count + " legs matched for inclusion on manifest."; btnDisplayManifest_Click(this, new EventArgs()); } }
void btnDisplayManifest_Click(object sender, EventArgs e) { btnDisplayManifest.DisableServerSideValidation(); int resourceId = 0; int subContractorId = 0; string resourceLabel = string.Empty; reportViewer.Visible = false; DataSet dsManifestData = null; Facade.IManifest facManifest = new Facade.Manifest(); DateTime startDateTime = GetStartDateTime(); List <int> jobIds = new List <int>(); foreach (GridViewRow row in gvManifest.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect"); if (chkSelect.Checked) { HiddenField hidJobId = (HiddenField)row.FindControl("hidJobId"); jobIds.Add(int.Parse(hidJobId.Value)); } } } if (int.TryParse(cboResource.SelectedValue, out resourceId)) { dsManifestData = facManifest.GetManifestForResource(resourceId, startDateTime, chkIncludePlannedWork.Checked, jobIds); resourceLabel = cboResource.Text; } else if (int.TryParse(cboSubContractor.SelectedValue, out subContractorId)) { dsManifestData = facManifest.GetManifestForSubContractor(subContractorId, startDateTime, jobIds); resourceLabel = cboSubContractor.Text; } int extraRowCount = 5; int.TryParse(txtExtraRowCount.Text, out extraRowCount); if (dsManifestData != null && dsManifestData.Tables[0].Rows.Count > 0) { if (!string.IsNullOrEmpty(cboSubContractor.SelectedValue)) { this.reportViewer.IdentityId = int.Parse(cboSubContractor.SelectedValue); } for (int extraRows = 0; extraRows < extraRowCount; extraRows++) { DataRow newRow = dsManifestData.Tables[0].NewRow(); dsManifestData.Tables[0].Rows.Add(newRow); } dsManifestData.AcceptChanges(); // Configure the report settings collection NameValueCollection reportParams = new NameValueCollection(); reportParams.Add("ResourceLabel", resourceLabel); reportParams.Add("StartDateTime", startDateTime.ToString("dd/MM/yy HH:mm")); reportParams.Add("ShowFullAddress", chkIncludeFullAddresses.Checked.ToString()); reportParams.Add("SpecialInstructions", txtSpecialInstructions.Text.ToString()); // Configure the Session variables used to pass data to the report Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable] = eReportType.Manifest; Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] = dsManifestData; Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable] = String.Empty; Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table"; Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable] = reportParams; reportViewer.Visible = true; } }