コード例 #1
0
        private void ChangeNameInExchangeRatesConfig(CountryConfig.SystemRow systemRow, string oldSystemName)
        {
            ExchangeRatesConfigFacade excf = EM_AppContext.Instance.GetExchangeRatesConfigFacade(false); if (excf == null)
            {
                return;
            }
            bool anyChange = false;

            foreach (ExchangeRatesConfig.ExchangeRatesRow exchangeRate in
                     from er in excf.GetExchangeRates() where er.Country.ToLower() == systemRow.CountryRow.ShortName.ToLower() &&
                     ExchangeRate.ValidForToList(er.ValidFor).Contains(oldSystemName.ToLower()) select er)
            {
                if (!anyChange && UserInfoHandler.GetInfo("Do you want to update the system name in the global exchange rate table?" + Environment.NewLine + Environment.NewLine +
                                                          "Note that, if no exchange rate is found for a system name, the exchange rate is assumed to be 1.", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
                exchangeRate.ValidFor = ExchangeRate.RemoveFromValidFor(exchangeRate.ValidFor, oldSystemName);
                exchangeRate.ValidFor = ExchangeRate.AddToValidFor(exchangeRate.ValidFor, systemRow.Name); anyChange = true;
            }
            if (anyChange)
            {
                excf.WriteXML();
            }
        }
コード例 #2
0
        void AddToExchangeRatesTable(string systemName, CountryConfig.SystemRow toCopySystemRow)
        {
            ExchangeRatesConfigFacade excf = EM_AppContext.Instance.GetExchangeRatesConfigFacade(false); if (excf == null)
            {
                return;
            }
            bool found = false;

            foreach (ExchangeRatesConfig.ExchangeRatesRow exchangeRate in excf.GetExchangeRates())
            {
                if (exchangeRate.Country.ToLower() != toCopySystemRow.CountryRow.ShortName.ToLower() ||
                    !ExchangeRate.ValidForToList(exchangeRate.ValidFor).Contains(toCopySystemRow.Name.ToLower()))
                {
                    continue;
                }
                exchangeRate.ValidFor = ExchangeRate.AddToValidFor(exchangeRate.ValidFor, systemName); found = true; break;
            }
            if (found)
            {
                excf.WriteXML();
            }
        }