/// <summary>
        /// seclects the information from the database and return a list of YearGroupsCL
        /// </summary>
        /// <returns></returns>
        public List<YearGroupCL> SeclectYearGroup()
        {
            string query = "SELECT * FROM yeargroup";

            List<YearGroupCL> allYGrop = new List<YearGroupCL>();

             //Open connection
            if (this.OpenConnection() == true)
            {
            //Create Command
            MySqlCommand cmd = new MySqlCommand(query, connection);
            //Create a data reader and Execute the command
            MySqlDataReader dataReader = cmd.ExecuteReader();

            //Read the data and store them in the list
            while (dataReader.Read())
            {
                Int32 YearGroupID = dataReader.GetInt32(0);
                String YearGroupName = dataReader.GetString(1);
                Int32 NumStudents = dataReader.GetInt32(2);

                YearGroupCL YG = new YearGroupCL(YearGroupID, YearGroupName, NumStudents);
                allYGrop.Add(YG);

            }
            //close Data Reader
            dataReader.Close();

            //close Connection
            this.CloseConnection();
            }
            // return all the records in the database for the lecturer
            return allYGrop;
        }
        /// <summary>
        /// insert statement for the YearGroupCL 
        /// </summary>
        /// <param name="YG">List of  YearGroups</param>
        public void insertYG(YearGroupCL YG)
        {
            string queryYG = "INSERT INTO yeargroup (yearGroupName, noStudents) VALUE('" + YG.YearGropName + "','"
            + YG.NumStudents  +"')";
            //open connection
            if (this.OpenConnection() == true)
            {
            //create command and assign the query and connection from the constructor
            MySqlCommand cmd = new MySqlCommand(queryYG, connection);

            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            this.CloseConnection();
            }
        }