Exemple #1
0
        private void GetTimeTableSubjectInfo(object sender, ExecutedRoutedEventArgs e)
        {
            Subject selectedSubject = SubjectControl.GetSelectedSubjectScheduleItem().Subject;

            SubjectList.SelectedItem = _displayedSubjects.First(subj => subj.SubjectId == selectedSubject.SubjectId);
            SubjectsTab.IsSelected   = true;
        }
Exemple #2
0
        private void GetTimeTableTeacherInfo(object sender, ExecutedRoutedEventArgs e)
        {
            int selectedTeacherId = SubjectControl.GetSelectedSubjectScheduleItem().Subject.TeacherId;

            TeachersList.SelectedItem = _displayedTeachers.First(teacher => teacher.TeacherId == selectedTeacherId);
            TeachersTab.IsSelected    = true;
        }
Exemple #3
0
        private void AddNewTimeTableSubject(object sender, RoutedEventArgs e)
        {
            var addDialog = new Dialogs.AddNewSubjectToTimeTableDialog(GetDisplatedDays());

            addDialog.ShowDialog();
            if (!addDialog.Selected)
            {
                return;
            }

            int        pairNumber       = -1;
            Subject    selectedSubject  = addDialog.SelectedSubject;
            DaysOfWeek selectedDay      = addDialog.SelectedDay;
            PairType   selectedPairType = addDialog.SelectedPairType;

            foreach (var day in _displayedSchedule.ScheduleDayColumns)
            {
                if (day.DayName == addDialog.SelectedDay)
                {
                    pairNumber = (day.SubjectDayDict.Count > 0) ? day.SubjectDayDict.Keys.Max() + 1 : 1;
                    day.SubjectDayDict.Add(pairNumber, new SubjectScheduleItem()
                    {
                        PairType = selectedPairType,
                        Subject  = selectedSubject
                    });
                    break;
                }
            }
            SubjectControl.LoadSchedule(_displayedSchedule);
            _subjectRepository.AddModifyOneTimeTableSubject(_displayedSchedule.Year, _displayedSchedule.SemesterNumber,
                                                            _displayedSchedule.WeekNumber, selectedDay, pairNumber, selectedSubject, selectedPairType);
        }
Exemple #4
0
        private void ModifySelectedTimeTableSubject(object sender, ExecutedRoutedEventArgs e)
        {
            int        selectedPairNumber = SubjectControl.GetSelectedPairNumber();
            DaysOfWeek selectedDay        = SubjectControl.GetSelectedDay();

            SubjectScheduleItem selectedSubjectScheduleItem = SubjectControl.GetSelectedSubjectScheduleItem();
            var modifyDialog = new Dialogs.ModifyTimeTableSubjectDialog(_subjectRepository.GetAllSubjects(),
                                                                        selectedSubjectScheduleItem, _pairTypeRepository.GetAllPairTypes().ToList());

            modifyDialog.ShowDialog();

            if (!modifyDialog.IsSeleted && modifyDialog.SelectedPairType == null && modifyDialog.SelectedSubject == null)
            {
                return;
            }
            SubjectScheduleItem modifiedScheduleItem = new SubjectScheduleItem()
            {
                PairType = modifyDialog.SelectedPairType,
                Subject  = modifyDialog.SelectedSubject
            };

            _displayedSchedule.ScheduleDayColumns.First(col => col.DayName == selectedDay).SubjectDayDict[
                selectedPairNumber] = modifiedScheduleItem;

            SubjectControl.LoadSchedule(_displayedSchedule);
            _subjectRepository.AddModifyOneTimeTableSubject(_displayedSchedule.Year, _displayedSchedule.SemesterNumber,
                                                            _displayedSchedule.WeekNumber,
                                                            selectedDay, selectedPairNumber, modifiedScheduleItem.Subject, modifiedScheduleItem.PairType);
        }
Exemple #5
0
 private void InitSubjectControl()
 {
     if (_displayedSchedule == null)
     {
         try
         {
             _displayedSchedule     = _timetableRepository.GetWeekByDate(DateTime.Now);
             _displayedDate         = DateTime.Now;
             Semesters.SelectedItem =
                 _allSemesters.First(
                     sem =>
                     sem.YearValue == _displayedDate.Year && sem.SemesterNumber == _displayedSchedule.SemesterNumber);
         }
         catch (ArgumentException)
         {
             _displayedSchedule = _timetableRepository.GetWeekByDate(_displayedSemester.StartDate);
             _displayedDate     = _displayedSemester.StartDate;
         }
     }
     else
     {
         _displayedSchedule = _timetableRepository.GetWeekByDate(_displayedSemester.StartDate);
         _displayedDate     = _displayedSemester.StartDate;
     }
     SubjectControl.DayClickHandler = SubjSelectionChanged;
     SubjectControl.LoadSchedule(_displayedSchedule);
     RefreshWeekStats();
 }
