public static void InitializeCurrencies() { currencies = new List <Currency>(); currencyInformation = new CurrencyInformation(); XmlDocument doc = new XmlDocument(); try { doc.Load(URLString); XmlNodeList elemList = doc.GetElementsByTagName("Rate"); for (int i = 0; i < elemList.Count; i++) { String s = elemList[i].Attributes["currency"].Value.ToString(); String v = elemList[i].InnerXml; v = v.Replace('.', ','); Decimal value = Convert.ToDecimal(v); Currency.CurrencyName currencyName = (Currency.CurrencyName)Enum.Parse(typeof(Currency.CurrencyName), s); Decimal multiplier = 1; if (elemList[i].Attributes["multiplier"] != null) { multiplier = Convert.ToDecimal(elemList[i].Attributes["multiplier"].Value.ToString()); } currencies.Add(new Currency(currencyName, value, multiplier)); } currencyInformation.SetCurrencies(currencies); SerializeCurrencyInformation(); } catch { DeserializeCurrencyInformation(); currencies = currencyInformation.GetCurrencies(); } }
public static Currency GetCurrencyByName(Currency.CurrencyName name) { for (int i = 0; i < currencies.Count; i++) { if (currencies[i].Name == name) { return(currencies[i]); } } return(null); }
private void comboBoxCurrencies_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBoxItem currentItem = comboBoxCurrencies.SelectedItem as ComboBoxItem; if (currentItem.Content != null) { lastCurrency = CurrencyHelper.GetProjectCurrency(); Currency.CurrencyName currencyName = (Currency.CurrencyName)Enum.Parse(typeof(Currency.CurrencyName), currentItem.Content.ToString()); if (currencyName == Currency.CurrencyName.RON) { CurrencyHelper.SetProjectCurrency(CurrencyHelper.GetDefaultCurrency()); } else { CurrencyHelper.SetProjectCurrency(CurrencyHelper.GetCurrencyByName(currencyName)); } //InitializeBudget(); } }
private void comboBoxCurrencies_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBoxItem currentItem = comboBoxCurrencies.SelectedItem as ComboBoxItem; if (currentItem.Content != null) { Currency.CurrencyName currencyName = (Currency.CurrencyName)Enum.Parse(typeof(Currency.CurrencyName), currentItem.Content.ToString()); if (currencyName != Currency.CurrencyName.RON) { lastCurrency = currentCurrency; currentCurrency = CurrencyHelper.GetCurrencyByName(currencyName); } else { lastCurrency = currentCurrency; currentCurrency = CurrencyHelper.GetDefaultCurrency(); } InitializeComboBoxCurrentCurrency(); InitializeTreeViewReceipt(); } }