/// <summary> /// Save a new Country to the Country List and deactivate the Button to add a new Country /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, RoutedEventArgs e) { if (txtDescription.Text != "" && txtPrefix.Text != "") { float pMin, pCall; NumberStyles style = NumberStyles.Any; CultureInfo culture = CultureInfo.InvariantCulture; Config.Country dublicat = null; Config.Country country = new Config.Country(txtDescription.Text, txtPrefix.Text); if (float.TryParse(txtPriceMin.Text, style, culture, out pMin)) { country.PriceMin = pMin; } else { country.PriceMin = null; } if (float.TryParse(txtPriceCall.Text, style, culture, out pCall)) { country.PriceCall = pCall; if (country.PriceMin == null) { country.PriceMin = 0; } } else { country.PriceCall = null; } foreach (Config.Country item in countryListe) { if (item.Prefix == country.Prefix) { dublicat = item; } } countryListe.Remove(dublicat); countryListe.Add(country); view.Refresh(); } BtnActivate(); }
/// <summary> /// Delete an Country at the listCountry list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelet_Click(object sender, RoutedEventArgs e) { if (listCountry.Items.Count != 0) { Config.Country index = (Config.Country)listCountry.SelectedItem; countryListe.Remove(index); if (countryListe.Count == 0) { btnDelet.IsEnabled = false; } else { listCountry.SelectedIndex = 0; } view.Refresh(); } else { btnDelet.IsEnabled = false; } }
public bool FilterComboCountry(object item) { Config.Country coun = (Config.Country)item; return(coun.Description.IndexOf(" - Mobile") == -1); }