/// <summary> /// Prepares the page for first time viewing. /// </summary> private void ConfigureDisplay() { // Populate master page information //this.Master.WizardTitle = "Order Group Details"; CultureInfo culture = new CultureInfo(OrderGroup.LCID); // Populate the basic order group information. lblRate.Visible = true; cboGroupedPlanning.ClearSelection(); ListItem selected = cboGroupedPlanning.Items.FindByValue(OrderGroup.GroupedPlanning.ToString().ToLower()); if (selected != null) { selected.Selected = true; } lblOrderCount.Text = OrderGroup.Orders.Count.ToString(); btnProducePILs.Enabled = OrderGroup.Orders.Count > 0; _decimalPlaces = GetDecimalPlaces(OrderGroup); if (_decimalPlaces != 2) { culture.NumberFormat.CurrencyDecimalDigits = _decimalPlaces; } lblRate.Text = OrderGroup.ForeignRate.ToString("C", culture); // Allow a job to be created for this order group, unless any of the orders have been attached to a job. Facade.ICollectDrop facCollectDrop = new Facade.CollectDrop(); Entities.CollectDropCollection collectDrops = facCollectDrop.GetForOrderID(OrderGroup.OrderIDs()); btnCreateJob.Enabled = collectDrops.Count == 0 && OrderGroup.Orders.Count > 0; // If the group is being invoiced, or has been invoiced do not allow the group to be changed. Facade.IOrder facOrder = new Facade.Order(); this.IsBeingInvoiced = facOrder.IsOrderBeingInvoiced(OrderGroup.OrderIDs()); cboGroupedPlanning.Enabled = !IsBeingInvoiced; btnRemoveAll.Visible = !IsBeingInvoiced; grdOrders.Columns[grdOrders.Columns.Count - 1].Display = !IsBeingInvoiced; // Rebind the grid. grdOrders.Rebind(); this.btnUpdateOrders.Enabled = !IsBeingInvoiced; // Set the rate tariff card. this.txtRateTariffCard.Text = this.OrderGroup.TariffRateDescription; // Configure the allocation field bool isAllocationEnabled = WebUI.Utilities.IsAllocationEnabled(); trAllocation.Visible = isAllocationEnabled; this.lblLoadNoText.Text = String.Format("Apply {0} to group.", Globals.Configuration.SystemLoadNumberText); if (isAllocationEnabled) { // An assumption is being made here that, for all orders in a group, the business logic will have // ensured that all are allocated (and subcontracted where that has happened) to the same subcontractor. int?allocatedToIdentityID = this.OrderGroup.Orders.Any() ? this.OrderGroup.Orders.First().AllocatedToIdentityID : null; string allocatedToName = string.Empty; if (allocatedToIdentityID.HasValue) { var allocatedTo = EF.DataContext.Current.OrganisationSet.First(o => o.IdentityId == allocatedToIdentityID); allocatedToName = allocatedTo.OrganisationName; } cboAllocatedTo.SelectedValue = allocatedToIdentityID.ToString(); cboAllocatedTo.Text = allocatedToName; lblAllocatedTo.Text = string.IsNullOrEmpty(allocatedToName) ? "- none -" : allocatedToName; // The user can't change allocation here if there are no orders in the group or if any order been subcontracted. bool changeAllowed = this.OrderGroup.Orders.Any() && !this.OrderGroup.Orders.Any(o => o.JobSubContractID > 0); if (changeAllowed) { // Check that none of the orders are on a run which has been subcontracted as a whole changeAllowed = !this.OrderGroup.Orders.Any(o => facOrder.IsOrderOnJobSubcontractedAsAWhole(o.OrderID)); } cboAllocatedTo.Visible = changeAllowed; lblAllocatedTo.Visible = !changeAllowed; } }
void btnNext_Click(object sender, EventArgs e) { if (this.ScannedFormId > 0) { Facade.Form facForm = new Facade.Form(); this.DehireReceipt = facForm.GetForScannedFormId(this.ScannedFormId); } int scanFormId = -1; // With job POD scanning if (this.OrderId > 0) { Facade.Form facForm = new Facade.Form(); Facade.IDeHireReceipt facDehireReceipt = new Facade.CollectDrop(); string userID = ((Entities.CustomPrincipal)Page.User).UserName; if (this.DehireReceipt == null) { this.DehireReceipt = new Entities.Scan(); } this.DehireReceipt.ScannedDateTime = DateTime.Today; this.DehireReceipt.FormTypeId = eFormTypeId.DehireReceipt; this.DehireReceipt.ScannedFormPDF = this.FileName; // N = No document available if (this.AppendOrReplace.Contains("N")) { if (this.DehireReceipt.ScannedFormId == 0) { this.DehireReceipt.ScannedFormPDF = Orchestrator.Globals.Constants.NO_DOCUMENT_AVAILABLE; } } else { this.DehireReceipt.ScannedFormPDF = this.FileName; } if (this.AppendOrReplace.Contains("A")) { this.DehireReceipt.IsAppend = true; } else { this.DehireReceipt.IsAppend = false; } // if this is not set then we don't know where to save the file locally so it must have been uploaded immediately. if (this.AppendOrReplace.Contains("U") || String.IsNullOrEmpty(Globals.Configuration.ScannedDocumentPath)) { this.DehireReceipt.IsUploaded = true; } else { this.DehireReceipt.IsUploaded = false; } // Update the receipt number, facDehireReceipt.UpdateReceiptNumber(DehireReceiptId, txtDehireReceiptNumber.Text, userID); // Create the scanned form. scanFormId = facForm.Create(this.DehireReceipt, userID); if (scanFormId > 0) { facDehireReceipt.UpdateScannedForm(DehireReceiptId, scanFormId, userID); } } this.Close(this.ScannedFormId.ToString()); }