private void UpdateCourses(object sender, SelectionChangedEventArgs e) { var sqlParams = new[] { new SqlParameter { ParameterName = "@InstituteId", Value = Institutes[InstitutesComboBoxTab3.SelectedIndex].InstituteId } }; var courses = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential, "GetCoursesByInstitute", "Courses", sqlParams).Tables["Courses"].Rows; Courses = Course.GetCollection(courses); CoursesComboBox.ItemsSource = Courses.Select(c => c.CourseName).ToList(); }
private void UpdateCourses(object sender, SelectionChangedEventArgs e) { if (DepartmentsComboBox.SelectedIndex == -1) { CoursesComboBox.ItemsSource = null; return; } var sqlParams = new[] { new SqlParameter { ParameterName = "@DepartmentId", Value = Departments[DepartmentsComboBox.SelectedIndex].DepartmentId } }; var courses = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential, "GetCoursesByDepartment", "Courses", sqlParams).Tables["Courses"].Rows; Courses = Course.GetCollection(courses); CoursesComboBox.ItemsSource = Courses.Select(c => c.CourseName).ToList(); }