Exemplo n.º 1
0
        private void btnPublishers_Click(object sender, RoutedEventArgs e)
        {
            GUIServices.SetBusyState();
            var publishersWindow = new PublishersWindow(_publishersManager);

            publishersWindow.ShowDialog();
        }
Exemplo n.º 2
0
        private void btnEmployees_Click(object sender, RoutedEventArgs e)
        {
            GUIServices.SetBusyState();
            var employeesWindow = new EmployeesWindow(_employeesManager);

            employeesWindow.ShowDialog();
        }
Exemplo n.º 3
0
        private void InitFiltersData()
        {
            cboISBNPrefixFilter.ItemsSource =
                Enum.GetValues(typeof(ISBN_Prefix)).Cast <short>().ToList();

            GUIServices.SetListControlBinding(
                lstCategoriesFilter,
                CategoriesRepository.Categories.Keys.ToList(),
                comparer: new NaturalStringComparer()
                );

            SetSubCategoriesListBinding();

            GUIServices.SetListControlBinding(
                lstPublishersFilter,
                new EntityManager <Publisher>().Search(),
                comparer: new NaturalStringComparer()
                );

            GUIServices.SetListControlBinding(
                lstAuthorsFilter,
                new EntityManager <LibraryItem>().Search <Book>()
                .Select(b => (b as Book).Author).Distinct().ToList(),
                comparer: new NaturalStringComparer()
                );
        }
Exemplo n.º 4
0
 private void btnGenerateDemoData_Click(object sender, RoutedEventArgs e)
 {
     GUIServices.SetBusyState();
     GenerateDemoData();
     SearchByTitle();    // Fill datagrid with generated data
     btnGenerateDemoData.Visibility = Visibility.Collapsed;
 }
Exemplo n.º 5
0
        private void InitFiltersData()
        {
            ResetFilters();

            if (Entities == null)
            {
                return;
            }

            cboISBNPrefixFilter.ItemsSource = Entities?.Select(i => (short)i.ISBN.Prefix).Distinct();

            GUIServices.SetListControlBinding(
                lstCategoriesFilter,
                Entities?.Select(i => i.Category).Distinct().ToList(),
                comparer: new NaturalStringComparer()
                );

            SetSubCategoriesListBinding();

            GUIServices.SetListControlBinding(
                lstPublishersFilter,
                Entities.Select(i => i.PublisherID != null ?
                                _publishersManager[i.PublisherID] : Publisher.Empty)
                .Distinct().ToList(),
                comparer: new NaturalStringComparer()
                );

            GUIServices.SetListControlBinding(
                lstAuthorsFilter,
                Entities?.Where(i => i.GetType() == typeof(Book))
                .Select(i => (i as Book).Author).Distinct().ToList(),
                comparer: new NaturalStringComparer()
                );
        }
Exemplo n.º 6
0
        private void InitCombos()
        {
            cboISBNPrefix.ItemsSource =
                Enum.GetValues(typeof(ISBN_Prefix)).Cast <short>().ToList();

            GUIServices.SetListControlBinding(
                cboSubCategories,
                new List <Enum>(),
                comparer: new NaturalStringComparer()
                );

            GUIServices.SetListControlBinding(
                cboCategories,
                CategoriesRepository.Categories.Keys.ToList(),
                comparer: new NaturalStringComparer()
                );

            GUIServices.SetListControlBinding(
                cboPublishers,
                new EntityManager <Publisher>().Search(),
                comparer: new NaturalStringComparer()
                );

            GUIServices.SetListControlBinding(
                cboAuthors,
                _authorsList,
                comparer: new NaturalStringComparer()
                );

            cboAuthors.Text             = (_entity as Book)?.Author ?? "";
            cboPublishers.SelectedValue = _entity?.PublisherID;
        }
Exemplo n.º 7
0
        private void btnCopies_Click(object sender, RoutedEventArgs e)
        {
            GUIServices.SetBusyState();
            var itemWindow = new ItemCopiesWindow(_entity, _entitiesManager.CurrentUser);

            itemWindow.ShowDialog();
        }
Exemplo n.º 8
0
        private void btnUsers_Click(object sender, RoutedEventArgs e)
        {
            GUIServices.SetBusyState();
            var usersWindow = new UsersWindow(_usersManager);

            usersWindow.ShowDialog();
        }
Exemplo n.º 9
0
        private void InitCombos()
        {
            cboEmployees.ItemsSource = _employees.OrderBy(e => e.EmployeeID).ToList();

            GUIServices.SetListControlBinding(
                cboUserTypes,
                Enum.GetValues(typeof(UserType)),
                comparer: new NaturalStringComparer()
                );
        }
