private void LoadJob() { int jobID = int.Parse(Request.QueryString["jID"]); Orchestrator.Entities.Job job = null; Orchestrator.Facade.IJob facJob = new Orchestrator.Facade.Job(); job = facJob.GetJob(jobID); Facade.IBusinessType facBusinessType = new Facade.BusinessType(); Entities.BusinessType businessType = facBusinessType.GetForBusinessTypeID(job.BusinessTypeID); if (businessType != null) { lblBusinessType.Text = businessType.Description; } else { lblBusinessType.Text = "No Business Type Set"; } DataSet dsTypes = facBusinessType.GetAll(); cboBusinessType.DataSource = dsTypes; cboBusinessType.DataTextField = "Description"; cboBusinessType.DataValueField = "BusinessTypeID"; cboBusinessType.DataBind(); if (businessType != null) { cboBusinessType.FindItemByValue(businessType.BusinessTypeID.ToString()).Selected = true; this.CurrentBusinessTypeID = businessType.BusinessTypeID; } }
/// <summary> /// Offer the user creating the job a choice of which business type the job should be. /// The default value is the business type which has the most pallets (based on the /// individual pallet count and business type of each order being added to the job). /// </summary> /// <param name="orders">The data set containing the order information.</param> private void ConfigureBusinessTypeChoices(DataSet orders) { // Clear the current business type options down. cboBusinessType.ClearSelection(); cboBusinessType.Items.Clear(); // Store a list of key value pairs that represents the total pallets involved for each business type. // In each item in the list the Key is the Business Type ID, and the Value is the pallet count for that // business type. List <KeyValuePair <int, int> > btCounts = new List <KeyValuePair <int, int> >(); if (orders != null && orders.Tables.Count > 0 && orders.Tables[0] != null) { foreach (DataRow order in orders.Tables[0].Rows) { int businessTypeID = (int)order["BusinessTypeID"]; int palletCount = (int)order["NoPallets"]; // The business type has already been encountered, increase the pallet count. // As the value property is read only, we need to remove the item and then // cause it to be recreated with the new total. if (btCounts.Exists(btCount => btCount.Key == businessTypeID)) { palletCount += btCounts.Find(btCount => btCount.Key == businessTypeID).Value; btCounts.RemoveAll(btCount => btCount.Key == businessTypeID); } // Record the entry. btCounts.Add(new KeyValuePair <int, int>(businessTypeID, palletCount)); } // Sort the different key value pairs based on their value properties (i.e. their pallet count). // The result of the value compare is multiplied by -1 to effectively reverse the sort direction as: // -1 * -1 = 1 // 1 * -1 = -1 // 0 * -1 = 0 btCounts.Sort((x, y) => x.Value.CompareTo(y.Value) * -1); } // Create the dropdown items that match the business type information. Facade.IBusinessType facBusinessType = new Facade.BusinessType(); foreach (KeyValuePair <int, int> btCount in btCounts) { ListItem li = new ListItem(); li.Value = btCount.Key.ToString(); Entities.BusinessType businessType = facBusinessType.GetForBusinessTypeID(btCount.Key); li.Text = string.Format("{0} ({1})", businessType.Description, btCount.Value); cboBusinessType.Items.Add(li); } }
private void LoadBusinessType() { Facade.IBusinessType facBT = new Facade.BusinessType(); this.businessType = facBT.GetForBusinessTypeID(this.BusinessTypeID); txtDescription.Text = this.businessType.Description; rblDeBreifRequired.ClearSelection(); rblDeBreifRequired.Items[0].Selected = this.businessType.RequireDeBreif; rblDeBreifRequired.Items[1].Selected = !this.businessType.RequireDeBreif; rblShowCreateJob.Items[0].Selected = this.businessType.ShowCreateJob; rblShowCreateJob.Items[1].Selected = !this.businessType.ShowCreateJob; rblCreateJobChecked.Items[0].Selected = this.businessType.CreateJobChecked; rblCreateJobChecked.Items[1].Selected = !this.businessType.CreateJobChecked; rblExcludeFromConsortiumMemberFileExport.SelectedIndex = this.businessType.ExcludeFromConsortiumMemberFileExport ? 0 : 1; rblIsBarcodeScannedOnDelivery.SelectedIndex = this.businessType.IsBarcodeScannedOnDelivery ? 0 : 1; rblIsCustomerNameCapturedOnCollection.SelectedIndex = this.businessType.IsCustomerNameCapturedOnCollection ? 0 : 1; rblIsCustomerNameCapturedOnDelivery.SelectedIndex = this.businessType.IsCustomerNameCapturedOnDelivery ? 0 : 1; rblIsCustomerSignatureCapturedOnCollection.SelectedIndex = this.businessType.IsCustomerSignatureCapturedOnCollection ? 0 : 1; rblIsCustomerSignatureCapturedOnDelivery.SelectedIndex = this.businessType.IsCustomerSignatureCapturedOnDelivery ? 0 : 1; rblMwfBypassCleanClausedScreen.SelectedIndex = this.businessType.MwfBypassCleanClausedScreen ? 0 : 1; rblMwfBypassCommentsScreen.SelectedIndex = this.businessType.MwfBypassCommentsScreen ? 0 : 1; rblMwfConfirmCallIn.SelectedIndex = this.businessType.MwfConfirmCallIn ? 0 : 1; txtPalletThresholdMin.Text = this.businessType.PalletThresholdMin.ToString(); txtPalletThresholdMax.Text = this.businessType.PalletThresholdMax.ToString(); chkPalletNetwork.Checked = this.businessType.IsPalletNetwork; txtPalletNetworkExportDepotCode.Text = this.businessType.PalletNetworkExportDepotCode; if (this.businessType.NominalCode.NominalCodeID > 0) { cboDefaultNominalCode.ClearSelection(); cboDefaultNominalCode.FindItemByValue(this.businessType.NominalCode.NominalCodeID.ToString()).Selected = true; } if (this.businessType.SubContractNominalCode.NominalCodeID > 0) { cboSubContractNominalCode.ClearSelection(); cboSubContractNominalCode.FindItemByValue(this.businessType.SubContractNominalCode.NominalCodeID.ToString()).Selected = true; } if (this.businessType.SubContractSelfBillNominalCode.NominalCodeID > 0) { cboSubContractSelfBillNominalCode.ClearSelection(); cboSubContractSelfBillNominalCode.FindItemByValue(this.businessType.SubContractSelfBillNominalCode.NominalCodeID.ToString()).Selected = true; } btnUpdate.Text = "Update"; }
private string GetBusinessTypeDescription(int businessTypeID) { string description = String.Empty; if (!_businessTypeDescriptions.TryGetValue(businessTypeID, out description)) { // Load the description from the database and add it to the dictionary. Facade.BusinessType facBusinessType = new Facade.BusinessType(); var bt = facBusinessType.GetForBusinessTypeID(businessTypeID); description = bt.Description; _businessTypeDescriptions.Add(bt.BusinessTypeID, bt.Description); } return(description); }