NumToWordsPersian.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Text;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. namespace FastReport.Functions
  6. {
  7. internal class NumToWordsPersian : NumToWordsBase
  8. {
  9. private static Dictionary<string, CurrencyInfo> currencyList;
  10. private static string[] fixedWords =
  11. {
  12. "", "یک", "دو", "سه", "چهار", "پنج", "شش",
  13. "هفت", "هشت", "نه", "ده", "یازده",
  14. "دوازده", "سیزده", "چهارده", "پانزده",
  15. "شانزده", "هفده", "هجده", "نوزده"
  16. };
  17. private static string[] tens =
  18. {
  19. "", "ده", "بیست", "سی", "چهل", "پنجاه",
  20. "شصت", "هفتاد", "هشتاد", "نود"
  21. };
  22. private static string[] hunds =
  23. {
  24. "", "صد", "دویست", "سیصد", "چهارصد",
  25. "پانصد", "ششصد", "هفتصد", "هشتصد", "نهصد"
  26. };
  27. private static WordInfo thousands = new WordInfo("هزار");
  28. private static WordInfo millions = new WordInfo("میلیون");
  29. private static WordInfo milliards = new WordInfo("میلیارد");
  30. private static WordInfo trillions = new WordInfo("تریلیون");
  31. protected override string GetFixedWords(bool male, long value)
  32. {
  33. string result = fixedWords[value];
  34. return result;
  35. }
  36. protected override string GetTen(bool male, long value)
  37. {
  38. return tens[value];
  39. }
  40. protected override string GetHund(bool male, long value)
  41. {
  42. return hunds[value / 100];
  43. }
  44. protected override WordInfo GetThousands()
  45. {
  46. return thousands;
  47. }
  48. protected override WordInfo GetMillions()
  49. {
  50. return millions;
  51. }
  52. protected override WordInfo GetMilliards()
  53. {
  54. return milliards;
  55. }
  56. protected override WordInfo GetTrillions()
  57. {
  58. return trillions;
  59. }
  60. protected override CurrencyInfo GetCurrency(string currencyName)
  61. {
  62. return currencyList[currencyName];
  63. }
  64. protected override string GetZero()
  65. {
  66. return "صفر";
  67. }
  68. protected override string GetMinus()
  69. {
  70. return "منفی";
  71. }
  72. protected override string Get10_1Separator()
  73. {
  74. return " و ";
  75. }
  76. protected override string Get100_10Separator()
  77. {
  78. return " و ";
  79. }
  80. protected override string GetDecimalSeparator()
  81. {
  82. return "و ";
  83. }
  84. static NumToWordsPersian()
  85. {
  86. currencyList = new Dictionary<string, CurrencyInfo>(3);
  87. currencyList.Add("EUR", new CurrencyInfo(
  88. new WordInfo("یورو"),
  89. new WordInfo("یورو سنت")));
  90. currencyList.Add("USD", new CurrencyInfo(
  91. new WordInfo("دلار"),
  92. new WordInfo("سنت")));
  93. currencyList.Add("IRR", new CurrencyInfo(
  94. new WordInfo("ریال‎"), new WordInfo("دینار")));
  95. }
  96. }
  97. }