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
Bharathi Raja
NA
1.1k
54.9k
combobox select with taxand without ta
Jul 27 2017 3:11 AM
with tax and with out tax same total view that is error:
public void calc_total()
{
double ser_tax = 0, vat = 0, total_tax = 0, sub_tot = 0, dis_amt = 0, sc = 0, discount = 0, balance = 0;
if (textBox5.Text != "" && textBox5.Text != null && textBox5.Text != "0")
{
connection.Close();
connection.Open();
MySqlCommand cmd_tax = new MySqlCommand("select tax_cat from item_master where cat='1' limit 0,3", connection);
MySqlDataReader dread_tax = cmd_tax.ExecuteReader();
int x = 0;
sub_tot = Convert.ToDouble(textBox5.Text);
if (textBox6.Text == null || textBox6.Text == "." || textBox6.Text == "")
{
discount = 0.0;
}
else
{
discount = Convert.ToDouble(textBox6.Text);
}
if (discount <= 100)
{
dis_amt = ((discount / 100) * sub_tot);
balance = sub_tot - dis_amt;
if (balance < 0)
{
discount = 0;
dis_amt = ((discount / 100) * sub_tot);
}
}
sub_tot -= dis_amt;
while (dread_tax.Read())
{
if (x == 0)
{
x = 1;
ser_tax = ((Convert.ToDouble(dread_tax.GetValue(0).ToString()) / 100) * sub_tot);
textBox10.Text = ser_tax.ToString();
}
else if (x == 1)
{
x = 2;
vat = ((Convert.ToDouble(dread_tax.GetValue(0).ToString()) / 100) * sub_tot);
textBox11.Text = vat.ToString();
}
else
{
sc = ((Convert.ToDouble(dread_tax.GetValue(0).ToString()) / 100) * sub_tot);
textBox15.Text = sc.ToString();
}
}
dread_tax.Close();
connection.Close();
}
double tt2 = 0;
if (comboBox4.SelectedIndex == 1)
{
ser_tax = vat = sc = 0;
}
// total_tax = ser_tax + vat + sc;
// total_tax += sub_tot;
int rowcount = dataGridView1.Rows.Count;
double total = 0;
double service = 0, vat1 = 0;
int i;
for (i = 0; i < rowcount; i++)
{
double val3 = Convert.ToDouble(dataGridView1.Rows[i].Cells[13].Value);
total += val3;
double tt = Convert.ToDouble(dataGridView1.Rows[i].Cells[11].Value);
service += tt;
double tt1 = Convert.ToDouble(dataGridView1.Rows[i].Cells[12].Value);
vat1 += tt1;
}
i = 0;
// textBox5.Text = total.ToString();
//textBox10.Text = service.ToString();
//textBox11.Text = vat1.ToString();
textBox10.Text = string.Format("{0:0.00}", service);
textBox11.Text = string.Format("{0:0.00}", vat1);
textBox15.Text = string.Format("{0:0.00}", sc);
//textBox10.Text = string.Format("{0:0.00}", ser_tax);
//textBox11.Text = string.Format("{0:0.00}", vat);
//textBox15.Text = string.Format("{0:0.00}", sc);
total_tax = service + vat1 + sc;
total_tax += sub_tot;
if (textBox8.Text != null && textBox8.Text != "")
{
dis_amt = Convert.ToDouble(textBox8.Text);
}
double roundoff = 0;
double voucher = 0;
if (textBox14.Text != null && textBox14.Text != "")
{
if (textBox14.Text == "-" || textBox14.Text == "-." || textBox14.Text == ".")
{
roundoff = 0;
}
else
{
roundoff = Convert.ToDouble(textBox14.Text);
}
}
if (textBox22.Text != null && textBox22.Text != "")
{
if (textBox22.Text == "-" || textBox22.Text == "-." || textBox22.Text == ".")
{
voucher = 0;
}
else
{
voucher = Convert.ToDouble(textBox22.Text);
}
}
double tot_val = ((total - ((voucher)) + roundoff) - dis_amt);
textBox12.Text = string.Format("{0:0.00}", tot_val);
get_cash_card();
}
Reply
Answers (
2
)
Error : Index was outside the bounds of the array.
i have prblm to alert textbox all fields onen by one