public static void UpdateBookAuthorCollection(DispatcherObject dob, GlobalDataObject gdo) { dob.InvokeIfRequired(() => { gdo.UpdateBookAuthorCollection(); }, DispatcherPriority.Render); }
private static void DeleteSelectedItems <T>(Window owner, DataGrid dataGrid, GlobalDataObject gdo, Action <T> deleteMethod, Action <DispatcherObject, GlobalDataObject> updateCollectionMethod) where T : class, IId, new() { if (dataGrid.SelectedItems.Count == 0) { MessageBox.Show(owner, "No item selected.", "Book Manager - Notice", MessageBoxButton.OK); return; } if (MessageBox.Show(owner, "Delete selected items?", "Book Manager - Items Deletion", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { foreach (var item in dataGrid.SelectedItems) { var entity = item as T; if (entity == null || entity.Id == 0) { MessageBox.Show("An item can not be deleted. Does not exists or has ID = 0.", "Book Manager - Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); continue; } deleteMethod(entity); } updateCollectionMethod(owner, gdo); } }
public static bool Open(GlobalDataObject gdo, Book dataObject) { if (gdo == null) { throw new ArgumentNullException("gdo"); } if (dataObject == null) { throw new ArgumentNullException("dataObject"); } var dialog = new BookEditorWindow(gdo) { DataContext = dataObject, Owner = Registry.Get <MainWindow>(), WindowStartupLocation = WindowStartupLocation.CenterOwner, Title = (dataObject.Id <= 0) ? "Book Manager - New Book" : String.Format("Book Manager - Book Edit {0}", dataObject.Id) }; dialog.LoadPreview(); dialog.ShowDialog(); return(dialog.DialogResult.GetValueOrDefault()); }
/// <summary> /// This is dangerous, but it should only be used to access the global object, which probably isn't necessary except on initialization /// It's up to the consumer to cast the returned value to the expected type /// </summary> /// <returns></returns> public object GlobalQuery(string fieldName) { object returnObj = new object(); GlobalDataObject foundRes = _globalC.Find(new BsonDocument()).FirstAsync().Result; returnObj = foundRes.GetType().GetField(fieldName).GetValue(foundRes); return(returnObj); }
public LookupsEditorWindow(GlobalDataObject gdo) { if (gdo == null) { throw new ArgumentNullException("gdo"); } _gdo = gdo; InitializeComponent(); Loaded += Window_Loaded; }
public void PushSolID(int ID) { if (_globalC.Find(Builders <GlobalDataObject> .Filter.Eq(g => g.Id, 0)).FirstOrDefaultAsync().Result != null) { GlobalDataObject g = new GlobalDataObject(); g.SolID = ID; _globalC.InsertOneAsync(g); } //Assuming there will only be one GlobalDataObject and it will always have an ID of 0 _globalC.FindOneAndUpdateAsync(Builders <GlobalDataObject> .Filter.Eq(g => g.Id, 0), Builders <GlobalDataObject> .Update.Set(g => g.SolID, ID)); }
public MainForm() { _gdo = new GlobalDataObject(); InitializeComponent(); Load += MainWindow_Load; Closing += MainWindow_Closing; Registry.RegisterInstance(this); //BookAuthorComboBox.ItemsSource = Gdo.UpdateBookAuthorCollection(); //BookPlacementComboBox.ItemsSource = Gdo.UpdateBookPlacementCollection(); }
public BookEditorWindow(GlobalDataObject gdo) { Gdo = gdo; InitializeComponent(); if (!UIHelper.DesignMode) { BookAuthorComboBox.ItemsSource = Gdo.UpdateBookAuthorCollection(); BookCategoryComboBox.ItemsSource = Gdo.UpdateBookCategoryCollection(); BookGenreComboBox.ItemsSource = Gdo.UpdateBookGenreCollection(); BookPublisherComboBox.ItemsSource = Gdo.UpdateBookPublisherCollection(); BookTypeComboBox.ItemsSource = Gdo.UpdateBookTypeCollection(); BookPlacementComboBox.ItemsSource = Gdo.UpdateBookPlacementCollection(); } DialogResultState = DialogResultStateType.Ok; }
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(); } }
public static BookCategory EditBookCategory(Window owner, GlobalDataObject gdo, object source, bool isNew = false, bool updateColection = true) { var entity = GetEntityForEditation <BookCategory>(owner, source, gdo.GetBookCategory, isNew); if (entity == null) { return(null); } if (BookCategoryEditorWindow.Open(entity)) { gdo.SaveBookCategory(entity); if (updateColection) { UpdateBookCategoryCollection(owner, gdo); } } return(entity); }
public static void DeleteBookAuthor(Window owner, DataGrid dataGrid, GlobalDataObject gdo) { DeleteSelectedItems <BookAuthor>(owner, dataGrid, gdo, gdo.DeleteBookAuthor, UpdateBookAuthorCollection); }
public static void DeleteBookPlacement(Window owner, DataGrid dataGrid, GlobalDataObject gdo) { DeleteSelectedItems <BookPlacement>(owner, dataGrid, gdo, gdo.DeleteBookPlacement, UpdateBookPlacementCollection); }
public static void DeleteBookGenre(Window owner, DataGrid dataGrid, GlobalDataObject gdo) { DeleteSelectedItems <BookGenre>(owner, dataGrid, gdo, gdo.DeleteBookGenre, UpdateBookGenreCollection); }
public static void DeleteBookCategory(Window owner, DataGrid dataGrid, GlobalDataObject gdo) { DeleteSelectedItems <BookCategory>(owner, dataGrid, gdo, gdo.DeleteBookCategory, UpdateBookCategoryCollection); }