예제 #1
0
        protected void Submit(object sender, EventArgs e)
        {
            Order order = (Order)Session["order"];

            if (order != null)
            {
                // Add checked toppings to the pizza
                foreach (GridViewRow row in ToppingsGridView.Rows)
                {
                    CheckBox cb = (CheckBox)row.FindControl("ToppingSelector");
                    if ((cb != null) && (cb.Checked))
                    {
                        DataKey topping_key =
                            ToppingsGridView.DataKeys[row.RowIndex];
                        string name = (string) topping_key["topping"];
                        decimal cost = (decimal) topping_key["cost"];
                        Topping topping = new Topping(name, cost);
                        pizza_to_add.AddTopping(topping);
                    }
                }

                // Add the pizza to the order, and go back to the order page
                order.AddPizza(pizza_to_add);
                Session["order"] = order;
            }

            Session["pizza_to_add"] = null;
            Response.Redirect("OrderPizza.aspx");
        }
예제 #2
0
 public void AddTopping(Topping topping)
 {
     toppings.Add(topping);
 }
예제 #3
0
 public void AddTopping(Topping topping)
 {
     toppings.Add(topping);
 }