How to Convert in this Screnario
HiHow to create function Decimal to words. - (Sql Server )
I need following output this
--823456.21
--Eight Lakh Twenty Three Thousand Four Hundread Fifty Six and Twenty one Paise Only
--823456.21
--Eight Lakh Twenty Three Thousand Four Hundread Fifty Six and Twenty one Paise Only
public string ConvertDecimaltoWords(long number)
{
if (number == 0) return "ZERO";
if (number < 0) return "minus " + ConvertDecimaltoWords(Math.Abs(number));
string words = "";
if ((number / 100000000) > 0)
{
words += ConvertDecimaltoWords(number / 10000000) + " CRORES";
number %= 10000000;
}
if ((number / 100000) > 0)
{
words += ConvertDecimaltoWords(number / 100000) + " LAKHS";
number %= 1000000;
}
if ((number / 1000) > 0)
{
words += ConvertDecimaltoWords(number / 1000) + " THOUSANDS";
number %= 1000;
}
if ((number / 100) > 0)
{
words += ConvertDecimaltoWords(number / 100) + " HUNDREDS";
number %= 100;
}
if ((number / 10) > 0)
{
words += ConvertDecimaltoWords(number / 10) + " RUPEES ";
number %= 10;
}
if (number > 0)
{
if (words != "") words += "AND ";
var unitsMap = new[]
{
"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN"
};
var tensMap = new[]
{
"ZERO", "TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY"
};
if (number < 20) words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0) words += " " + unitsMap[number % 10];
}
}
return words;
}