private void btn_search_Click(object sender, EventArgs e) { string sql; string type; if (!IsNumberic(txt_id.Text) && txt_id.Text != "") { MessageBox.Show("ID must be a number"); } else { if (comboB_type.Text == "All") { type = ""; } else { type = comboB_type.Text; } if (txt_id.Text == "") { sql = "select * from stock where itemID like '%" + txt_id.Text + "%' and itemName like '%" + txt_name.Text + "%' and type like '%" + type + "%'"; } else { sql = "select * from stock where itemID = '" + txt_id.Text + "' and itemName like '%" + txt_name.Text + "%' and type like '%" + type + "%'"; } if (local) { DataSet ds = GetDataSet(sql); this.dataGridView1.DataSource = ds; this.dataGridView1.DataMember = "tb"; ColumnOrder(); } else { DataSet ds = MySQLConnection.GetDataSetValue(sql, "tb"); this.dataGridView1.DataSource = ds; this.dataGridView1.DataMember = "tb"; ColumnOrder(); } } isSearchOrAddIsClick = true; }
private void InitialGrid() { DataSet ds; if (local) { ds = GetDataSet("select * from stock"); } else { ds = MySQLConnection.GetDataSetValue("select * from stock", "tb"); } this.dataGridView1.DataSource = ds; this.dataGridView1.DataMember = "tb"; ColumnOrder(); style(); }