Example #1
0
        public void TimesToInsertToCourses(int studentID, Check_ID check_ID, DataClasses1DataContext db) // Λίστα με τυς αριθμούς των μαθημάτων που θέλουμε να εγγραφούμε
        {
            Course course = new Course();
            int    count  = 1;
            int    limitNumberOfCourses = check_ID.AvailableNumberOfCourses(studentID, db);

            if (limitNumberOfCourses > 0)
            {
                Console.WriteLine($"\n\tNumber Of available course/s for register {check_ID.AvailableNumberOfCourses(studentID, db)}!");
                int numberTocourses = GetNumberToInsertToCourses();
                while (numberTocourses > limitNumberOfCourses)
                {
                    Console.WriteLine("\n\tΥou have overtaken the limit of Courses!!!");
                    Console.Write($"\tEnter again a number of courses between 1-{limitNumberOfCourses}: ");
                    numberTocourses = GetNumberToInsertToCourses();
                }
                int courseID = course.GetCourseIDFromStudentID(studentID, db);
                var listNumbersOfcoursesID = new List <int>();
                while (count <= numberTocourses)
                {
                    courseID = check_ID.GetTrueCourseID(studentID, courseID, db); // Έγκυρο COURSE ID
                    check_ID.CheckAvailableCoursesID(listNumbersOfcoursesID, check_ID, studentID, courseID, db);
                    count += 1;
                    Console.WriteLine("\tEnrolled successfully");
                }
            }
            else
            {
                Console.WriteLine("\n\tΥou have completed the courses limit!!!");
            }
        }
Example #2
0
        public int GetTrueCourseIDForCreate(Check_ID check_ID, DataClasses1DataContext db) // Για δημιουργία
        {
            Console.Write("\n\tEnter Course ID: ");
            string courseId = Console.ReadLine();
            int    courseidOut;

            while (!int.TryParse(courseId, out courseidOut))
            {
                Console.WriteLine("\n\t" + "Course ID should be Only Integer!!!");
                Console.Write("\t" + "Give a new Course ID: ");
                courseId = Console.ReadLine();
            }
            int  courseID = courseidOut;
            bool exist    = check_ID.CheckCourseID(courseID, db);

            while (!exist)
            {
                Console.Write("\n\tThis Course ID not Exist!!! ");
                Console.Write("\n\tEnter New Course ID: ");
                courseId = Console.ReadLine();
                while (!int.TryParse(courseId, out courseidOut))
                {
                    Console.WriteLine("\n\t" + "Course ID should be Only Integer!!!");
                    Console.Write("\t" + "Give a new Course ID: ");
                    courseId = Console.ReadLine();
                }
                courseID = courseidOut;
                exist    = check_ID.CheckCourseID(courseID, db);
            }
            return(courseID);
        }
Example #3
0
        public TRAINER CreateTrainer(int user_ID, DataClasses1DataContext db, TRAINER trainer)
        {
            Check_ID check_ID = new Check_ID();
            User     user     = new User();

            Console.WriteLine("\n\n\t" + "CREATE TRAINER" + "\n\t--------------");
            trainer = new TRAINER();

            Console.Write("\t" + "Firstname (Only Letter!): ");
            trainer.F_NAME = Console.ReadLine();

            while (!trainer.F_NAME.All(char.IsLetter) || string.IsNullOrEmpty(trainer.F_NAME))
            {
                Console.Write("\n\t" + "Trainer firstname should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Trainer firtsname: ");
                trainer.F_NAME = Console.ReadLine();
            }
            trainer.F_NAME = char.ToUpper(trainer.F_NAME[0]) + trainer.F_NAME.Substring(1);

            Console.Write("\t" + "Lastname (Only Letter!): ");
            trainer.L_NAME = Console.ReadLine();

            while (!trainer.L_NAME.All(char.IsLetter) || string.IsNullOrEmpty(trainer.L_NAME))
            {
                Console.Write("\n\t" + "Trainer lastname should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Trainer lastname: ");
                trainer.L_NAME = Console.ReadLine();
            }
            trainer.L_NAME = char.ToUpper(trainer.L_NAME[0]) + trainer.L_NAME.Substring(1);

            Console.Write("\t" + "Subject (Only Letter!): ");
            trainer.SUBJECT = Console.ReadLine();

            while (!trainer.SUBJECT.All(char.IsLetter) || string.IsNullOrEmpty(trainer.SUBJECT))
            {
                Console.Write("\n\t" + "Trainer Subject should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Trainer Subject: ");
                trainer.SUBJECT = Console.ReadLine();
            }
            trainer.SUBJECT.ToUpper();

            Console.Write("\t" + "Trainer ID (Only Integer!): ");
            string trainerId = Console.ReadLine();
            int    trainerIdOut;

            while (!int.TryParse(trainerId, out trainerIdOut) || trainerIdOut <= 0)
            {
                Console.WriteLine("\n\t" + "Trainer ID should be Only Integer and not Zero!!!");
                Console.Write("\t" + "Give a new Trainer ID: ");
                trainerId = Console.ReadLine();
            }
            int trainerIDAfterCheck = check_ID.positiveIntegerForTrainerID(trainerIdOut);

            trainer.TRAINER_ID = check_ID.UniqueTrainerID(trainerIDAfterCheck, db);
            trainer.USERR_ID   = user_ID;

            InsertTrainer(trainer, db);
            Console.WriteLine("\n\tCreate Trainer Cuccessfully!!!");
            return(trainer);
        }
