Exemplo n.º 1
0
        public List <AssignmentsPerCourse> GetAssignmetsPerCourse()
        {
            List <AssignmentsPerCourse> assignmentsPerCourse = new List <AssignmentsPerCourse>();

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    string queryString = "select Course.Title as Course , Assignment.title as [Assignment title], " +
                                         "description as Description from Assignment, Course where Assignment.Cid = Course.Cid";
                    con.Open();
                    SqlCommand    cmd    = new SqlCommand(queryString, con);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        AssignmentsPerCourse apc = new AssignmentsPerCourse(courseTitle: reader[0].ToString(), assignmentTitle: reader[1].ToString(), description: reader[2].ToString());
                        assignmentsPerCourse.Add(apc);
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Something went wrong Code: S_S_GAPC");
            }
            return(assignmentsPerCourse);
        }
        public List <AssignmentsPerCourse> AllAssignmentsPerAllCourses()
        {
            List <Course>           courses     = GetAll();
            List <Assignment>       assignments = new AssignmentService().GetAll();
            List <AssignmentCourse> assigns     = new AssignmentCourseService().GetAll();
            var querySql = from a in assignments
                           join ass in assigns
                           on a.AssignmentId equals ass.AssignmentId
                           join c in courses
                           on ass.CourseId equals c.CourseId
                           select new
            {
                Assignment = a,
                Course     = c
            };
            List <AssignmentsPerCourse> allAssignmentsPerAllCourses = new List <AssignmentsPerCourse>();
            var groupedByCourses = querySql.GroupBy(g => g.Course);

            foreach (var group in groupedByCourses)
            {
                AssignmentsPerCourse assignmentsPerCourse = new AssignmentsPerCourse();
                assignmentsPerCourse.Course = group.Key;
                foreach (var item in group)
                {
                    assignmentsPerCourse.Assignments.Add(item.Assignment);
                }
                allAssignmentsPerAllCourses.Add(assignmentsPerCourse);
            }
            return(allAssignmentsPerAllCourses);
        }
