private void Button8_Click(object sender, EventArgs e) { try { m.Close(); m.Open(); SqlCommand cmd = new SqlCommand("update [dbo].[pesticide] set Pname = '" + textBox2.Text + "', Ptype = '" + textBox3.Text + "', Rate = '" + textBox4.Text + "', Quantity = '" + textBox5.Text + "' where Pid='" + textBox1.Text + "'", m); int a = cmd.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("Updated"); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); this.Hide(); PesticideReport f1 = new PesticideReport(); f1.Show(); } else { MessageBox.Show("Invalid"); } m.Close(); } catch { MessageBox.Show("Error!!"); } }
private void Button7_Click(object sender, EventArgs e) { try { m.Close(); m.Open(); SqlCommand cmd = new SqlCommand("delete from [dbo].[pesticide] where Pid='" + textBox1.Text + "'", m); int a = cmd.ExecuteNonQuery(); if (a > 0) { MessageBox.Show("Deleted"); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); this.Hide(); PesticideReport p1 = new PesticideReport(); p1.Show(); } else { MessageBox.Show("Invalid"); } m.Close(); } catch { } }
private void Button10_Click(object sender, EventArgs e) { PesticideReport p1 = new PesticideReport(); this.Hide(); p1.Show(); }