Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
        }