private void addButton_Click(object sender, EventArgs e) { var books = _context.booksProvider.GetAll(); var editor = new BooksFormEditor(books); var res = editor.ShowDialog(); if (res != DialogResult.OK) { return; } _context.booksProvider.Add(editor.book); RefreshData(); }
private void editButton_Click(object sender, EventArgs e) { if (booksGridView.SelectedRows == null) { return; } var selectedBook = booksGridView.SelectedRows[0].DataBoundItem as Book; var books = _context.booksProvider.GetAll(); var booksFormEditor = new BooksFormEditor(books); var res = booksFormEditor.ShowDialog(selectedBook); if (res != DialogResult.OK) { return; } _context.booksProvider.Update(booksFormEditor.book); RefreshData(); }