private void Category_Load(object sender, EventArgs e) { string query = "select Name,Color,Guage,Bore from Category"; DataTable dt = DBConnection.display(query); dataGridView1.DataSource = dt; }
private void addCategoryBtn_Click(object sender, EventArgs e) { if (nameTxt.Text == string.Empty) { MessageBox.Show("Please enter category name"); } else if (boreBox.SelectedIndex < 0) { MessageBox.Show("Please select Bore"); } else if (guageBox.SelectedIndex < 0) { MessageBox.Show("Please select the guage"); } else if (colourBox.SelectedIndex < 0) { MessageBox.Show("Please select colour"); } else { //MessageBox.Show("All is well!"); addCategory(); string query = "select Name,Color,Guage,Bore from Category"; DBConnection.display(query); } }
private void searchBtn_Click(object sender, EventArgs e) { string query = "select Name,Color,Guage,Bore from Category where Name LIKE '%" + nameTxt.Text + "%'"; DataTable dt = DBConnection.display(query); if (dt.Rows.Count > 0) { dataGridView1.DataSource = dt; } else { MessageBox.Show("Nothing Found"); } }