Example #4
0
        public void DeleteStudentsPerCourses(STUDENT_PER_COURSE studentPerCourse, DataClasses1DataContext db)
        {
            STUDENT  sTudent  = new STUDENT();
            Student  student  = new Student();
            Course   course   = new Course();
            Check_ID check_ID = new Check_ID();
            var      listTotalNumbersOfCourses = new List <int>();

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


            Console.WriteLine("\t" + "For Dalete one only course press --> {1}");
            Console.WriteLine("\t" + "For Delete all courses prees     --> {2}");
            Console.Write("\t" + "Give a choise between    v  -->  {1 - 2}: ");
            string selection = Console.ReadLine();
            int    choice;

            while (!int.TryParse(selection, out choice) || string.IsNullOrEmpty(selection) || choice < 1 || choice > 2)
            {
                Console.Write("\n\t" + "Give choice again Only Integer between {1 - 2}!!!: ");
                selection = Console.ReadLine();
            }

            int studentID = check_ID.GetTrueStudentIDWhoHaveCourses(student, db);

            if (choice == 1)
            {
                int courseID = course.GetTrueCourseIDForCreate(check_ID, db);
                studentPerCourse            = db.STUDENT_PER_COURSEs.Single(i => i.STUDENT_ID == studentID && i.COURSE_ID == courseID);
                studentPerCourse.STUDENT_ID = studentID;
                studentPerCourse.COURSE_ID  = courseID;
                db.STUDENT_PER_COURSEs.DeleteOnSubmit(studentPerCourse);
                db.SubmitChanges();
            }
            else
            {
                listTotalNumbersOfCourses = GetListTotalNumbersOfCourses(db, studentID);
                int count = 1;

                while (count <= listTotalNumbersOfCourses.Count())
                {
                    foreach (int i in listTotalNumbersOfCourses)
                    {
                        studentPerCourse            = db.STUDENT_PER_COURSEs.Single(j => j.STUDENT_ID == studentID && j.COURSE_ID == i);
                        studentPerCourse.STUDENT_ID = studentID;
                        studentPerCourse.COURSE_ID  = i;
                        db.STUDENT_PER_COURSEs.DeleteOnSubmit(studentPerCourse);
                        db.SubmitChanges();
                        count += 1;
                    }
                }
            }
            Console.WriteLine("\n\tDeleted Succesfully!!!");
        }
Example #5
0
        public void MenuUser(DataClasses1DataContext db)
        {
            Check_ID check_ID = new Check_ID();
            string   userID;

            Console.WriteLine("\n\tUSER MENU\n\t" + "---------\n");
            check_ID.AvailableUserID(db);
            Console.Write("\n\n\tEnter User ID for Deleted (Only Integer!): ");
            userID = Console.ReadLine();
            int userIDOut;

            while (!int.TryParse(userID, out userIDOut))
            {
                Console.WriteLine("\n\tUser ID should be Only Integer!!!");
                Console.Write("\tEnter again User ID: ");
                userID = Console.ReadLine();
            }
            int user_ID = userIDOut;

            int userIdAfterCheck = check_ID.GetTrueUserID(user_ID, db);
            var getUser          = from i in db.USERRs
                                   where i.USERR_ID == userIdAfterCheck
                                   select i;

            var user = getUser.ToList().FirstOrDefault();

            Console.WriteLine($"\tRole: {user.ROLEE}");

            switch (user.ROLEE)
            {
            case "STUDENT":
            case "student":
                int studentID    = getStudentIdFromUserID(userIdAfterCheck, db);
                int courseID     = getCourseIdFromStudentID(studentID, db);
                int assignmnetID = getAssignmentIDFromCourseIDThisUser(courseID, db);
                DeleteOfStudentsAsUsers(db, studentID, userIdAfterCheck, courseID, assignmnetID);
                break;

            case "TRAINER":
            case "trainer":
                int trainerID = getTrainerIdFromUserID(userIdAfterCheck, db);
                int courseId  = getCourseIdFromTrainerID(trainerID, db);
                DeleteOfTrainersAsUsers(db, userIdAfterCheck, courseId, trainerID);
                break;

            default:
                Console.WriteLine("\tThis User not exist!");
                break;
            }
        }
