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(); }
private void Edit_Button(object sender, RoutedEventArgs e) { //int index = InventoryListing.SelectedIndex; //this gets the row #. Starts at 0 for top of list Global.SetIndex(InventoryListing.SelectedIndex); Window editItemWindow = new Edit_ItemWindow(); editItemWindow.Show(); this.Close(); }
private void Cancel_Button(object sender, RoutedEventArgs e) { // Reset the global item index Global.SetIndex(-1); // 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 interative update window this.Close(); }
// logic for the full inventory button private void Full_Inventory_Button(object sender, RoutedEventArgs e) { // Sets the global index to 0 so it can start at the beginning of the list Global.SetIndex(0); // Creates an instance of the iterative update window Window iterativeUpdateWindow = new Iterative_Update_Window(); // Shows the instance of the iterative update window iterativeUpdateWindow.Show(); // Closes the main window this.Close(); }
// logic for the edit button private void Edit_Button(object sender, RoutedEventArgs e) { // Sets a global variable to the index of the selected row Global.SetIndex(inventoryList[(InventoryItem)InventoryListing.SelectedItem]); // Creates an instance of the edit item window Window editItemWindow = new EditItem(); // Makes the instance visible editItemWindow.Show(); // Closes the current instance of the main window this.Close(); }
private void Add_Item_Button(object sender, RoutedEventArgs e) { ; //test methods for myself - nathan. feel free to delete //InventoryList.FillAdditionalSampleItems(inventoryList); //InventoryList.PercentageFillerAll(inventoryList); //int index = InventoryListing.SelectedIndex; //this gets the row #. Starts at 0 for top of list Global.SetIndex(InventoryListing.SelectedIndex); Window addItemWindow = new Window2(); addItemWindow.Show(); this.Close(); }
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(); } }