private void addButton_Click(object sender, EventArgs e) { var book = GetBook(); if (book == null) { return; } DBHandler.AddBook(book); Close(); }
public void AddBook() { Forms.AddBook dlg = new Forms.AddBook(); if (dlg.ShowDialog() == DialogResult.OK) { string isbn = ISBNApi.CleanISBN(dlg.isbn.Text); string title = dlg.title.Text; string author = dlg.authors.Text; string desc = dlg.desc.Text; string rem = dlg.remarks.Text; int quant = (int)dlg.quantity.Value; Book b = new Book(-1, title, author, isbn, desc, rem, quant); if (!db_handler.AddBook(b)) { MessageBox.Show("An error occured.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } PopulateListView(); } }