protected void ToForm() { CustomCurrency cc = Currency; hdnCCId.Value = cc.ID.ToString(CultureInfo.InvariantCulture); txtRuleName.Text = cc.DisplayName; cmbLimitType.SelectedValue = cc.CurrencyLimitType.ToString(); txtNumEvents.Text = cc.RequiredEvents.ToString(CultureInfo.CurrentCulture); cmbEventTypes.SelectedValue = ((int)cc.EventType).ToString(CultureInfo.InvariantCulture); SelectedTimespanType = cc.TimespanType; txtTimeFrame.Text = cc.TimespanType.IsAligned() ? string.Empty : cc.ExpirationSpan.ToString(CultureInfo.InvariantCulture); foreach (ListItem li in lstModels.Items) { li.Selected = cc.ModelsRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)); } foreach (ListItem li in lstAircraft.Items) { li.Selected = cc.AircraftRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)); } cmbCategory.SelectedValue = cc.CategoryRestriction; cmbCatClass.SelectedValue = cc.CatClassRestriction.ToString(); btnAddCurrencyRule.Visible = cc.ID <= 0; // only show the add button if we're doing a new currency. }
protected void ToForm() { CustomCurrency cc = Currency; hdnCCId.Value = cc.ID.ToString(CultureInfo.InvariantCulture); txtRuleName.Text = cc.DisplayName; cmbLimitType.SelectedValue = cc.CurrencyLimitType.ToString(); if (cc.EventType.IsIntegerOnly()) { decMinEvents.EditingMode = Controls_mfbDecimalEdit.EditMode.Integer; decMinEvents.IntValue = (int)cc.RequiredEvents; } else { decMinEvents.EditingMode = Controls_mfbDecimalEdit.EditMode.Decimal; decMinEvents.Value = cc.RequiredEvents; } cmbEventTypes.SelectedValue = ((int)cc.EventType).ToString(CultureInfo.InvariantCulture); SelectedTimespanType = cc.TimespanType; txtTimeFrame.Text = cc.TimespanType.IsAligned() ? string.Empty : cc.ExpirationSpan.ToString(CultureInfo.InvariantCulture); foreach (ListItem li in lstModels.Items) { li.Selected = cc.ModelsRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)); } foreach (ListItem li in lstAircraft.Items) { li.Selected = cc.AircraftRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)); } cmbCategory.SelectedValue = cc.CategoryRestriction; cmbCatClass.SelectedValue = cc.CatClassRestriction.ToString(); txtAirport.Text = cc.AirportRestriction; txtContainedText.Text = cc.TextRestriction; if (cc.PropertyRestriction != null) { HashSet <int> hsPropsChecked = new HashSet <int>(cc.PropertyRestriction); foreach (ListItem li in lstProps.Items) { int propID = Convert.ToInt32(li.Value, CultureInfo.InvariantCulture); li.Selected = cc.PropertyRestriction.Contains(propID); hsPropsChecked.Remove(propID); } // Add in any properties that were not found above! (I.e., blacklisted or otherwise not favorite) IEnumerable <CustomPropertyType> rgBlackListProps = CustomPropertyType.GetCustomPropertyTypes(hsPropsChecked); foreach (CustomPropertyType cpt in rgBlackListProps) { lstProps.Items.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture)) { Selected = true }); } } btnAddCurrencyRule.Visible = cc.ID <= 0; // only show the add button if we're doing a new currency. }