private void Search() { this.listView1.Items.Clear(); string query = "SELECT * FROM dbo.Users WHERE LOWER(FirstName) LIKE LOWER(@sc) " + "OR LOWER(LastName) LIKE LOWER(@sc)"; DBHandler.SQLParameter par = new DBHandler.SQLParameter(); par.name = "@sc"; par.value = "%" + this.textBox1.Text + "%"; List <User> users = db_handler.UserQuery(query, new DBHandler.SQLParameter[] { par }); foreach (User u in users) { string[] items = { u.Id.ToString(), u.FirstName, u.LastName, u.Birthday.ToString().Split(' ')[0] }; ListViewItem itm = new ListViewItem(items); this.listView1.Items.Add(itm); } }
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); } }