Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ShopProduct curProd = (ShopProduct)((Button)sender).Tag;

            if (selectedProducts.Contains(curProd))//Check if product is already in cart
            {
                cartNotification.Text    = "Already in Cart";
                cartNotificationBG.Color = Colors.Cyan;
            }
            else
            {
                //Add to Cart
                cartItem newItem = new cartItem();
                newItem.Product = curProd;
                newItem.Qty     = 1;
                selectedProducts.Add(curProd);
                myCart.Add(newItem);
                cartNotification.Text    = "Added to Cart";
                cartNotificationBG.Color = Colors.Yellow;
                btnCheckout.IsEnabled    = true;
                btnClearCart.IsEnabled   = true;
                cartHeader.Visibility    = Visibility.Visible;


                //Update Cart Amount
                totalAmount = 0;
                totalTax    = 0;
                for (int i = 0; i < myCart.Count; i++)
                {
                    totalAmount += myCart[i].Rate;
                    totalTax    += myCart[i].Tax;
                }
                lbltax.Text       = string.Format("${0:N2}", totalTax);
                lblsubAmount.Text = string.Format("${0:N2}", totalAmount);
                lbltotal.Text     = string.Format("${0:N2}", totalAmount + totalTax);
            }

            cartPopupNotify.IsOpen = true;//Notify
            dtClockTime.Stop();
            dtClockTime.Start();
        }
Beispiel #2
0
        private void qty_add_Click(object sender, RoutedEventArgs e)
        {
            //Increase Product Quantity
            cartItem curProd = (cartItem)((Button)sender).Tag;

            if (curProd.Qty < curProd.Product.StockQuantity)
            {
                curProd.Qty++;
            }

            totalAmount = 0;
            totalTax    = 0;
            for (int i = 0; i < myCart.Count; i++)
            {
                totalAmount += myCart[i].Rate;
                totalTax    += myCart[i].Tax;
            }
            lbltax.Text       = string.Format("${0:N2}", totalTax);
            lblsubAmount.Text = string.Format("${0:N2}", totalAmount);
            lbltotal.Text     = string.Format("${0:N2}", totalAmount + totalTax);
        }
Beispiel #3
0
        private void qty_sub_Click(object sender, RoutedEventArgs e)
        {
            //Reduce Product Quantity

            cartItem curProd = (cartItem)((Button)sender).Tag;

            curProd.Qty--;
            if (curProd.Qty == 0)
            {
                myCart.Remove(curProd);
                lstCart.ItemsSource = null;
                lstCart.ItemsSource = myCart;
                if (myCart.Count == 0)
                {
                    btnCheckout.IsEnabled  = false;
                    btnClearCart.IsEnabled = false;
                    selectedProducts.Remove(curProd.Product);
                    lbltax.Text           = "$0.00";
                    lblsubAmount.Text     = "$0.00";
                    lbltotal.Text         = "$0.00";
                    cartHeader.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                totalAmount = 0;
                totalTax    = 0;
                for (int i = 0; i < myCart.Count; i++)
                {
                    totalAmount += myCart[i].Rate;
                    totalTax    += myCart[i].Tax;
                }
                lbltax.Text       = string.Format("${0:N2}", totalTax);
                lblsubAmount.Text = string.Format("${0:N2}", totalAmount);
                lbltotal.Text     = string.Format("${0:N2}", totalAmount + totalTax);
            }
        }