ar amount
Mon Feb 19 2024 10:45:23 GMT+0000 (Coordinated Universal Time)
Saved by @MinaTimo
public class WordToNumAR { str bigCurrency; str smallCurrency; real X; real InputNo; str OutStr; str bigCurrency( str _bigCurrency = bigCurrency) { bigCurrency = _bigCurrency; return bigCurrency; } protected void Eightd() { real xx; ; if (InputNo < 10000000 || X < 10000000) { this.Sevend(); return; } //double xx; xx = X; X = real2int(X / 1000000); this.Twod(); OutStr = OutStr + " مليون"; X = xx - real2int(xx / 1000000) * 1000000; if (X != 0) { OutStr = OutStr + " و"; } this.Sixd(); X = xx; } protected void Fived() { real xx; ; if (InputNo < 10000 || X < 10000) { this.Fourd(); return; } xx = X; X = real2int(X / 1000); this.Twod(); OutStr = OutStr + " ألف"; X = xx - real2int(xx / 1000) * 1000; if (X != 0) { OutStr = OutStr + " و"; } this.Threed(); } protected void Fourd() { real xx ; if (InputNo < 1000 || X < 1000) { this.Threed(); return; } xx = X; X = real2int(X / 1000); switch (X) { case 1: OutStr = OutStr + " ألف"; break; case 2: OutStr = OutStr + " ألفان"; break; default: this.Oned(); OutStr = OutStr + " آلاف"; break; } X = xx - (X * 1000); if (X != 0) { OutStr = OutStr + " و"; } this.Threed(); } protected void Nined() { real xx; if (InputNo < 100000000 || X < 100000000) { this.Eightd(); return; } xx = X; X = real2int(X / 1000000); this.Threed(); OutStr = OutStr + " مليون"; X = xx - real2int(xx / 1000000) * 1000000; if (X != 0) { OutStr = OutStr + " و"; } this.Sixd(); } protected boolean Oned() { switch (X) { case 1: OutStr = OutStr + " واحد"; return true; case 2: OutStr = OutStr + " اثنان"; return true; case 3: OutStr = OutStr + " ثلاثة"; return true; case 4: OutStr = OutStr + " أربعة"; return true; case 5: OutStr = OutStr + " خمسة"; return true; case 6: OutStr = OutStr + " ستة"; return true; case 7: OutStr = OutStr + " سبعة"; return true; case 8: OutStr = OutStr + " ثمانية"; return true; case 9: OutStr = OutStr + " تسعة"; return true; } // case 0 return false; } protected void Sevend() { real xx; ; if (InputNo < 1000000 || X < 1000000) { this.Sixd(); return; } xx = X; X = real2int(X / 1000000); switch (X) { case 1: OutStr = OutStr + " مليون"; break; case 2: OutStr = OutStr + " مليونان"; break; default: this.Oned(); OutStr = OutStr + " ملايين"; break; } X = xx - (X * 1000000); if (X != 0) { OutStr = OutStr + " و"; } this.Sixd(); } protected void Sixd() { real xx; if (InputNo < 100000 || X < 100000) { this.Fived(); return; } xx = X; X = real2int(X / 1000); this.Threed(); OutStr = OutStr + " ألف"; X = xx - (X * 1000); if (X != 0) { OutStr = OutStr + " و"; } this.Threed(); } str smallCurrency( str _smallCurrency = smallCurrency) { smallCurrency = _smallCurrency; return smallCurrency; } protected void Teen() { if (InputNo < 10 || X < 10) { this.Oned(); return; } switch (real2int(X)) { case 10: OutStr = OutStr + " عشرة"; break; case 11: OutStr = OutStr + " أحد عشر"; break; case 12: OutStr = OutStr + " اثنى عشر"; break; case 13: OutStr = OutStr + " ثلاث عشر"; break; case 14: OutStr = OutStr + " أربعة عشر"; break; case 15: OutStr = OutStr + " خمسة عشر"; break; case 16: OutStr = OutStr + " ستة عشر"; break; case 17: OutStr = OutStr + " سبعة عشر"; break; case 18: OutStr = OutStr + " ثمانية عشر"; break; case 19: OutStr = OutStr + " تسعة عشر"; break; } } protected void Threed() { real xx; if (InputNo < 100 || X < 100) { this.Twod(); return; } xx = X; if (X>=100 && X<=199) OutStr = OutStr + " مائة"; else if (X>=200 && X<=299) OutStr = OutStr + " مائتان"; else if (X >= 300 && X <= 399) OutStr = OutStr + " ثلاثمائة"; else if (X >= 400 && X <= 499) OutStr = OutStr + " أربعمائة"; else if (X >= 500 && X <= 599) OutStr = OutStr + " خمسمائة"; else if (X >= 600 && X <= 699) OutStr = OutStr + " ستمائة"; else if (X >= 700 && X <= 799) OutStr = OutStr + " سبعمائة"; else if (X >= 800 && X <= 899) OutStr = OutStr + " ثمانمائة"; else if (X >= 900 && X <= 999) OutStr = OutStr + " تسعمائة"; X = X - (real2int(X / 100) * 100); if (X != 0) { OutStr = OutStr + " و"; } this.Twod(); X = xx; } protected void Twod() { real xx; if (InputNo < 20 || X < 20) { this.Teen(); return; } xx = X; X = X - real2int(X / 10) * 10; if (this.Oned()) OutStr = OutStr + " و"; X = xx; if (X >= 20 && X <= 29) OutStr = OutStr + " عشرون "; else if (X >= 30 && X <= 39) OutStr = OutStr + " ثلاثون "; else if (X >= 40 && X <= 49) OutStr = OutStr + " أربعون "; else if (X >= 50 && X <= 59) OutStr = OutStr + " خمسون"; else if (X >= 60 && X <= 69) OutStr = OutStr + " ستون"; else if (X >= 70 && X <= 79) OutStr = OutStr + " سبعون"; else if (X >= 80 && X <= 89) OutStr = OutStr + " ثمانون"; else if (X >= 90 && X <= 99) OutStr = OutStr + " تسعون"; } public str WordToNumAR(str Amount) { str des = subStr( Amount, strLen(Amount) - 1 , 2); str Taf1 = ""; real tmpInputNo = InputNo; str Taf2 = ""; InputNo = str2num(Amount); // Amount = InputNo.ToString("N2"); if (InputNo >= 1) { X = real2int(InputNo); this.Nined(); Taf1 = OutStr; Taf1 += bigCurrency; } OutStr = ""; InputNo = str2num(des); if (InputNo > 0) { X = real2int(InputNo); this.Nined(); if (tmpInputNo >= 0) Taf2 = " و "; Taf2 += OutStr; Taf2 += " " + smallCurrency; } X = 0; InputNo = 0; OutStr = ""; return Taf1 + Taf2; } }
Comments