private void Button1_Click(object sender, EventArgs e) { //9780980200447 string isbn = ISBNApi.CleanISBN(this.textBox1.Text); this.textBox1.Text = isbn; string query = "SELECT * FROM dbo.Books WHERE ISBN=@isbn"; DBHandler.SQLParameter par = new DBHandler.SQLParameter(); par.name = "@isbn"; par.value = isbn; List <Book> books = db_handler.BookQuery(query, new DBHandler.SQLParameter[] { par }); if (books.Count > 0) { this.BookId = books[0].Id; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("No book found with that ISBN", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
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(); } }
private void Button1_Click(object sender, EventArgs e) { string isbn = this.isbn.Content; isbn = ISBNApi.CleanISBN(isbn); }
public AddBook() { isbn_api = new ISBNApi(); InitializeComponent(); }