예제 #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 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);
        }
예제 #3
0
        public TrainerInfo()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            money.Maximum = 9999999;
            bp.Maximum    = 9999;

            if (MainForm.save.B2W2 == false)             //BW1 battle points are in another block
            {
                battle_block        = 58;
                battle              = new BATTLE(MainForm.save.getBlock(battle_block), 1);
                rival_name.Visible  = false;
                rival_label.Visible = false;
            }
            else             //B2W2
            {
                battle = new BATTLE(MainForm.save.getBlock(battle_block));
                gary   = new RIVAL(MainForm.save.getBlock(rival_block));
            }

            //Common data
            ash   = new TRAINER(MainForm.save.getBlock(trainer_block));
            badge = new BADGES(MainForm.save.getBlock(badges_block));
            card  = new CARDSIG(MainForm.save.getBlock(cardsig_block));

            load_data();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
        }
예제 #4
0
        public void Execute(object parameter)
        {
            this.execute(parameter);
            try
            {
                Random        value        = new Random();
                TRAINER       trainer1     = (TRAINER)parameter;
                OracleCommand get_trainers = new OracleCommand("GET_INFO_TRAINER", (OracleConnection)WindowOfViews.database.Database.Connection);
                get_trainers.CommandType = CommandType.StoredProcedure;
                var pResult = new OracleParameter("pResult", OracleDbType.RefCursor, ParameterDirection.Output);
                get_trainers.Parameters.Add(pResult);
                get_trainers.ExecuteNonQuery();
                var       res    = (OracleRefCursor)pResult.Value;
                var       reader = res.GetDataReader();
                DataTable dt     = new DataTable();
                dt.Load(reader);
                int rand = dt.Rows.Count + 1;
Found:
                foreach (DataRow row in dt.Rows)
                {
                    if (row[4].ToString() == trainer1.LOGIN)
                    {
                        throw new Exception("Такой логин уже используется");
                    }
                }
                if ((double)trainer1.DATATRAINER.BARBELLSQUAT < (double)trainer1.DATATRAINER.WEIGHT * 1.4 && (double)trainer1.DATATRAINER.DEADLIFT < (double)trainer1.DATATRAINER.WEIGHT * 1.8 &&
                    (double)trainer1.DATATRAINER.BENCHPRESS < (double)trainer1.DATATRAINER.WEIGHT * 1.2 && trainer1.DATATRAINER.PULLUPS < 10)
                {
                    throw new Exception("Вы слабоваты для тренера");
                }
                OracleCommand command1 = new OracleCommand("REG_TRAINER", (OracleConnection)WindowOfViews.database.Database.Connection);
                command1.CommandType = CommandType.StoredProcedure;
                command1.Parameters.Add("trainer_id", rand);
                command1.Parameters.Add("trainer_firstname", trainer1.FIRSTNAME);
                command1.Parameters.Add("trainer_secondname", trainer1.SECONDNAME);
                command1.Parameters.Add("trainer_login", trainer1.LOGIN);
                command1.Parameters.Add("trainer_password", trainer1.PASSWORD);
                command1.Parameters.Add("trainer_group", trainer1.NUMBER_GROUP);
                command1.ExecuteNonQuery();
                OracleCommand command2 = new OracleCommand("REG_TRAINER_DATA", (OracleConnection)WindowOfViews.database.Database.Connection);
                command2.CommandType = CommandType.StoredProcedure;
                command2.Parameters.Add("trainer_id", rand);
                command2.Parameters.Add("trainer_weight", trainer1.DATATRAINER.WEIGHT);
                command2.Parameters.Add("trainer_height", trainer1.DATATRAINER.HEIGHT);
                command2.Parameters.Add("trainer_BARBELLSQUAT", trainer1.DATATRAINER.BARBELLSQUAT);
                command2.Parameters.Add("trainer_DEADLIFT", trainer1.DATATRAINER.DEADLIFT);
                command2.Parameters.Add("trainer_BENCHPRESS", trainer1.DATATRAINER.BENCHPRESS);
                command2.Parameters.Add("trainer_PULLUPS", trainer1.DATATRAINER.PULLUPS);
                command2.Parameters.Add("trainer_BODYTYPE", trainer1.DATATRAINER.BODYTYPE);
                command2.ExecuteNonQuery();
                //WindowOfViews.database.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show("значения введены неверно, перепроверьте пожалуйсто");
            }
        }
예제 #5
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;
            }
        }
예제 #6
0
        public void UpdateStudentsPerCourses(TRAINER_PER_COURSE trainerPerCourse, DataClasses1DataContext db)
        {
            TRAINER tRainer = new TRAINER();
            Trainer trainer = new Trainer();

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

            tRainer = trainer.UpdateTrainer(db, tRainer);
            int courseID = GetCourseIdFromTrainerID(db, tRainer.TRAINER_ID);

            trainerPerCourse.TRAINER_ID = tRainer.TRAINER_ID;
            trainerPerCourse.COURSE_ID  = courseID;
            db.SubmitChanges();

            Console.WriteLine("\n\tTrainers Per Courses was successfully enrolled!!!");
        }
