Exemple #1
0
        public void populateShoppingCartView()
        {
            ShoppingCartItemsUserControl[] shoppingCartItemsUserControl = new ShoppingCartItemsUserControl[ShoppingCartClass.itemsToPurchase.Count];
            shoppingCartItemsUserControl = ShoppingCartClass.printProducts();
            if (flpShoppingCart.Controls.Count > 0)
            {
                flpShoppingCart.Controls.Clear();
            }
            int i = 0;

            foreach (ItemToPurchaseClass item in ShoppingCartClass.itemsToPurchase)
            {
                flpShoppingCart.Controls.Add(shoppingCartItemsUserControl[i]);
                i++;
            }
            lblTotalPriceValueGeneral.Text = ShoppingCartClass.calculateActualTotalPrice().ToString();
        }
Exemple #2
0
        public static ShoppingCartItemsUserControl[] printProducts()
        {
            ShoppingCartItemsUserControl[] shoppingCartItemsUserControl = new ShoppingCartItemsUserControl[ShoppingCartClass.itemsToPurchase.Count];

            //Prepare items to show at shoppingcart
            int i = 0;

            Console.WriteLine("Items in customers shopping cart are:");
            foreach (ItemToPurchaseClass item in ShoppingCartClass.itemsToPurchase)
            {
                shoppingCartItemsUserControl[i]                = new ShoppingCartItemsUserControl();
                shoppingCartItemsUserControl[i].id             = item.product.id;
                shoppingCartItemsUserControl[i].name           = item.product.name;
                shoppingCartItemsUserControl[i].quantity       = item.quantity;
                shoppingCartItemsUserControl[i].unitPriceValue = item.product.price;
                shoppingCartItemsUserControl[i].type           = item.product.GetType();
                shoppingCartItemsUserControl[i].picture        = item.product.cover_page_picture;
                //Print the item details to Console
                Console.WriteLine("Id: " + item.product.id + " Name: " + item.product.name + " Quantity: " + item.quantity + " Unit Price Value: " + item.product.price + " Item Type: " + item.product.GetType());
                i++;
            }
            return(shoppingCartItemsUserControl);
        }