I am creating an application like a kiosk ordering machine that allows customers to purchase hoagies and pizzas.
There are five forms included. The main form, the hoagie form, the pizza form, the size form, and the toppings form.
The main form has two buttons:
- hoagie
- pizza
When a customer clicks on the hoagie button, the hoagie form opens. When a customer clicks on the pizza form, the pizza form opens. These two forms each have different choices accordingly.
Hoagie form has 3 buttons such as hoagie1 / hoagie2 / hoagie3.
Pizza form has 3 buttons such as pizza1 / pizza2 / pizza3.
When a button is clicked, the size form is opened. The size form has 3 buttons such as small / medium / large. The size form is shared by both the hoagie form and the pizza form.
When a button is clicked, the toppings form will open which contains different toppings. One for hoagies and one for pizzas.
This is where I am stuck. If i clicked on hoagie button previously then on hoagie1 button and then on small button, then the hoagie toppings form should open. If I clicked on pizza button previously then on pizza1 button and then on small button, then the pizza toppings form should open. How would I go about this?
This is what I have for the small button click event from the size form.
private void btnSmall_Click(object sender, EventArgs e)
{
frmToppings frmToppings = new frmToppings();
if (//hoagies)
{
frmToppings.DrawHoagieToppingsForm();
}
else (//pizzas)
{
frmToppings.DrawPizzaToppingsForm();
}
}
In your constructor of your size form you could pass through an enum value containing details of the form you are on. Put this into your size form:
And then your size form constructor and private field:
And then in your button click handler
And using this from your Pizza or Hoagies form:
You could also pass through some delegate that holds your
frmToppings.DrawHoagieToppingsForm();
orfrmToppings.DrawPizzaToppingsForm();
and then calls this delegate in yourbtnSmall_Click