Sunday, May 11, 2008

Digit to String

This is procedure to convert no to string:


public static String ConvertDigitToString(string No, string Currency)
{
return ConvertDigitToString(Convert.ToInt64(No), Currency);
}
public static String ConvertDigitToString(Int64 No, string Currency)
{
string adad = "", bilion, miliard, million, thousand, digit, EnteredNo = No.ToString();
for (; EnteredNo.Length < 15; EnteredNo = "0" + EnteredNo) ;
bilion = EnteredNo.Substring(0, 3);
miliard = EnteredNo.Substring(3, 3);
million = EnteredNo.Substring(6, 3);
thousand = EnteredNo.Substring(9, 3);
digit = EnteredNo.Substring(12, 3);
if (bilion != "000")
{
adad = ReadDigit(bilion);
adad = adad + " ïéïيë ";
}
if (miliard != "000")
{
if (adad != "") adad = adad + "ي ";
adad = adad + ReadDigit(miliard);
adad = adad + " êïéïں©§ ";
}
if (million != "000")
{
if (adad != "") adad = adad + "ي ";
adad = adad + ReadDigit(million);
adad = adad + " êïéïيë ";
}
if (thousand != "000")
{
if (adad != "") adad = adad + "ي ";
adad = adad + ReadDigit(thousand);
adad = adad + " ىھں© ";
}
if (digit != "000")
{
if (adad != "") adad = adad + "ي ";
adad = adad + ReadDigit(digit);
}
return adad + " " + Currency;
}
private static String ReadDigit(string EnteredDigits)
{
string Sadgan, Dahgan, Yekan, adad = "";
Sadgan = EnteredDigits.Substring(0, 1);
Dahgan = EnteredDigits.Substring(1, 1);
Yekan = EnteredDigits.Substring(2, 1);
if (Convert.ToInt16(Sadgan) != 0)
{
switch (Convert.ToInt16(Sadgan))
{
case 1: adad = "ïè­§"; break;
case 2: adad = "§يï«¢"; break;
case 3: adad = "«ï­§"; break;
case 4: adad = "چىں© ­§"; break;
case 5: adad = "پںë­§"; break;
case 6: adad = "¬¬­§"; break;
case 7: adad = "ىه¢­§"; break;
case 8: adad = "ى¬¢­§"; break;
case 9: adad = "ëى­§"; break;
}
if (((Convert.ToInt16(Dahgan) != 0) (Convert.ToInt16(Yekan) != 0)) &&
(Convert.ToInt16(Sadgan) != 0)) adad = adad + " ي ";
switch (Convert.ToInt16(Dahgan))
{
case 1:
switch (Convert.ToInt16(Yekan))
{
case 0: adad = adad + "§ى"; break;
case 1: adad = adad + "ïںھ§ى"; break;
case 2: adad = adad + "§يںھ§ى"; break;
case 3: adad = adad + "«ïھ§ى"; break;
case 4: adad = adad + "چىں©§ى"; break;
case 5: adad = adad + "پںëھ§ى"; break;
case 6: adad = adad + "¬ںëھ§ى"; break;
case 7: adad = adad + "ىه§ى"; break;
case 8: adad = adad + "ى¤§ى"; break;
case 9: adad = adad + "ëيھ§ى"; break;
}
break;
case 2: adad = adad + " ï«¢"; break;
case 3: adad = adad + "«ï"; break;
case 4: adad = adad + "چىé"; break;
case 5: adad = adad + "پë¤ںى"; break;
case 6: adad = adad + "¬­¢"; break;
case 7: adad = adad + "ىه¢ں§"; break;
case 8: adad = adad + "ى¬¢ں§"; break;
case 9: adad = adad + "ëي§"; break;
}
if ((Convert.ToInt16(Yekan) != 0) &&
(Convert.ToInt16(Dahgan) != 0) &&
(Convert.ToInt16(Dahgan) != 1)
) adad = adad + " ي ";
switch (Convert.ToInt16(Yekan))
{
case 1: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ïè"; break;
case 2: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "§ي"; break;
case 3: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "«ى"; break;
case 4: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "چىں©"; break;
case 5: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "پë¤"; break;
case 6: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "¬¬"; break;
case 7: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ىه¢"; break;
case 8: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ى¬¢"; break;
case 9: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ëى"; break;
}
}
else
if (Convert.ToInt16(Dahgan) != 0)
{
switch (Convert.ToInt16(Dahgan))
{
case 1:
switch (Convert.ToInt16(Yekan))
{
case 0: adad = adad + "§ى"; break;
case 1: adad = adad + "ïںھ§ى"; break;
case 2: adad = adad + "§يںھ§ى"; break;
case 3: adad = adad + "«ïھ§ى"; break;
case 4: adad = adad + "چىں©§ى"; break;
case 5: adad = adad + "پںëھ§ى"; break;
case 6: adad = adad + "¬ںëھ§ى"; break;
case 7: adad = adad + "ىه§ى"; break;
case 8: adad = adad + "ى蠟ى"; break;
case 9: adad = adad + "ëيھ§ى"; break;
}
break;
case 2: adad = adad + " ï«¢"; break;
case 3: adad = adad + "«ï"; break;
case 4: adad = adad + "چىé"; break;
case 5: adad = adad + "پë¤ںى"; break;
case 6: adad = adad + "¬­¢"; break;
case 7: adad = adad + "ىه¢ں§"; break;
case 8: adad = adad + "ى¬¢ں§"; break;
case 9: adad = adad + "ëي§"; break;
}
if ((Convert.ToInt16(Yekan) != 0) && (Convert.ToInt16(Dahgan) != 1)) adad = adad + " ي ";
switch (Convert.ToInt16(Yekan))
{
case 1: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ïè"; break;
case 2: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "§ي"; break;
case 3: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "«ى"; break;
case 4: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "چىں©"; break;
case 5: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "پë¤"; break;
case 6: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "¬¬"; break;
case 7: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ىه¢"; break;
case 8: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ى¬¢"; break;
case 9: if (Convert.ToInt16(Dahgan) != 1) adad = adad + "ëى"; break;
}
}
else
{//Convert.ToInt16(Dahgan)=0
switch (Convert.ToInt16(Yekan))
{
case 1: adad = adad + "ïè"; break;
case 2: adad = adad + "§ي"; break;
case 3: adad = adad + "«ى"; break;
case 4: adad = adad + "چىں©"; break;
case 5: adad = adad + "پë¤"; break;
case 6: adad = adad + "¬¬"; break;
case 7: adad = adad + "ىه¢"; break;
case 8: adad = adad + "ى¬¢"; break;
case 9: adad = adad + "ëى"; break;
}
}
return adad;
}

No comments: