private void GetUserInput() { this.rule.Formula.Value = Convert.ToDecimal(this.tbxValue.Text); Presentation.Models.PriceOperationItem op = (Presentation.Models.PriceOperationItem) this.cbxPriceOperation.SelectedItem; Presentation.Models.ValueOperationItem val = (Presentation.Models.ValueOperationItem) this.cbxValueOperation.SelectedItem; if (op != null && val != null) { this.rule.Formula.PriceOperation = (Entities.TourCostFormula.PriceOperations)op.Id; if (val.CustomObject is Entities.MoneyCurrency) { this.rule.Formula.Currency = val.CustomObject as Entities.MoneyCurrency; this.rule.Formula.ValueOperation = Entities.TourCostFormula.ValueOperations.Currency; } else { this.rule.Formula.ValueOperation = Entities.TourCostFormula.ValueOperations.Percent; } } }
private void BindControlsData() { Array priceOperations = Enum.GetValues(typeof(Entities.TourCostFormula.PriceOperations)); foreach (Entities.TourCostFormula.PriceOperations operation in priceOperations) { Presentation.Models.PriceOperationItem item = new Presentation.Models.PriceOperationItem(); item.Id = Convert.ToInt32(operation); item.Name = Convert.ToString(operation); item.ImageName = this.opImageNames[item.Id]; this.cbxPriceOperation.Items.Add(item); } //this.cbxPriceOperation.DisplayMember = "Name"; Array valueOperations = Enum.GetValues(typeof(Entities.TourCostFormula.ValueOperations)); foreach (Entities.TourCostFormula.ValueOperations operation in valueOperations) { if (operation != Entities.TourCostFormula.ValueOperations.Currency) { Presentation.Models.ValueOperationItem item = new Presentation.Models.ValueOperationItem(); item.Id = Convert.ToInt32(operation); item.Name = Convert.ToString(operation); item.Label = this.opLabels[item.Id]; item.CustomObject = operation; this.cbxValueOperation.Items.Add(item); } } foreach (Entities.MoneyCurrency currency in DomainModel.Currencies.GetAll()) { Presentation.Models.ValueOperationItem item = new Presentation.Models.ValueOperationItem(); item.Id = currency.Id; item.Name = currency.Name; item.Label = currency.Symbol; item.CustomObject = currency; this.cbxValueOperation.Items.Add(item); } this.cbxValueOperation.DisplayMember = "Label"; this.tbxRuleName.DataBindings.Add( new Binding( "Text", this.rule, "Name", false, DataSourceUpdateMode.OnPropertyChanged, string.Empty, string.Empty, null)); }