Example #6
0
        public void CheckAvailableCoursesID(List <int> listNumbersOfCourses, Check_ID check_ID, int studentID, int courseID, DataClasses1DataContext db)
        {
            StudentPerCourse   studentPerCourse = new StudentPerCourse();
            STUDENT_PER_COURSE sTudentPerCourse = new STUDENT_PER_COURSE();

            bool thisCourseIDExist = GetAvailableCoursesIdForThisStudentFromDB(studentID, courseID, db);

            while (thisCourseIDExist)
            {
                Console.WriteLine("\tΥou are enrolled in this course!");
                courseID          = check_ID.GetTrueCourseID(studentID, courseID, db); // Έγκυρο COURSE ID
                thisCourseIDExist = GetAvailableCoursesIdForThisStudentFromDB(studentID, courseID, db);
            }

            studentPerCourse.AddStudentsToCourses(studentID, courseID, sTudentPerCourse, check_ID, db);
            listNumbersOfCourses.Add(courseID);
        }
Example #7
0
        public void MenuStudentPerCourse(DataClasses1DataContext db)
        {
            STUDENT_PER_COURSE studentPerCourse = new STUDENT_PER_COURSE();
            Student            student          = new Student();
            Check_ID           check_ID         = new Check_ID();

            string stringChoice;

            Console.WriteLine("\n\tSTUDENT PER COURSE MENU\n\t" + "-----------------------");
            Console.WriteLine("\tCreate STUDENT PER COURSE press     --->  {1}");
            Console.WriteLine("\tRead STUDENT PER COURSE press       --->  {2}");
            Console.WriteLine("\tUpdate STUDENT PER COURSE press     --->  {3}");
            Console.WriteLine("\tDelete STUDENT PER COURSE press     --->  {4}");
            Console.Write("\tEnter a choice between --->           {1 - 4}: ");
            stringChoice = Console.ReadLine();
            Console.WriteLine();
            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)SelectionStudentPerCourse.create:
                CreateStudentsPerCourses(studentPerCourse, db);
                break;

            case (int)SelectionStudentPerCourse.read:
                int studentID = check_ID.GetTrueStudentIDWhoHaveCourses(student, db);
                ReadStudentsPerCourses(db, studentID);
                break;

            case (int)SelectionStudentPerCourse.update:
                UpdateStudentsPerCourses(studentPerCourse, db);
                break;

            case (int)SelectionStudentPerCourse.delete:
                DeleteStudentsPerCourses(studentPerCourse, db);
                break;
            }
        }
Example #8
0
        public void MenuTrainer(DataClasses1DataContext db, TRAINER trainer)
        {
            Check_ID check_ID = new Check_ID();
            string   stringChoice;

            Console.WriteLine("\n\tTRAINER MENU\n\t" + "------------");
            Console.WriteLine("\tCreate Trainer press   --->     {1}");
            Console.WriteLine("\tRead Trainer press     --->     {2}");
            Console.WriteLine("\tUpdate Trainer press   --->     {3}");
            Console.WriteLine("\tDelete Trainer press   --->     {4}");
            Console.Write("\tEnter a choice between ---> {1 - 4}: ");
            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)SelectionTrainer.create:
                int user_ID = CreateUser(db);
                CreateTrainer(user_ID, db, trainer);
                break;

            case (int)SelectionTrainer.read:
                ReadTrainer(db);
                break;

            case (int)SelectionTrainer.update:
                UpdateTrainer(db, trainer);
                break;

            case (int)SelectionTrainer.delete:
                int trainerID = check_ID.GetTrueTrainerID(db);
                int uSer_ID   = getUserIdFromTrainerID(trainerID, db);
                int courseId  = getCourseIdFromTrainerID(trainerID, db);
                DeleteOfTrainersAsUsers(db, uSer_ID, courseId, trainerID);
                break;
            }
        }