Exemplo n.º 10
0
        protected virtual bool Save()
        {
            GUIServices.SetBusyState();

            if (!IsValid())
            {
                DisplayValidationMessage();
                return(false);
            }

            return(true);
        }
Exemplo n.º 11
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            GUIServices.SetBusyState();

            SaveDeletedCopies();
            SaveNewAndUpdatedCopies();

            btnSave.IsEnabled          = false;
            lblBorrowedVsTotal.Content = BorrowedVsTotal;

            dgCopies.Items.Refresh();
            MainWindow.RefreshView();
        }
Exemplo n.º 12
0
        private void SearchByTitle(string title = null)
        {
            GUIServices.SetBusyState();

            if (string.IsNullOrEmpty(title))
            {
                Items = EntitiesManager.Search();
            }
            else
            {
                Items = EntitiesManager.Search(i => i.Title.ToLower().Contains(title.ToLower()));
            }
        }
Exemplo n.º 13
0
        private List <LibraryItem> Search()
        {
            GUIServices.SetBusyState();

            return(_itemsManager.Search(new Predicate <LibraryItem>(i =>
            {
                var item = i as LibraryItem;

                return
                (cboISBNPrefixFilter.SelectedIndex != -1 ?
                 item.ISBN.Prefix == (ISBN_Prefix)cboISBNPrefixFilter.SelectedValue : true) &&
                (cboISBNGroupFilter.SelectedIndex != -1 ?
                 item.ISBN.GroupIdentifier == (int)cboISBNGroupFilter.SelectedItem : true) &&
                (txtISBNPublisherFilter.Text != string.Empty ?
                 item.ISBN.PublisherCode.Contains(txtISBNPublisherFilter.Text) : true) &&
                (txtISBNCatalogueFilter.Text != string.Empty ?
                 item.ISBN.CatalogueNumber.Contains(txtISBNCatalogueFilter.Text) : true) &&
                (txtTitle.Text != string.Empty ?
                 item.Title.ToLower().Contains(txtTitle.Text.ToLower()) : true) &&
                (lstCategoriesFilter.SelectedItems.Count > 0 ?
                 lstCategoriesFilter.SelectedItems.Contains(item.Category) : true) &&
                (lstSubCategoriesFilter.SelectedItems.Count > 0 ?
                 lstSubCategoriesFilter.SelectedItems.Cast <KeyValuePair <Enum, Enum> >()
                 .Any(kv => item.SubCategory == null ?
                      kv.Value.Equals(EMPTY_ENUM._Empty_) :
                      kv.Key.Equals(item.Category) && kv.Value.Equals(item.SubCategory)) : true) &&
                (lstPublishersFilter.SelectedItems.Count > 0 ?
                 lstPublishersFilter.SelectedItems.Cast <Publisher>()
                 .Any(p => p.PublisherID == item.PublisherID) : true) &&
                (txtGraphicDesigner.Text != string.Empty ?
                 item.GraphicDesigner?.ToLower().Contains(txtGraphicDesigner.Text.ToLower()) ?? false : true) &&
                (optTypeBook.IsChecked.GetValueOrDefault() ?
                 (item.GetType() == typeof(Book) ?
                  (lstAuthorsFilter.SelectedItems.Count > 0 ?
                   lstAuthorsFilter.SelectedItems.Contains((item as Book).Author) : true) &&
                  (txtEdition.Text != string.Empty ?
                   (item as Book).Edition?.Contains(txtEdition.Text) ?? false : true) &&
                  (txtTranslator.Text != string.Empty ?
                   (item as Book).Translator?.Contains(txtTranslator.Text) ?? false : true)
                        : false) : (optTypeJournal.IsChecked.GetValueOrDefault() ?
                                    (item.GetType() == typeof(Journal) ?
                                     (txtEditor.Text != string.Empty ?
                                      (item as Journal).Editor?.Contains(txtEditor.Text) ?? false : true)
                            : false)
                        : true)) &&
                (dtPrintDateFromFilter.SelectedDate != null ?
                 item.PrintDate >= dtPrintDateFromFilter.SelectedDate : true) &&
                (dtPrintDateToFilter.SelectedDate != null ?
                 item.PrintDate <= dtPrintDateToFilter.SelectedDate : true);
            })));
        }
Exemplo n.º 14
0
        private void HandleDatePickerFilterChange(DatePicker datePicker,
                                                  FilterEventHandler filter, FilterType filterType, SelectionChangedEventArgs e)
        {
            GUIServices.SetBusyState();

            if (e.RemovedItems.Count == 0)
            {
                AddFilter(filter, filterType);
                return;
            }

            if (datePicker.SelectedDate == null)
            {
                RemoveFilter(filterType);
            }

            RefreshView();
        }
