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 LoadMagazineCombobox() { MagazineType AllType = new MagazineType { Title = "Все", Id = 0 }; List <MagazineType> AllList = new List <MagazineType>(); AllList.Add(AllType); foreach (MagazineType item in GetTypeDB().Load()) { AllList.Add(item); } TypeBox.ItemsSource = AllList; TypeBox.SelectedValuePath = "Id"; TypeBox.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 TypeSelect(object sender, SelectionChangedEventArgs e) { MagazineType TypeMagazine = (MagazineType)TypeBox.SelectedItem; MagazineGrid.ItemsSource = TypeMagazine.Magazines; }