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(); }
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(); }
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"; }
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(); }
private void TypeBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { BookGenre GenreBook = (BookGenre)GenreBox.SelectedItem; BookGrid.ItemsSource = GenreBook.Books; }