Я пытаюсь создать своего рода калькулятор, который суммирует базовую цену, любые добавленные радиокнопки / галочки, плюс налог и помещает результат в промежуточный итог.Почему я не могу сделать так, чтобы мое текстовое поле baseprice появилось в моем текстовом поле промежуточных итогов?Я попробовал несколько методов, но они, кажется, не работают.Любой совет, ребята?Вот мой код:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txttradein_TextChanged(object sender, EventArgs e)
{
lblTradein.Text = txtTradeIn.Text;
}
private void btnCalculate_Click(object sender, EventArgs e)
{
double BasePrice = double.Parse(txtBasePrice.Text);
try
{
if (BasePrice < 0)
{
MessageBox.Show("Error");
txtBasePrice.Focus();
txtBasePrice.SelectAll();
}
}
catch (FormatException)
{
txtBasePrice.SelectAll();
MessageBox.Show("Numbers Only");
}
try
{
double TradeIn= double.Parse(txtTradeIn.Text);
if(TradeIn < 0)
{
MessageBox.Show("Error");
txtTradeIn.Focus();
txtTradeIn.SelectAll();
}
}
catch (FormatException)
{
txtTradeIn.SelectAll();
MessageBox.Show("Numbers Only");
}
double stereoPrice = 0, leatherPrice = 0, navPrice = 0;
if (chkStereo.Checked) {
stereoPrice = 425.76;
} if (chkLeather.Checked){
leatherPrice = 987.41;
} if (chkComputer.Checked){
navPrice = 1741.23;
}
double exteriorFinish = 0;
if(radPearlized.Checked)
{
exteriorFinish = 345.72;
}
else if (radCustom.Checked)
{
exteriorFinish = 599.99;
}
else
{
exteriorFinish = 0;
}
double subTotal = stereoPrice + leatherPrice + navPrice + exteriorFinish;
double txtRate = 0.08, tax = 0;
tax = subTotal * txtRate;
txtTax.Text = tax.ToString();
txtSubtotal.Text = subTotal.ToString();
}
}
}