Ejemplo n.º 1
0
 private void LvCheckOut_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     //display values to user
     listViewIndex      = lvCheckOut.SelectedIndex;
     tbProductName.Text = StaticCheckOutList.GetByIndex(listViewIndex).ProductName;
     tbChangeQty.Text   = StaticCheckOutList.GetByIndex(listViewIndex).Quntity.ToString();
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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";
                }
            }
        }