private void button5_Click(object sender, EventArgs e) { conn.Open(); try { string text = ControlID.TextData; OleDbCommand cmd = new OleDbCommand("Delete * from Product where Product_ID= " + text, conn); cmd.ExecuteNonQuery(); MessageBox.Show("Data Deleted"); } catch (Exception ex) { MessageBox.Show("Error Occur: " + ex); } conn.Close(); Form7 f7 = new Form7(); f7.Show(); this.Close(); }
private void button5_Click(object sender, EventArgs e) { conn.Open(); try { string str = ""; for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.GetItemChecked(i)) { str += (string)checkedListBox1.Items[i] + ","; } } str = str.TrimEnd(','); cmd = new OleDbCommand("insert into Product(P_Name,Color,[Size],Weight,Cost,Type,Photo) values('" + textBox2.Text + "','" + textBox1.Text + "','" + str + "','" + textBox5.Text + "','" + textBox6.Text + "','" + comboBox3.Text + "',@photo)", conn); conv_photo(); int n = cmd.ExecuteNonQuery(); if (n > 0) { MessageBox.Show("record inserted"); } else { MessageBox.Show("insertion failed"); } Form7 f7 = new Form7(); f7.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show("Fillup all the Fields!! "); } conn.Close(); }
private void button4_Click(object sender, EventArgs e) { conn.Open(); try { string text = ControlID.TextData; cmd = new OleDbCommand("update Product set P_Name='" + textBox2.Text + "', [Size]='" + textBox3.Text + "',Color= '" + textBox4.Text + "',Weight = '" + textBox5.Text + "', Cost= '" + textBox6.Text + "', Type= '" + textBox7.Text + "', photo=@photo where Product_ID=" + text, conn); conv_photo(); int n = cmd.ExecuteNonQuery(); MessageBox.Show("Data Updated"); } catch (Exception ex) { MessageBox.Show("Error Occur: " + ex); } conn.Close(); Form7 f7 = new Form7(); f7.Show(); this.Close(); }