Example #9
0
        public void UpdateStudentsPerCourses(STUDENT_PER_COURSE studentPerCourse, DataClasses1DataContext db)
        {
            STUDENT  sTudent  = new STUDENT();
            Student  student  = new Student();
            Check_ID check_ID = new Check_ID();

            int studentID = check_ID.GetTrueStudentIDWhoHaveCourses(student, db);

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

            sTudent = student.UpdateStudent(db, sTudent, studentID);
            int courseID = GetCourseIdFromStudent(db, sTudent.STUDENT_ID);

            studentPerCourse.STUDENT_ID = sTudent.STUDENT_ID;
            studentPerCourse.COURSE_ID  = courseID;
            db.SubmitChanges();
            Console.WriteLine("\n\tStudents Per Courses was successfully enrolled!!!");
        }
Example #10
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;
            }
        }
Example #11
0
        public void DeleteCourses(int studentID, STUDENT_PER_COURSE studentPerCourse, DataClasses1DataContext db) // Χρησιμοποιείται στη κλάση USER στη μέθοδο
        {                                                                                                         // DeleteOfAll για γενική διαγραφή
            Student  student  = new Student();
            Check_ID check_ID = new Check_ID();

            var listTotalNumbersOfCourses = new List <int>();

            listTotalNumbersOfCourses = GetListTotalNumbersOfCourses(db, studentID);
            int count = 1;

            while (count <= listTotalNumbersOfCourses.Count())
            {
                foreach (int i in listTotalNumbersOfCourses)
                {
                    studentPerCourse            = db.STUDENT_PER_COURSEs.Single(j => j.STUDENT_ID == studentID && j.COURSE_ID == i);
                    studentPerCourse.STUDENT_ID = studentID;
                    studentPerCourse.COURSE_ID  = i;
                    db.STUDENT_PER_COURSEs.DeleteOnSubmit(studentPerCourse);
                    db.SubmitChanges();
                    count += 1;
                }
            }
        }
Example #12
0
        public void DeleteTrainersGeneral(int trainerID, TRAINER_PER_COURSE tRainerPerCourse, DataClasses1DataContext db) // Χρησιμοποιείται στη κλάση USER στη μέθοδο
        {                                                                                                                 // DeleteOfAll για γενική διαγραφή
            Trainer  trainer  = new Trainer();
            Check_ID check_ID = new Check_ID();

            var listTotalNumbersOfCourses = new List <int>();

            listTotalNumbersOfCourses = GetListTotalNumbersOfCourses(db, trainerID);
            int count = 1;

            while (count <= listTotalNumbersOfCourses.Count())
            {
                foreach (int i in listTotalNumbersOfCourses)
                {
                    tRainerPerCourse            = db.TRAINER_PER_COURSEs.Single(j => j.TRAINER_ID == trainerID && j.COURSE_ID == i);
                    tRainerPerCourse.TRAINER_ID = trainerID;
                    tRainerPerCourse.COURSE_ID  = i;
                    db.TRAINER_PER_COURSEs.DeleteOnSubmit(tRainerPerCourse);
                    db.SubmitChanges();
                    count += 1;
                }
            }
        }
Example #13
0
        public void ReadStudentsPerCourses(DataClasses1DataContext db, int studentID)
        {
            Check_ID           check_ID         = new Check_ID();
            STUDENT_PER_COURSE studentPerCourse = new STUDENT_PER_COURSE();
            Student            student          = new Student();

            var resultStudentPerCourse = from i in db.STUDENT_PER_COURSEs
                                         where i.STUDENT_ID == studentID
                                         select i;

            studentPerCourse = resultStudentPerCourse.ToList().FirstOrDefault();

            var studentName = resultStudentPerCourse.ToList().Take(1);

            studentName.ToList().ForEach(i => Console.WriteLine("\n\t" + "STUDENT" + "\n" +
                                                                "\t" + "-------" + "\n" +
                                                                "\t" + $"Firstname: {i.STUDENT.F_NAME}" + "\n" +
                                                                "\t" + $"Lastname: {i.STUDENT.L_NAME}" + "\n"));

            Console.WriteLine("\t" + "COURSES" + "\n" + "\t" + "-------");
            resultStudentPerCourse.ToList().ForEach(i => Console.WriteLine("\t" + $"Course Stream: { i.COURSE.STREAM }" + "\n" +
                                                                           "\t" + $"Week Day: {i.COURSE.WEEK_DAY}" + "\n"));
        }
        public void DeleteAssignemnts(int studentID, ASSIGNMENT_PER_STUDENT aSSignmentPerStudent, DataClasses1DataContext db) // Χρησιμοποιείται στη κλάση USER στη μέθοδο
        {                                                                                                                     // DeleteOfAll για γενική διαγραφή
            Student  student  = new Student();
            Check_ID check_ID = new Check_ID();

            var listTotalNumbersOfAssignemnts = new List <int>();

            listTotalNumbersOfAssignemnts = GetListTotalNumbersOfAssignments(db, studentID);
            int count = 1;

            while (count <= listTotalNumbersOfAssignemnts.Count())
            {
                foreach (int i in listTotalNumbersOfAssignemnts)
                {
                    aSSignmentPerStudent               = db.ASSIGNMENT_PER_STUDENTs.Single(j => j.STUDENT_ID == studentID && j.ASSIGNMENT_ID == i);
                    aSSignmentPerStudent.STUDENT_ID    = studentID;
                    aSSignmentPerStudent.ASSIGNMENT_ID = i;
                    db.ASSIGNMENT_PER_STUDENTs.DeleteOnSubmit(aSSignmentPerStudent);
                    db.SubmitChanges();
                    count += 1;
                }
            }
        }
