public EditAssociatedSubjectWindow(MainWindow mainWindow, string connectionString, SqlCredential credential,
                                           AssociatedSubject selectedAssociatedSubject)
            : this()
        {
            _mainWindow = mainWindow;

            _connectionString          = connectionString;
            _userCredential            = credential;
            _selectedAssociatedSubject = selectedAssociatedSubject;

            InstitutesComboBox.ItemsSource  = _mainWindow.Institutes.Select(i => i.InstituteSName).ToList();
            InstitutesComboBox2.ItemsSource = _mainWindow.Institutes.Select(i => i.InstituteSName).ToList();

            InstitutesComboBox.SelectedIndex = _mainWindow.InstitutesComboBoxTab5.SelectedIndex;
            StudyGroupComboBox.SelectedItem  = selectedAssociatedSubject.GroupName;
            SubjectsComboBox.SelectedItem    = selectedAssociatedSubject.SubjectName;
            InstitutesComboBox2.SelectedItem = selectedAssociatedSubject.InstituteSName;
            DepartmentsComboBox.SelectedItem = selectedAssociatedSubject.DepartmentName;
            TeachersComboBox.SelectedItem    = selectedAssociatedSubject.AcademicRankName
                                               + " " + selectedAssociatedSubject.TeacherFullName;
        }
Beispiel #2
0
        public void UpdateAssociatedSubjectsDataGrid(object sender, SelectionChangedEventArgs e)
        {
            if (CoursesComboBoxTab5.SelectedIndex == -1)
            {
                AssociatedSubjects = null;
                return;
            }

            var sqlParams = new[]
            {
                new SqlParameter
                {
                    ParameterName = "@CourseId",
                    Value         = CoursesTab5[CoursesComboBoxTab5.SelectedIndex].CourseId
                }
            };

            var associatedSubjects = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential,
                                                                                "GetAssociatedSubjectsByCourse", "AssociatedSubjectsView", sqlParams).Tables["AssociatedSubjectsView"]
                                     .Rows;

            AssociatedSubjects = AssociatedSubject.GetCollection(associatedSubjects);
        }