Exemple #1
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            string s = textBox1.Text;

            book[] books = null;

            switch (comboBox1.SelectedIndex)
            {
            case 0:
                books = bm.searchByTitle(s);
                break;

            case 1:
                books = bm.searchByAuthor(s);
                break;

            case 2:
                if (bm.searchByISBN(s) != null)
                {
                    books = new book[] { bm.searchByISBN(s) }
                }
                ;
                break;
            }

            dataGridView1.DataSource = books;
        }
Exemple #2
0
        private void btn_SearchButton_Click(object sender, EventArgs e)
        {
            book[] books = null;
            switch (cb_SearchCriteria.SelectedIndex)
            {
            case 0:
                books = bookManager.searchByTitle(tb_SearchQuery.Text);
                break;

            case 1:
                books = bookManager.searchByAuthor(tb_SearchQuery.Text);
                break;

            case 2:
                book b = bookManager.searchByIsbn(tb_SearchQuery.Text);
                if (b != null)
                {
                    books    = new book[1];
                    books[0] = b;
                }
                break;
            }
            if (books != null)
            {
                dgv_Results.DataSource = books;
            }
            else
            {
                dgv_Results.DataSource = null;
                MessageBox.Show("Search did not yield any results.");
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            BookManagerClient bm    = new BookManagerClient();
            List <book>       books = new List <book>();

            switch (comboBox1.SelectedIndex)
            {
            case 0:
                string author = textBox1.Text;
                if (!string.IsNullOrEmpty(author))
                {
                    books.AddRange(bm.searchByAuthor(author));
                }
                break;

            case 1:
                string title = textBox1.Text;
                if (!string.IsNullOrEmpty(title))
                {
                    books.AddRange(bm.searchByTitle(title));
                }
                break;

            case 2:
                string isbn = textBox1.Text;
                if (!string.IsNullOrEmpty(isbn))
                {
                    books.Add(bm.searchByISBN(isbn));
                }
                break;

            default:
                MessageBox.Show("Wybierz typ argumentu z listy");
                break;
            }
            dataGridView1.DataSource = books;
        }