Example #15
0
        public int CreateUser(DataClasses1DataContext db)
        {
            Check_ID check_ID = new Check_ID();
            USERR    uSer     = new USERR();

            string password;

            Console.WriteLine("\n\tWe must first create a new User!\n\t" +
                              "--------------------------------");
            Console.Write("\tEnter Username: "******"\n\tUsername shouldn't be empty!!!");
                Console.Write("\n\t" + "Give a new Username: "******"\tEnter Password: "******"\n\tPassword shouldn't be empty!!!");
                Console.Write("\n\t" + "Give a new Password: "******"\tEncrypted Password: {" + $"{hashedpass}" + "}");

            Console.Write("\tEnter User Role between {STUDENT - TRAINER - HEADMASTER}: ");
            string role = Console.ReadLine().ToUpper();

            while (!role.All(char.IsLetter) || string.IsNullOrEmpty(role))
            {
                Console.Write("\n\tUser role should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new User role: ");
                role = Console.ReadLine().ToUpper();
            }
            uSer.ROLEE = check_ID.CheckRole(role);


            Console.Write("\tEnter User ID (Only Integer!): ");
            string userId = Console.ReadLine();
            int    userIDOut;

            while (!int.TryParse(userId, out userIDOut) || userIDOut <= 0)
            {
                Console.Write("\n\tUser ID should be Only Integer and not Zero!!!");
                Console.Write("\n\t" + "Give a new User ID: ");
                userId = Console.ReadLine();
            }
            int userIDAfterCheck = check_ID.positiveInteger(userIDOut);

            uSer.USERR_ID = check_ID.UniqueUserID(userIDAfterCheck, db);
            db.USERRs.InsertOnSubmit(uSer);
            db.SubmitChanges();
            ReadUser(uSer.USERR_ID, db);
            return(uSer.USERR_ID);
        }
Example #16
0
        public COURSE CreateCourse(DataClasses1DataContext db, COURSE course)
        {
            Check_ID check_ID = new Check_ID();
            DateTime date     = new DateTime();

            Console.WriteLine("\n\n\t" + "CREATE COURSE" + "\n\t-------------");
            Console.Write("\t" + "Course ID (Only Integer!): ");
            string courseID = Console.ReadLine();
            int    courseIdOut;

            while (!int.TryParse(courseID, out courseIdOut) || courseIdOut <= 0)
            {
                Console.WriteLine("\n\t" + "Course ID should be Only Integer and not Zero!!!");
                Console.Write("\t" + "Give a new Course ID: ");
                courseID = Console.ReadLine();
            }
            int courseIDAfterCheck = check_ID.positiveIntegerForCourseID(courseIdOut);

            course.COURSE_ID = check_ID.UniqueCourseID(courseIDAfterCheck, db);

            Console.Write("\t" + "Title (Only Letter!): ");
            course.TITLE = Console.ReadLine();
            while (!course.TITLE.All(char.IsLetter) || string.IsNullOrEmpty(course.TITLE))
            {
                Console.Write("\n\t" + "Course Title should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Course Title: ");
                course.TITLE = Console.ReadLine();
            }
            course.TITLE = char.ToUpper(course.TITLE[0]) + course.TITLE.Substring(1);

            Console.Write("\t" + "Stream (Only Letter!): ");
            course.STREAM = Console.ReadLine();
            while (!course.STREAM.All(char.IsLetter) || string.IsNullOrEmpty(course.STREAM))
            {
                Console.Write("\n\t" + "Course Stream should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Course Stream: ");
                course.STREAM = Console.ReadLine();
            }
            course.STREAM = char.ToUpper(course.STREAM[0]) + course.STREAM.Substring(1);

            Console.Write("\t" + "Type (Only Letter!): ");
            course.TYPE = Console.ReadLine();
            while (!course.TYPE.All(char.IsLetter) || string.IsNullOrEmpty(course.TYPE))
            {
                Console.Write("\n\t" + "Course Type should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Course Type: ");
                course.TYPE = Console.ReadLine();
            }
            course.TYPE = char.ToUpper(course.TYPE[0]) + course.TYPE.Substring(1);

            Console.Write("\t" + "Start Date (Example: {" + $"{DateTime.Now.ToShortDateString()}" + "}): ");
            string startDate = Console.ReadLine();

            while (!DateTime.TryParse(startDate, out date))
            {
                Console.Write("\n\tInvalid Date Type!!!\n\tExample {" + $"{DateTime.Now.ToShortDateString()}" + "}: ");
                startDate = Console.ReadLine();
            }
            DateTime dateTime = date;

            course.START_DATE = dateTime;

            Console.Write("\t" + "End Time (Example: {" + $"{DateTime.Now.ToShortDateString()}" + "}): ");
            string endDate = Console.ReadLine();

            while (!DateTime.TryParse(endDate, out date))
            {
                Console.Write("\n\tInvalid Date Type!!!\n\tExample {" + $"{DateTime.Now.ToShortDateString()}" + "}: ");
                endDate = Console.ReadLine();
            }
            DateTime datetime = date;

            course.END_TIME = datetime;

            Console.Write("\t" + "Week Day (Only Letter!): ");
            course.WEEK_DAY = Console.ReadLine().ToUpper();
            while (!course.WEEK_DAY.All(char.IsLetter) || string.IsNullOrEmpty(course.WEEK_DAY))
            {
                Console.Write("\n\t" + "Course Week Day should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Course Week Day: ");
                course.WEEK_DAY = Console.ReadLine().ToUpper();
            }
            InsertCourse(course, db);
            Console.WriteLine("\n\tInsert Course Cuccessfully!!!");
            return(course);
        }
