Imports System.Data
Imports BDNotasAlumnos

Class MainWindow
  Private pAsigsNotas As New CProveedorAsignaturasNotas()
  Private vistaAsignaturas As DataView

  Private Sub dgAlumnos_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
    If e.AddedItems.Count = 0 Then Return
    Dim drv As DataRowView = TryCast(e.AddedItems(0), DataRowView)
    If drv Is Nothing Then Return
    Dim fila As DataSetBDNotasAlumnos.alumnosRow = TryCast(drv.Row, DataSetBDNotasAlumnos.alumnosRow)
    If fila.RowState = DataRowState.Detached Then Return
    vistaAsignaturas = pAsigsNotas.ObtenerAsignaturasNotas(fila.id_alumno)
    vistaAsignaturas.Sort = "nombreAsig"
    spAsignaturas.DataContext = vistaAsignaturas
  End Sub

  Private Sub boTodas_Checked(sender As Object, e As RoutedEventArgs)
    If vistaAsignaturas Is Nothing Then Return
    vistaAsignaturas.RowFilter = ""
    spAsignaturas.DataContext = vistaAsignaturas
  End Sub

  Private Sub boSuspensas_Checked(sender As Object, e As RoutedEventArgs)
    If vistaAsignaturas Is Nothing Then Return
    vistaAsignaturas.RowFilter = "nota < '5'"
    spAsignaturas.DataContext = vistaAsignaturas
  End Sub

  Private Sub boAprobadas_Checked(sender As Object, e As RoutedEventArgs)
    If vistaAsignaturas Is Nothing Then Return
    vistaAsignaturas.RowFilter = "nota >= '5'"
    spAsignaturas.DataContext = vistaAsignaturas
  End Sub
End Class
