Esempio n. 1
0
        protected void RemoveFromCart_OnClick(object sender, EventArgs e)
        {
            LinkButton senderItem = (LinkButton)sender;

            CurrentCart.RemoveItem(MediaDetailsMapper.GetByID(long.Parse(senderItem.CommandArgument)));
        }
Esempio n. 2
0
        protected void grdItems_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            Page.Validate("vgCart");
            if (!Page.IsValid)
            {
                return;
            }

            int itemID;
            int quantity;

            switch (e.CommandName)
            {
            case "Update":
                itemID = (int)grdItems.DataKeys[Convert.ToInt32(e.CommandArgument)];
                TextBox txtQuantity = (TextBox)((WebControl)e.CommandSource).Parent.FindControl("txtQuantity");
                quantity = int.Parse(txtQuantity.Text);
                if (quantity > 0)
                {
                    CurrentCart.UpdateItem(PortalId, StoreSettings.SecureCookie, itemID, quantity);
                }
                else
                {
                    CurrentCart.RemoveItem(itemID);
                }
                UpdateCartGrid();
                InvokeEditComplete();

                break;

            case "Delete":
                itemID = (int)grdItems.DataKeys[Convert.ToInt32(e.CommandArgument)];
                CurrentCart.RemoveItem(itemID);
                UpdateCartGrid();
                InvokeEditComplete();

                break;

            case "UpdateCart":
                foreach (DataGridItem dgItem in grdItems.Items)
                {
                    itemID   = (int)grdItems.DataKeys[dgItem.ItemIndex];
                    quantity = int.Parse(((TextBox)dgItem.FindControl("txtQuantity")).Text);
                    if (quantity > 0)
                    {
                        CurrentCart.UpdateItem(PortalId, StoreSettings.SecureCookie, itemID, quantity);
                    }
                    else
                    {
                        CurrentCart.RemoveItem(itemID);
                    }
                }
                UpdateCartGrid();
                InvokeEditComplete();

                break;

            default:
                break;
            }
        }