private void btnAdd_Click(object sender, RoutedEventArgs e) { try { Category oCategory= new Category(); ucAddEditCategory oucAddEditCategory = new ucAddEditCategory(oCategory, false); winDialog oDialog = new winDialog(oucAddEditCategory) { ShowInTaskbar = true, WindowTitle = "Add a new Category", Height = 170, Width = 500 }; oDialog.ShowDialog(); UpdateDataGrid(); } catch (Exception) { MessageBox.Show("Can not open window to add category"); } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { try { if (dtgCategories.SelectedItem != null) { Category oCategory = dtgCategories.SelectedItem as Category; ucAddEditCategory oucAddEditCategory = new ucAddEditCategory(oCategory, true); winDialog oDialog = new winDialog(oucAddEditCategory) { ShowInTaskbar = true, WindowTitle = "Edit Category", Height = 170, Width = 500 }; oDialog.ShowDialog(); UpdateDataGrid(); } else { MessageBox.Show("Please select a category from grid"); } } catch (Exception) { MessageBox.Show("Can not open window to edit category"); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { Category oCategory = new Category(); ucAddEditCategory oucAddEditCategory = new ucAddEditCategory(oCategory, false); winDialog oDialog = new winDialog(oucAddEditCategory) { ShowInTaskbar = true, WindowTitle = "Add a new Category", Height = 170, Width = 500 }; oDialog.ShowDialog(); UpdateDataGrid(); } catch (Exception) { MessageBox.Show("Can not open window to add category"); } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { try { if (dtgCategories.SelectedItem != null) { Category oCategory = dtgCategories.SelectedItem as Category; ucAddEditCategory oucAddEditCategory = new ucAddEditCategory(oCategory, true); winDialog oDialog = new winDialog(oucAddEditCategory) { ShowInTaskbar = true, WindowTitle = "Edit Category", Height = 170, Width = 500 }; oDialog.ShowDialog(); UpdateDataGrid(); } else MessageBox.Show("Please select a category from grid"); } catch (Exception) { MessageBox.Show("Can not open window to edit category"); } }