Example #17
0
 public void AddStudentsToCourses(int studentID, int courseID, STUDENT_PER_COURSE studentPerCourse, Check_ID check_ID, DataClasses1DataContext db)
 {
     studentPerCourse.COURSE_ID  = courseID;
     studentPerCourse.STUDENT_ID = studentID;
     db.STUDENT_PER_COURSEs.InsertOnSubmit(studentPerCourse);
     db.SubmitChanges();
 }
Example #18
0
        public ASSIGNMENT CreateAssignment(ASSIGNMENT assignment, DataClasses1DataContext db)
        {
            Check_ID check_ID = new Check_ID();
            DateTime date     = new DateTime();

            Console.WriteLine("\n\n\t" + "CREATE ASSIGNMENT" + "\n\t-----------------");
            assignment = new ASSIGNMENT();

            Console.Write("\t" + "Assignment ID (Only Integer!): ");
            string assignmentId = Console.ReadLine();
            int    assignmentIdOut;

            while (!int.TryParse(assignmentId, out assignmentIdOut) || assignmentIdOut <= 0)
            {
                Console.WriteLine("\n\t" + "Assignment ID should be Only Integer and not Zero!!!");
                Console.Write("\t" + "Give a new Assignment ID: ");
                assignmentId = Console.ReadLine();
            }
            int assignmnetIDAfterCheck = check_ID.positiveIntegerForAssignmnetID(assignmentIdOut);

            assignment.ASSIGNMENT_ID = check_ID.UniqueAssignmentID(assignmnetIDAfterCheck, db);

            Console.Write("\t" + "Title (Only Letter!): ");
            assignment.TITLE = Console.ReadLine();

            while (!assignment.TITLE.All(char.IsLetter) || string.IsNullOrEmpty(assignment.TITLE))
            {
                Console.Write("\n\t" + "Assignment Title should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Assignment Title: ");
                assignment.TITLE = Console.ReadLine();
            }
            assignment.TITLE.ToUpper();

            Console.Write("\t" + "Description (Only Letter!): ");
            assignment.DESCRIPTIONN = Console.ReadLine();

            while (!assignment.DESCRIPTIONN.All(char.IsLetter) || string.IsNullOrEmpty(assignment.DESCRIPTIONN))
            {
                Console.Write("\n\t" + "Assignment Description should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Assignment Description: ");
                assignment.DESCRIPTIONN = Console.ReadLine();
            }
            assignment.DESCRIPTIONN.ToUpper();

            Console.Write("\t" + "Subbmision date and time (Example: {" + $"{DateTime.Now.ToShortDateString()}" + "}): ");
            string subbmisionDateAndTime = Console.ReadLine();

            while (!DateTime.TryParse(subbmisionDateAndTime, out date))
            {
                Console.Write("\n\tInvalid Date Type!!!\n\tExample {" + $"{DateTime.Now.ToShortDateString()}" + "}: ");
                subbmisionDateAndTime = Console.ReadLine();
            }
            DateTime dateTime = date;

            assignment.SUBMISSION_DATE_AND_TIME = dateTime;

            Console.Write("\t" + "Assignment Oral Mark (Only Decimal!): ");
            string  assignmentOralMark = Console.ReadLine();
            decimal assignmentOralMarkOut;

            while (!decimal.TryParse(assignmentOralMark, out assignmentOralMarkOut))
            {
                Console.WriteLine("\n\t" + "Assignment Oral Mark should be Only Decimal!!!");
                Console.Write("\t" + "Give a new Assignment Oral Mark: ");
                assignmentOralMark = Console.ReadLine();
            }
            decimal assignmentORalMark = assignmentOralMarkOut;

            assignment.ORAL_MARK = assignmentORalMark;

            Console.Write("\t" + "Assignment Total Mark (Only Decimal!): ");
            string  assignmentTotalMark = Console.ReadLine();
            decimal assignmentTotalMarkOut;

            while (!decimal.TryParse(assignmentTotalMark, out assignmentTotalMarkOut))
            {
                Console.WriteLine("\n\t" + "Assignment Total Mark should be Only Decimal!!!");
                Console.Write("\t" + "Give a new Assignment Total Mark: ");
                assignmentTotalMark = Console.ReadLine();
            }
            decimal assignmenTOtalMark = assignmentTotalMarkOut;

            assignment.TOTAL_MARK = assignmenTOtalMark;

            InsertAssignment(assignment, db);
            Console.WriteLine("\n\tCreate Assignment Cuccessfully!!!");

            return(assignment);
        }
