//------------- Get Students than belong to more than one Courses
        public static List <StudentCourses> GetStudentCourses()
        {
            List <StudentCourses> studentCourses = new List <StudentCourses>();
            string query = "select concat(FirstName,' ', LastName) as Student, " +
                           "Count(s.StudentId) as NumberOfCourses from Student s " +
                           "inner join CourseStudent cs on cs.StudentId = s.StudentId " +
                           "group by LastName, FirstName having Count(s.StudentId) > 1";

            using (SqlConnection con = new SqlConnection(ConString))
            {
                con.Open();
                SqlCommand    sqlCommand = new SqlCommand(query, con);
                SqlDataReader reader     = sqlCommand.ExecuteReader();
                int           count      = 0;
                while (reader.Read())
                {
                    count++;
                    string student         = reader[0].ToString();
                    int    numberOfCourses = Convert.ToInt32(reader[1].ToString());

                    StudentCourses SC = new StudentCourses(count, student, numberOfCourses);
                    studentCourses.Add(SC);
                }
            }
            return(studentCourses);
        }
Example #2
0
        public static void ExportData()
        {
            ShowExportData();
            string input = CheckCorrectValueExporttMenu();

            if (input == "1")
            {
                //Students List
                Student.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "2")
            {
                //Trainers List
                Trainer.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "3")
            {
                //Assignmgents List
                Assignment.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "4")
            {
                //Courses List
                Course.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "5")
            {
                //Students Per Course
                StudentPerCourse.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "6")
            {
                //Trainers Per Course
                TrainerPerCourse.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "7")
            {
                //Assignments Per Course
                AssignmentPerCourse.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "8")
            {
                //Assignments Per Course Per Student
                AssignmentPerCoursePerStudent.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "9")
            {
                //Students than belong to more than one Courses
                StudentCourses.Output();
                Exit.CheckToExitFolderSyntetic();
            }
            else if (input == "10")
            {
                //Exit
                Exit.CheckToExitFolderSyntetic();
            }
        }