Exemplo n.º 3
0
        /// <summary>
        /// The database constructor where all entities are constructed and connected accordingly in the database
        /// </summary>
        public Database()
        {
            Student s1  = new Student("Alex", "Perikleous", new DateTime(1993, 12, 06), 2500);
            Student s2  = new Student("Xenofon", "Vlachogiannis", new DateTime(1989, 06, 01), 2200);
            Student s3  = new Student("Zack", "Drimiskianakis", new DateTime(1993, 12, 11), 3000);
            Student s4  = new Student("Eleni", "Parisi", new DateTime(1989, 06, 03), 2400);
            Student s5  = new Student("Panagiotis", "Rizos", new DateTime(1993, 07, 02), 2600);
            Student s6  = new Student("Alexandros", "Nomikos", new DateTime(1973, 04, 25), 2700);
            Student s7  = new Student("Konstantinos", "Argyropoulos", new DateTime(1990, 08, 01), 2800);
            Student s8  = new Student("Chris", "Vasilakis", new DateTime(1989, 04, 09), 2900);
            Student s9  = new Student("Thanasis", "Kontodimas", new DateTime(1991, 08, 03), 2000);
            Student s10 = new Student("Thanos", "Katrakis", new DateTime(1988, 02, 01), 3000);

            students.Add(s1);
            students.Add(s2);
            students.Add(s3);
            students.Add(s4);
            students.Add(s5);
            students.Add(s6);
            students.Add(s7);
            students.Add(s8);
            students.Add(s9);
            students.Add(s10);

            Course c1 = new Course("CB9", "C#", "Full-Time", new DateTime(2019, 11, 11), new DateTime(2020, 03, 01));
            Course c2 = new Course("CB8", "C#", "Part-Time", new DateTime(2019, 11, 18), new DateTime(2020, 06, 01));
            Course c3 = new Course("JB9", "Java", "Full-Time", new DateTime(2019, 11, 11), new DateTime(2020, 06, 03));
            Course c4 = new Course("JB8", "Java", "Part-Time", new DateTime(2019, 11, 18), new DateTime(2020, 06, 01));

            courses.Add(c1);
            courses.Add(c2);
            courses.Add(c3);
            courses.Add(c4);

            Assignment a1 = new Assignment("ChessMaster", "Assign random pieces to chessboard", new DateTime(2020, 03, 06), 30, 100);
            Assignment a2 = new Assignment("Databases", "Connect to database", new DateTime(2020, 02, 01), 20, 100);
            Assignment a3 = new Assignment("String assignment", "Randomize string inputs", new DateTime(2020, 04, 01), 15, 100);
            Assignment a4 = new Assignment("C#", "Fundamentals of OOP", new DateTime(2020, 05, 20), 30, 100);
            Assignment a5 = new Assignment("Headfirst", "Advanced abstract classes", new DateTime(2020, 04, 22), 30, 100);

            assignments.Add(a1);
            assignments.Add(a2);
            assignments.Add(a3);
            assignments.Add(a4);
            assignments.Add(a5);

            Trainer t1 = new Trainer("Panagiotis", "Bozas", "OOP");
            Trainer t2 = new Trainer("Kostas", "Zitis", "SQL");
            Trainer t3 = new Trainer("George", "Pasparakis", "Databases");
            Trainer t4 = new Trainer("Ektoras", "Gantzos", "C#");

            trainers.Add(t1);
            trainers.Add(t2);
            trainers.Add(t3);
            trainers.Add(t4);

            StudentCourse SC1  = new StudentCourse(students[0], courses[0]);
            StudentCourse SC2  = new StudentCourse(students[1], courses[0]);
            StudentCourse SC3  = new StudentCourse(students[2], courses[0]);
            StudentCourse SC4  = new StudentCourse(students[3], courses[0]);
            StudentCourse SC5  = new StudentCourse(students[3], courses[1]);
            StudentCourse SC6  = new StudentCourse(students[4], courses[1]);
            StudentCourse SC7  = new StudentCourse(students[5], courses[1]);
            StudentCourse SC8  = new StudentCourse(students[6], courses[2]);
            StudentCourse SC9  = new StudentCourse(students[7], courses[2]);
            StudentCourse SC10 = new StudentCourse(students[8], courses[3]);
            StudentCourse SC11 = new StudentCourse(students[9], courses[3]);

            studentCourses.Add(SC1);
            studentCourses.Add(SC2);
            studentCourses.Add(SC3);
            studentCourses.Add(SC4);
            studentCourses.Add(SC5);
            studentCourses.Add(SC6);
            studentCourses.Add(SC7);
            studentCourses.Add(SC8);
            studentCourses.Add(SC9);
            studentCourses.Add(SC10);
            studentCourses.Add(SC11);

            TrainerCourse TC1 = new TrainerCourse(trainers[0], courses[0]);
            TrainerCourse TC2 = new TrainerCourse(trainers[1], courses[0]);
            TrainerCourse TC3 = new TrainerCourse(trainers[1], courses[1]);
            TrainerCourse TC4 = new TrainerCourse(trainers[2], courses[1]);
            TrainerCourse TC5 = new TrainerCourse(trainers[2], courses[2]);
            TrainerCourse TC6 = new TrainerCourse(trainers[3], courses[3]);

            trainerCourses.Add(TC1);
            trainerCourses.Add(TC2);
            trainerCourses.Add(TC3);
            trainerCourses.Add(TC4);
            trainerCourses.Add(TC5);
            trainerCourses.Add(TC6);

            List <Assignment> assignments1 = new List <Assignment> {
                assignments[0], assignments[1]
            };
            AssignmentsPerCourse APC1 = new AssignmentsPerCourse(courses[0], assignments1);

            List <Assignment> assignments2 = new List <Assignment> {
                assignments[2]
            };
            AssignmentsPerCourse APC2 = new AssignmentsPerCourse(courses[1], assignments2);

            List <Assignment> assignments3 = new List <Assignment> {
                assignments[3]
            };
            AssignmentsPerCourse APC3 = new AssignmentsPerCourse(courses[2], assignments3);

            List <Assignment> assignments4 = new List <Assignment> {
                assignments[4]
            };
            AssignmentsPerCourse APC4 = new AssignmentsPerCourse(courses[3], assignments4);

            assignmentsPerCourse.Add(APC1);
            assignmentsPerCourse.Add(APC2);
            assignmentsPerCourse.Add(APC3);
            assignmentsPerCourse.Add(APC4);

            StudentAssignment SA1  = new StudentAssignment(students[0], assignments[0]);
            StudentAssignment SA2  = new StudentAssignment(students[0], assignments[1]);
            StudentAssignment SA3  = new StudentAssignment(students[1], assignments[0]);
            StudentAssignment SA4  = new StudentAssignment(students[1], assignments[1]);
            StudentAssignment SA5  = new StudentAssignment(students[2], assignments[0]);
            StudentAssignment SA6  = new StudentAssignment(students[2], assignments[1]);
            StudentAssignment SA7  = new StudentAssignment(students[3], assignments[0]);
            StudentAssignment SA8  = new StudentAssignment(students[3], assignments[1]);
            StudentAssignment SA9  = new StudentAssignment(students[3], assignments[2]);
            StudentAssignment SA10 = new StudentAssignment(students[4], assignments[2]);
            StudentAssignment SA11 = new StudentAssignment(students[5], assignments[2]);
            StudentAssignment SA12 = new StudentAssignment(students[6], assignments[3]);
            StudentAssignment SA13 = new StudentAssignment(students[7], assignments[3]);
            StudentAssignment SA14 = new StudentAssignment(students[8], assignments[4]);
            StudentAssignment SA15 = new StudentAssignment(students[9], assignments[4]);

            studentAssignments.Add(SA1);
            studentAssignments.Add(SA2);
            studentAssignments.Add(SA3);
            studentAssignments.Add(SA4);
            studentAssignments.Add(SA5);
            studentAssignments.Add(SA6);
            studentAssignments.Add(SA7);
            studentAssignments.Add(SA8);
            studentAssignments.Add(SA9);
            studentAssignments.Add(SA10);
            studentAssignments.Add(SA11);
            studentAssignments.Add(SA12);
            studentAssignments.Add(SA13);
            studentAssignments.Add(SA14);
            studentAssignments.Add(SA15);
        }
        public static void Run()
        {
            Course                         c1            = new Course();
            Assignment                     a1            = new Assignment();
            Trainer                        tr1           = new Trainer();
            Student                        s1            = new Student();
            StudentsPerCourse              sPC           = new StudentsPerCourse();
            TrainersPerCourse              tPC           = new TrainersPerCourse();
            AssignmentsPerCourse           aPC           = new AssignmentsPerCourse();
            AssignmetsPerStudent           aPS           = new AssignmetsPerStudent();
            AssignmentsPerCoursePerStudent aPCPS         = new AssignmentsPerCoursePerStudent();
            StudentsWithMoreThanOneCourse  sMTOC         = new StudentsWithMoreThanOneCourse();
            ServiceGet                     serviseGet    = new ServiceGet();
            ServiceInsert                  serviseInsert = new ServiceInsert();
            ServiceCheck                   serviceCheck  = new ServiceCheck();

            string userInput2 = "", userInput3 = "", userInput5 = "";
            int    selectCourse;


            do
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine();
                Console.WriteLine("\tWellcome to Private School! What would you like to do?");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.White;

                Console.WriteLine("\t0. Exit.");
                Console.WriteLine("\t1. Course.");
                Console.WriteLine("\t2. Assignment.");
                Console.WriteLine("\t3. Trainer.");
                Console.WriteLine("\t4. Student.");


                Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                userInput2 = Console.ReadLine();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\n\t=================================================================================\n");
                Console.ForegroundColor = ConsoleColor.White;

                //UserInput2 = 1, normal mode, Course--------------------------------------------------------------------------------------------------------------------
                if (userInput2 == "1")
                {
                    do
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine();
                        Console.WriteLine("\tYou are in the course mode! What would you like to do?");
                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.White;

                        Console.WriteLine("\t0. Exit.");
                        Console.WriteLine("\t1. New course.");
                        Console.WriteLine("\t2. Output list with all courses.");
                        Console.WriteLine("\t3. Add students at courses.");
                        Console.WriteLine("\t4. Output students per course.");
                        Console.WriteLine("\t5. Add trainers at courses.");
                        Console.WriteLine("\t6. Output trainers per course.");
                        Console.WriteLine("\t7. Add assignments at courses.");
                        Console.WriteLine("\t8. Output assignments per course.");
                        Console.WriteLine("\t9. Go back.");

                        Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                        userInput3 = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("\n\t=================================================================================\n");
                        Console.ForegroundColor = ConsoleColor.White;

                        //UserInput3 = 1, normal mode, New course-------------------------------------------------------------------------------------------------------
                        if (userInput3 == "1")
                        {
                            serviseInsert.InsertCourse();
                        }
                        //UserInput3 = 2, normal mode, List of courses-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "2")
                        {
                            c1.ListOfCoursecOutput(serviseGet.GetAllCourses());
                            MyStaticClass.PressKeyToContinue();
                        }
                        //UserInput3 = 3, normal mode, Add students at courses-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "3")
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine();
                            Console.WriteLine("\tSelect the number of course that you want to add students.");
                            Console.WriteLine();
                            Console.ForegroundColor = ConsoleColor.White;


                            List <Course> allCourses = serviseGet.GetAllCourses();
                            c1.ListOfCoursecOutput(allCourses);
                            Console.WriteLine();

                            do
                            {
                                Console.Write("\tEnter the apropriate number : ");
                                selectCourse = MyStaticClass.InputTryToConvertToInt();
                            } while (selectCourse <= 0 || selectCourse > allCourses.Count);


                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("\n\t=================================================================================\n");
                            Console.ForegroundColor = ConsoleColor.White;
                            do
                            {
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine("\tSelect how you want to add a student.");
                                Console.ForegroundColor = ConsoleColor.White;

                                Console.WriteLine();
                                Console.WriteLine("\t1. Add a new student.");
                                Console.WriteLine("\t2. Add an excisting student.");
                                Console.WriteLine("\t9. Go back.");

                                Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                                userInput5 = Console.ReadLine();

                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("\n\t=================================================================================\n");
                                Console.ForegroundColor = ConsoleColor.White;

                                if (userInput5 == "1")
                                {
                                    serviseInsert.InsertStudent();
                                    List <Student> students = serviseGet.GetAllStudents();
                                    serviseInsert.InsertStudentAtCourse((int)students[students.Count - 1].Sid, (int)allCourses[selectCourse - 1].Cid);
                                }
                                else if (userInput5 == "2")
                                {
                                    string addAnotherStudentfromList;
                                    bool   notSuccededAdd = true;
                                    do
                                    {
                                        Console.ForegroundColor = ConsoleColor.Yellow;
                                        Console.WriteLine();
                                        Console.WriteLine("\tSelect the number of student.");
                                        Console.WriteLine();
                                        Console.ForegroundColor = ConsoleColor.White;

                                        List <Student> allStudents = serviseGet.GetAllStudents();
                                        s1.ListOfStudentsOutput(allStudents);

                                        do
                                        {
                                            int userSelectStudent = 0;
                                            try
                                            {
                                                Console.WriteLine();
                                                Console.Write("\tEnter a propriate number : ");

                                                userSelectStudent = Convert.ToInt32(Console.ReadLine());
                                                if (userSelectStudent >= 0 && userSelectStudent <= allStudents.Count)
                                                {
                                                    if (serviceCheck.ExistStudentsPerCourse((int)allStudents[userSelectStudent - 1].Sid, (int)allCourses[selectCourse - 1].Cid))
                                                    {
                                                        Console.ForegroundColor = ConsoleColor.Red;
                                                        Console.WriteLine();
                                                        Console.WriteLine("\tThe student already exist in the course.");
                                                        Console.ForegroundColor = ConsoleColor.White;
                                                        notSuccededAdd          = true;
                                                    }
                                                    else
                                                    {
                                                        serviseInsert.InsertStudentAtCourse((int)allStudents[userSelectStudent - 1].Sid, (int)allCourses[selectCourse - 1].Cid);
                                                        notSuccededAdd = false;
                                                    }
                                                }
                                                else
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("\tPlease select a propriate number.");
                                                    Console.ForegroundColor = ConsoleColor.White;
                                                    notSuccededAdd          = true;
                                                }
                                            }
                                            catch (Exception)
                                            {
                                                Console.ForegroundColor = ConsoleColor.Red;
                                                Console.WriteLine("\tPlease select a propriate number.");

                                                Console.ForegroundColor = ConsoleColor.White;
                                                notSuccededAdd          = true;
                                            }
                                        } while (notSuccededAdd);

                                        //Ask to add another student from the list in course
                                        do
                                        {
                                            Console.WriteLine();
                                            Console.Write("\tWould you like to add another student from the list in course? Y/N : ");
                                            addAnotherStudentfromList = Console.ReadLine();
                                            Console.WriteLine();
                                        } while (addAnotherStudentfromList.ToUpper() != "Y" && addAnotherStudentfromList.ToUpper() != "N");
                                    } while (addAnotherStudentfromList.ToUpper() != "N");
                                }
                            } while ((userInput5 != "1" && userInput5 != "2") && userInput5 != "9");
                        }
                        //UserInput3 = 4, normal mode, Output students per course-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "4")
                        {
                            sPC.ListOfStudentsPerCourseOutput(serviseGet.GetStudentsPerCourse());
                            MyStaticClass.PressKeyToContinue();
                        }
                        //UserInput3 = 5, normal mode, Add trainers at courses-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "5")
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine();
                            Console.WriteLine("\tSelect the number of course that you want to add trainers.");
                            Console.WriteLine();
                            Console.ForegroundColor = ConsoleColor.White;

                            List <Course> allCourses = serviseGet.GetAllCourses();
                            c1.ListOfCoursecOutput(allCourses);
                            Console.WriteLine();

                            do
                            {
                                Console.Write("\tEnter the apropriate number : ");
                                selectCourse = MyStaticClass.InputTryToConvertToInt();
                            } while (selectCourse <= 0 || selectCourse > allCourses.Count);


                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("\n\t=================================================================================\n");
                            Console.ForegroundColor = ConsoleColor.White;
                            do
                            {
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine("\tSelect how you want to add a trainer.");
                                Console.ForegroundColor = ConsoleColor.White;

                                Console.WriteLine();
                                Console.WriteLine("\t1. Add a new trainer.");
                                Console.WriteLine("\t2. Add an excisting trainer.");
                                Console.WriteLine("\t9. Go back.");

                                Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                                userInput5 = Console.ReadLine();

                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("\n\t=================================================================================\n");
                                Console.ForegroundColor = ConsoleColor.White;
                            } while ((userInput5 != "1" && userInput5 != "2") && userInput5 != "9");

                            if (userInput5 == "1")
                            {
                                serviseInsert.InsertTrainer();
                                List <Trainer> trainers = serviseGet.GetAllTrainers();
                                serviseInsert.InsertTrainerAtCourse((int)trainers[trainers.Count - 1].Tid, (int)allCourses[selectCourse - 1].Cid);
                            }
                            else if (userInput5 == "2")
                            {
                                string addAnotherTrainerfromList;
                                bool   notSuccededAdd = true;
                                do
                                {
                                    Console.ForegroundColor = ConsoleColor.Yellow;
                                    Console.WriteLine();
                                    Console.WriteLine("\tSelect the number of trainer.");
                                    Console.WriteLine();
                                    Console.ForegroundColor = ConsoleColor.White;

                                    List <Trainer> allTrainers = serviseGet.GetAllTrainers();
                                    tr1.ListOfTrainersOutput(allTrainers);

                                    do
                                    {
                                        int selectTrainer = 0;
                                        try
                                        {
                                            Console.WriteLine();
                                            Console.Write("\tEnter a propriate number : ");

                                            selectTrainer = Convert.ToInt32(Console.ReadLine());
                                            if (selectTrainer >= 0 && selectTrainer <= allTrainers.Count)
                                            {
                                                if (serviceCheck.ExistTrainerPerCourse((int)allTrainers[selectTrainer - 1].Tid, (int)allCourses[selectCourse - 1].Cid))
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine();
                                                    Console.WriteLine("\tThe trainer already exist in the course.");
                                                    Console.ForegroundColor = ConsoleColor.White;
                                                    notSuccededAdd          = true;
                                                }
                                                else
                                                {
                                                    serviseInsert.InsertTrainerAtCourse((int)allTrainers[selectTrainer - 1].Tid, (int)allCourses[selectCourse - 1].Cid);
                                                    notSuccededAdd = false;
                                                }
                                            }
                                            else
                                            {
                                                Console.ForegroundColor = ConsoleColor.Red;
                                                Console.WriteLine("\tPlease select a propriate number.");
                                                Console.ForegroundColor = ConsoleColor.White;
                                                notSuccededAdd          = true;
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("\tPlease select a propriate number.");

                                            Console.ForegroundColor = ConsoleColor.White;
                                            notSuccededAdd          = true;
                                        }
                                    } while (notSuccededAdd);

                                    //Ask to add another student from the list in course
                                    do
                                    {
                                        Console.WriteLine();
                                        Console.Write("\tWould you like to add another student from the list in course? Y/N : ");
                                        addAnotherTrainerfromList = Console.ReadLine();
                                        Console.WriteLine();
                                    } while (addAnotherTrainerfromList.ToUpper() != "Y" && addAnotherTrainerfromList.ToUpper() != "N");
                                } while (addAnotherTrainerfromList.ToUpper() != "N");
                            }
                        }
                        //UserInput3 = 6, normal mode, Output trainers per course-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "6")
                        {
                            tPC.ListOfTrainersPerCourseOutput(serviseGet.GetTrainersPerCourse());
                            MyStaticClass.PressKeyToContinue();
                        }
                        //UserInput3 = 7, normal mode, Add assignments at courses-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "7")
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine();
                            Console.WriteLine("\tSelect the number of course that you want to add assignments.");
                            Console.WriteLine();
                            Console.ForegroundColor = ConsoleColor.White;


                            List <Course> allCourses = serviseGet.GetAllCourses();
                            c1.ListOfCoursecOutput(allCourses);
                            Console.WriteLine();

                            do
                            {
                                Console.Write("\tEnter the apropriate number : ");
                                selectCourse = MyStaticClass.InputTryToConvertToInt();
                            } while (selectCourse <= 0 || selectCourse > allCourses.Count);


                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("\n\t=================================================================================\n");
                            Console.ForegroundColor = ConsoleColor.White;

                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("\tSelect how you want to add an assignment.");
                            Console.ForegroundColor = ConsoleColor.White;
                            do
                            {
                                Console.WriteLine();
                                Console.WriteLine("\t1. Add a new assignment.");
                                Console.WriteLine("\t2. Add an excisting assignment.");
                                Console.WriteLine("\t9. Go back.");

                                Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                                userInput5 = Console.ReadLine();

                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("\n\t=================================================================================\n");
                                Console.ForegroundColor = ConsoleColor.White;
                            } while ((userInput5 != "1" && userInput5 != "2") && userInput5 != "9");

                            if (userInput5 == "1")
                            {
                                serviseInsert.InsertNewAssignmentAtCourse((int)allCourses[selectCourse - 1].Cid);
                            }
                            else if (userInput5 == "2")
                            {
                                string addAnotherAssignmentfromList;
                                bool   notSuccededAdd = true;

                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine();
                                Console.WriteLine("\tSelect the number of the assignment.");
                                Console.WriteLine();
                                Console.ForegroundColor = ConsoleColor.White;

                                List <Assignment> allAssignments = serviseGet.GetAllAssignments();
                                a1.ListOfAssignmentsOutput(allAssignments);

                                do
                                {
                                    int selectAssignment = 0;
                                    try
                                    {
                                        Console.WriteLine();
                                        Console.Write("\tEnter a propriate number : ");

                                        selectAssignment = Convert.ToInt32(Console.ReadLine());
                                        if (selectAssignment >= 0 && selectAssignment <= allAssignments.Count)
                                        {
                                            serviseInsert.InsertAssignmentAtCourse((int)allAssignments[selectAssignment - 1].Aid, (int)allCourses[selectCourse - 1].Cid);
                                            notSuccededAdd = false;
                                        }
                                        else
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("\tPlease select a propriate number.");
                                            Console.ForegroundColor = ConsoleColor.White;
                                            notSuccededAdd          = true;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        Console.WriteLine("\tPlease select a propriate number.");

                                        Console.ForegroundColor = ConsoleColor.White;
                                        notSuccededAdd          = true;
                                    }
                                } while (notSuccededAdd);
                            }
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("\n\t=================================================================================\n");
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        //UserInput3 = 8, normal mode, Output assignments per course-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "8")
                        {
                            aPC.OutputAssignmetsPerCourse(serviseGet.GetAssignmetsPerCourse());
                            MyStaticClass.PressKeyToContinue();
                        }
                    } while (userInput3 != "0" && userInput3 != "9");
                }
                //UserInput2 = 2, normal mode, Assignment--------------------------------------------------------------------------------------------------------------------
                else if (userInput2 == "2")
                {
                    do
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine();
                        Console.WriteLine("\tYou are in the assignment mode! What would you like to do?");
                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\t0. Exit.");
                        Console.WriteLine("\t1. New assignment.");
                        Console.WriteLine("\t2. Output list with all assignments.");
                        Console.WriteLine("\t3. Output list with assignments per course per student.");
                        Console.WriteLine("\t9. Go back.");

                        Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                        userInput3 = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("\n\t=================================================================================\n");
                        Console.ForegroundColor = ConsoleColor.White;

                        //UserInput3 = 1, normal mode, New Assignment-------------------------------------------------------------------------------------------------------
                        if (userInput3 == "1")
                        {
                            serviseInsert.InsertAssignment();
                        }
                        //UserInput3 = 2, normal mode, List of assignments-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "2")
                        {
                            a1.ListOfAssignmentsWithoutMarkOutput(serviseGet.GetAllAssignments());
                            MyStaticClass.PressKeyToContinue();
                        }
                        else if (userInput3 == "3")
                        {
                            aPCPS.ListOfAssignmentsPerCoursePerStudentOutput(serviseGet.GetAssignmentsPerCoursePerStudents());
                            MyStaticClass.PressKeyToContinue();
                        }
                    } while ((userInput3 != "0" && userInput3 != "9") && (userInput3 != "1" && (userInput3 != "2" && userInput3 != "3")));
                }
                //UserInput2 = 3, normal mode, Trainer--------------------------------------------------------------------------------------------------------------------
                else if (userInput2 == "3")
                {
                    do
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine();
                        Console.WriteLine("\tYou are in the trainer mode! What would you like to do?");
                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\t0. Exit.");
                        Console.WriteLine("\t1. New trainer.");
                        Console.WriteLine("\t2. Output list with all trainers.");
                        Console.WriteLine("\t9. Go back.");

                        Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                        userInput3 = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("\n\t=================================================================================\n");
                        Console.ForegroundColor = ConsoleColor.White;

                        //UserInput3 = 1, normal mode, New trainer-------------------------------------------------------------------------------------------------------
                        if (userInput3 == "1")
                        {
                            serviseInsert.InsertTrainer();
                        }
                        //UserInput3 = 2, normal mode, List of trainers-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "2")
                        {
                            tr1.ListOfTrainersOutput(serviseGet.GetAllTrainers());
                            MyStaticClass.PressKeyToContinue();
                        }
                    } while ((userInput3 != "0" && userInput3 != "9") && (userInput3 != "1" && userInput3 != "2"));
                }
                //UserInput2 = 4, normal mode, Student--------------------------------------------------------------------------------------------------------------------
                else if (userInput2 == "4")
                {
                    do
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine();
                        Console.WriteLine("\tYou are in the student mode! What would you like to do?");
                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\t0. Exit.");
                        Console.WriteLine("\t1. New student.");
                        Console.WriteLine("\t2. Output list with all students.");
                        Console.WriteLine("\t3. Output list witn students who belongs to more than one course.");
                        Console.WriteLine("\t9. Go back.");

                        Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : ");
                        userInput3 = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("\n\t=================================================================================\n");
                        Console.ForegroundColor = ConsoleColor.White;

                        //UserInput3 = 1, normal mode, New Student-------------------------------------------------------------------------------------------------------
                        if (userInput3 == "1")
                        {
                            serviseInsert.InsertStudent();
                        }
                        //UserInput3 = 2, normal mode, List of students-------------------------------------------------------------------------------------------------------
                        else if (userInput3 == "2")
                        {
                            s1.ListOfStudentsOutput(serviseGet.GetAllStudents());
                            MyStaticClass.PressKeyToContinue();
                        }

                        //UserInput3 = 3, normal mode, List of students who belongs to more than one course------------------------------------------------------------------------------------------------------ -
                        else if (userInput3 == "3")
                        {
                            sMTOC.ListOfStudentsOutput(serviseGet.GetStudentsWithMoreThanOneCourses());
                            MyStaticClass.PressKeyToContinue();
                        }
                    } while ((userInput3 != "0" && userInput3 != "9") && (userInput3 != "1" && userInput3 != "2") && (userInput3 != "3"));
                }
            } while ((userInput2 != "0" && userInput2 != "9") && userInput3 != "0");


            Console.WriteLine("\n\tTHANK YOU!!!");


            Console.ReadKey();
        }
