补充一 就是将数据库中的属性与tscboxCondition控件进行绑定
private void tsbtnFind_Click(object sender, EventArgs e)
{
try
{
if (tstxtKeyWord.Text == "")
{
frmFeedManage_Load(sender, e);
}
if (tscboxCondition.Text.Trim() == "单价")
{
DataSet myds = datacon.getds(M_str_sql + " where FPrice like '%" + tstxtKeyWord.Text.Trim() + "%'", M_str_table);
if (myds.Tables[0].Rows.Count > 0)
dgvFeed.DataSource = myds.Tables[0];
else
MessageBox.Show("没有要查找的相关记录!");
}
if (tscboxCondition.Text.Trim() == "饲料名称")
{
DataSet myds = datacon.getds(M_str_sql + " where FName like '%" + tstxtKeyWord.Text.Trim() + "%'", M_str_table);
if (myds.Tables[0].Rows.Count > 0)
dgvFeed.DataSource = myds.Tables[0];
else
MessageBox.Show("没有要查找的相关记录!");
}
if (tscboxCondition.Text.Trim() == "所属类别")
{
DataSet myds = datacon.getds(M_str_sql + " where FType like '%" + tstxtKeyWord.Text.Trim() + "%'", M_str_table);
if (myds.Tables[0].Rows.Count > 0)
dgvFeed.DataSource = myds.Tables[0];
else
MessageBox.Show("没有要查找的相关记录!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
[
本帖最后由 wxqwxq 于 2013-3-12 09:36 编辑 ]