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; }
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; }