private void searchPictureBox_Click(object sender, EventArgs e)//查询 { List <Book> books = new List <Book>(); if (searchTextBox.Text == null) { MessageBox.Show("没有输入用于查询的关键词!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { switch (searchComboBox.Text) { case "书号": books = BookShelfService.Search(1, searchTextBox.Text); break; case "书名": books = BookShelfService.Search(2, searchTextBox.Text); break; case "作者": books = BookShelfService.Search(3, searchTextBox.Text); break; case "分类": books = BookShelfService.Search(4, searchTextBox.Text); break; case "书架号": books = BookShelfService.Search(5, searchTextBox.Text); break; default: MessageBox.Show("没有选择正确的查询方式!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } this.bookBindingSource.DataSource = books; }