Hi everybody!
I have asp.net project I want to calculate numbers by 9 label.text and 9 textbox.text values but when I input two of them I have problem but when I fill all of them there is no problem.:my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class dieh : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dbmanager dbm = new dbmanager();
dbm.fillddl(DropDownList1, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList2, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList3, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList4, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList5, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList6, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList7, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList8, "dieh", "sal_dieh", "derham");
dbm.fillddl(DropDownList9, "dieh", "sal_dieh", "derham");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue.ToString();
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
Label2.Text = DropDownList2.SelectedValue.ToString();
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
Label3.Text = DropDownList3.SelectedValue.ToString();
}
protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
{
Label4.Text = DropDownList4.SelectedValue.ToString();
}
protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
{
Label5.Text = DropDownList5.SelectedValue.ToString();
}
protected void DropDownList6_SelectedIndexChanged(object sender, EventArgs e)
{
Label6.Text = DropDownList6.SelectedValue.ToString();
}
protected void DropDownList7_SelectedIndexChanged(object sender, EventArgs e)
{
Label7.Text = DropDownList7.SelectedValue.ToString();
}
protected void DropDownList8_SelectedIndexChanged(object sender, EventArgs e)
{
Label8.Text = DropDownList8.SelectedValue.ToString();
}
protected void DropDownList9_SelectedIndexChanged(object sender, EventArgs e)
{
Label9.Text = DropDownList9.SelectedValue.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
Decimal lbl1;
Decimal.TryParse(Label1.Text.Trim(), out lbl1);
Decimal lbl2;
Decimal.TryParse(Label2.Text.Trim(), out lbl2);
Decimal lbl3;
Decimal.TryParse(Label3.Text.Trim(), out lbl3);
Decimal lbl4;
Decimal.TryParse(Label4.Text.Trim(), out lbl4);
Decimal lbl5;
Decimal.TryParse(Label5.Text.Trim(), out lbl5);
Decimal lbl6;
Decimal.TryParse(Label6.Text.Trim(), out lbl6);
Decimal lbl7;
Decimal.TryParse(Label7.Text.Trim(), out lbl7);
Decimal lbl8;
Decimal.TryParse(Label8.Text.Trim(), out lbl8);
Decimal lbl9;
Decimal.TryParse(Label9.Text.Trim(), out lbl9);
Decimal txt1 = Decimal .Parse(TextBox1.Text);
Decimal txt2 = Decimal .Parse(TextBox2.Text);
Decimal txt3 = Decimal .Parse(TextBox3.Text);
Decimal txt4 = Decimal .Parse(TextBox4.Text);
Decimal txt5 = Decimal .Parse(TextBox5.Text);
Decimal txt6 = Decimal .Parse(TextBox6.Text);
Decimal txt7 = Decimal .Parse(TextBox7.Text);
Decimal txt8 = Decimal .Parse(TextBox8.Text);
Decimal txt9 = Decimal .Parse(TextBox9.Text);
Decimal total;
Decimal der;
Decimal result;
total = (txt1 / lbl1) + (txt2 / lbl2) + (txt3 / lbl3) + (txt4 / lbl4) +(txt5 / lbl5) + (txt6 / lbl6) + (txt7 / lbl7) + (txt8 / lbl8);
der = total * lbl9;
result = txt9 - der;
Label10.Text = result.ToString();
}
}