예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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);
        }