Exemple #1
0
        /// <summary>
        /// Fills the combobox with the maxium of lessons that should be able to be selected
        /// </summary>
        /// <param name="comboBox">The combobox that should be filled</param>
        /// <param name="lessons">The lessons that can be selected</param>
        private void FillComboBox(ComboBox comboBox, int lessons)
        {
            int maxLessonsToBook = addThisLesson.LessonTemplate.Time - Session.GetLastLessonFromType(_appointment.LessonType).Progress;

            if (maxLessonsToBook == 0) // when users have completed a different lesson type and the next lesson type have to start
            {
                addThisLessonLessonTemplate = DatabaseParser.GetNextLessonTemplateFromID(addThisLesson.LessonTemplate.Id, _appointment.LessonType);
                addThisLessonTemplateID     = addThisLesson.LessonTemplate.Id;
                maxLessonsToBook            = addThisLessonLessonTemplate.Time;
            }


            if (addThisLessonLessonTemplate.Type != DatabaseParser.GetLessonTemplateFromID(addThisLessonLessonTemplate.Id + 1).Type)
            {
                lessons = maxLessonsToBook < lessons ? maxLessonsToBook : lessons; // always make sure that the you can only book the required lessons to complete a lesson type
            }
            else
            {
                lessons = 4 < lessons ? 4 : lessons; // if type is diferent
            }

            lessonsComboBox.Items.Clear();
            for (int i = 0; i < lessons; i++)
            {
                comboBox.Items.Add(i + 1);
            }
        }
Exemple #2
0
        /// <summary>
        /// Method to check if a user does not have a lesson in the type and makes sure that there always is a lesson
        /// </summary>
        private void CheckForFirstLessons()
        {
            // if a user does not already have a lesson in lessontype a temp lesson is created before first lesson is added to database
            if (Session.LastTheoraticalLesson == null && _appointment.LessonType == LessonTypes.Theoretical)
            {
                Session.LastTheoraticalLesson = new Lesson(_appointment.InstructorName, "", _appointment.Id, 2, 0, _appointment.StartTime, _appointment.StartTime.AddMinutes(45), true, null, null, Session.LoggedInUser.Id);
                Session.LastTheoraticalLesson.LessonTemplate = DatabaseParser.GetLessonTemplateFromID(Session.LastTheoraticalLesson.TemplateID);
                addedFirstLesson = true;
            }

            if (Session.LastPracticalLesson == null && _appointment.LessonType == LessonTypes.Practical)
            {
                Session.LastPracticalLesson = new Lesson(_appointment.InstructorName, "", _appointment.Id, 5, 0, _appointment.StartTime, _appointment.StartTime.AddMinutes(45), true, null, null, Session.LoggedInUser.Id);
                Session.LastPracticalLesson.LessonTemplate = DatabaseParser.GetLessonTemplateFromID(Session.LastPracticalLesson.TemplateID);
                addedFirstLesson = true;
            }
        }