private void editBookToolStripMenuItem_Click(object sender, EventArgs e) { if (booksDataGridView.CurrentCell.OwningRow.DataBoundItem as Books != null) { AddEditBookForm addEditBookForm = new AddEditBookForm(booksDataGridView.CurrentCell.OwningRow.DataBoundItem as Books, publishers); addEditBookForm.ShowDialog(); RefreshViews(); } }
private void addNewBookToolStripMenuItem_Click(object sender, EventArgs e) { if ((authorsDataGridView.CurrentCell.OwningRow.DataBoundItem as Authors) != null && booksDataGridView.AllowUserToAddRows && !booksDataGridView.CurrentCell.OwningRow.IsNewRow) { var book = new Books(); AddEditBookForm addEditBookForm = new AddEditBookForm(book, publishers); addEditBookForm.ShowDialog(); if (addEditBookForm.DialogResult == DialogResult.OK) { (authorsDataGridView.CurrentCell.OwningRow.DataBoundItem as Authors).Books.Add(book); } } }