There are some conceptual problems with your code.
You don't add a number (v) to the ArrayList but a pizzaOrder, and you don't react to the text_changed event every time. In WinForms this is called for every character typed. If your user make a mistake and type 3 when he/she means 2 you have already added the number 3 to the array. Also, there are better alternative to the ArrayList class used....
So, first thing remove the global pizzaOrder
and change your ArrayList to a List<pizzaOrder>
// pizzaOrder aOrder = new pizzaOrder();
public List<pizzaOrder> pizzasOrdered = new List<pizzaOrder>();
then add a new button called InsertOrder
and add this code for its click event
private void InsertOrder_Click_1(object sender, EventArgs e)
{
// Call a common function that creates an object of pizzaOrder
// from the values typed by your user and add it to the List
pizzaOrder aOrder = MakeAnOrder();
pizzasOrdered.Add(aOrder);
}
private pizzaOrder MakeAnOrder()
{
double d;
int v;
pizzaOrder aOrder = new pizzaOrder();
// If zero is an acceptable value for pizza/cokes and amount then
// you don't need to check the outcome of the tryparse...
int.TryParse(textBox1.Text, out v);
aOrder.numberOfPizzas = v;
int.TryParse(textBox2.Text, out v);
aOrder.numberOfCokes = v;
double.TryParse(textBox5.Text, out d);
aOrder.getAmountPaid = d;
return aOrder;
}
Now you can remove the event handler on the textboxes and change the code in the following events
private void calculateAmountDue_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString(MakeAnOrder().GetAmountDue());
}
.....
// the same code for the other buttons
Finally, when you need to pass the List<pizzaOrder>
to another form, just pass the global variable in the constructor of the second form
private void summaryOfOrdersToolStripMenuItem_Click(object sender, EventArgs e)
{
SummaryOfOrdersPlaced myForm = new SummaryOfOrdersPlaced(pizzasOrdered);
myForm.Show();
}
And receive the List in the constructor of the form
public class SummaryOfOrdersPlaced : Form
{
public SummaryOfOrdersPlaced(List<pizzaOrder> orders)
{
foreach(pizzaOrder o in orders)
... use the passed in variable to loop on orders and create your display
}
}