Exemple #1
0
        /// <summary>
        /// This method requires a user id and send it to the business layer.
        /// </summary>
        /// <param name="id">The id</param>
        /// <returns>Returns a list of prestation indicator objects</returns>
        public List <PrestationIndicator> getAverageGradeById(int id)
        {
            PrestationIndicator        prestationIndicator = new PrestationIndicator();
            List <PrestationIndicator> gradeList           = prestationIndicator.getAverageGradeById(id);

            return(gradeList);
        }
Exemple #2
0
        /// <summary>
        /// This method requires a user id and send it to the business layer.
        /// </summary>
        /// <param name="id">The id</param>
        /// <returns>Returns a list of prestation indicator objects.</returns>
        public List <PrestationIndicator> getPrestationIndicatorsById(int id)
        {
            PrestationIndicator        prestationIndicator = new PrestationIndicator();
            List <PrestationIndicator> piList = prestationIndicator.getPrestationIndicatorsById(id);

            return(piList);
        }
Exemple #3
0
        /// <summary>
        /// This method gets all the average grades from the prestation indicators.
        /// </summary>
        /// <param name="cmd">querystring</param>
        /// <returns>Returns a list of grades from the prestation indicators.</returns>
        public List <PrestationIndicator> SelectAverageGrades(SqlCommand cmd)
        {
            PrestationIndicator        prestationIndicator = new PrestationIndicator();
            List <PrestationIndicator> gradeList           = new List <PrestationIndicator>();

            try
            {
                connectDB();
                conn.Open();
                cmd.Connection = conn;
                SqlDataReader reader      = cmd.ExecuteReader();
                DataTable     schemaTable = reader.GetSchemaTable();

                while (reader.Read())
                {
                    foreach (DataRow row in schemaTable.Rows)
                    {
                        prestationIndicator = new PrestationIndicator()
                        {
                            courseId = reader.GetInt32(reader.GetOrdinal("courseId")),
                            avgGrade = reader.GetDecimal(reader.GetOrdinal("avgGrade"))
                        };
                    }
                    // Remove excessive zeroes
                    string zeroLess = prestationIndicator.avgGrade.ToString("N1");
                    prestationIndicator.avgGrade = Decimal.Parse(zeroLess);
                    gradeList.Add(prestationIndicator);
                }
            }
            catch (System.Data.SqlClient.SqlException error)
            {
                throw error;
            }
            this.conn.Close();
            return(gradeList);
        }
Exemple #4
0
        /// <summary>
        /// This method gets the prestation indicators from a single student.
        /// </summary>
        /// <param name="cmd">querystring</param>
        /// <returns>Returns a list of prestation indicators.</returns>
        public List <PrestationIndicator> SelectPrestationIndicators(SqlCommand cmd)
        {
            PrestationIndicator        prestationIndicator = new PrestationIndicator();
            List <PrestationIndicator> piList = new List <PrestationIndicator>();

            try
            {
                connectDB();
                conn.Open();
                cmd.Connection = conn;
                SqlDataReader reader      = cmd.ExecuteReader();
                DataTable     schemaTable = reader.GetSchemaTable();

                while (reader.Read())
                {
                    foreach (DataRow row in schemaTable.Rows)
                    {
                        prestationIndicator = new PrestationIndicator()
                        {
                            studentId = reader.GetInt32(reader.GetOrdinal("studentId")),
                            courseId  = reader.GetInt32(reader.GetOrdinal("courseId")),
                            piCode    = reader.GetInt32(reader.GetOrdinal("piCode")),
                            grade     = reader.GetDecimal(reader.GetOrdinal("grade"))
                        };
                    }

                    piList.Add(prestationIndicator);
                }
            }
            catch (System.Data.SqlClient.SqlException error)
            {
                throw error;
            }
            this.conn.Close();
            return(piList);
        }