예제 #7
0
        public void DeleteTrainersPerCourses(TRAINER_PER_COURSE trainerPerCourse, DataClasses1DataContext db)
        {
            TRAINER tRainer = new TRAINER();
            Trainer trainer = new Trainer();
            Course  course  = new Course();

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

            int trainer_ID = trainer.GetTrainerIDForCreate();
            int courseID   = GetCourseIdFromTrainerID(db, trainer_ID);

            trainerPerCourse = db.TRAINER_PER_COURSEs.Single(i => i.TRAINER_ID == trainer_ID);

            trainerPerCourse.TRAINER_ID = trainer_ID;
            trainerPerCourse.COURSE_ID  = courseID;
            db.TRAINER_PER_COURSEs.DeleteOnSubmit(trainerPerCourse);
            db.SubmitChanges();

            Console.WriteLine("\n\tDeleted Succesfully!!!");
        }
예제 #8
0
        public void CreateTrainerPerCourses(TRAINER_PER_COURSE trainerPerCourse, DataClasses1DataContext db)
        {
            TRAINER tRainer = new TRAINER();
            Trainer trainer = new Trainer();
            Course  course  = new Course();

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

            int userID = CreateUser(db);

            tRainer = trainer.CreateTrainer(userID, db, tRainer);

            int courseID = course.GetCourseID();

            trainerPerCourse.TRAINER_ID = tRainer.TRAINER_ID;
            trainerPerCourse.COURSE_ID  = courseID;
            db.TRAINER_PER_COURSEs.InsertOnSubmit(trainerPerCourse);
            db.SubmitChanges();

            Console.WriteLine("\n\tΤhe student was successfully enrolled!!!");
        }
예제 #9
0
 public void DeleteTrainer(DataClasses1DataContext db, TRAINER trainer, int trainerID)
 {
     trainer = db.TRAINERs.Single(i => i.TRAINER_ID == trainerID);
     db.TRAINERs.DeleteOnSubmit(trainer);
     db.SubmitChanges();
 }
예제 #10
0
        public TRAINER UpdateTrainer(DataClasses1DataContext db, TRAINER trainer)
        {
            Console.WriteLine("\n\tEnter Trainer ID you want to change: ");
            string stringChoice;

            Console.WriteLine("\n\tUPDATE TRAINER\n\t" + "--------------");
            Console.WriteLine("\tFor firstname press      --> {1}");
            Console.WriteLine("\tFor lastname press       --> {2}");
            Console.WriteLine("\tFor subject press        --> {3}");
            Console.Write("\tEnter a choice: ");
            stringChoice = Console.ReadLine();

            int outChoice;

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

            switch (choice)
            {
            case (int)SelectionUpDateForTrainer.firstname:
                int trainerID = GetTrainerIDToInteger();
                trainer = db.TRAINERs.Single(i => i.TRAINER_ID == trainerID);
                Console.Write("\tEnter new Firstname: ");

                trainer.F_NAME = Console.ReadLine();
                while (!trainer.F_NAME.All(char.IsLetter) || string.IsNullOrEmpty(trainer.F_NAME))
                {
                    Console.Write("\n\t" + "Student Firstname should be Only Letter!!!");
                    Console.Write("\n\t" + "Give a new Student Firstname: ");
                    trainer.F_NAME = Console.ReadLine();
                }
                trainer.F_NAME.ToUpper();
                db.SubmitChanges();
                Console.WriteLine("\n\tChange firstname Cuccessfully!!!");
                break;

            case (int)SelectionUpDateForTrainer.lastname:
                int trainer_Id = GetTrainerIDToInteger();
                trainer = db.TRAINERs.Single(i => i.TRAINER_ID == trainer_Id);
                Console.Write("\tEnter new Lastname: ");
                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.ToUpper();
                db.SubmitChanges();
                Console.WriteLine("\n\tChange Lastname Cuccessfully!!!");
                break;

            case (int)SelectionUpDateForTrainer.subject:
                int tRainer_id = GetTrainerIDToInteger();
                trainer = db.TRAINERs.Single(i => i.TRAINER_ID == tRainer_id);
                Console.Write("\tEnter new Subject: ");
                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();
                db.SubmitChanges();
                Console.WriteLine("\n\tChange Subject Cuccessfully!!!");
                break;
            }
            return(trainer);
        }
예제 #11
0
 public void InsertTrainer(TRAINER trainer, DataClasses1DataContext db)
 {
     db.TRAINERs.InsertOnSubmit(trainer);
     db.SubmitChanges();
 }
예제 #12
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();
            }
        }