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");
VulpesPosted Sep 7, 2011, 3:49 PM
mike DelvottiPosted Sep 7, 2011, 4:11 PM
mike DelvottiPosted Sep 7, 2011, 3:28 PM
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? :)
VulpesPosted Sep 7, 2011, 2:50 PM
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.