110,499
社区成员
发帖
与我相关
我的任务
分享
private void comboBox1_TextChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "订单号" || comboBox1.Text == "货单号")
{
textBox1.Visible = true;
comboBox2.Visible = false;
}
else if (comboBox1.Text == "商品简称")
{
comboBox2.Visible = true;
textBox1.Visible = false;
try
{
string sql = "select distinct 商品简称 from 商户结算";
conn = new SqlConnection(connstr);
da = new SqlDataAdapter(sql, conn);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
ds = new DataSet();
da.Fill(ds);
comboBox2.DataSource = ds.Tables[0].DefaultView;
comboBox2.DisplayMember = "商品简称";
}
catch
{
MessageBox.Show("该数据不存在!", "系统提示", MessageBoxButtons.OK);
}
finally
{
if (conn.State != ConnectionState.Closed)
{
try
{
conn.Close();
}
catch { }
}
}
}
else if (comboBox1.Text == "结算状态")
{
comboBox2.Visible = true;
textBox1.Visible = false;
//填充关键字
string[] strzt = { "未结款", "已结款" };
foreach (String str in strzt)
{
this.comboBox2.Items.Add(str);
}
this.comboBox2.SelectedIndex = 0;
}
}