示例#1
0
        public AddNewSubjectToTimeTableDialog(List <DaysOfWeek> freeDays)
        {
            InitializeComponent();
            var connString = ConfigurationManager.ConnectionStrings["StudentDiaryConnectionString"].ConnectionString;

            _subjectRepository  = new SubjectRepository(connString);
            _pairTypeRepository = new PairTypeRepository(connString);

            AwailableDaysList.ItemsSource  = freeDays;
            AwailableDaysList.SelectedItem = freeDays[0];

            var awailableSubjects = _subjectRepository.GetAllSubjects();

            AwailableSubjectsList.ItemsSource  = awailableSubjects;
            AwailableSubjectsList.SelectedItem = awailableSubjects[0];

            var awailablePairTypes = _pairTypeRepository.GetAllPairTypes().ToList();

            AwailablePairTypesList.ItemsSource  = awailablePairTypes;
            AwailablePairTypesList.SelectedItem = awailablePairTypes[0];
        }
示例#2
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);
        }