private void GrpStudisp_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 4) { DialogResult result = MessageBox.Show("Are you sure you want to delete this Group Student?", "Group Student", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { try { con.Close(); con.Open(); int index = GrpStudisp.CurrentCell.RowIndex; GrpStudisp.Rows[index].Selected = true; string id = GrpStudisp.SelectedCells[1].Value.ToString(); SqlCommand cmd = new SqlCommand("DELETE FROM GroupStudent WHERE StudentId = '" + id + "';", con); cmd.ExecuteNonQuery(); con.Close(); GrpStudisp.Rows.RemoveAt(index); GrpStudisp.DataSource = dt1; MessageBox.Show("Deleted!"); } catch { con.Close(); MessageBox.Show("Something went wrong!"); } } else if (result == DialogResult.No) { updatepan.Hide(); upgrpstu.Hide(); panel5.Hide(); panel1.Hide(); GroupStudentPan.Hide(); stugrpdispan.Show(); } } if (e.ColumnIndex == 5) { DialogResult result = MessageBox.Show("Are you sure you want to Update this Group Student?", "GroupStudent", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { panel5.Hide(); panel1.Hide(); GroupStudentPan.Hide(); stugrpdispan.Hide(); upgrpstu.Show(); } else { this.Hide(); Display obj = new Display(); obj.Show(); } } }
private void grpstu_Click(object sender, EventArgs e) { updatepan.Hide(); upgrpstu.Hide(); //AddStudent.Hide(); panel5.Hide(); panel1.Hide(); GroupStudentPan.Hide(); stugrpdispan.Show(); }
private void Form1_Load(object sender, EventArgs e) { disp_data(); //display data of Student upgrpstu.Hide(); disp_data_grpstu();//display data of student group //panel2.Hide(); GroupStudentPan.Hide(); updatepan.Hide(); panel5.Hide(); stugrpdispan.Hide(); panel1.Show(); }