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; } }