/// <summary> /// Creator: Robert Holmes /// Created: 2020/03/11 /// Approver: Cash Carlson /// /// Loads values into item sources. /// </summary> /// <remarks> /// Updater: Robert Holmes /// Updated: 2020/03/19 /// Update: Now loads ALL relevant data /// /// </remarks> private void loadFields() { try { cboPromotionType.ItemsSource = _promotionManager.GetAllPromotionTypes(); dgProducts.ItemsSource = _promotion.Products; _productManager = new ProductManager(); if (_promotion.PromotionID != null) { txtPromotionID.Text = _promotion.PromotionID; } if (_promotion.PromotionTypeID != null) { cboPromotionType.SelectedItem = _promotion.PromotionTypeID; } if (_promotion.StartDate != null) { dateStartDate.SelectedDate = _promotion.StartDate; } if (_promotion.EndDate != null) { dateEndDate.SelectedDate = _promotion.EndDate; } if (_promotion.Description != null) { txtDescription.Text = _promotion.Description; } numDiscount.Value = _promotion.Discount; if (_promotion.Active) { txtActive.Text = "Active"; btnToggleActive.Content = "Deactivate"; } else { txtActive.Text = "Inactive"; btnToggleActive.Content = "Reactivate"; } setupNumUpDown(); if (cboPromotionType.SelectedItem.ToString().Equals("Percent")) { numDiscount.FormatString = "P0"; } if (cboPromotionType.SelectedItem.ToString().Equals("Flat Amount")) { numDiscount.FormatString = "C2"; } } catch (Exception ex) { WPFErrorHandler.ErrorMessage("There was an issue loading the data", ex.Message); } }
/// <summary> /// Creator: Robert Holmes /// Created: 2020/03/10 /// Approver: Cash Carlson /// /// Constructor used for add operations. /// </summary> /// <remarks> /// Updater: /// Updated: /// Update: /// /// </remarks> public pgAddEditViewPromotion(IPromotionManager promotionManager, Frame frame) { _promotionManager = promotionManager; _frame = frame; _promotion = new Promotion(); InitializeComponent(); lblPageHeading.Content = "Add New Promotion"; btnAction.Content = "Add Promo"; cboPromotionType.ItemsSource = _promotionManager.GetAllPromotionTypes(); dgProducts.ItemsSource = _promotion.Products; _productManager = new ProductManager(); makeEditable(); setupNumUpDown(); btnToggleActive.IsEnabled = false; txtActive.Text = "Active"; }