예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var         closeLink     = (Control)sender;
            GridViewRow row           = (GridViewRow)closeLink.NamingContainer;
            string      firstCellText = row.Cells[2].Text;
            Items       item          = new Items();
            string      output        = firstCellText.ToLower().Replace(" desert", "_desert");

            for (int i = 0; i < desertList.Count; i++)
            {
                if (desertList[i].item_name.ToLower().Replace(" desert", "_desert") == output)
                {
                    item.item_id          = desertList[i].item_id;
                    item.item_name        = desertList[i].item_name;
                    item.item_price       = desertList[i].item_price;
                    item.item_description = desertList[i].item_description;
                    item.image            = desertList[i].image;
                }
            }
            CartItemList cart     = CartItemList.GetCart();
            ItemList     cartItem = cart[item.item_name];
            int          quantity = 1;

            if (cartItem == null)
            {
                cart.AddItem(item, quantity);
            }
            else
            {
                cartItem.AddQuantity(quantity);
            }
            Response.Redirect("~/cart.aspx");
        }