/// <summary> /// 10 000 рублей 67 копеек /// </summary> /// <param name="amount"></param> /// <returns></returns> public static string CurrencyToTxtShort(double amount, DigitItems rubles, DigitItems copecks) { //10 000 рублей 67 копеек long rublesAmount = (long)Math.Floor(amount); long copecksAmount = ((long)Math.Round(amount * 100)) % 100; int lastRublesDigit = lastDigit(rublesAmount); int lastCopecksDigit = lastDigit(copecksAmount); string s = String.Format("{0:N0} ", rublesAmount) + Declines.DeclineAny(lastRublesDigit, rubles) + " "; s += String.Format("{0:00} ", copecksAmount) + Declines.DeclineAny(lastCopecksDigit, copecks); return(s.Trim()); }
/// <summary> /// 10 000 (Десять тысяч) рублей 67 копеек /// </summary> /// <param name="amount"></param> /// <param name="firstCapital"></param> /// <returns></returns> public static string CurrencyToTxtFull(double amount, bool firstCapital, DigitItems rubles, DigitItems copecks) { //10 000 (Десять тысяч) рублей 67 копеек long rublesAmount = (long)Math.Floor(amount); long copecksAmount = ((long)Math.Round(amount * 100)) % 100; int lastRublesDigit = lastDigit(rublesAmount); int lastCopecksDigit = lastDigit(copecksAmount); string s = String.Format("{0:N0} ({1}) ", rublesAmount, NumeralsToTxt(rublesAmount, TextCase.Nominative, true, firstCapital)) + Declines.DeclineAny(lastRublesDigit, rubles) + " "; s += String.Format("{0:00} ", copecksAmount) + Declines.DeclineAny(lastCopecksDigit, copecks); return(s.Trim()); }
public static string MakeText(int digits, string[] hundreds, string[] tens, string[] from3till19, string second, string first, string[] power) { string s = ""; if (digits >= 100) { s += hundreds[digits / 100] + " "; digits = digits % 100; } if (digits >= 20) { s += tens[digits / 10 - 1] + " "; digits = digits % 10; } if (digits >= 3) { s += from3till19[digits - 2] + " "; } else if (digits == 2) { s += second + " "; } else if (digits == 1) { s += first + " "; } if (digits != 0 && power.Length > 0) { digits = lastDigit(digits); if (Declines.IsPluralGenitive(digits)) { s += power[3] + " "; } else if (Declines.IsSingularGenitive(digits)) { s += power[2] + " "; } else { s += power[1] + " "; } } return(s); }