Пример #1
0
        public void DeleteOfTrainersAsUsers(DataClasses1DataContext db, int userID, int courseID, int trainerID)
        {
            TRAINER_PER_COURSE tRainerPerCourse = new TRAINER_PER_COURSE();
            TrainerPerCourse   trainerPerCourse = new TrainerPerCourse();
            TRAINER            tRainer          = new TRAINER();
            Trainer            trainer          = new Trainer();
            USERR user = new USERR();

            if (trainerID < 1)
            {
                DeleteUser(user, userID, db);
            }
            else if (trainerID > 0 && courseID < 1)
            {
                trainer.DeleteTrainer(db, tRainer, trainerID);
                DeleteUser(user, userID, db);
            }
            else if (trainerID > 0 && courseID > 0)
            {
                trainerPerCourse.DeleteTrainersGeneral(trainerID, tRainerPerCourse, db);
                trainer.DeleteTrainer(db, tRainer, trainerID);
                DeleteUser(user, userID, db);
            }
            Console.WriteLine("\n\tDeleted Succesfully!!!");
        }
Пример #2
0
        public void DeleteOfStudentsAsUsers(DataClasses1DataContext db, int studentID, int userID, int courseID, int assignmentIDThisUser)
        {
            ASSIGNMENT_PER_STUDENT assignmnetPerStudent = new ASSIGNMENT_PER_STUDENT();
            STUDENT_PER_COURSE     sTudentPerCourse     = new STUDENT_PER_COURSE();
            StudentPerAssignment   studentPerAssignment = new StudentPerAssignment();
            StudentPerCourse       studentPerCourse     = new StudentPerCourse();
            STUDENT sTudent = new STUDENT();
            Student student = new Student();
            USERR   user    = new USERR();

            if (studentID < 1)
            {
                DeleteUser(user, userID, db);
            }
            else if (studentID > 0 && courseID < 1 && assignmentIDThisUser < 1)
            {
                student.DeleteStudent(db, sTudent, studentID);
                DeleteUser(user, userID, db);
            }
            else if (studentID > 0 && courseID > 0 && assignmentIDThisUser < 1)
            {
                studentPerCourse.DeleteCourses(studentID, sTudentPerCourse, db);
                student.DeleteStudent(db, sTudent, studentID);
                DeleteUser(user, userID, db);
            }
            else if (studentID > 0 && courseID > 0 && assignmentIDThisUser > 0)
            {
                studentPerAssignment.DeleteAssignemnts(studentID, assignmnetPerStudent, db);
                studentPerCourse.DeleteCourses(studentID, sTudentPerCourse, db);
                student.DeleteStudent(db, sTudent, studentID);
                DeleteUser(user, userID, db);
            }
            Console.WriteLine("\n\tDeleted Succesfully!!!");
        }
Пример #3
0
 public void DeleteUser(USERR user, int userID, DataClasses1DataContext db)
 {
     user = db.USERRs.Single(i => i.USERR_ID == userID);
     db.USERRs.DeleteOnSubmit(user);
     db.SubmitChanges();
 }
Пример #4
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);
        }
Пример #5
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();
            }
        }