Пример #1
0
 public void addItemBtn_Click(object sender, RoutedEventArgs e)
 {
     if (newItemNameTextBox.Text == "" || newItemPriceTextBox.Text == "" || newItemQuantityTextBox.Text == "" || newItemIdTextBox.Text == "" || newItemTypeComboBox.SelectedIndex < 0)
     {
         MessageBox.Show("One or more boxes are left unfilled!");
     }
     else
     {
         string tempType = newItemTypeComboBox.SelectedValue.ToString();
         tempType = tempType.Replace("System.Windows.Controls.ComboBoxItem: ", "");
         invItem tempItem = new invItem();
         tempItem.invName     = newItemNameTextBox.Text;
         tempItem.invId       = Convert.ToInt32(newItemIdTextBox.Text);
         tempItem.invQuantity = Convert.ToInt32(newItemQuantityTextBox.Text);
         tempItem.invType     = tempType;
         tempItem.invPrice    = Convert.ToDouble(newItemPriceTextBox.Text);
         tempItem.invStrPrice = "$" + tempItem.invPrice.ToString();
         if (checkForDuplicate(tempItem, listOfInv) == true)
         {
             MessageBox.Show("ItemName and/or Id Already Used");
         }
         else
         {
             MessageBox.Show(tempItem.invName + " has been added to the inventory with the id " + tempItem.invId.ToString());
             listOfInv.Add(tempItem);
             listOfInv = listOfInv.OrderBy(invItem => invItem.invId).ToList();
             CollectionViewSource.GetDefaultView(invList.ItemsSource).Refresh();
             clearAddItemPanel();
         }
     }
 }
Пример #2
0
        public void invListCart_dClick(object sender, MouseButtonEventArgs e)
        {
            if (employee == true)
            {
                foreach (invItem tempItem in cartList.SelectedItems)
                {
                    runningTotal         -= tempItem.invPrice;
                    totalLabel.Content    = "Total: $" + runningTotal.ToString();
                    taxTotalLabel.Content = "Total+Tax: $" + Math.Round(taxRateMult * runningTotal, 2);
                    invItem listItem = new invItem();
                    listItem              = getItemFromInv(tempItem, listOfInv);
                    listItem.invQuantity += 1;
                }


                int index = cartList.Items.IndexOf(cartList.SelectedItem);
                cartList.ItemsSource = null;
                listOfCartItems.Remove(listOfCartItems[index]);
                cartList.ItemsSource = listOfCartItems;
            }
            else
            {
                MessageBox.Show("You need elevated access to remove an item!");
            }
            if (listOfCartItems.Count == 0)
            {
                CheckoutBtn.IsEnabled = false;
            }
        }
Пример #3
0
 public void addItemtoCart(ListView listViewName)
 {
     CheckoutBtn.IsEnabled = true;
     foreach (invItem listItem in listViewName.SelectedItems)
     {
         invItem tempItem = new invItem();
         tempItem = getItemFromInv(listItem, listOfInv);
         if (tempItem.invQuantity == 0)
         {
             MessageBox.Show("We are all out of " + tempItem.invName);
         }
         else
         {
             listOfCartItems.Add(listItem);
             CollectionViewSource.GetDefaultView(cartList.ItemsSource).Refresh();
             runningTotal         += listItem.invPrice;
             runningTotal          = Math.Round(runningTotal, 2);
             taxedRunningTotal     = taxRateMult * runningTotal;
             taxedRunningTotal     = Math.Round(taxedRunningTotal, 2);
             totalLabel.Content    = "Total: $" + runningTotal.ToString();
             taxTotalLabel.Content = "Total+Tax: $" + taxedRunningTotal.ToString();
             tempItem.invQuantity -= 1;
         }
     }
 }
Пример #4
0
 public invItem getItemFromInv(invItem selectedItem, List <invItem> selectedList)
 {
     foreach (invItem tempItem in selectedList)
     {
         if (tempItem.invId == selectedItem.invId)
         {
             return(tempItem);
         }
     }
     return(selectedItem);
 }
Пример #5
0
 public bool checkForDuplicate(invItem tempItem, List <invItem> tempList)
 {
     foreach (invItem listItem in tempList)
     {
         if (tempItem.invId == listItem.invId)
         {
             return(true);
         }
         if (tempItem.invName == listItem.invName)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #6
0
        // <summary>
        // This cs file is mainly responsible for the backend behind the implementation of the inventory
        //    (1) getInventory:        Main function that is responsible for building the base inventory
        //         1. Open up the inventory file in the debug folder
        //         2. Parse through the data
        //         3. Create and invItem that gets added to the total list of Inventory
        //    (2) getCategories:       helper functon that is responsible for building the subcategory lists
        //         1.  Clears out the previous lists just in case
        //         2.  Scans through the listOfInv and makes a copy of each item and determines which categorical list to put it into
        //    (3) printCategories:     Helper function that calls printList for all the categories
        //    (4) printList:           Main function that prints the entire contents of a categoryList into the Console
        //    (5) updateInventory:     Called after every checkout, this main function allows the inventory to be ready for the next checkout
        //         1.  Creates a new file of the inventory and sets it as the default for the next update to the inventory
        //         2.  Gets the current date and adds it to the file
        // </summary>
        public void getInventory(string filename)
        {
            listOfInv.Clear();
            string       line;
            StreamReader file = new StreamReader(currDir + "/" + filename);

            while ((line = file.ReadLine()) != null)
            {
                string[] words    = line.Split(',');
                invItem  tempItem = new invItem();
                tempItem.invName     = words[0];
                tempItem.invType     = words[1];
                tempItem.invId       = Convert.ToInt32(words[2]);
                tempItem.invQuantity = Convert.ToInt32(words[3]);
                tempItem.invPrice    = Convert.ToDouble(words[4]);
                tempItem.invStrPrice = "$" + Convert.ToString(words[4]);
                listOfInv.Add(tempItem);
            }
        }