How can I add a price range in my code and make " num1 " depended on the price range ! I want to assign some specific values to price range and then make my num1 to fetch that value ! Eg 1.if price range is (1 to 1000) then num1 = 10 ... 2.if price range is (1000 to 2000) then num1 = 20 ...
My Code :
int num1 = Convert.ToInt32(Price.Text);
int num2 = Convert.ToInt32(DropDownList1.SelectedValue);
int num3 = Convert.ToInt32(DropDownList2.SelectedValue);
int tax;
int petrol;
int cng;
int diesel;
int personal;
int commercial;
petrol = 1000;
cng = 2000;
diesel = 3000;
personal = 500;
commercial = 700;
tax = 0;
if (DropDownList1.SelectedValue == "1" | DropDownList2.SelectedValue == "1" )
{
tax = num1 + petrol + personal;
}
else if (DropDownList1.SelectedValue == "2" | DropDownList2.SelectedValue == "1" )
{
tax = num1 + cng + personal;
}
else if (DropDownList1.SelectedValue == "3" | DropDownList2.SelectedValue == "1" )
{
tax = num1 + diesel + personal;
}
else
{
}
if (DropDownList1.SelectedValue == "1" | DropDownList2.SelectedValue == "2" )
{
tax = num1 + petrol + commercial;
}
else if (DropDownList1.SelectedValue == "2" | DropDownList2.SelectedValue == "2" )
{
tax = num1 + cng + commercial;
}
else if (DropDownList1.SelectedValue == "3" | DropDownList2.SelectedValue == "2" )
{
tax = num1 + diesel + commercial;
}
else
{
}
CalTax.Text = tax.ToString();
Aucun commentaire:
Enregistrer un commentaire