/// <summary> /// Edit a product group /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChange_Click(object sender, RoutedEventArgs e) { // Make sure the sure the user has selected an item in the listview if (lvProductGroups.SelectedItem == null) { MessageBox.Show("Markera en produktgrupp att ändra", "Ingen produktgrupp vald"); return; } // Initilize a new window for editing a group ProductGroupCategory pgc = new ProductGroupCategory(SelectedProductGroup); // Show the window pgc.ShowDialog(); // If the users presses OK, update the item if (pgc.DialogResult == true) { // Update the database context ProductGroupManagement.Instance.UpdateProductGroup(); } else { // The user pressed cancel, revert changes ProductGroupManagement.Instance.ResetProductGroup(SelectedProductGroup); } }
/// <summary> /// Add a new product group /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, RoutedEventArgs e) { // Initilize a new window for adding a new account ProductGroupCategory pgc = new ProductGroupCategory(true); // Show the window pgc.ShowDialog(); // If the users presses OK, add the new user if (pgc.DialogResult.Equals(true)) { // Add the category to the database ProductGroupManagement.Instance.AddProductGroup(pgc.ProductGroup); } }