private void DeletOrder(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button != null) { var result = MessageBox.Show("Вы хотите вернуть книгу", "Возврат", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { int id = (int)button.Tag; Issuance_Books issuance = Connection.library.Issuance_Books.Find(id); issuance_Books.Remove(issuance); Connection.library.Issuance_Books.Remove(issuance); Books = Connection.library.Books.Find(issuance.Books_id); Books.count++; try { Connection.library.SaveChanges(); } catch (DbUpdateException) { MessageBox.Show("При удалении произошла ошибка."); Connection.library.Issuance_Books.Add(issuance); issuance_Books.Add(issuance); } Connection.library.SaveChanges(); } } }
public AddOrderBook() { InitializeComponent(); book = new Books(); newOrder = new Order(); newissuanceBooks = new Issuance_Books(); ReadersComboBox.ItemsSource = Connection.library.Readers.ToList(); BooksComboBox.ItemsSource = Connection.library.Books.ToList().Where(x => x.count > 0); }