Exemplo n.º 15
0
        private void HandleListBoxFilterChange(ListBox listBox,
                                               FilterEventHandler filter, FilterType filterType, SelectionChangedEventArgs e)
        {
            GUIServices.SetBusyState();

            if (listBox.SelectedItems.Count == 1 && e.AddedItems.Count == 1)
            {
                AddFilter(filter, filterType);
                return;
            }

            if (listBox.SelectedItems.Count == 0)
            {
                RemoveFilter(filterType);
            }

            RefreshView();
        }
Exemplo n.º 16
0
        private void HandleComboBoxFilterChange(ComboBox comboBox,
                                                FilterEventHandler filter, FilterType filterType, SelectionChangedEventArgs e)
        {
            GUIServices.SetBusyState();

            if (e.RemovedItems.Count == 0)
            {
                AddFilter(filter, filterType);
                return;
            }

            if (comboBox.SelectedIndex == -1)
            {
                RemoveFilter(filterType);
            }

            RefreshView();
        }
Exemplo n.º 17
0
        private static void HandleCustomSorting(object sender, DataGridSortingEventArgs e)
        {
            GUIServices.SetBusyState();

            IComparer sorter = GetSorter(e.Column);

            if (sorter == null)
            {
                return;
            }

            var grid = (DataGrid)sender;

            e.Column.SortDirection = e.Column.SortDirection == ListSortDirection.Ascending ?
                                     ListSortDirection.Descending : ListSortDirection.Ascending;
            if (ApplySort(grid, e.Column))
            {
                e.Handled = true;
            }
        }
Exemplo n.º 18
0
        private void HandleTextBoxFilterChange(
            TextBox textBox, FilterEventHandler filter, FilterType filterType)
        {
            GUIServices.SetBusyState();

            if (!_textFilters.Contains(filterType))
            {
                AddFilter(filter, filterType);
                _textFilters.Add(filterType);
                return;
            }

            if (textBox.Text == string.Empty)
            {
                RemoveFilter(filterType);
                _textFilters.Remove(filterType);
            }

            RefreshView();
        }
Exemplo n.º 19
0
        private void SetSubCategoriesListBinding()
        {
            IEnumerable <KeyValuePair <Enum, Enum> > items;

            if (lstCategoriesFilter.SelectedItems.Count > 0)
            {
                items = CategoriesRepository.GetSubCategoriesAsKeyValuePairs(lstCategoriesFilter.SelectedItems.Cast <Enum>())
                        .Select(i => i.Value != null ? i : new KeyValuePair <Enum, Enum>(i.Key, EMPTY_ENUM._Empty_));
            }
            else
            {
                items = CategoriesRepository.GetSubCategoriesAsKeyValuePairs()
                        .Select(i => i.Value != null ? i : new KeyValuePair <Enum, Enum>(i.Key, EMPTY_ENUM._Empty_));
            }

            GUIServices.SetListControlBinding(
                lstSubCategoriesFilter,
                items.Distinct().ToList(),
                comparer: new EnumKeyValueComparer()
                );
        }
Exemplo n.º 20
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            var loginWindow = new LoginWindow();

            loginWindow.ShowDialog();

            if (loginWindow.IsLoginRequest)
            {
                GUIServices.SetBusyState();

                CurrentUser = loginWindow.CurrentUser;

                if (CurrentUser != null)
                {
                    InitEntities(new ItemsManager(CurrentUser));
                    InitEntitiesManagers(CurrentUser);
                    InitUI();
                    InitUIData();
                }
            }
        }
Exemplo n.º 21
0
        private void SetSubCategoriesListBinding()
        {
            IEnumerable <KeyValuePair <Enum, Enum> > items;

            if (lstCategoriesFilter.SelectedItems.Count > 0)
            {
                items = Entities.Where(i => lstCategoriesFilter.SelectedItems.Contains(i.Category))
                        .Select(i =>
                                new KeyValuePair <Enum, Enum>(i.Category, i.SubCategory ?? EMPTY_ENUM._Empty_));
            }
            else
            {
                items = Entities.Select(i =>
                                        new KeyValuePair <Enum, Enum>(i.Category, i.SubCategory ?? EMPTY_ENUM._Empty_));
            }

            GUIServices.SetListControlBinding(
                lstSubCategoriesFilter,
                items.Distinct().ToList(),
                comparer: new EnumKeyValueComparer()
                );
        }