private void Update_Home(object sender, RoutedEventArgs e)
        {
            // Update the inventory list with the new stock
            inventoryList[itemIndex] = tempInventoryItem;
            // Calculate the new percentage based on the new stock
            InventoryList.PercentageFillerSingle(inventoryList, itemIndex);
            // reset the global item index
            Global.SetIndex(-1);

            using (SQLiteConnection conn = new SQLiteConnection(App.databasePath))
            {
                conn.CreateTable <Inventory>();

                Inventory m = (from p in conn.Table <Inventory>()
                               where p.Product == ProductNameTextBlock.Text
                               select p).FirstOrDefault();
                if (m != null)
                {
                    m.Actual = Convert.ToInt32(UpdateIdealTextBox.Text);
                    conn.Update(m);
                }
            }

            // create a new instance of the main window
            Window mainWindow = new MainWindow();

            // Show the new instance of the main window
            mainWindow.Show();
            // Close the instance of the iterative update window
            this.Close();
        }
Exemple #2
0
        private void Submit_button(object sender, RoutedEventArgs e)
        {
            inventoryList[itemIndex] = tempInventoryItem;
            InventoryList.PercentageFillerSingle(inventoryList, itemIndex);
            Window mainWindow = new MainWindow();

            mainWindow.Show();
            this.Close();
        }
        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();
        }
Exemple #4
0
        // logic for pushing any changes through to the inventory list
        private void Submit_button(object sender, RoutedEventArgs e)
        {
            /*
             *   Data Validation on the text boxes
             *
             *       true => modify file
             *       false => invalidEntry window
             */

            // checks all the fields in the textboxes using validation inside of the global class
            if (Global.IsValid(EditItemNameBox.Text, EditItemCurrentStockBox.Text, EditItemIdealStockBox.Text))
            {
                // replaces the row with in the inventory list with the modified inventory item using the global itemIndex
                inventoryList[itemIndex] = tempInventoryItem;
                // calclulates the percentage by sending the inventorylist and index of the row
                InventoryList.PercentageFillerSingle(inventoryList, itemIndex);

                using (SQLiteConnection conn = new SQLiteConnection(App.databasePath))
                {
                    conn.CreateTable <Inventory>();

                    Inventory m = (from p in conn.Table <Inventory>()
                                   where p.Product == EditItemNameBox.Text
                                   select p).FirstOrDefault();
                    if (m != null)
                    {
                        m.Product = EditItemNameBox.Text;
                        m.Actual  = Convert.ToInt32(EditItemCurrentStockBox.Text);
                        m.Ideal   = Convert.ToInt32(EditItemIdealStockBox.Text);
                        conn.Update(m);
                    }
                }

                // sorts the newly edited inventory list to ensure items are in descending alphabetical order
                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 edit 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();
            }
        }
        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();
            }
        }
        private void Update_Next(object sender, RoutedEventArgs e)
        {
            // Stores the inventory
            inventoryList[itemIndex] = tempInventoryItem;
            InventoryList.PercentageFillerSingle(inventoryList, itemIndex);
            // Increments to the next item in the inventory list
            itemIndex++;

            // If we're at the end of the inventory list
            if (itemIndex > inventoryList.Count - 1) // greater than total number of items in list, then at end of list
            {
                // reset the global item index
                Global.SetIndex(-1);

                using (SQLiteConnection conn = new SQLiteConnection(App.databasePath))
                {
                    conn.CreateTable <Inventory>();

                    Inventory m = (from p in conn.Table <Inventory>()
                                   where p.Product == ProductNameTextBlock.Text
                                   select p).FirstOrDefault();
                    if (m != null)
                    {
                        m.Actual = Convert.ToInt32(UpdateIdealTextBox.Text);
                        conn.Update(m);
                        //Console.WriteLine("This ran");
                    }
                }

                // create a new instance of the main window
                Window mainWindow = new MainWindow();
                // show the instance of the main window
                mainWindow.Show();
                // close the full iterative update window
                this.Close();
            }
            // if we're not at the end yet
            else
            {
                // set the global item index to the incremented index
                Global.SetIndex(itemIndex);

                using (SQLiteConnection conn = new SQLiteConnection(App.databasePath))
                {
                    conn.CreateTable <Inventory>();

                    Inventory m = (from p in conn.Table <Inventory>()
                                   where p.Product == ProductNameTextBlock.Text
                                   select p).FirstOrDefault();
                    if (m != null)
                    {
                        m.Actual = Convert.ToInt32(UpdateIdealTextBox.Text);
                        conn.Update(m);
                    }
                }

                // create a new instance of the iterative update window
                Window iterativeUpdateWindow = new Iterative_Update_Window();
                // show the instance of the iterative update window
                iterativeUpdateWindow.Show();
                // close the previous instance of the iterative update window
                this.Close();
            }
        }