Esempio n. 1
0
 public static void UpdateBookAuthorCollection(DispatcherObject dob, GlobalDataObject gdo)
 {
     dob.InvokeIfRequired(() =>
     {
         gdo.UpdateBookAuthorCollection();
     }, DispatcherPriority.Render);
 }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
        public LookupsEditorWindow(GlobalDataObject gdo)
        {
            if (gdo == null)
            {
                throw new ArgumentNullException("gdo");
            }

            _gdo = gdo;

            InitializeComponent();

            Loaded += Window_Loaded;
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        public MainForm()
        {
            _gdo = new GlobalDataObject();

            InitializeComponent();

            Load    += MainWindow_Load;
            Closing += MainWindow_Closing;

            Registry.RegisterInstance(this);

            //BookAuthorComboBox.ItemsSource = Gdo.UpdateBookAuthorCollection();
            //BookPlacementComboBox.ItemsSource = Gdo.UpdateBookPlacementCollection();
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
        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();
            }
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
 public static void DeleteBookAuthor(Window owner, DataGrid dataGrid, GlobalDataObject gdo)
 {
     DeleteSelectedItems <BookAuthor>(owner, dataGrid, gdo, gdo.DeleteBookAuthor, UpdateBookAuthorCollection);
 }
Esempio n. 12
0
 public static void DeleteBookPlacement(Window owner, DataGrid dataGrid, GlobalDataObject gdo)
 {
     DeleteSelectedItems <BookPlacement>(owner, dataGrid, gdo, gdo.DeleteBookPlacement, UpdateBookPlacementCollection);
 }
Esempio n. 13
0
 public static void DeleteBookGenre(Window owner, DataGrid dataGrid, GlobalDataObject gdo)
 {
     DeleteSelectedItems <BookGenre>(owner, dataGrid, gdo, gdo.DeleteBookGenre, UpdateBookGenreCollection);
 }
Esempio n. 14
0
 public static void DeleteBookCategory(Window owner, DataGrid dataGrid, GlobalDataObject gdo)
 {
     DeleteSelectedItems <BookCategory>(owner, dataGrid, gdo, gdo.DeleteBookCategory, UpdateBookCategoryCollection);
 }