private void insert_j_role_btn_Click(object sender, EventArgs e)
        {
            CloseAndNullAllSubforms();
            //create new mainform object to send to this form
            //as refrence for job role form
            MainForm newform = new MainForm();

            newform = this;
            //send form refrence and sert insert flag to true
            jobRoleFrm = new JobRoleForm(ref newform, true);
            //shwo and set open flag
            jobRoleFrm.Show();
            jobRoleIsOpen = true;
        }
        public void DeleteOrUpdateSelectedRow(string tableName, string idFieldName,
                                              DataGridView datagridUpdate, bool isUpdate)
        {
            // check of rows in data grid
            bool isSelected = false;
            int  rowId      = 0;
            int  numRows    = 0;

            //number of rows in data grid
            numRows = datagridUpdate.Rows.Count;

            //loop though the rows
            for (int i = 0; i < numRows; i++)
            {
                //of row selected in data grid
                if (datagridUpdate.Rows[i].Selected)
                {
                    rowId      = i;
                    isSelected = true;
                }
            }
            if (isSelected)
            {
                string idValue = datagridUpdate.Rows[rowId].Cells[0].Value.ToString();
                //to debug comment / uncomment to show value of id selected
                //we will send this value to the query method
                //check if update or delete
                if (isUpdate)
                {
                    CloseAndNullAllSubforms();

                    //create new main form object to send to this
                    // as refrence to the student form
                    MainForm newform = new MainForm();
                    newform = this;

                    //send from refrence and set insert flag to false
                    //send id from selected row
                    switch (tableName)
                    {
                    case "student":
                    {
                        studentFrm = new StudentForm(ref newform, false, idValue);
                        //show form and set open flag
                        studentFrm.Show();
                        studentFrmIsOpen = true;
                    }
                    break;

                    case "user_account":
                    {
                        userAccountFrm = new UserAccountForm(ref newform, false, idValue);
                        //show form and set open flag
                        userAccountFrm.Show();
                        userAccountFrmIsOpen = true;
                    }
                    break;

                    case "staff":
                    {
                        staffFrm = new StaffForm(ref newform, false, idValue);
                        //show form and set open faLSE
                        staffFrm.Show();
                        staffFrmIsOpen = true;
                    }
                    break;

                    case "next_of_kin":
                    {
                        nextOfKinFrm = new NextOfKinForm(ref newform, false, idValue);
                        //show form and set open false
                        nextOfKinFrm.Show();
                        nextOfKinIsOpen = true;
                    }
                    break;

                    case "address":
                    {
                        addressFrm = new AddressForm(ref newform, false, idValue);
                        //show form and set open false
                        addressFrm.Show();
                        addressIsOpen = true;
                    }
                    break;

                    case "department":
                    {
                        depFrm = new DepartmentForm(ref newform, false, idValue);
                        //show form and set open false
                        depFrm.Show();
                        depIsOpen = true;
                    }
                    break;

                    case "job_role":
                    {
                        jobRoleFrm = new JobRoleForm(ref newform, false, idValue);
                        //show form and set open false
                        jobRoleFrm.Show();
                        jobRoleIsOpen = true;
                    }
                    break;

                    case "learning_aim":
                    {
                        learningAimFrm = new LearningAimForm(ref newform, false, idValue);
                        //show form and set open false
                        learningAimFrm.Show();
                        learningAimIsOpen = true;
                    }
                    break;

                    case "course":
                    {
                        courseFrm = new CourseForm(ref newform, false, idValue);
                        //show form and set open false
                        courseFrm.Show();
                        courseIsOpen = true;
                    }
                    break;

                    case "enrolment":
                    {
                        enrolmentFrm = new EnrolmentForm(ref newform, false, idValue);
                        //show form and set open false
                        enrolmentFrm.Show();
                        enrolmentIsOpen = true;
                    }
                    break;
                    }
                }
                else if (!isUpdate)
                {
                    //calls delete row method on DB connection
                    //and sends the id value to selected row
                    mySqlSrc.DeleteRowWithId(tableName, idFieldName, idValue);
                }
            }
            else
            {
                // if no row selcted disply to user
                MessageBox.Show("No Row Selcted");
            }
        }