I have a subroutine in C# that executes code:
private void txtPrice_TextChanged(object s, eventargs e)
{
if (!goThroughProcedure)
{
goThroughProc = true;
return;
}
//to do did this because may change the price b4 on the dtProducts because already has a 1 by qty.
foreach (DataRow row in dtProductsForInvoice.Rows)
{
if (row["ITEM"].ToString() == txtID.Text)
{
row["Price"] = txtPrice.Text == ""? "0.00" : txtPrice.Text;
row["ExtPrice"] = (Convert.ToDecimal(row["Price"]) * Convert.ToInt32(row["Qty"])).ToString();
txtExtPrice.Text = row["ExtPrice"].ToString();
LoadListviewOnPriceChange();
if (txtPrice.Text.Length == 0)
{
goThroughProc = false;
txtPrice.Text = "0.00";
txtExtPrice.Text = "0.00";
}
return;
}
}
if (nudQty.Value != 0)
{
DataRow row = dtProductsForInvoice.NewRow();
row["Item"] = txtID.Text;
row["Description"] = txtDesc.Text;
row["Qty"] = nudQty.Value;
row["Price"] = txtPrice.Text == "" ? "0.00" : txtPrice.Text;
row["ExtPrice"] = (Convert.ToDecimal(row["Price"]) * nudQty.Value).ToString();
row["Type"] = UserControl1.type;
row["Type2"] = UserControl1.type2;
row["ApplyDiscount"] = UserControl1.applyDiscount;
dtProductsForInvoice.Rows.Add(row);
LoadListviewadvanced();
if (UserControl1.InvoiceType != "ar")
{
btnSave.Enabled = true;
}
if (UserControl1.InvoiceType == "wo")
{
btnSaveAsInvoice.Enabled = true;
}
}
if (txtPrice.Text.Length == 0)
{
goThroughProc = false;
txtPrice.Text = "0.00";
}
}
whenever it reaches the code of txtPrice.Text = "0.00";
the textchanged event happens again and even when I tell it to skip over certain code and return; it returns and then comes back into the procedure to do to the txtPrice.text = "0.00". Does that make sense or is there something wrong with my code?
Debra has a question