Alright so, i have got most of the things working except when i want to order something else like Pizza the Add-On items should change to Pepperoni, Sausage, Olives or Salad the Add-On items should change to Croutons, Bacon bits, Bread stick but its not changing. Here is what i have got so far:
enter code here public partial class Form1 : Form
{
decimal Subtotal;
decimal Tax = 0.0775m;
decimal OrderTotal;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
decimal add = 0m;
if (chk1.Checked)
{
add ;
}
if (chk2.Checked)
{
add ;
}
if (chk3.Checked)
{
add ;
}
if (rdoHamburger.Checked)
{
decimal Hamburger = Convert.ToDecimal(rdoHamburger.Checked);
Hamburger = 6.95m;
Subtotal = Hamburger (add * .75m);
Tax = Subtotal * 0.0775m;
OrderTotal = Tax Subtotal;
textBox1.Text = Subtotal.ToString("c");
textBox2.Text = Tax.ToString("c");
textBox3.Text = OrderTotal.ToString("c");
}
else if (rdoPizza.Checked)
{
decimal Pizza = Convert.ToDecimal(rdoPizza.Checked);
Pizza = 5.95m;
Subtotal = Pizza (add * .50m);
Tax = Subtotal * 0.00775m;
OrderTotal = Tax Subtotal;
textBox1.Text = Subtotal.ToString("c");
textBox2.Text = Tax.ToString("c");
textBox3.Text = OrderTotal.ToString("c");
}
else if (rdoSalad.Checked)
{
decimal salad = Convert.ToDecimal(rdoSalad.Checked);
salad = 4.95m;
Subtotal = salad (add * .25m);
Tax = Subtotal * 0.0775m;
OrderTotal = Tax Subtotal;
textBox1.Text = Subtotal.ToString("c");
textBox2.Text = Tax.ToString("c");
textBox3.Text = OrderTotal.ToString("c");
}
}
private void groupBox1_Enter(object sender, EventArgs e)
{
if (rdoHamburger.Checked)
{
gbxAddOnItems.Text = "Add-on items ($.75 each)";
chk1.Text = "Lettuce, tomato and ketchup";
chk2.Text = "Ketchup , mustard and mayo";
chk3.Text = "French fries";
chk1.Checked = false;
chk2.Checked = false;
chk3.Checked = false;
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
else if (rdoPizza.Checked)
{
gbxAddOnItems.Text = "Add-on items ($.50 each)";
chk1.Text = "Pepperoni";
chk2.Text = "Sausage";
chk3.Text = "Olives";
chk1.Checked = false;
chk2.Checked = false;
chk3.Checked = false;
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
else if (rdoSalad.Checked)
{
gbxAddOnItems.Text = "Add-on items ($.25 each)";
chk1.Text = "Croutons";
chk2.Text = "Bacon bits";
chk3.Text = "Bread Sticks";
chk1.Checked = false;
chk2.Checked = false;
chk3.Checked = false;
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
string message = "Thank You for Using Our Service!\n Would You Like use our service again?";
DialogResult button =
MessageBox.Show(message, "Dear Customer",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
if (button == DialogResult.No)
{
this.Close();
}
if (button == DialogResult.Yes)
{
MessageBox.Show("Thank You!! \n We Hope you will come Soon!", "Greeting Message");
this.Close();
}
}
}
...
Image of the project i want to get done I would be grateful if anyone could help have 2 days left.
CodePudding user response:
Have you tried this.refresh() or Application.DoEvents()?
CodePudding user response:
you problem is that you are updating that menu using the Enter event. This is triggered if the user tabs into that control see https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.enter?view=windowsdesktop-6.0
This is not what you want , you want to run that update code based on the click events of the pizza / etc checkboxes