Exemple #6
0
        private void GetTimeTableTasksInfo(object sender, ExecutedRoutedEventArgs e)
        {
            Subject selectedSubject = SubjectControl.GetSelectedSubjectScheduleItem().Subject;

            if (CertainSubjectTasks.IsChecked != null && !(bool)CertainSubjectTasks.IsChecked)
            {
                CertainSubjectTasks.IsChecked = true;
            }
            AwailableSubjects.SelectedItem = _displayedSubjects.First(subj => subj.SubjectId == selectedSubject.SubjectId);
            TasksTab.IsSelected            = true;
        }
Exemple #7
0
        private void IsTimeTableSubjectSelectedToRemove(object sender, CanExecuteRoutedEventArgs e)
        {
            int pairNumber = SubjectControl.GetSelectedPairNumber();

            if (pairNumber == -1)
            {
                return;
            }
            Entities.DayOfWeek selectedDay =
                _displayedSchedule.ScheduleDayColumns
                .First(day => day.DayName == SubjectControl.GetSelectedDay());
            e.CanExecute = (pairNumber != -1) && (selectedDay.SubjectDayDict[pairNumber] != null);
        }
Exemple #8
0
        private void RemoveSelectedTimeTableSubject(object sender, ExecutedRoutedEventArgs e)
        {
            DaysOfWeek selectedDay = SubjectControl.GetSelectedDay();
            int        pairNumber  = SubjectControl.GetSelectedPairNumber();

            foreach (var dayCol in _displayedSchedule.ScheduleDayColumns)
            {
                if (dayCol.DayName != selectedDay)
                {
                    continue;
                }
                dayCol.SubjectDayDict.Remove(pairNumber);
            }
            SubjectControl.LoadSchedule(_displayedSchedule);
            _subjectRepository.RemoveOneTimeTableSubject(_displayedSchedule.Year, _displayedSchedule.SemesterNumber,
                                                         _displayedSchedule.WeekNumber, selectedDay, pairNumber);
        }
Exemple #9
0
        private void GetNextWeek(object sender, RoutedEventArgs e)
        {
            DateTime nextDate = _displayedDate + new TimeSpan(7, 0, 0, 0);

            if (nextDate > GetDayDateByDisplayedSemester(_displayedSemester.NumberOfWeeks, DaysOfWeek.Sunday))
            {
                return;
            }
            try
            {
                _displayedSchedule = _timetableRepository.GetWeekByDate(nextDate);
            }
            catch (ArgumentException)
            {
                return;
            }
            SubjectControl.LoadSchedule(_displayedSchedule);
            RefreshWeekStats();
            _displayedDate = nextDate;
        }
Exemple #10
0
        private void SubjSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedScheduleItem = SubjectControl.GetSelectedSubjectScheduleItem();

            if (selectedScheduleItem == null)
            {
                TimeTableDescriptionType.Text         = "";
                TimeTableDescriptionName.Text         = "";
                TimeTableDescriptionTeacher.Text      = "";
                TimeTableDescriptionNuberOfTasks.Text = "";
                return;
            }
            var selectedItemTeacher =
                _displayedTeachers.First(teach => teach.TeacherId == selectedScheduleItem.Subject.TeacherId);

            TimeTableDescriptionType.Text         = "Type of the subject: " + selectedScheduleItem.PairType.TypeName;
            TimeTableDescriptionName.Text         = "Subject Name: " + selectedScheduleItem.Subject.Name;
            TimeTableDescriptionTeacher.Text      = "Subject Teacher: " + selectedItemTeacher.FirstName + " " + selectedItemTeacher.MiddleName;
            TimeTableDescriptionNuberOfTasks.Text = "Count of tasks: " + _displayedTaskTableItems.Count(item => item.TaskTableItemSubject.SubjectId == selectedScheduleItem.Subject.SubjectId).ToString();
        }
Exemple #11
0
        private void GetPreviousWeek(object sender, RoutedEventArgs e)
        {
            DateTime prevDate = _displayedDate - new TimeSpan(7, 0, 0, 0);

            if (prevDate < _displayedSemester.StartDate)
            {
                return;
            }
            try
            {
                _displayedSchedule = _timetableRepository.GetWeekByDate(prevDate);
            }
            catch (ArgumentException)
            {
                return;
            }
            SubjectControl.LoadSchedule(_displayedSchedule);
            WeekNumber.Text = _displayedSchedule.WeekNumber.ToString();
            RefreshWeekStats();
            _displayedDate = prevDate;
        }
