Example #1
0
 // add an order to the hashtable
 public void AddOrder(Order order)
 {
     Order _order = (Order)_Orders[order.ItemID];
     if (_order != null)
         _order.Quantity += order.Quantity;
     else
         _Orders.Add(order.ItemID, order);
 }
Example #2
0
        // when a datagrid item command is placed
        public void OnItemCommand(Object sender, DataGridCommandEventArgs e)
        {
            // add an item to the cart
            if (e.CommandName == "addItemToCart")
            {
                Order order = new Order(e.Item.Cells[0].Text, e.Item.Cells[1].Text, e.Item.Cells[2].Text, e.Item.Cells[3].Text, 1);
                ShoppingCart cart = (ShoppingCart)Session["MyShoppingCart"];
                if (cart != null)
                    cart.AddOrder(order);

                cartLink.Text = "Shopping Cart (" + cart.CartCount() + ")";
            }
        }