private void button5_Click(object sender, EventArgs e) { DGVClo h = new DGVClo(); this.Hide(); h.Show(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "") { { if (button1.Text == "Add Clo's") { SqlConnection conn = new SqlConnection("Data Source=DESKTOP-OQV6IBM;Initial Catalog=ProjectB;Integrated Security=True"); conn.Open(); string Query = "insert into Clo(Name,DateCreated,DateUpdated) values('" + this.textBox1.Text + "','" + DateTime.Now + "','" + DateTime.Now + "')"; SqlCommand cmd = new SqlCommand(Query, conn); cmd.ExecuteNonQuery(); MessageBox.Show("Data Successfully Added"); } else { SqlConnection conn = new SqlConnection("Data Source=DESKTOP-OQV6IBM;Initial Catalog=ProjectB;Integrated Security=True"); conn.Open(); string Query = "update Clo set Name='" + this.textBox1.Text + "',DateUpdated='" + DateTime.Now + "' where Id = '" + StdId + "'"; SqlCommand cmd = new SqlCommand(Query, conn); cmd.ExecuteNonQuery(); MessageBox.Show("Data Updated Successfully"); } DGVClo f = new DGVClo(); this.Hide(); f.Show(); } } else { MessageBox.Show("Please fill the required fields"); } }