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); }
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(); }
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); }
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); }
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; }
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; }
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(); }
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(); }