private void addToolStripMenuItem_Click(object sender, EventArgs e) { addForm = new BookAddForm(null); if (addForm.ShowDialog() == DialogResult.OK) { Book book = new Book(addForm.BookTitle(), addForm.BookAuthor(), addForm.BookDate(), addForm.BookCategory()); items.Add(book); ListViewItem item = new ListViewItem(); item.Tag = book; UpdateItem(item); mainForm.addBookInAllViews(book); } }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 1) { Book book = (Book)listView1.SelectedItems[0].Tag; addForm = new BookAddForm(book); if (addForm.ShowDialog() == DialogResult.OK) { book.title = addForm.BookTitle(); book.author = addForm.BookAuthor(); book.date = addForm.BookDate(); book.category = addForm.BookCategory(); UpdateItem(listView1.SelectedItems[0]); mainForm.updateBookInAllViews(book); } } }