Beispiel #1
0
        public void MenuStudent(DataClasses1DataContext db, STUDENT sTuDent, Student student, Check_ID check_ID)
        {
            Course     course     = new Course();
            Assignment assignment = new Assignment();

            Console.WriteLine("\n\tSTUDENT MENU\n\t" + "------------");
            Console.WriteLine("\tCreate Student press   --->     {1}");
            Console.WriteLine("\tRead Student press     --->     {2}");
            Console.WriteLine("\tUpdate Student press   --->     {3}");
            Console.WriteLine("\tDelete Student press   --->     {4}");
            Console.Write("\tEnter a choice between ---> {1 - 4}: ");
            string stringChoice;

            stringChoice = Console.ReadLine();

            int outChoice;

            while (!int.TryParse(stringChoice, out outChoice) || outChoice < 1 || outChoice > 4)
            {
                Console.WriteLine("\n\tThe choice should be Only integer between {1- 4}!!!");
                Console.Write("\tEnter a new choice: ");
                stringChoice = Console.ReadLine();
            }
            int choice = outChoice;

            switch (choice)
            {
            case (int)SelectionforStudent.create:
                int user_ID = CreateUser(db);
                student.CreateStudent(user_ID, db);
                break;

            case (int)SelectionforStudent.read:
                int studentID = check_ID.GetTrueStudentID(student, db);
                student.ReadStudent(db, studentID);
                break;

            case (int)SelectionforStudent.update:
                studentID = check_ID.GetTrueStudentID(student, db);
                student.UpdateStudent(db, sTuDent, studentID);
                break;

            case (int)SelectionforStudent.delete:
                studentID = check_ID.GetTrueStudentID(student, db);
                user_ID   = GetUserID(studentID, db);
                int courseID     = course.GetCourseIDFromStudentID(studentID, db);
                int assignmentID = getAssignmentIDFromCourseIDThisUser(courseID, db);
                DeleteOfStudentsAsUsers(db, studentID, user_ID, courseID, assignmentID);
                break;
            }
        }
Beispiel #2
0
        public void CreateStudentsPerCourses(STUDENT_PER_COURSE sTudentPerCourse, DataClasses1DataContext db)
        {
            StudentPerCourse studentPerCourse = new StudentPerCourse();
            Student          student          = new Student();

            Console.WriteLine("\n\n\t" + "CREATE STUDENTS PER COURSES" +
                              "\n\t----------------------------");

            Console.WriteLine("\tFor Create a new student press  --> {1}");
            Console.WriteLine("\tAdd Student to course/s press   --> {2}");
            Console.Write("\tEnter a choice between     -->  {1 - 2}: ");
            string stringChoice = Console.ReadLine();

            Console.WriteLine();
            int outChoice;

            while (!int.TryParse(stringChoice, out outChoice) || outChoice < 1 || outChoice > 2)
            {
                Console.WriteLine("\n\tThe choice should be Only integer between {1- 2}!!!");
                Console.Write("\tEnter a new choice: ");
                stringChoice = Console.ReadLine();
            }
            int choice = outChoice;
            int studentID;

            switch (choice)
            {
            case (int)SelectionCreateStudentOrAdd.create:
                int user_ID = CreateUser(db);
                student.CreateStudent(user_ID, db);
                break;

            case (int)SelectionCreateStudentOrAdd.add:
                Check_ID check_ID = new Check_ID();
                studentID = check_ID.GetTrueStudentID(student, db);     // Έγκυρο STUDENT ID
                TimesToInsertToCourses(studentID, check_ID, db);
                break;
            }
        }