コード例 #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
ファイル: MainWindow.xaml.cs プロジェクト: pavelkaps/store
        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
ファイル: MainWindow.xaml.cs プロジェクト: pavelkaps/store
        private void TypeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BookGenre GenreBook = (BookGenre)GenreBox.SelectedItem;

            BookGrid.ItemsSource = GenreBook.Books;
        }