Example #19
0
        public STUDENT CreateStudent(int user_ID, DataClasses1DataContext db)
        {
            DateTime date     = new DateTime();
            STUDENT  student  = new STUDENT();
            User     user     = new User();
            Check_ID check_ID = new Check_ID();

            Console.WriteLine("\n\n\t" + "CREATE STUDENT" + "\n\t--------------");
            student = new STUDENT();
            Console.Write("\t" + "Firstname (Only Letter!): ");
            student.F_NAME = Console.ReadLine();
            while (!student.F_NAME.All(char.IsLetter) || string.IsNullOrEmpty(student.F_NAME)) // Μόνο γράμματα όχι αριθμούς και κενή συμβολοσειρά
            {
                Console.Write("\n\t" + "Student firstname should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Student firtsname: ");
                student.F_NAME = Console.ReadLine();
            }
            student.F_NAME = char.ToUpper(student.F_NAME[0]) + student.F_NAME.Substring(1); // Πρώτο γράμμα κεφαλαίο
            Console.Write("\t" + "Lastname (Only Letter!): ");
            student.L_NAME = Console.ReadLine();
            while (!student.L_NAME.All(char.IsLetter) || string.IsNullOrEmpty(student.L_NAME))
            {
                Console.Write("\n\t" + "Student lastname should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Student lastname: ");
                student.L_NAME = Console.ReadLine();
            }
            student.L_NAME = char.ToUpper(student.L_NAME[0]) + student.L_NAME.Substring(1);

            Console.Write("\t" + "Student ID (Only Integer!): ");
            string studentId = Console.ReadLine();
            int    studentIdOut;

            while (!int.TryParse(studentId, out studentIdOut) || studentIdOut <= 0)
            {
                Console.WriteLine("\n\t" + "Student ID should be Only Integer and not Zero!!!");
                Console.Write("\t" + "Give a new Student ID: ");
                studentId = Console.ReadLine();
            }
            int studentIDAfterCheck = check_ID.positiveIntegerForStudentID(studentIdOut);

            student.STUDENT_ID = check_ID.UniqueStudentID(studentIDAfterCheck, db);
            Console.Write("\t" + "Tuition (Only Decimal!): ");
            string  studentTuition = Console.ReadLine();
            decimal studentTuitionOut;

            while (!decimal.TryParse(studentTuition, out studentTuitionOut))
            {
                Console.WriteLine("\n\t" + "Student tuition should be Only Decimal!!!");
                Console.Write("\t" + "Give a new student tuition: ");
                studentTuition = Console.ReadLine();
            }
            decimal studentTuiTion = studentTuitionOut;

            student.TUITION = studentTuiTion;
            Console.Write("\t" + "Date of birth (Example: {" + $"{DateTime.Now.ToShortDateString()}" + "}): ");
            string dateOfBirth = Console.ReadLine();

            while (!DateTime.TryParse(dateOfBirth, out date))
            {
                Console.Write("\n\tInvalid Date Type!!!\n\tExample {" + $"{DateTime.Now.ToShortDateString()}" + "}: ");
                dateOfBirth = Console.ReadLine();
            }
            DateTime dateTime = date;

            student.DATE_OF_BIRTH = dateTime;

            student.USERR_ID = user_ID;
            InsertStudent(student, db);

            Console.WriteLine("\n\tCreate Student Cuccessfully!!!");
            return(student);
        }
