private void InsertStudent_Click_1(object sender, EventArgs e)
        {
            string     firstName  = "";
            string     lastName   = "";
            string     regno      = "";
            string     contact    = "";
            string     email      = "";
            DateTime   dob        = DateTime.Now;
            string     gender     = "";
            AddStudent addStudent = new AddStudent(firstName, lastName, regno, contact, email, dob, gender, "add");

            this.Hide();
            addStudent.Show();
        }
        private void Students_CellClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == Students.NewRowIndex || e.RowIndex < 0)
            {
                return;
            }

            if (e.ColumnIndex == Students.Columns["StudentDeleteButton"].Index)
            {
                int    i        = e.RowIndex;
                String email    = Students.Rows[i].Cells[3].Value.ToString();
                string regno    = Students.Rows[i].Cells[1].Value.ToString();
                string fullName = Students.Rows[i].Cells[0].Value.ToString();

                string       dialog       = string.Format("Are you sure you want to delete the student '{0}' and all its information?", fullName);
                DialogResult dialogResult = MessageBox.Show(dialog, "Delete Student", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    SqlConnection connection = new SqlConnection(connString);
                    connection.Open();

                    string     getid = string.Format("SELECT Id FROM Student WHERE RegistrationNo = '{0}'", regno);
                    SqlCommand cmd   = new SqlCommand(getid, connection);
                    int        id    = (Int32)cmd.ExecuteScalar();

                    cmd.CommandText = string.Format("DELETE FROM GroupStudent WHERE StudentId = '{0}'", id);
                    cmd.ExecuteNonQuery();

                    string del = String.Format("DELETE FROM Student WHERE RegistrationNo = '{0}'", regno);
                    cmd.CommandText = del;
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = string.Format("DELETE FROM Person WHERE Email = '{0}'", email);
                    cmd.ExecuteNonQuery();
                    Students.Rows.RemoveAt(i);
                    MessageBox.Show("Student deleted successfully!");
                    connection.Close();
                }
                else if (dialogResult == DialogResult.No)
                {
                    MessageBox.Show("Student not deleted!");
                }
            }
            if (e.ColumnIndex == Students.Columns["StudentEditButton"].Index)
            {
                int        i         = e.RowIndex;
                string     fullName  = Students.Rows[i].Cells[0].Value.ToString();
                var        names     = fullName.Split(' ');
                string     firstName = names[0];
                string     lastName  = names[1];
                string     regno     = Students.Rows[i].Cells[1].Value.ToString();
                string     contact   = Students.Rows[i].Cells[2].Value.ToString();
                string     email     = Students.Rows[i].Cells[3].Value.ToString();
                string     DOB1      = Students.Rows[i].Cells[4].Value.ToString();
                DateTime   dob       = Convert.ToDateTime(DOB1);
                string     gender    = Students.Rows[i].Cells[5].Value.ToString();
                AddStudent form      = new AddStudent(firstName, lastName, regno, contact, email, dob, gender, "edit");
                form.Show();
                this.Hide();
            }
        }