示例#1
0
        private void newToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            BookForm bookForm = new BookForm(new Book());

            if (bookForm.ShowDialog() == DialogResult.OK)
            {
                _library.AddBook(bookForm.Book);
                // for LibraryM
                bookBindingSource.DataSource = _library.Books;
                // for Library
                bookBindingSource.ResetBindings(false);

                bookBox.SelectedIndex = bookBox.Items.Count - 1;
            }
        }
示例#2
0
        private void updateToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (!(bookBox.SelectedItem is Book book))
            {
                return;
            }
            BookForm bookForm = new BookForm(book);

            if (bookForm.ShowDialog() == DialogResult.OK)
            {
                // for LibraryM
                bookBindingSource.DataSource = _library.Books;
                // for Library
                bookBindingSource.ResetBindings(false);
                bookBox.SelectedIndex = bookBox.Items.Count - 1;
            }
        }