private void GetOrders() { int resourceId = 0; int subContractorId = 0; //pnlMatchedOrders.Visible = false; reportViewer.Visible = false; DataSet dsManifestData = null; Facade.IManifest facManifest = new Facade.Manifest(); DateTime startDateTime = GetStartDateTime(); lblOrderCount.Text = string.Empty; if (int.TryParse(cboResource.SelectedValue, out resourceId)) { lblOrderCount.Text = "Searching for matches for resource. "; dsManifestData = facManifest.GetOrdersBasedManifestForResource(resourceId, startDateTime, chkIncludePlannedWork.Checked); } else if (int.TryParse(cboSubContractor.SelectedValue, out subContractorId)) { lblOrderCount.Text = "Searching for matches for sub-contractor. "; dsManifestData = facManifest.GetOrdersBasedManifestForSubContractor(subContractorId, startDateTime); } if (dsManifestData != null) { if (this.OrderManifest != null) { // Remove those orders that are already in the manifest (and not marked as removed). for (int i = dsManifestData.Tables[0].Rows.Count; i > 0; i--) { DataRow row = dsManifestData.Tables[0].Rows[i - 1]; int orderId = Convert.ToInt32(row["OrderId"].ToString()); foreach (Entities.OrderManifestOrder omo in this.OrderManifest.OrderManifestOrders) { if (omo.OrderId == orderId && omo.Removed == false) { // This order is already on the manifest, remove it from the // list of orders to add... dsManifestData.Tables[0].Rows.Remove(row); break; } } } } grdManifestAddOrders.DataSource = dsManifestData; //grdManifestAddOrders.DataBind(); grdManifestAddOrders.Visible = true; lblOrderCount.Text += dsManifestData.Tables[0].Rows.Count + " Orders matched for inclusion on manifest."; pnlSaveAndDisplay.Visible = true; } }
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; } }