Imports BDNotasAlumnos
Imports System.ComponentModel

Class MainWindow
  Private asigs As Object

  Private Sub dgAlumnos_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs)
    If e.AddedItems.Count = 0 Then Return
    Dim alum As alumno = TryCast(e.AddedItems(0), alumno)
    If alum Is Nothing Then Return
    Dim pAsigsNotas As New CProveedorAsignaturasNotas()
    asigs = pAsigsNotas.ObtenerAsignaturasNotas(alum.id_alumno)
    spAsignaturas.DataContext = asigs
  End Sub

  Private Sub boTodas_Checked(sender As System.Object, e As System.Windows.RoutedEventArgs)
    Dim vista As ICollectionView = CollectionViewSource.GetDefaultView(asigs)
    If vista Is Nothing Then Return
    vista.Filter = Nothing
  End Sub

  Private Sub boSuspensas_Checked(sender As System.Object, e As System.Windows.RoutedEventArgs)
    Dim vista As ICollectionView = CollectionViewSource.GetDefaultView(asigs)
    If vista Is Nothing Then Return
    vista.Filter = Function(elemento As Object) elemento.nota < 5
  End Sub

  Private Sub boAprobadas_Checked(sender As System.Object, e As System.Windows.RoutedEventArgs)
    Dim vista As ICollectionView = CollectionViewSource.GetDefaultView(asigs)
    If vista Is Nothing Then Return
    vista.Filter = Function(elemento As Object) elemento.nota >= 5
  End Sub
End Class
