Example #1
0
        private void Button5_Click(object sender, EventArgs e)
        {
            string searchQuery = txtSearchBox.Text;

            //search by book title
            if (cmbSearchFilter.SelectedIndex == 0)
            {
                bookSearchGridView.DataSource = SelectQueries.SearchBookByTitle(searchQuery);
            }
            //search by author
            if (cmbSearchFilter.SelectedIndex == 1)
            {
                bookSearchGridView.DataSource = SelectQueries.SearchBookByAuthor(searchQuery);
            }
            //search by publisher
            if (cmbSearchFilter.SelectedIndex == 2)
            {
                bookSearchGridView.DataSource = SelectQueries.SearchBookByPublisher(searchQuery);
            }
            //search by category
            if (cmbSearchFilter.SelectedIndex == 3)
            {
                bookSearchGridView.DataSource = SelectQueries.SearchBookByCategory(searchQuery);
            }
            if (bookSearchGridView.Rows.Count == 1)
            {
                MessageBox.Show("Book not found.\n Please try searching again", "NOT FOUND"
                                , MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("Book Found", "FOUND", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            string    searchQuery = txtBoxSearch.Text;
            DataTable dt          = new DataTable();

            //search by book title
            if (cmbFilter.SelectedIndex == 0)
            {
                dt = SelectQueries.SearchBookByTitle(searchQuery);
                bookSearchGridView.DataSource = dt;
            }
            //search by author
            if (cmbFilter.SelectedIndex == 1)
            {
                dt = SelectQueries.SearchBookByAuthor(searchQuery);
                bookSearchGridView.DataSource = dt;
            }
            //search by publisher
            if (cmbFilter.SelectedIndex == 2)
            {
                dt = SelectQueries.SearchBookByPublisher(searchQuery);
                bookSearchGridView.DataSource = dt;
            }
            //search by category
            if (cmbFilter.SelectedIndex == 3)
            {
                dt = SelectQueries.SearchBookByCategory(searchQuery);
                bookSearchGridView.DataSource = dt;
            }
            if (bookSearchGridView.Rows.Count == 1)
            {
                lblMsg.Text = "Book not found!";
                MessageBox.Show("Book not found.\n Please try searching again", "NOT FOUND"
                                , MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                lblMsg.Text = "Book Found";
                MessageBox.Show("Book Found", "FOUND", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cmbBookID.ValueMember   = "book_id";
                cmbBookID.DisplayMember = "book_id";
                cmbBookID.DataSource    = dt;
            }
        }