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"); } }
public List<Category> SelectAll() { try { List<Category> oCategoryList = new List<Category>(); Category oCategory = new Category(); oCategory.Id = 1; oCategory.name = "Engine"; oCategoryList.Add(oCategory); oCategory = new Category(); oCategory.Id = 2; oCategory.name = "Break"; oCategoryList.Add(oCategory); oCategory = new Category(); oCategory.Id = 3; oCategory.name = "Suspension"; oCategoryList.Add(oCategory); return oCategoryList; } catch (Exception) { throw; } }
public ucAddEditCategory(Category oCategory, bool isEdit) { InitializeComponent(); try { this.oCategory = oCategory; this.isEdit = isEdit; if (isEdit) { InitializeWindow(); } } catch (Exception) { MessageBox.Show("Can not initialize add edit Category"); } }