private void Assessmentrecord_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (Assessmentrecord.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Edit") { Class1.stuId = Convert.ToInt32(Assessmentrecord.Rows[e.RowIndex].Cells[0].Value); this.Hide(); AddAssessment cl = new AddAssessment(); cl.Show(); } if (Assessmentrecord.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Delete") { int Id = Convert.ToInt32(Assessmentrecord.Rows[e.RowIndex].Cells[0].Value); if (MessageBox.Show("Are you sure to perform this action!?" + Assessmentrecord.Rows[e.RowIndex].Cells[1].Value.ToString() + "?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SqlConnection newconn = new SqlConnection(con); newconn.Open(); SqlCommand command = new SqlCommand("delete from AssessmentComponent where AssessmentId = '" + Id + "'", newconn); command.ExecuteNonQuery(); newconn.Close(); newconn.Open(); SqlCommand command1 = new SqlCommand("delete from Assessment where Id = '" + Id + "'", newconn); command1.ExecuteNonQuery(); newconn.Close(); this.assessmentTableAdapter.Fill(this.projectBDataSet.Assessment); } } }
private void btnaddclo_Click(object sender, EventArgs e) { this.Hide(); AddAssessment addnew = new AddAssessment(); addnew.Show(); }