private void getPizzas() { lstPizzas.Items.Clear(); //adding to the Pizzas list using (ds.spGetPizzasDataTable tblP = new dsTableAdapters.spGetPizzasTableAdapter().GetData(Order.currentOrder)) { foreach (ds.spGetPizzasRow row in tblP.Rows) { int PizzaID = row.PizzaID; string[] toppings = new string[15]; using (ds.spGetToppingsDataTable tblT = new dsTableAdapters.spGetToppingsTableAdapter().GetData(PizzaID)) { int i = 0; foreach (ds.spGetToppingsRow r in tblT.Rows) { toppings[i] = r.ToppingName; //if there are no toppings, state Cheese i = i + 1; } if (toppings[0] == null) { toppings[0] = "Cheese"; } } lstPizzas.Items.Add(new Pizza(row.PizzaID, row.Size, toppings, row.Price)); } } }
public override string ToString() { string pizzas = ""; using (ds.spGetPizzasDataTable tblP = new dsTableAdapters.spGetPizzasTableAdapter().GetData(OrderID)) { int j = 0; foreach (ds.spGetPizzasRow rP in tblP.Rows) { string allToppings = ""; string[] toppings = new string[15]; pizzas = pizzas + "\n\t"; int pizzaID = rP.PizzaID; using (ds.spGetToppingsDataTable tblT = new dsTableAdapters.spGetToppingsTableAdapter().GetData(pizzaID)) { int h = 0; foreach (ds.spGetToppingsRow rT in tblT.Rows) { toppings[h] = rT.ToppingName; h = h + 1; } if (toppings[0] == null) { toppings[0] = "Cheese"; } j = j + 1; h = 0; } for (int k = 0; k < toppings.Length; k++) { allToppings = allToppings + toppings[k] + " "; } pizzas = String.Format("{0,-15} - {1,-5} - {2,-40}", pizzas, rP.Size, allToppings); } return(String.Format("${0,-5} - {1,-15} - {2,-15} - {3,-60}", OrderTotal, customerFName, customerLName, pizzas)); } }