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(); } }