Exemple #1
0
        protected void LoginUser_LoggedIn(object sender, EventArgs e)
        {
            Tailspin.Classes.MyShoppingCart usersShoppingCart = new Tailspin.Classes.MyShoppingCart();
            String cartId = usersShoppingCart.GetShoppingCartId();
            usersShoppingCart.MigrateCart(cartId, LoginUser.UserName);
            string rawId = Request.QueryString["ReturnUrl"];

            if(Session["LoginReferrer"] != null)
            {
               // Response.Redirect(Session["LoginReferrer"].ToString());
                Response.Redirect(rawId);
            }

            Session["UserName"] = LoginUser.UserName;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     Classes.MyShoppingCart usersShoppingCart = new Classes.MyShoppingCart();
     String cartId = usersShoppingCart.GetShoppingCartId();
     decimal cartTotal = 0;
     cartTotal = usersShoppingCart.GetTotal(cartId);
     if (cartTotal > 0)
     {
         lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal(cartId));
     }
     else
     {
         LableTotalText.Text = "";
         lblTotal.Text = "";
         ShoppingCartTitle.InnerText = "Shopping Cart is Empty";
         UpdateBtn.Visible = false;
         CheckoutBtn.Visible = false;
     }
 }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int productId;

            if (!String.IsNullOrEmpty(rawId) && Int32.TryParse(rawId, out productId))
            {

                Tailspin.Classes.MyShoppingCart usersShoppingCart = new Classes.MyShoppingCart();
                String cartId = usersShoppingCart.GetShoppingCartId();
                usersShoppingCart.AddItem(cartId, productId, 1);
            }
            else
            {
                Debug.Fail("Error : We should never get to AddToCart.aspx without a ProductId.");

                throw new Exception("Error : It is illegal to load AddToCart.aspx without setting a ProductId");
            }

            Response.Redirect("MyShoppingCart.aspx");
        }
        protected void UpdateBtn_Click(object sender, ImageClickEventArgs e)
        {
            Tailspin.Classes.MyShoppingCart usersShoppingCart = new Tailspin.Classes.MyShoppingCart();

            String cartId = usersShoppingCart.GetShoppingCartId();

            Tailspin.Classes.MyShoppingCart.ShoppingCartUpdates[] cartUpdates = new Tailspin.Classes.MyShoppingCart.ShoppingCartUpdates[MyList.Rows.Count];
            for (int i = 0; i < MyList.Rows.Count; i++)
            {

                IOrderedDictionary rowValues = new OrderedDictionary();
                rowValues = GetValues(MyList.Rows[i]);
                cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);
                cartUpdates[i].PurchaseQantity = Convert.ToInt32(rowValues["Quantity"]);

                CheckBox cbRemove = new CheckBox();
                cbRemove = (CheckBox)MyList.Rows[i].FindControl("Remove");
                cartUpdates[i].RemoveItem = cbRemove.Checked;
            }

            usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
            MyList.DataBind();
            lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal(cartId));
        }