TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
venky n
NA
110
38.8k
amount calculation
Mar 3 2015 5:32 AM
some error occured:reason..i dn't now to input get dropdown
Reply
Answers (
5
)
0
Pradeep
1.4k
313
0
Mar 6 2015 12:35 AM
protected void Button1_Click(object sender, EventArgs e)
{
lblamtwrd.Text = "";
string[] Ones = new string[] { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
string[] Twos = new string[] { "", "Eleven", "Twolve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Ninteen" };
string[] Tens = new string[] { "", "Ten", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninty" };
int Crore = Convert.ToInt32(ddlCrore.SelectedValue);
txtamt.Text = Convert.ToString(Crore * 10000000);
int Onesdigit = 0;
int tensDigit = 0;
string StrCre = "";
string StrLcs = "";
string StrThsnd = "";
if (Crore > 19 || Crore == 10)
{
Onesdigit = Crore % 10;
tensDigit = Crore / 10;
StrCre = Tens[tensDigit] + " " + Ones[Onesdigit] + " Crore ";
}
else if (Crore > 10 && Crore < 20)
{
Onesdigit = Crore % 10;
StrCre = Twos[Onesdigit] + " Crore ";
}
else if (Crore < 10)
{
StrCre = Ones[Crore] + " Crore ";
}
int Lacs = Convert.ToInt32(ddlLacs.SelectedValue);
txtamt.Text = Convert.ToString(Convert.ToInt32(txtamt.Text) + (Lacs * 100000));
if (Lacs > 19 || Lacs==10 )
{
Onesdigit = Lacs % 10;
tensDigit = Lacs / 10;
StrLcs = Tens[tensDigit] + " " + Ones[Onesdigit] + " Lacs ";
}
else if (Lacs > 10 && Lacs < 20)
{
Onesdigit = Lacs % 10;
StrLcs = Twos[Onesdigit] + " Lacs ";
}
else
{
StrLcs = Ones[Lacs] + " Lacs ";
}
int Thsnds = Convert.ToInt32(ddlTsnd.SelectedValue);
txtamt.Text = Convert.ToString(Convert.ToInt32(txtamt.Text) + (Thsnds * 1000));
if (Thsnds > 19 || Thsnds == 10)
{
Onesdigit = Thsnds % 10;
tensDigit = Thsnds / 10;
StrThsnd = Tens[tensDigit] + " " + Ones[Onesdigit] + " Thousands ";
}
else if (Thsnds > 10 && Thsnds < 20)
{
Onesdigit = Thsnds % 10;
StrThsnd = Twos[Onesdigit] + " Thousands ";
}
else
{
StrThsnd = Ones[Thsnds] + " Thousands ";
}
lblamtwrd.Text = StrCre + " " + StrLcs + " " + StrThsnd;
}
Accepted Answer
0
venky n
0
110
38.8k
Mar 7 2015 2:05 AM
Total amount calculation coding Very useful for me... Thank you..Pradeep Kumar sir
0
Vulpes
0
96k
2.6m
Mar 3 2015 6:08 AM
Try this instead:
protected void ddcroes_SelectedIndexChanged(object sender, EventArgs e)
{
Total();
}
protected void ddlaks_SelectedIndexChanged(object sender, EventArgs e)
{
Total();
}
protected void ddths_SelectedIndexChanged(object sender, EventArgs e)
{
Total();
}
public static void Total()
{
int n, n1, n2;
int.TryParse(ddcroes.SelectedItem.Text, out n);
n *= 10000000;
int.TryParse(ddlaks.SelectedItem.Text, out n1);
n1 *= 100000;
int.TryParse(ddths.SelectedItem.Text, out n2);
n2 *= 1000;
int inputNumber = n + n1 + n2;
lblWords.Text = NumbersToWords(inputNumber);
}
0
venky n
0
110
38.8k
Mar 3 2015 5:50 AM
How to calculate amount total and words format using three dropdown(Ex:crores,Laks,Thousands)....total amt display textbox and words total amount display for label control
protected void ddcroes_SelectedIndexChanged(object sender, EventArgs e)
{
int inpno = Convert.ToInt32(ddcroes.SelectedIndex);
int n = inpno * 10000000;
Total(n);
}
protected void ddlaks_SelectedIndexChanged(object sender, EventArgs e)
{
int inpno = Convert.ToInt32(ddcroes.SelectedIndex);
int n1 = inpno * 100000;
Total(n1);
}
protected void ddths_SelectedIndexChanged(object sender, EventArgs e)
{
int inpno = Convert.ToInt32(ddcroes.SelectedIndex);
int n2 = inpno * 1000;
Total(n2);
}
public static int Total(int no,int no1, int no2)
{
int inputNumber=no+no1+no2;
string outwords = NumbersToWords(inputNumber);
lblWords.Text = outwords;
}
public static string NumbersToWords(int inputNumber)
{
int inputNo = inputNumber;
if (inputNo == 0)
return "Zero";
int[] numbers = new int[4];
int first = 0;
int u, h, t;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
if (inputNo < 0)
{
sb.Append("Minus ");
inputNo = -inputNo;
}
string[] words0 = {"" ,"One ", "Two ", "Three ", "Four ",
"Five " ,"Six ", "Seven ", "Eight ", "Nine "};
string[] words1 = {"Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ",
"Fifteen ","Sixteen ","Seventeen ","Eighteen ", "Nineteen "};
string[] words2 = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ",
"Seventy ","Eighty ", "Ninety "};
string[] words3 = { "Thousand ", "Lakh ", "Crore " };
numbers[0] = inputNo % 1000; // units
numbers[1] = inputNo / 1000;
numbers[2] = inputNo / 100000;
numbers[1] = numbers[1] - 100 * numbers[2]; // thousands
numbers[3] = inputNo / 10000000; // crores
numbers[2] = numbers[2] - 100 * numbers[3]; // lakhs
for (int i = 3; i > 0; i--)
{
if (numbers[i] != 0)
{
first = i;
break;
}
}
for (int i = first; i >= 0; i--)
{
if (numbers[i] == 0) continue;
u = numbers[i] % 10; // ones
t = numbers[i] / 10;
h = numbers[i] / 100; // hundreds
t = t - 10 * h; // tens
if (h > 0) sb.Append(words0[h] + "Hundred ");
if (u > 0 || t > 0)
{
if (h > 0 || i == 0) sb.Append("and ");
if (t == 0)
sb.Append(words0[u]);
else if (t == 1)
sb.Append(words1[u]);
else
sb.Append(words2[t - 2] + words0[u]);
}
if (i != 0) sb.Append(words3[i - 1]);
}
return sb.ToString().TrimEnd();
}
0
Anil Kumar
0
641
378.9k
Mar 3 2015 5:36 AM
Questions which are hard to understand are very difficult to answer.. Please provide more information
Hosting WebSite
C# Store Procedure