示例#1
0
        //*******************************************************
        //
        // The CheckoutBtn_Click event is raised when a user clicks
        // the "checkout" button on the client.  The event handler
        // updates all items in the cart back to the database,
        // and then redirects the user to the checkout.aspx page
        //
        //*******************************************************

        private void CheckoutBtn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            // Update Shopping Cart
            UpdateShoppingCartDatabase();

            // If cart is not empty, proceed on to checkout page
            IBuySpy.ShoppingCartDB cart = new IBuySpy.ShoppingCartDB();

            // Calculate shopping cart ID
            String cartId = cart.GetShoppingCartId();

            // If the cart isn't empty, navigate to checkout page
            if (cart.GetItemCount(cartId) != 0)
            {
                Response.Redirect("Checkout.aspx");
            }
            else
            {
                MyError.Text = "You can't proceed to the Check Out page with an empty cart.";
            }
        }
示例#2
0
        //*******************************************************
        //
        // The PopulateShoppingCartList helper method is used to
        // dynamically populate a GridControl with the contents of
        // the current user's shopping cart.
        //
        //*******************************************************

        void PopulateShoppingCartList()
        {
            IBuySpy.ShoppingCartDB cart = new IBuySpy.ShoppingCartDB();

            // Obtain current user's shopping cart ID
            String cartId = cart.GetShoppingCartId();

            // If no items, hide details and display message
            if (cart.GetItemCount(cartId) == 0)
            {
                DetailsPanel.Visible = false;
                MyError.Text         = "There are currently no items in your shopping cart.";
            }
            else
            {
                // Databind Gridcontrol with Shopping Cart Items
                MyList.DataSource = cart.GetItems(cartId);
                MyList.DataBind();

                //Update Total Price Label
                lblTotal.Text = String.Format("{0:c}", cart.GetTotal(cartId));
            }
        }