private void EditBook() { var item = BookDataGrid.SelectedItem as BookDataGridItem; if (item == null) { MessageBox.Show("Select a book for editation.", "Book Manager - Notice", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } // We Reload here to make sure, that we get, what is in the DB. var entity = Registry.Get <BookDataLayer>().Reload(item.Id); if (entity == null) { MessageBox.Show("The selected book can not be read for editation.", "Book Manager - Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (BookEditorWindow.Open(Gdo, entity)) { Registry.Get <BookDataLayer>().Save(entity); Update(); } }
private void DeleteBook() { if (BookDataGrid.SelectedItems.Count == 0) { MessageBox.Show(this, "No book is selected.", "Book Manager - Notice", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (MessageBox.Show(this, "Delete selected books?", "Book Manager - Delete Books", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var dal = Registry.Get <BookDataLayer>(); foreach (var item in BookDataGrid.SelectedItems) { var entity = Registry.Get <BookDataLayer>().Get((item as BookDataGridItem).Id); if (entity == null) { continue; } dal.Delete(entity); } Update(); } }
private void AddBook() { var obj = new Book(); if (BookEditorWindow.Open(Gdo, obj)) { Registry.Get <BookDataLayer>().Save(obj); Update(); } }
public MainForm() { _gdo = new GlobalDataObject(); InitializeComponent(); Load += MainWindow_Load; Closing += MainWindow_Closing; Registry.RegisterInstance(this); //BookAuthorComboBox.ItemsSource = Gdo.UpdateBookAuthorCollection(); //BookPlacementComboBox.ItemsSource = Gdo.UpdateBookPlacementCollection(); }
public MainWindow() { _gdo = new GlobalDataObject(); InitializeComponent(); SourceInitialized += MainWindow_SourceInitiated; Loaded += MainWindow_Loaded; Closing += MainWindow_Closing; Registry.RegisterInstance(this); if (!UIHelper.DesignMode) { BookAuthorComboBox.ItemsSource = Gdo.UpdateBookAuthorCollection(); BookPlacementComboBox.ItemsSource = Gdo.UpdateBookPlacementCollection(); } }