Exemple #12
0
        private void DeleteScheduleColumn(object sender, RoutedEventArgs e)
        {
            List <DaysOfWeek> freeDays = new List <DaysOfWeek>();

            foreach (var day in _displayedSchedule.ScheduleDayColumns)
            {
                freeDays.Add(day.DayName);
            }
            Dialogs.SelectDayDialog dialog = new Dialogs.SelectDayDialog(freeDays);
            dialog.ShowDialog();
            if (!dialog.IsSelected)
            {
                return;
            }
            DaysOfWeek dayToRemove = dialog.SelectedDay;

            _displayedSchedule.ScheduleDayColumns.RemoveAll(dayCol => dayCol.DayName == dayToRemove);
            SubjectControl.LoadSchedule(_displayedSchedule);
            _subjectRepository.RemoveAllTimeTableSubjectsFromDay(dayToRemove, _displayedSchedule.Year,
                                                                 _displayedSchedule.SemesterNumber, _displayedSchedule.WeekNumber);
            RefreshWeekStats();
        }
Exemple #13
0
        private void AddNewScheduleColumn(object sender, RoutedEventArgs e)
        {
            List <DaysOfWeek> freeDays = new List <DaysOfWeek>();

            foreach (DaysOfWeek item in Enum.GetValues(typeof(DaysOfWeek)))
            {
                freeDays.Add(item);
            }
            foreach (Entities.DayOfWeek day in _displayedSchedule.ScheduleDayColumns)
            {
                freeDays.Remove(day.DayName);
            }
            if (_displayedSchedule.WeekNumber == 1)
            {
                freeDays.RemoveAll(freeday =>
                {
                    DateTime dateDayTakePlace = GetDayDateByDisplayedSemester(_displayedSchedule.WeekNumber, freeday);
                    return(dateDayTakePlace < _displayedSemester.StartDate);
                });
            }
            Dialogs.SelectDayDialog newDay = new Dialogs.SelectDayDialog(freeDays);
            newDay.ShowDialog();
            if (!newDay.IsSelected)
            {
                return;
            }
            DaysOfWeek dayToAdd = newDay.SelectedDay;

            _displayedSchedule.ScheduleDayColumns.Add(new Entities.DayOfWeek()
            {
                DayName        = dayToAdd,
                SubjectDayDict = new Dictionary <int, SubjectScheduleItem>()
            });
            SubjectControl.LoadSchedule(_displayedSchedule);
            RefreshWeekStats();
        }
Exemple #14
0
        private async void ListViewCollectionsSelectedIndexChanged(object sender, EventArgs e)
        {
            if (subject_list == null)
            {
                return;
            }

            SubjectControl.DataContext = null;
            SubjectControl.Reset();
            SubjectControl.subject = null;
            SubjectControl.buttonSummary.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));

            var index = ListViewCollections.SelectedIndex;

            if (index == -1)
            {
                return;
            }
            Model.SubjectLarge subject = new Model.SubjectLarge();
            try
            {
                subject = await Retry.Do(() => ApiHelper.GetSubject(subject_list[index].subject_id), TimeSpan.FromSeconds(3));
            }
            catch (WebException web_exception)
            {
                Console.WriteLine(web_exception.Message);
                return;
            }

            SubjectControl.DataContext = subject;
            SubjectControl.subject     = subject;

            Model.SubjectProgress subject_progress = new Model.SubjectProgress();
            try
            {
                subject_progress = await Retry.Do(() => ApiHelper.GetProgress(Settings.Default.UserID, subject.id), TimeSpan.FromSeconds(3));
            }
            catch (WebException web_exception)
            {
                Console.WriteLine(web_exception.Message);
            }
            catch (AuthorizationException authorization_exception)
            {
                Console.WriteLine(authorization_exception.Message);
            }
            if (subject_progress != null && subject_progress.eps != null)
            {
                foreach (var ep in subject_progress.eps)
                {
                    foreach (var ep_src in subject.eps)
                    {
                        if (ep.id == ep_src.id)
                        {
                            ep_src.ep_status = ep.status.id;
                            break;
                        }
                    }
                }
            }
            subject.eps_filter();
            return;
        }
Exemple #15
0
 private void IsTimeTableSubjectSelected(object sender, CanExecuteRoutedEventArgs e)
 {
     e.CanExecute = SubjectControl.GetSelectedPairNumber() != -1;
 }