Exemplo n.º 5
0
        public Data()
        {
            //creating students
            Student s1 = new Student("Panagiotis", "Grigoriou", new DateTime(1987, 3, 4), 3000);
            Student s2 = new Student("Konstantinos", "Pantelidis", new DateTime(1991, 6, 2), 4000);
            Student s3 = new Student("Spiros", "Aggelatos", new DateTime(1996, 4, 7), 3500);
            Student s4 = new Student("Dimitris", "Pantelopoulos", new DateTime(2000, 5, 2), 6200);
            Student s5 = new Student("Antonis", "Mixelakakis", new DateTime(1989, 10, 3), 5800);

            Students.Add(s1);
            Students.Add(s2);
            Students.Add(s3);
            Students.Add(s4);
            Students.Add(s5);

            //creating courses
            Course c1 = new Course("Javascript", "Web Development", "Practical Subject", new DateTime(2020, 1, 10), new DateTime(2020, 3, 11));
            Course c2 = new Course("C++", "Object-Oriented Programming", "Practical Subject", new DateTime(2020, 1, 18), new DateTime(2020, 4, 2));
            Course c3 = new Course("Pascal", "Procedural Programming", "Theoretical Subject", new DateTime(2020, 2, 15), new DateTime(2020, 5, 20));
            Course c4 = new Course("Visual Basic", "Windows Application Development", "Practical Subject", new DateTime(2020, 3, 20), new DateTime(2020, 6, 1));

            Courses.Add(c1);
            Courses.Add(c2);
            Courses.Add(c3);
            Courses.Add(c4);

            //creating trainers
            Trainer t1 = new Trainer("Giannis", "Aggelopoulos", "Object-Oriented Programming");
            Trainer t2 = new Trainer("Manolis", "Daskalakis", "Procedural Programming");
            Trainer t3 = new Trainer("Giorgos", "Mpatzoglou", "Procedural Programming");
            Trainer t4 = new Trainer("Thanassis", "Giorgakopoulos", "Object-Oriented Programming");

            Trainers.Add(t1);
            Trainers.Add(t2);
            Trainers.Add(t3);
            Trainers.Add(t4);

            //creating assignments
            Assignment a1 = new Assignment("Project Bank", "Banking application for android phones", new DateTime(2020, 4, 24), 40, 200);
            Assignment a2 = new Assignment("Project E-shop", "Shopping website", new DateTime(2020, 6, 11), 20, 100);
            Assignment a3 = new Assignment("Project Library", "Book rental service", new DateTime(2020, 4, 15), 35, 200);
            Assignment a4 = new Assignment("Project Cinema", "Movie distribution to cinemas", new DateTime(2020, 1, 2), 73, 100);
            Assignment a5 = new Assignment("Project Stocks", "Stock change notifications", new DateTime(2020, 3, 27), 110, 200);
            Assignment a6 = new Assignment("Project Architecture", "Blueprint making software", new DateTime(2020, 3, 24), 40, 150);

            Assignments.Add(a1);
            Assignments.Add(a2);
            Assignments.Add(a3);
            Assignments.Add(a4);
            Assignments.Add(a5);
            Assignments.Add(a6);

            //putting students in mini-lists (students per Course)
            List <Student> C1Stu = new List <Student>();
            List <Student> C2Stu = new List <Student>();
            List <Student> C3Stu = new List <Student>();

            C1Stu.Add(s2);
            C1Stu.Add(s3);

            C2Stu.Add(s1);
            C2Stu.Add(s2);
            C2Stu.Add(s3);

            C3Stu.Add(s1);

            //putting mini-lists in big lists (students per Course)
            StudentPerCourse stuPerCour1 = new StudentPerCourse(c1, C1Stu);
            StudentPerCourse stuPerCour2 = new StudentPerCourse(c2, C2Stu);
            StudentPerCourse stuPerCour3 = new StudentPerCourse(c3, C3Stu);

            StudentsPerCourse.Add(stuPerCour1);
            StudentsPerCourse.Add(stuPerCour2);
            StudentsPerCourse.Add(stuPerCour3);

            //putting trainers in mini-lists (trainers per Course)
            List <Trainer> C1Train = new List <Trainer>();
            List <Trainer> C2Train = new List <Trainer>();
            List <Trainer> C3Train = new List <Trainer>();

            C1Train.Add(t1);
            C1Train.Add(t2);

            C2Train.Add(t1);
            C2Train.Add(t3);

            C3Train.Add(t4);
            C3Train.Add(t1);

            //putting mini-lists in big lists (trainers per Course)
            TrainerPerCourse trainPerCour1 = new TrainerPerCourse(c1, C1Train);
            TrainerPerCourse trainPerCour2 = new TrainerPerCourse(c2, C2Train);
            TrainerPerCourse trainPerCour3 = new TrainerPerCourse(c3, C3Train);

            TrainersPerCourse.Add(trainPerCour1);
            TrainersPerCourse.Add(trainPerCour2);
            TrainersPerCourse.Add(trainPerCour3);

            //putting assignments in mini-lists (assignments per Course)
            List <Assignment> C1Assign = new List <Assignment>();
            List <Assignment> C2Assign = new List <Assignment>();
            List <Assignment> C3Assign = new List <Assignment>();

            C1Assign.Add(a1);
            C1Assign.Add(a2);

            C2Assign.Add(a3);

            C3Assign.Add(a5);
            C3Assign.Add(a4);

            //putting mini-lists in big lists (assignments per Course)
            AssignmentPerCourse assignPerCour1 = new AssignmentPerCourse(c1, C1Assign);
            AssignmentPerCourse assignPerCour2 = new AssignmentPerCourse(c2, C2Assign);
            AssignmentPerCourse assignPerCour3 = new AssignmentPerCourse(c3, C2Assign);

            AssignmentsPerCourse.Add(assignPerCour1);
            AssignmentsPerCourse.Add(assignPerCour2);
            AssignmentsPerCourse.Add(assignPerCour3);

            //putting assignments in mini-lists (assignments per Student)
            List <Assignment> S1Assign = new List <Assignment>();
            List <Assignment> S2Assign = new List <Assignment>();
            List <Assignment> S3Assign = new List <Assignment>();

            S1Assign.Add(a1);
            S1Assign.Add(a2);

            S2Assign.Add(a3);
            S2Assign.Add(a4);
            S2Assign.Add(a5);

            S3Assign.Add(a6);

            //putting mini-lists in big lists (assignments per Student)
            AssignmentPerStudent assignPerStu1 = new AssignmentPerStudent(s1, S1Assign);
            AssignmentPerStudent assignPerStu2 = new AssignmentPerStudent(s2, S2Assign);
            AssignmentPerStudent assignPerStu3 = new AssignmentPerStudent(s3, S3Assign);

            AssignmentsPerStudent.Add(assignPerStu1);
            AssignmentsPerStudent.Add(assignPerStu2);
            AssignmentsPerStudent.Add(assignPerStu3);

            //putting courses in mini-lists (courses per Student)
            List <Course> S1Cour = new List <Course>();
            List <Course> S2Cour = new List <Course>();
            List <Course> S3Cour = new List <Course>();

            S1Cour.Add(c2);
            S1Cour.Add(c3);


            S2Cour.Add(c1);
            S2Cour.Add(c2);

            S3Cour.Add(c1);
            S3Cour.Add(c2);

            //putting mini-lists in big lists (courses per Student)
            CoursePerStudent courPerStu1 = new CoursePerStudent(s1, S1Cour);
            CoursePerStudent courPerStu2 = new CoursePerStudent(s2, S2Cour);
            CoursePerStudent courPerStu3 = new CoursePerStudent(s3, S3Cour);


            CoursesPerStudent.Add(courPerStu1);
            CoursesPerStudent.Add(courPerStu2);
            CoursesPerStudent.Add(courPerStu3);

            //-------------------------------------------------------

            //AssignmentCourseStudent ACS1 = new AssignmentCourseStudent(s1, c2, a3);
            //AssignmentCourseStudent ACS2 = new AssignmentCourseStudent(s1, c3, a6);
            //AssignmentCourseStudent ACS3 = new AssignmentCourseStudent(s2, c1, a1);
            //AssignmentCourseStudent ACS4 = new AssignmentCourseStudent(s2, c2, a4);
            //AssignmentCourseStudent ACS5 = new AssignmentCourseStudent(s3, c1, a2);
            //AssignmentCourseStudent ACS6 = new AssignmentCourseStudent(s3, c2, a5);

            //ACSList.Add(ACS1);
            //ACSList.Add(ACS2);
            //ACSList.Add(ACS3);
            //ACSList.Add(ACS4);
            //ACSList.Add(ACS5);
            //ACSList.Add(ACS6);
        }