コード例 #1
0
        //Retrieves seleceted Dessert to be added to the total order list
        private void dessertCbBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            StoreGoods_Desserts selectedItem = null;

            selectedItem = (StoreGoods_Desserts)dessertCbBox.SelectedItem;
            newItem      = new StoreGoods();


            if (selectedItem != null && !refreshOrderList(false, selectedItem.DessertName, true))
            {
                newItem.PurchaseName     = selectedItem.DessertName;
                newItem.PurchaseCategory = selectedItem.DessertCategory;
                newItem.PurchasePrice    = selectedItem.DessertPrice;
                newItem.Quantity         = 1;

                newItemList.Add(newItem);
                BillCalculatorXMAL.Items.Add(newItem);
            }
            else if (selectedItem != null)
            {
                refreshOrderList(true, selectedItem.DessertName, false);
            }
            //Clear Combobox
            dessertCbBox.SelectedIndex = -1;
        }
コード例 #2
0
 //When Remove Button Is clicked
 void RemoveRow(object sender, RoutedEventArgs e)
 {
     for (var vis = sender as Visual; vis != null; vis = VisualTreeHelper.GetParent(vis) as Visual)
     {
         if (vis is DataGridRow)
         {
             var row = (DataGridRow)vis;
             if (row.IsSelected == true)
             {
                 StoreGoods selectedForDelete = (StoreGoods)row.Item;
                 refreshOrderList(false, selectedForDelete.PurchaseName, false);
             }
         }
     }
 }
コード例 #3
0
        //Caluclates total by adding all the orders which were passed and added  to the list
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            double total = 0;

            foreach (StoreGoods items in newItemList)
            {
                total += items.PurchasePrice * items.Quantity;
            }

            StoreGoods finalOrder = new StoreGoods();

            subtotalTxt.Text   = "$" + total.ToString();
            taxTxt.Text        = finalOrder.calculateTax(total).ToString();
            grandTotalTxt.Text = finalOrder.calculateGrandTotal(total).ToString();
        }