private void btnSelect_Click(object sender, EventArgs e) { string seach = ""; //存储查询条件 try { if (cbQuery.SelectedIndex == 0) { BindData(); return; } else if (cbQuery.SelectedIndex == 1) { seach = txtQueryValue.Text.Trim(); //从文本框取出查询值 if (seach == "") //判断是否为空 { MessageBox.Show("请输入查询值!"); txtQueryValue.Focus(); return; } s = sBLL.FindByID(seach); if (s != null) { list = new List <Supplier>(); list.Add(s); dgSupplierInfo.DataSource = null; dgSupplierInfo.DataSource = list; if (list.Count > 0) { dgSupplierInfo.CurrentCell.Selected = false; //取消反蓝 } return; } else { MessageBox.Show("没有查询到记录!"); txtQueryValue.Text = ""; txtQueryValue.Focus(); return; } } else if (cbQuery.SelectedIndex == 2) { seach = txtQueryValue.Text.Trim(); //从文本框取出查询值 if (seach == "") //判断是否为空 { MessageBox.Show("请输入查询值!"); txtQueryValue.Focus(); return; } list = sBLL.FindByName(txtQueryValue.Text.Trim()); if (list == null) { MessageBox.Show("没有查询到记录!"); txtQueryValue.Text = ""; txtQueryValue.Focus(); return; } if (list.Count > 0) { dgSupplierInfo.DataSource = null; dgSupplierInfo.DataSource = list; dgSupplierInfo.CurrentCell.Selected = false; //取消反蓝 return; } else { MessageBox.Show("没有查询到记录!"); txtQueryValue.Text = ""; txtQueryValue.Focus(); return; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }