The current code is:
decimal subtotal = 0.00M,
VATRate = 0.00M,
VAT,
Total;
try
{
subtotal = decimal.Parse(subtotalTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show("The value you entered for the " +
"Input Amount is not valid");
}
try
{
VATRate = decimal.Parse(vATrateTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show("Wrong Value: The VAT rate must " +
"be a value between 0 and 100");
}
decimal I = VATRate / 100;
VAT = subtotal * I;
Total = subtotal + VAT;
vATTextBox.Text = VAT.ToString("F2");
total_ChargeTextBox.Text = total_ChargeTextBox.Text = Total.ToString("F2");

VulpesRank #55 · 29.2K reputationPosted Sep 7, 2011, 11:49 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 7, 2011, 10:50 AM EDT
Unless you know in advance what the VAT rates will be for each textbox, it seems to me that you will need a VAT rate box for each one if you're going to total the net amounts, VAT thereon and gross amounts for all the textboxes.
As far as I can tell, you only have one VAT rate textbox here.
mike DelvottiRank #7,298 · 244 reputationPosted Sep 7, 2011, 11:28 AM EDT
Damage_waiver is a fixed amount and doesn't total in the subtotal textbox but needs to be applied to the final calculation after VAT has been applied in total_chargeTextbox
It would be great if the value in Damage_waiverTextbox could just be applied to the total_chargeTextbox as the demo below:
decimal I = VATRate / 100;
VAT = subtotal * I;
Total = subtotal + VAT;
vATTextBox.Text = VAT.ToString("F2");
total_ChargeTextBox.Text = total_ChargeTextBox.Text = Total.ToString("F2");
//Now add the damage waiver amount to the final total
total_ChargeTextBox.Text = total_ChargeTextBox.Text +Damage_WaiverTextbox.ToString("F2");
The above doesn't work as it doesn't sum it just adds it on the end of the output.
I was thinking that by adding the net amount in Damage_waiver to the total amount (inc VAT) would do the job or am I way of the mark? :)
mike DelvottiRank #7,298 · 244 reputationPosted Sep 7, 2011, 12:11 PM EDT