private void Submit_Add_Button(object sender, RoutedEventArgs e)
        {
            inventoryList.Add(tempInventoryItem);
            InventoryList.PercentageFillerSingle(inventoryList, inventoryList.Count - 1);
            Window mainWindow = new MainWindow();

            mainWindow.Show();
            this.Close();
        }
        private void Submit_Add_Button(object sender, RoutedEventArgs e)
        {
            /*
             *   Data Validation on the text boxes
             *
             *       true => add item
             *       false => invalidEntry window
             */

            if (Global.IsValid(AddItemNameBox.Text, AddItemCurrentStockBox.Text, AddItemIdealStockBox.Text))
            {
                // Uses add method from inventoryList class to add the data in textboxes to inventory list
                inventoryList.Add(tempInventoryItem);
                // Calculates the percentage for the new item added to the inventory
                InventoryList.PercentageFillerSingle(inventoryList, inventoryList.Count - 1);

                using (SQLiteConnection conn = new SQLiteConnection(App.databasePath))
                {
                    Inventory inventory = new Inventory()
                    {
                        Product = AddItemNameBox.Text,
                        Actual  = Convert.ToInt32(AddItemCurrentStockBox.Text),
                        Ideal   = Convert.ToInt32(AddItemIdealStockBox.Text)
                    };

                    conn.CreateTable <Inventory>();
                    conn.Insert(inventory);
                }

                // sorts the inventorylist again
                InventoryList.SortByItemName(inventoryList);
                // Creates a new instance of the main window
                Window mainWindow = new MainWindow();
                // Shows the new instance of the main window
                mainWindow.Show();
                // Closes the instance of the add item window
                this.Close();
            }
            else
            {
                // create an instance of the invalid entry window
                Window invalidEntry = new InvalidEntry();
                // show it, however the edit item window is not closed
                invalidEntry.Show();
            }
        }
        public static InventoryList FillInventoryListFromCSV()
        {
            InventoryList inList = new InventoryList();

            System.IO.DirectoryInfo myDirectory = new DirectoryInfo(Environment.CurrentDirectory);
            string gparent = myDirectory.Parent.Parent.FullName;

            gparent += "\\InventoryDatabase.csv";
            var reader = new StreamReader(@gparent);

            while (!reader.EndOfStream)
            {
                string   line = reader.ReadLine();
                string[] data = line.Split(',');

                inList.Add(new InventoryItem(data[0], Int32.Parse(data[1]), Int32.Parse(data[2])));
            }
            reader.Close();
            PercentageFillerAll(inList);

            return(inList);
        }
        public static InventoryList FillInventoryListFromSQL()
        {
            // creates an inventory list object
            InventoryList inList = new InventoryList();

            // sql reader object to get all the rows from the query
            using (SQLiteConnection conn = new SQLiteConnection(App.databasePath))
            {
                conn.CreateTable <Inventory>();

                foreach (Inventory item in conn.Table <Inventory>().ToList())
                {
                    inList.Add(new InventoryItem(item.Product, item.Actual, item.Ideal));
                }
            }

            // calculate the stock percentages for all the items in the inventory list
            PercentageFillerAll(inList);

            // Sorts by the item name!
            SortByItemName(inList);

            return(inList);
        }
 public static void FillAdditionalSampleItems(InventoryList inList)
 {
     inList.Add(new InventoryItem("Computer", 3, 5));
     inList.Add(new InventoryItem("Monitor", 2, 3));
     inList.Add(new InventoryItem("Keyboard", 3, 4));
 }