private void buttonOk_Click(object sender, EventArgs e) { try { string searchSql = "select *from StoreInfoProduct where 1 = 1 "; if (checkBoxId.Checked) { searchSql += " and products_id = " + textBoxId.Text; } if (checkBoxName.Checked) { searchSql += " and products_name = '" + textBoxName.Text.ToString() + "'"; } if (checkBoxSpec.Checked) { searchSql += " and products_spec = '" + textBoxSpec.Text.ToString() + "'"; } if (checkBoxQuality.Checked) { searchSql += " and products_quality_date = " + comboBoxQuality.Text; } if (checkBoxShengcha.Checked) { searchSql += " and products_date >= '" + dateTimePickerFrom.Text + "'"; searchSql += " and products_date <= '" + dateTimePickeTo.Text + "'"; } Console.WriteLine(searchSql); operat.OperateData(searchSql); operat.BindDataGridView(dataGridView1, searchSql); }catch (Exception ex) { MessageBox.Show("查询商品时发生" + ex.Message + "的错误"); return; } }
private void FormPro_Load(object sender, EventArgs e) { //string searchsql = "select products_id,products_name,products_spec,sealling_price,products_num,seall_date"; //searchsql += "from Products_Temp "; //searchsql += "where products_id = " + textBoxId.Text; string searchsql = "select *from Products_Temp"; operat.BindDataGridView(this.dataGridView1, searchsql); this.InitDataGridViewHead(); this.labelTotalPrice.Text = ""; this.labelNum.Text = ""; this.listBox1.Visible = false; CountProductNum(); }