Exemplo n.º 1
0
        public List <ViewStudentResult> GetAllResults(int id)
        {
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = connectionString;
            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandText = "SELECT * FROM VW_StudentResult WHERE StudentRegistrationId='" + id + "'";
            connection.Open();
            SqlDataReader            reader = command.ExecuteReader();
            List <ViewStudentResult> _viewStudentResults = new List <ViewStudentResult>();

            while (reader.Read())
            {
                ViewStudentResult _viewStudentResult = new ViewStudentResult
                {
                    CourseCode = reader["Code"].ToString(),
                    CourseName = reader["CourseName"].ToString(),
                    Grade      = reader["GradeName"].ToString()
                };

                _viewStudentResults.Add(_viewStudentResult);
            }
            reader.Close();
            connection.Close();
            return(_viewStudentResults);
        }
Exemplo n.º 2
0
        internal List <ViewStudentResult> GetAllStudentResult()
        {
            connection.ConnectionString = connectionString;
            string query = "SELECT * FROM StudentResultDetails ";

            connection.ConnectionString = connectionString;

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader            reader           = command.ExecuteReader();
            List <ViewStudentResult> studenResultList = new List <ViewStudentResult>();

            while (reader.Read())
            {
                ViewStudentResult aStudentResult = new ViewStudentResult();
                aStudentResult.StudentId      = (int)reader["StudentId"];
                aStudentResult.StudentName    = reader["StudentName"].ToString();
                aStudentResult.RegistrationId = reader["RegistrationId"].ToString();
                aStudentResult.StudentEmail   = reader["StudentEmail"].ToString();
                aStudentResult.DepartmentName = reader["DepartmentName"].ToString();
                aStudentResult.CourseId       = (int)reader["CourseId"];
                aStudentResult.CourseCode     = reader["CourseCode"].ToString();
                string s = reader["Grade"].ToString();
                if (s == "")
                {
                    aStudentResult.Grade = "Not Graded Yet";
                }
                else
                {
                    aStudentResult.Grade = s;
                }
                aStudentResult.CourseName = reader["CourseName"].ToString();
                studenResultList.Add(aStudentResult);
            }
            reader.Close();
            connection.Close();

            return(studenResultList);
        }