Example #20
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;
            }
        }
Example #21
0
        public void Selection(DataClasses1DataContext db)
        {
            STUDENT student = new STUDENT();
            TRAINER trainer = new TRAINER();
            USERR   uSer    = new USERR();

            string selection;
            string newSelection;
            int    choiceCategory;
            bool   iWantTocontinue = true;

            while (iWantTocontinue)
            {
                Console.WriteLine("\t" + "     SELECTION MENU" + "\n\t" + "   ------------------");
                Console.WriteLine("\t" + "For Course Press                {1}");
                Console.WriteLine("\t" + "For Student Press               {2}");
                Console.WriteLine("\t" + "For Assignment Press            {3}");
                Console.WriteLine("\t" + "For Trainer Press               {4}");
                Console.WriteLine("\t" + "For User Press (Only Delete)    {5}");
                Console.WriteLine("\t" + "For Student Per Course Press    {6}");
                Console.WriteLine("\t" + "For Trainer Per Course Press    {7}");
                Console.WriteLine("\t" + "For Assignment Per Course Press {8}");
                Console.WriteLine("\t" + "For Schedule Per Course Press   {9}");
                Console.Write("\n\t" + "Give a choise between {1 - 8}: ");
                selection = Console.ReadLine();

                int choice;
                while (!int.TryParse(selection, out choice) || string.IsNullOrEmpty(selection) || choice < 1 || choice > 9)
                {
                    Console.Write("\n\t" + "Give choice again Only Integer between {1 - 9}!!!: ");
                    selection = Console.ReadLine();
                }
                choiceCategory = choice;

                switch (choiceCategory)
                {
                case (int)SelectionCategory.course:
                    Course course = new Course();
                    course.MenuCourse(db);
                    break;

                case (int)SelectionCategory.student:
                    Student  sTudent  = new Student();
                    Check_ID check_ID = new Check_ID();
                    sTudent.MenuStudent(db, student, sTudent, check_ID);
                    break;

                case (int)SelectionCategory.assignment:
                    Assignment assignment = new Assignment();
                    assignment.MenuAssignment(db);
                    break;

                case (int)SelectionCategory.trainer:
                    Trainer tRainer = new Trainer();
                    tRainer.MenuTrainer(db, trainer);
                    break;

                case (int)SelectionCategory.user:
                    User user = new User();
                    user.MenuUser(db);
                    break;

                case (int)SelectionCategory.student_per_course:
                    StudentPerCourse studentPerCourse = new StudentPerCourse();
                    studentPerCourse.MenuStudentPerCourse(db);
                    break;

                case (int)SelectionCategory.trainer_per_course:
                    TrainerPerCourse trainerPerCourse = new TrainerPerCourse();
                    trainerPerCourse.MenuTrainerPerCourse(db);
                    break;

                case (int)SelectionCategory.assgnment_per_course:
                    AssignmentPerCourse assignmentPerCourse = new AssignmentPerCourse();
                    assignmentPerCourse.MenuAssignmentPerCourse(db);
                    break;

                case (int)SelectionCategory.schedule_per_course:
                    SchedulePerCourse schedulePerCourse = new SchedulePerCourse();
                    schedulePerCourse.MenuSchedulePerCourse(db);
                    break;
                }

                Console.WriteLine("\n\t" + "Do you want a new selection?");
                Console.WriteLine("\t" + "If yes press --> {Y} or {y}");
                Console.WriteLine("\t" + "If no press --> {N} or {n}");
                Console.Write("\n\t" + "Give a new selection: ");
                newSelection = Console.ReadLine();

                while (newSelection != "Y" && newSelection != "y" && newSelection != "N" && newSelection != "n")
                {
                    Console.WriteLine("\n\t" + "     Wrong Choise" + "\n\t" + "   ---------------");
                    Console.WriteLine("\t" + "If yes press --> {Y} or {y}");
                    Console.WriteLine("\t" + "If no press --> {N} or {n}");
                    Console.Write("\n\t" + "Give again a new selection: ");
                    newSelection = Console.ReadLine();
                }
                if (newSelection == "Y" || newSelection == "y")
                {
                    iWantTocontinue = true;
                }
                else if (newSelection == "N" || newSelection == "n")
                {
                    iWantTocontinue = false;
                }
                Console.WriteLine();
            }
        }