Ejemplo n.º 1
0
        public List <Carrinho> UpdateCartItems()
        {
            using (CarrinhodecomprasAction usersShoppingCart = new CarrinhodecomprasAction())
            {
                String cartId = usersShoppingCart.GetCartId();

                CarrinhodecomprasAction.ShoppingCartUpdates[] cartUpdates = new CarrinhodecomprasAction.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

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

                    // TextBox quantityTextBox = new TextBox();
                    // quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                    // cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                }
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (CarrinhodecomprasAction usersShoppingCart = new CarrinhodecomprasAction())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("ERRO : O id do produto é nulo.");
                throw new Exception("ERRO: Recarregar o produto sem id");
            }
            Response.Redirect("/Carrinhoc.aspx");
        }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (CarrinhodecomprasAction usersShoppingCart = new CarrinhodecomprasAction())
     {
         decimal cartTotal = 0;
         cartTotal = usersShoppingCart.GetTotal();
         if (cartTotal > 0)
         {
             // Display Total.
             lblTotal.Text        = String.Format("{0:c}", cartTotal);
             UpdateBtn.Visible    = true;
             Btncontinuar.Visible = true;
         }
         else
         {
             LabelTotalText.Text         = "";
             lblTotal.Text               = "";
             ShoppingCartTitle.InnerText = "O carrinho de compras esta vazio";
             UpdateBtn.Visible           = false;
             Btncontinuar.Visible        = false;
         }
     }
 }
Ejemplo n.º 4
0
        public List <Carrinho> GetShoppingCartItems()
        {
            CarrinhodecomprasAction actions = new CarrinhodecomprasAction();

            return(actions.GetCartItems());
        }