예제 #1
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            ComboBoxItem selectedItem = (ComboBoxItem)TypeBox.SelectedItem;

            if (selectedItem.Content.ToString() == "Жанр")
            {
                BookGenre genre = (BookGenre)ListBox.SelectedItem; if (TextBox.Text != "")
                {
                    genre.Title = TextBox.Text;
                }
                else
                {
                    genre.Title = "N/A";
                }; main.GetGenreDB().Update(); MessageBox.Show("Жанр успешно изменен", "Успешно", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            if (selectedItem.Content.ToString() == "Тип")
            {
                MagazineType type = (MagazineType)ListBox.SelectedItem; if (TextBox.Text != "")
                {
                    type.Title = TextBox.Text;
                }
                else
                {
                    type.Title = "N/A";
                }; main.GetTypeDB().Update(); MessageBox.Show("Тип успешно изменен", "Успешно", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            Close();
        }
예제 #2
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            ComboBoxItem selectedItem = (ComboBoxItem)TypeBox.SelectedItem;

            if (selectedItem.Content.ToString() == "Жанр")
            {
                BookGenre genre = (BookGenre)ListBox.SelectedItem; main.GetGenreDB().Delete(genre.Id); MessageBox.Show("Жанр успешно удален", "Успешно удалено", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            if (selectedItem.Content.ToString() == "Тип")
            {
                MagazineType type = (MagazineType)ListBox.SelectedItem; main.GetTypeDB().Delete(type.Id); MessageBox.Show("Тип успешно удален", "Успешно удалено", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            Close();
        }
예제 #3
0
        public void LoadBookCombobox()
        {
            BookGenre AllMenu = new BookGenre {
                Title = "Все", Id = 99
            };

            AllList = new List <BookGenre>();
            AllList.Add(AllMenu);
            foreach (BookGenre item in GetGenreDB().Load())
            {
                AllList.Add(item);
            }
            GenreBox.ItemsSource = AllList;

            GenreBox.SelectedValuePath = "Id";
            GenreBox.DisplayMemberPath = "Title";
        }
예제 #4
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            switch (ChangeType())
            {
            case 1:
                BookGenre newGenre = new BookGenre();
                newGenre.Title = TextBox.Text;
                Main.GetGenreDB().Insert(newGenre);
                break;

            case 2:
                MagazineType newType = new MagazineType();
                newType.Title = TextBox.Text;
                Main.GetTypeDB().Insert(newType);
                break;
            }

            this.DialogResult = true;
            Close();
        }
예제 #5
0
        private void TypeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BookGenre GenreBook = (BookGenre)GenreBox.SelectedItem;

            BookGrid.ItemsSource = GenreBook.Books;
        }