I written like below code but when i enter value second time in other textboxes assing/subtracting again
public void regCustCalculation()
{
double amountToPay = double.Parse(txtAmntToPay.Text);
double noOfConn = double.Parse(txtNoOfConn.Text);
double chargePerConn = double.Parse(txtChargePerConn.Text);
double installCharge = double.Parse(txtInstallCharge.Text);
double discount = double.Parse(txtDiscount.Text);
double packPrice = double.Parse(txtAmntToPay.Text);
if (ddlPackName.SelectedIndex != 0)
{
txtAmntToPay.Text = "0";
packPrice = amountToPay;
packPrice = amountToPay + (noOfConn * chargePerConn);
packPrice = packPrice + installCharge;
packPrice = packPrice - discount;
txtAmntToPay.Text = packPrice.ToString();
}
if (ddlPackName.SelectedIndex==0)
{
txtAmntToPay.Text = "0";
packPrice = noOfConn * chargePerConn;
packPrice = packPrice + installCharge;
packPrice = packPrice - discount;
txtAmntToPay.Text = packPrice.ToString();
}
}
protected void txtNoOfConn_TextChanged(object sender, EventArgs e)
{
//regCustCalculation();
}
protected void txtChargePerConn_TextChanged(object sender, EventArgs e)
{
regCustCalculation();
}
protected void txtInstallCharge_TextChanged(object sender, EventArgs e)
{
regCustCalculation();
}
protected void txtDiscount_TextChanged(object sender, EventArgs e)
{
regCustCalculation();
}
public void ddlPackPriceBind()
{
try
{
//open the db connection if it is closed...
if (connection.State == ConnectionState.Closed)
connection.Open();
string packNameEdit = ddlPackName.SelectedItem.ToString();
command = new SqlCommand();
command.CommandText = "sp_Get_PackPrice";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@packageName", packNameEdit);
da = new SqlDataAdapter(command);
command.Connection = connection;
ds = new DataSet();
da.Fill(ds);
txtAmntToPay.Text = "";
txtAmntToPay.Text = ds.Tables[0].Rows[0]["PackagePrice"].ToString();
}
protected void ddlPackName_SelectedIndexChanged(object sender, EventArgs e)
{
ddlPackPriceBind();
regCustCalculation();
}