Example #1
0
        /// <summary>
        /// Представляет число суммой прописью
        /// </summary>
        /// <param name="n">Число</param>
        /// <param name="d">Количественные размерности</param>
        /// <returns>Сумма прописью</returns>
        public static string Convert(System.Int64 n, NumberDeclension d)
        {
            NumberDeclension[] declensions =
                new NumberDeclension[] {
                d,
                _thousand,
                _million,
                _billion,
                _trillion,
                _quadrillion
            };

            if (n == Int64.MinValue)
            {
                throw new ArgumentException();
            }

            System.Int64  number = n > 0 ? n : -n;
            StringBuilder s      = new StringBuilder();

            if (number == 0)
            {
                s.Insert(0,
                         "ноль " +
                         d.GetDeclension((ushort)(number)));
            }
            else
            {
                foreach (NumberDeclension declension in declensions)
                {
                    s.Insert(0,
                             TillThousandToStringConverter.Convert((ushort)(number % 1000), declension.IsMale) +
                             declension.GetDeclension((ushort)(number % 1000)));



                    number /= 1000;

                    if (number == 0)
                    {
                        break;
                    }
                }
            }

            if (n < 0)
            {
                s.Insert(0, "минус ");
            }

            return(s.ToString());
        }
Example #2
0
 /// <summary>
 /// Преобразовывает число с сумму прописью
 /// </summary>
 /// <param name="n">Число</param>
 /// <param name="majorCurrency">Основная валюта</param>
 /// <param name="minorCurrency">Младшая валюта (копейки по отношению к рублям)</param>
 /// <returns></returns>
 public static string Convert(decimal n, NumberDeclension majorCurrency, NumberDeclension minorCurrency)
 {
     return(new CurrencySumsConverter(majorCurrency, minorCurrency).Convert(n));
 }
Example #3
0
 public CurrencySumsConverter(NumberDeclension majorCurrency, NumberDeclension minorCurrency)
 {
     _majorCurrency = majorCurrency;
     _minorCurrency = minorCurrency;
 }