예제 #1
0
        public store()
        {
            InitializeComponent();
            // create a teas list object
            teas = new TeaList();

            // load combobox of teas
            for (var i = 0; i < teas.Length(); ++i)
            {
                cbTeas.Items.Add(teas.GetTea(i).Name);
            }

            //set data for first tea object
            imgTeaPicture.Source = new BitmapImage(new Uri(teas.GetTea(0).Image, UriKind.Relative));
            tbName.Text          = teas.GetTea(0).Name;
            tbDescription.Text   = teas.GetTea(0).Description;
            tbCost.Text          = string.Format("${0:0.00}", teas.GetTea(0).Cost);

            //enable button when your checkoutlist is bigger than 0
            if (StaticCheckOutList.Count() != 0)
            {
                btnProccedToCheckOut.IsEnabled = true;
            }

            //load combo box
            lvCheckOut.ItemsSource = StaticCheckOutList.GetList();
        }
예제 #2
0
 private void CheckOutOnClick(object sender, RoutedEventArgs e)
 {
     //disable button if the user isn't set and checkoutlist isn't set
     if (StaticUser.FirstName != null && StaticCheckOutList.Count() != 0)
     {
         Main.Content = new Checkout();
     }
 }
        public Checkout()
        {
            DataContext = this;
            InitializeComponent();

            //load items into list view from static object
            lvCheckOut.ItemsSource = StaticCheckOutList.GetList();
            for (var i = 0; i < StaticCheckOutList.Count(); ++i)
            {
                subtotal += StaticCheckOutList.GetByIndex(i).ProductTotal;
            }

            //load sub-total tax and grand total
            tbSubTotal.Text = string.Format("${0:0.00}", subtotal);
            tbTax.Text      = string.Format("${0:0.00}", (subtotal * 0.13));
            tbTotal.Text    = string.Format("${0:0.00}", (subtotal * 1.13));

            //set mail address from static user
            tbMailAddress.Text = StaticUser.Address;
        }
        private void UpdateOnClick(object sender, RoutedEventArgs e)
        {
            if (tbChangeQty.Text != "")
            {
                // if the user types a letter or anything else don't crash
                bool isNumeric = int.TryParse(tbChangeQty.Text, out int n);
                if (isNumeric)
                {
                    //if user puts number 0 or negative
                    if (Convert.ToInt32(tbChangeQty.Text) <= 0)
                    {
                        StaticCheckOutList.EditQty(listViewIndex, 0);
                    }
                    else
                    {
                        StaticCheckOutList.EditQty(listViewIndex, Convert.ToInt32(tbChangeQty.Text));
                    }
                    lvCheckOut.Items.Refresh();

                    //load sub-total tax and grand total
                    subtotal = 0;
                    for (var i = 0; i < StaticCheckOutList.Count(); ++i)
                    {
                        subtotal += StaticCheckOutList.GetByIndex(i).ProductTotal;
                    }
                    tbSubTotal.Text = string.Format("${0:0.00}", subtotal);
                    tbTax.Text      = string.Format("${0:0.00}", (subtotal * 0.13));
                    tbTotal.Text    = string.Format("${0:0.00}", (subtotal * 1.13));
                }
                else
                {
                    // show the user the error
                    tbProductName.Text = "Not a number";
                }
            }
        }