求助DataTable.select()方法 急 急
梦里独赏花 2011-05-03 09:46:39 如何生成动态组合条件进行查询????????
private void button1_Click(object sender, EventArgs e)
{
Repository.TBRepository tbrep = Repository.TBRepository.GetInstance();
TB.TBInfoDataTable tbDT = tbrep.getTB();
//药敏号
string yaominId = this.textBoxymID.Text;
//菌株来源
string laiyuan = this.comboBoxlaiyuan.SelectedItem.ToString();
//菌株代期
string daiqi = this.comboBoxTBdaiqi.SelectedItem.ToString();
//菌株保存培养基
string pyj = this.comboBox3pyji.SelectedItem.ToString();
//菌株冰箱编号
int fridgeID = int.Parse (this.fridgeID.Text);
//菌株保存架编号
int jiaID = int.Parse(this.textBox5jiaID.Text);
//菌株保存盒编号
int heID = int.Parse(this.textBox6heID.Text);
//保存管数
int guanshu = int.Parse (this.numericUpDown1.Value.ToString ());
//入库时间
DateTime dt = this.dateTimePickerruku.Value ;
//入库人
string inPeople = this.Inpeople.SelectedItem.ToString();
//备注
string remarks = this.richTextBox1.Text;
// (如何对以下他们进行动态的组合查询 ????????????????)
DataRow[] dr = tbDT.Select ("YaominID='" + yaominId + "' and TBcause='" + laiyuan + "' and TBculture='" + pyj + "' and TBdaiqi='" + daiqi + "' and TBfridge= " + fridgeID + " and TBjiaID=" + jiaID + " and TBheID=" + heID + " and TBnumber=" + guanshu + " and TBindate='" + dt + "'and TBinpeople='" + inPeople + "' and TBremarks='" + remarks + "'");//
this.listView1.Items.Clear();
foreach (TB.TBInfoRow item in dr)
{
ListViewItem showItem = new ListViewItem();
showItem.Text = item.YaominID;
showItem.SubItems.Add(item.TBcause.ToString());
showItem.SubItems.Add(item.TBdaiqi.ToString());
showItem.SubItems.Add(item.TBculture.ToString());
showItem.SubItems.Add(item.TBfridge.ToString ());
showItem.SubItems.Add(item.TBjiaID.ToString ());
showItem.SubItems.Add(item.TBheID.ToString ());
showItem.SubItems.Add(item.TBnumber.ToString());
showItem.SubItems.Add(item.TBindate.ToString());
showItem.SubItems.Add(item.TBinpeople);
showItem.SubItems.Add(item.TBremarks);
showItem.Tag = item;
listView1.Items.Add(showItem);
}