The code below keeps giving me a stackoverflowexception.
I've a form_Load() function which clears all values on load. then I add code to fill in the values from the database and get the error.
I'm trying the get product from the database and fill in the textbox in winforms application.
The code looks like this:
private void txtNetAmount_TextChanged(object sender, EventArgs e)
{
try
{
decimal dcNetAmount = 0;
decimal dcRate = 0;
decimal dcWeight = 0;
decimal dcGrossAmount;
decimal dcMaking = 0;
decimal dcDicount = 0;
//TODO: calculate stone price
//TaxAmountCalculation();
if (EditingMakingAmount == false && EditingDiscountAmount == false)
{
if (txtNetAmount.Text.Trim() != string.Empty)
{
dcNetAmount = Convert.ToDecimal(txtNetAmount.Text.Trim());
}
if (txtRate.Text.Trim() != string.Empty)
{
dcRate = Convert.ToDecimal(txtRate.Text.Trim());
}
if (txtWeight.Text.Trim() != string.Empty)
{
dcWeight = Convert.ToDecimal(txtWeight.Text.Trim());
}
dcGrossAmount = dcRate * dcWeight;
if (dcNetAmount > dcGrossAmount)
{
dcMaking = dcNetAmount - dcGrossAmount;
}
else if (dcNetAmount < dcGrossAmount)
{
dcDicount = dcGrossAmount - dcNetAmount;
}
txtMaking.Text = Math.Round(dcMaking, PublicVariables._inNoOfDecimalPlaces).ToString();
txtDiscountAmount.Text = Math.Round(dcDicount, PublicVariables._inNoOfDecimalPlaces).ToString();
txtAmount.Text = Math.Round(dcNetAmount, PublicVariables._inNoOfDecimalPlaces).ToString();
}
}
catch (Exception ex)
{
formMDI.infoError.ErrorString = "POS88:" + ex.Message;
}
}
In the above code the exception is at the following line:
txtMaking.Text = Math.Round(dcMaking, PublicVariables._inNoOfDecimalPlaces).ToString();
I can't see the problem. PS the application is being developed in winforms.