private void Insert_Click(object sender, EventArgs e) { BookDB db = new BookDB(); try { db.iBookCode = db.primarykey(); db.strTitle = tbTitle.Text; db.strAuthor = tbAuthor.Text; db.insert(); tbAuthor.Text = ""; tbTitle.Text = ""; MessageBox.Show("register a book."); } catch (FormatException) { MessageBox.Show("error"); tbAuthor.Text = ""; tbTitle.Text = ""; } catch (OverflowException) { MessageBox.Show("error"); tbAuthor.Text = ""; tbTitle.Text = ""; } }
private void btSearch_Click(object sender, EventArgs e) { BookDB book = new BookDB(); book.DBOpen(); int tmp; tmp = comboBox.SelectedIndex; if (tmp == 0) { DataSet ds = book.GetData(eItem.TITLE, tb.Text); dataGridView1.DataSource = ds.Tables[0]; } else if (tmp == 1) { DataSet ds = book.GetData(eItem.AUTHOR, tb.Text); dataGridView1.DataSource = ds.Tables[0]; } }