VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_asist_sub 
   Caption         =   "Form1"
   ClientHeight    =   7305
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10965
   Icon            =   "Form_asist_sub.frx":0000
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7305
   ScaleWidth      =   10965
   Begin VB.Frame Frame1 
      Height          =   6975
      Left            =   120
      TabIndex        =   16
      Top             =   120
      Width           =   10695
      Begin VB.CommandButton Command7 
         Caption         =   "&Cerrar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   240
         Picture         =   "Form_asist_sub.frx":2A8B2
         Style           =   1  'Graphical
         TabIndex        =   27
         Top             =   5760
         Width           =   1215
      End
      Begin VB.Frame Frame4 
         Caption         =   "Modo de Revisión"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1095
         Left            =   120
         TabIndex        =   23
         Top             =   240
         Width           =   6495
         Begin VB.ComboBox cmbListaMeses 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   4320
            TabIndex        =   3
            Top             =   240
            Width           =   2055
         End
         Begin VB.ComboBox cmbSelVision 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   5160
            TabIndex        =   4
            Top             =   600
            Width           =   1215
         End
         Begin VB.OptionButton optModoVer 
            Caption         =   "Diario"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   2
            Left            =   240
            TabIndex        =   2
            Top             =   720
            Value           =   -1  'True
            Width           =   1455
         End
         Begin VB.OptionButton optModoVer 
            Caption         =   "Semana"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   240
            TabIndex        =   1
            Top             =   480
            Width           =   1575
         End
         Begin VB.OptionButton optModoVer 
            Caption         =   "Mensual"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   240
            TabIndex        =   0
            Top             =   240
            Width           =   1455
         End
         Begin VB.Label Label7 
            Caption         =   "Mes"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   3600
            TabIndex        =   26
            Top             =   240
            Width           =   615
         End
         Begin VB.Label Label7 
            Caption         =   "Mes Completo"
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   6
            Left            =   3600
            TabIndex        =   24
            Top             =   720
            Width           =   1095
         End
      End
      Begin VB.ComboBox cmbListaModal 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   6840
         TabIndex        =   5
         Top             =   720
         Width           =   3615
      End
      Begin VB.Frame Frame2 
         Height          =   5535
         Left            =   120
         TabIndex        =   17
         Top             =   1320
         Width           =   10455
         Begin VB.CommandButton cmdTermina 
            Height          =   615
            Index           =   2
            Left            =   7680
            Picture         =   "Form_asist_sub.frx":2AED8
            Style           =   1  'Graphical
            TabIndex        =   29
            Top             =   1800
            Width           =   1095
         End
         Begin VB.CommandButton Command1 
            Enabled         =   0   'False
            Height          =   615
            Left            =   7800
            Picture         =   "Form_asist_sub.frx":2B534
            Style           =   1  'Graphical
            TabIndex        =   28
            Top             =   4800
            Width           =   855
         End
         Begin VB.CommandButton cmdTermina 
            Height          =   615
            Index           =   1
            Left            =   7680
            Picture         =   "Form_asist_sub.frx":2B976
            Style           =   1  'Graphical
            TabIndex        =   13
            Top             =   4080
            Width           =   1095
         End
         Begin VB.CommandButton cmdTermina 
            Height          =   615
            Index           =   0
            Left            =   7680
            Picture         =   "Form_asist_sub.frx":2BFEC
            Style           =   1  'Graphical
            TabIndex        =   12
            Top             =   960
            Width           =   1095
         End
         Begin VB.ListBox List4 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   1740
            Left            =   8880
            Sorted          =   -1  'True
            TabIndex        =   14
            Top             =   3480
            Width           =   1455
         End
         Begin VB.ListBox lstGrado 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   2580
            Left            =   120
            TabIndex        =   9
            Top             =   1560
            Width           =   495
         End
         Begin VB.ListBox lstLetra 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   2580
            Left            =   720
            TabIndex        =   10
            Top             =   1560
            Width           =   615
         End
         Begin VB.Frame Frame3 
            Height          =   1095
            Left            =   120
            TabIndex        =   19
            Top             =   120
            Width           =   1215
            Begin VB.OptionButton Option1 
               Caption         =   "Mañana"
               Enabled         =   0   'False
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   195
               Index           =   0
               Left            =   120
               TabIndex        =   6
               Top             =   240
               Width           =   975
            End
            Begin VB.OptionButton Option1 
               Caption         =   "Tarde"
               Enabled         =   0   'False
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   195
               Index           =   1
               Left            =   120
               TabIndex        =   7
               Top             =   480
               Width           =   975
            End
            Begin VB.OptionButton Option1 
               Caption         =   "Todos"
               Enabled         =   0   'False
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   195
               Index           =   2
               Left            =   120
               TabIndex        =   8
               Top             =   720
               Width           =   975
            End
         End
         Begin VB.ListBox List3 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   2580
            Left            =   8880
            Sorted          =   -1  'True
            TabIndex        =   15
            Top             =   480
            Width           =   1455
         End
         Begin MSHierarchicalFlexGridLib.MSHFlexGrid GrillaAlumnos 
            Height          =   5175
            Left            =   1440
            TabIndex        =   11
            Top             =   240
            Width           =   6135
            _ExtentX        =   10821
            _ExtentY        =   9128
            _Version        =   393216
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            _NumberOfBands  =   1
            _Band(0).Cols   =   2
         End
         Begin VB.Label Label7 
            Caption         =   "Con Errores"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   5
            Left            =   8880
            TabIndex        =   22
            Top             =   3240
            Width           =   1095
         End
         Begin VB.Label Label7 
            Caption         =   "Grado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   2
            Left            =   120
            TabIndex        =   21
            Top             =   1320
            Width           =   615
         End
         Begin VB.Label Label7 
            Caption         =   "Letra"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   3
            Left            =   720
            TabIndex        =   20
            Top             =   1320
            Width           =   615
         End
         Begin VB.Label Label7 
            Caption         =   "Terminado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   4
            Left            =   8880
            TabIndex        =   18
            Top             =   240
            Width           =   1095
         End
      End
      Begin VB.Label Label7 
         Caption         =   "Modalidad de Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   6840
         TabIndex        =   25
         Top             =   480
         Width           =   1935
      End
   End
End
Attribute VB_Name = "Form_asist_sub"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Aact As Integer
Dim intListaCursos As Integer

Private Sub cmbListaMeses_click()
    Dim rsModalidad As ADODB.Recordset
    Dim rsCalen As ADODB.Recordset
    Dim modalidad(0 To 10, 2) As String
    Dim Cuenta As Integer
    Dim nModal As Integer
    Dim bExiste As Boolean
    Dim sModali As String
    Set rsCalen = New ADODB.Recordset
    Set rsModalidad = New ADODB.Recordset
    
    rsCalen.CursorType = adOpenDynamic
    rsModalidad.CursorType = adOpenDynamic
    rsCalen.LockType = adLockOptimistic
    rsModalidad.LockType = adLockOptimistic
    rsModalidad.Open "SELECT * FROM CODIGOS_ENSENANZA", conn
    Cuenta = 0
    
    While Not rsModalidad.EOF
        modalidad(Cuenta, 1) = rsModalidad("COD_ENS")
        modalidad(Cuenta, 2) = rsModalidad("DES_ENS")
        Cuenta = Cuenta + 1
        rsModalidad.MoveNext
    Wend
    
    nModal = Cuenta
    rsModalidad.Close
    rsCalen.Open "SELECT * FROM CAL_X_CUR WHERE MES = '" & Left(Me.cmbListaMeses.Text, 3) & "'", conn
    Me.cmbListaModal.Clear
    
    While Not rsCalen.EOF
        For i = 0 To nModal
            If rsCalen("cod_ens") = modalidad(i, 1) Then
                sModali = modalidad(i, 1) & " - " & modalidad(i, 2)
                Exit For
            End If
        Next
        bExiste = False
        For i = 0 To Me.cmbListaModal.ListCount - 1
            If sModali = Me.cmbListaModal.List(i) Then
                bExiste = True
                Exit For
            End If
        Next
        If Not bExiste Then
            Me.cmbListaModal.AddItem sModali
        End If
        rsCalen.MoveNext
    Wend
    rsCalen.Close
    If Me.optModoVer.Item(0).Value Then
        Me.cmbListaModal.Enabled = True
    Else
        Me.cmbListaModal.Enabled = False
    End If
    Me.Option1.Item(0).Value = False
    Me.Option1.Item(1).Value = False
    Me.Option1.Item(2).Value = False
    Me.cmbSelVision.Text = ""
    Me.GrillaAlumnos.FixedRows = 0
    Me.GrillaAlumnos.Rows = 1
    Me.lstGrado.Clear
    Me.lstLetra.Clear
    
End Sub


Private Sub cmbListaModal_Click()
    ActualizaListasCursos
    For i = 0 To 2
        Me.Option1.Item(i).Enabled = True
        Me.Option1.Item(i).Value = False
    Next
End Sub

Private Sub cmbSelVision_Click()
    Dim rsBase As ADODB.Recordset
    If Me.optModoVer.Item(0).Value Then
    ElseIf Me.optModoVer.Item(1).Value Then
    ElseIf Me.optModoVer.Item(2).Value Then
        Set rsBase = New ADODB.Recordset
        rsBase.LockType = adLockReadOnly
        rsBase.CursorLocation = adUseClient
        rsBase.CursorType = adOpenDynamic
        rsBase.Open "SELECT * FROM CAL_X_CUR WHERE MES ='" & UCase(Left(Me.cmbListaMeses, 3)) & "' AND MID(DIAS," & str(Val(Right(Me.cmbSelVision.Text, 2))) & ",1)", conn
        If rsBase.RecordCount > 0 Then
            ActivaDia Me.cmbSelVision.Text
        Else
            MsgBox "El dia seleccionado no tiene cursos con asistencia", vbInformation + vbOKOnly, "Dia sin Asistencia..."
            Exit Sub
        End If
    End If
    Me.cmbListaModal.Enabled = True
    Me.GrillaAlumnos.FixedRows = 0
    Me.GrillaAlumnos.Rows = 1
    Me.lstGrado.Clear
    Me.lstLetra.Clear
    Me.cmbListaModal.Text = ""
    Me.Option1.Item(0).Value = False
    Me.Option1.Item(1).Value = False
    Me.Option1.Item(2).Value = False
End Sub


Private Sub cmdTermina_Click(Index As Integer)
    Dim rsDatos  As ADODB.Recordset
    Dim strDia As String
    Dim strDiaOk As String
    Set rsDatos = New ADODB.Recordset
    rsDatos.LockType = adLockOptimistic
    rsDatos.CursorLocation = adUseClient
    rsDatos.CursorType = adOpenDynamic
    If Index = 2 Then
        rsDatos.Open "SELECT * FROM CAL_X_CUR WHERE COD_ENS = '" & Left(Me.List3.Text, 3) & "' AND NUM_GRA = '" & Mid(Me.List3, 7, 1) & "' AND LET_CUR = '" & Mid(Me.List3, 10, 1) & "' AND MES='" & UCase(Left(Me.cmbListaMeses.Text, 3)) & "'", conn
    Else
        rsDatos.Open "SELECT * FROM CAL_X_CUR WHERE COD_ENS = '" & Left(Me.cmbListaModal.Text, 3) & "' AND NUM_GRA = '" & Me.lstGrado & "' AND LET_CUR = '" & Me.lstLetra & "' AND MES='" & UCase(Left(Me.cmbListaMeses.Text, 3)) & "'", conn
    End If
    While Not rsDatos.EOF
        With rsDatos
            Select Case Index
                Case Is = 0
                    For i = 1 To Len(rsDatos("DIAS"))
                        If i = Val(Right(Me.cmbSelVision.Text, 3)) Then
                            strDiaOk = strDiaOk + "2"
                        Else
                            strDiaOk = strDiaOk + Mid(rsDatos("DIAS"), i, 1)
                        End If
                    Next
                    conn.Execute "UPDATE CAL_X_CUR SET DIAS='" & strDiaOk & "' WHERE COD_ENS = '" & Left(Me.cmbListaModal.Text, 3) & "' AND NUM_GRA = '" & Me.lstGrado & "' AND LET_CUR = '" & Me.lstLetra & "' AND MES='" & UCase(Left(Me.cmbListaMeses.Text, 3)) & "'"
                Case Is = 1
                    For i = 1 To Len(rsDatos("DIAS"))
                        If i = Val(Right(Me.cmbSelVision.Text, 3)) Then
                            strDiaOk = strDiaOk + "4"
                        Else
                            strDiaOk = strDiaOk + Mid(rsDatos("DIAS"), i, 1)
                        End If
                    Next
                    conn.Execute "UPDATE CAL_X_CUR SET DIAS='" & strDiaOk & "' WHERE COD_ENS = '" & Left(Me.cmbListaModal.Text, 3) & "' AND NUM_GRA = '" & Me.lstGrado & "' AND LET_CUR = '" & Me.lstLetra & "' AND MES='" & UCase(Left(Me.cmbListaMeses.Text, 3)) & "'"
                Case Is = 2
                    For i = 1 To Len(rsDatos("DIAS"))
                        If i = Val(Right(Me.cmbSelVision.Text, 3)) Then
                            strDiaOk = strDiaOk + "1"
                        Else
                            strDiaOk = strDiaOk + Mid(rsDatos("DIAS"), i, 1)
                        End If
                    Next
                    conn.Execute "UPDATE CAL_X_CUR SET DIAS='" & strDiaOk & "' WHERE COD_ENS = '" & Left(Me.List3.Text, 3) & "' AND NUM_GRA = '" & Mid(Me.List3, 7, 1) & "' AND LET_CUR = '" & Mid(Me.List3, 10, 1) & "' AND MES='" & UCase(Left(Me.cmbListaMeses.Text, 3)) & "'"
            End Select
            .MoveNext
        End With
    Wend
    rsDatos.Close
    ActualizaListasCursos
    Me.GrillaAlumnos.FixedRows = 0
    Me.GrillaAlumnos.Rows = 1
End Sub

Private Sub Command1_Click()
    'Me.CrystalReport1.DataFiles = ""
    'Me.CrystalReport1.Action = 1
End Sub

Private Sub Command7_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Aact = Anno
End Sub

Private Sub lstGrado_Click()
    Dim rsLetras As ADODB.Recordset
    Dim Consulta As String
    Set rsLetras = New ADODB.Recordset
    rsLetras.CursorLocation = adUseClient
    rsLetras.LockType = adLockReadOnly
    rsLetras.CursorType = adOpenDynamic
    Consulta = "SELECT C.LET_CUR FROM CAL_X_CUR C, CURSOS L WHERE L.COD_ENS = C.COD_ENS AND L.NUM_GRA=C.NUM_GRA AND L.LET_CUR =C.LET_CUR AND L.COD_ENS = '" & Left(Me.cmbListaModal, 3) & "' AND L.NUM_GRA = '" & Me.lstGrado.Text & "' AND C.MES ='" & Left(Me.cmbListaMeses.Text, 3) & "'"
    If Me.Option1(0).Value Then
        Consulta = Consulta + " AND COD_JOR='2'"
    ElseIf Me.Option1(1).Value Then
        Consulta = Consulta + " AND COD_JOR='3'"
    End If
    If Me.optModoVer.Item(2).Value Then
        Consulta = Consulta + " AND MID(C.DIAS," & str(Val(Right(Me.cmbSelVision.Text, 2))) & ",1)<>'2'"
    Else
        'Consulta = Consulta + " AND C.DIAS LIKE '%2%'"
    End If
    rsLetras.Open Consulta, conn
    Me.lstLetra.Clear
    While Not rsLetras.EOF
        Me.lstLetra.AddItem rsLetras("LET_CUR")
        rsLetras.MoveNext
    Wend
    rsLetras.Close
    Me.GrillaAlumnos.FixedRows = 0
    Me.GrillaAlumnos.Rows = 1
End Sub

Private Sub lstLetra_Click()
    Dim rsAlumnos As ADODB.Recordset
    Dim nLin As Integer
    Dim nCol As Integer
    Dim strCons As String
    Dim i As Integer
    Dim hoy As Integer
    Dim FRet As Date
    Dim FMat As Date
    Dim FCam As Date
    Dim pre As Integer, mat As Integer, aus As Integer
    Set rsAlumnos = New ADODB.Recordset
    rsAlumnos.CursorLocation = adUseClient
    rsAlumnos.CursorType = adOpenDynamic
    rsAlumnos.LockType = adLockReadOnly
    strCons = "SELECT  A.CI_ALU, P.APE_PAT_ALU, P.APE_MAT_ALU, P.NOM_ALU, A.ASIS " & _
                        "FROM ASISTENCIA A, ALU_X_CUR AX, POSTULANTES P " & _
                        "WHERE A.CI_ALU = AX.CI_ALU AND AX.CI_ALU = P.CI_ALU AND A.COD_ENS = AX.COD_ENS AND A.NUM_GRA = AX.NUM_GRA And A.LET_CUR = AX.LET_CUR " & _
                                "AND AX.COD_ENS='" & Left(Me.cmbListaModal.Text, 3) & "' AND AX.NUM_GRA='" & Me.lstGrado.Text & "' AND AX.LET_CUR='" & Me.lstLetra.Text & "'"
    If Me.optModoVer.Item(0).Value Then
        strCons = strCons + " " + "AND ASIS LIKE '%X%'"
    ElseIf Me.optModoVer.Item(1).Value Then
    ElseIf Me.optModoVer.Item(2).Value Then
        strCons = strCons + "AND MID(ASIS," + str(Val(Right(Me.cmbSelVision.Text, 2))) + ",1)='X'"
    End If
    strCons = strCons + " " + "ORDER BY APE_PAT_ALU, APE_MAT_ALU, NOM_ALU"
    rsAlumnos.Open strCons, conn
    i = 1
    With Me.GrillaAlumnos
        .FixedCols = 0
        .FixedRows = 0
        .Cols = 35
        .Rows = 1
        .ClearStructure
        .Clear
        .ColWidth(0) = 250
        .ColWidth(1) = 0
        .ColWidth(2) = 3000
        For nCol = 3 To 33
            .ColAlignmentFixed(nCol) = 4
            .ColAlignment(nCol) = 4
            .TextMatrix(0, nCol) = i
            i = i + 1
        Next
        nLin = 1
        nCol = 1
        While Not rsAlumnos.EOF
            .AddItem nLin
            .TextMatrix(nLin, 1) = rsAlumnos(0)
            .TextMatrix(nLin, 2) = rsAlumnos(1) + " " + rsAlumnos(2) + " " + rsAlumnos(3)
            i = 1
            For nCol = 3 To 34
                .TextMatrix(nLin, nCol) = Mid(rsAlumnos(4), i, 1)
                i = i + 1
            Next
            .Refresh
            rsAlumnos.MoveNext
            nLin = nLin + 1
        Wend
        rsAlumnos.Close
            
        For nCol = 3 To 34
            If Val(.TextMatrix(0, nCol)) = Val(Right(Me.cmbSelVision.Text, 2)) Then
                hoy = nCol
                Exit For
            End If
        Next

        .AddItem " "
        pre = 0
        mat = 0
        aus = Me.GrillaAlumnos.Rows - 2
        
        rsAlumnos.Open "SELECT M.CI_ALU, A.FEC_MAT, A.FEC_CAM, M.FEC_RETIRO FROM MATRICULAS M, ALU_X_CUR A WHERE M.CI_ALU=A.CI_ALU AND M.COD_ENS = A.COD_ENS AND A.COD_ENS = '" & Left(Me.cmbListaModal.Text, 3) & "' AND A.NUM_GRA = '" & Me.lstGrado.Text & "' AND A.LET_CUR = '" & Me.lstLetra & "'", conn
        While Not rsAlumnos.EOF
            FMat = rsAlumnos("FEC_MAT")
            FCam = rsAlumnos("FEC_CAM")
            FRet = IIf(IsNull(rsAlumnos("FEC_RETIRO")), Format("11-11-1111", "dd-mm-yyyy"), rsAlumnos("FEC_RETIRO"))
            If Year(FRet) = 1111 Then
                If Year(FCam) = 1111 Then
                    mat = mat + 1
                Else
                    If Month(FMat) <= MesToNumero(Me.cmbListaMeses.Text) Then
                    End If
                End If
            Else
                If Month(FMat) <= MesToNumero(Me.cmbListaMeses.Text) Then
                    If Month(FRet) > MesToNumero(Me.cmbListaMeses.Text) Then
                        mat = mat + 1
                    Else
                        If Val(Me.GrillaAlumnos.TextMatrix(0, hoy)) <= Day(FRet) Then
                            mat = mat + 1
                        End If
                    End If
                End If
            End If
            rsAlumnos.MoveNext
        Wend
        pre = mat - aus
        rsAlumnos.Close
        .AddItem " "
        .AddItem " "
        .TextMatrix(.Rows - 1, 2) = "Presentes"
        .TextMatrix(.Rows - 1, hoy) = pre
        .AddItem " "
        .TextMatrix(.Rows - 1, 2) = "Ausentes"
        .TextMatrix(.Rows - 1, hoy) = aus
        .AddItem " "
        .TextMatrix(.Rows - 1, 2) = "Matrícula"
        .TextMatrix(.Rows - 1, hoy) = mat
        
        If .Rows > 1 Then
            
            .FixedRows = 1
            .FixedCols = 3
        End If
    
    End With
    
    Me.optModoVer.Item(0).Enabled = True
    Me.optModoVer.Item(1).Enabled = True
    Me.optModoVer.Item(2).Enabled = True
End Sub

Private Sub Option1_Click(Index As Integer)
    Dim Consulta As String
    Dim rsCursos As ADODB.Recordset
    Set rsCursos = New ADODB.Recordset
    rsCursos.CursorLocation = adUseClient
    rsCursos.CursorType = adOpenDynamic
    rsCursos.LockType = adLockReadOnly
    Consulta = ""
    Select Case Index
        Case Is = 0
            Consulta = "SELECT DISTINCT NUM_GRA FROM CURSOS WHERE COD_ENS = '" & Left(Me.cmbListaModal, 3) & "' AND COD_JOR='2'"
        Case Is = 1
            Consulta = "SELECT DISTINCT NUM_GRA FROM CURSOS WHERE COD_ENS = '" & Left(Me.cmbListaModal, 3) & "' AND COD_JOR='3'"
        Case Is = 2
            Consulta = "SELECT DISTINCT NUM_GRA FROM CURSOS WHERE COD_ENS = '" & Left(Me.cmbListaModal, 3) & "'"
    End Select
    rsCursos.Open Consulta, conn
    Me.lstGrado.Clear
    While Not rsCursos.EOF
        Me.lstGrado.AddItem rsCursos("NUM_GRA")
        rsCursos.MoveNext
    Wend
    rsCursos.Close
    'Me.lstLetra.Clear
    'Me.GrillaAlumnos.Clear
    'Me.GrillaAlumnos.Cols = 10
    'Me.GrillaAlumnos.Rows = 20
    
End Sub



Private Sub optModoVer_Click(Index As Integer)
    Dim rsBase As ADODB.Recordset
    Dim i As Integer
    Me.cmbSelVision.Clear
    Me.cmbSelVision.Text = ""
    Me.Label7.Item(0).Visible = True
    Me.Label7.Item(0).Enabled = True
    Me.cmbListaMeses.Visible = True
    i = 1
    With Me.GrillaAlumnos
        .FixedCols = 0
        .FixedRows = 0
        .Cols = 35
        .Rows = 1
        .ClearStructure
        .Clear
        .ColWidth(0) = 250
        .ColWidth(1) = 0
        .ColWidth(2) = 3000
        For nCol = 3 To 33
            .ColAlignmentFixed(nCol) = 4
            .ColAlignment(nCol) = 4
            .ColWidth(nCol) = 350
            .TextMatrix(0, nCol) = i
            i = i + 1
        Next
    End With

    Select Case Index
        Case Is = 0
            Me.Label7.Item(6).Visible = True
            Me.Label7.Item(6).Enabled = False
            Me.Label7.Item(6).Caption = "Mes Completo"
            Me.cmbSelVision.Enabled = False
        Case Is = 1
            Me.Label7.Item(6).Caption = "Semana"
            Me.Label7.Item(6).Enabled = True
            Me.cmbSelVision.Enabled = False
        Case Is = 2
            Me.Label7.Item(6).Caption = "Dia"
            Me.Label7.Item(6).Enabled = True
            Me.cmbSelVision.Visible = True
            Me.cmbSelVision.Enabled = True
            For i = 1 To 31
                If i > 28 Then
                    If Int(ANACT / 4) = ANACT Then
                        Me.cmbSelVision.AddItem "Día " & Format(i, "00")
                    End If
                Else
                    Me.cmbSelVision.AddItem "Día " & Format(i, "00")
                End If
            Next
    End Select
    
End Sub

Private Static Sub ActivaDia(texto As String)
    Dim i As Integer
    For i = 3 To 33
        If Val(Me.GrillaAlumnos.TextMatrix(0, i)) = Val(Right(Me.cmbSelVision, 2)) Then
            Me.GrillaAlumnos.ColWidth(i) = 350
        Else
            Me.GrillaAlumnos.ColWidth(i) = 0
        End If
    Next
End Sub

Private Sub ActualizaListasCursos()
    Dim i As Integer
    Dim rsBase As ADODB.Recordset
    Dim strCons As String
    Dim strMalos As String
    Set rsBase = New ADODB.Recordset
    rsBase.LockType = adLockReadOnly
    rsBase.CursorLocation = adUseClient
    rsBase.CursorType = adOpenDynamic
    Me.List3.Clear
    Me.List4.Clear
    If Me.optModoVer.Item(0).Value Then
        strCons = "DIAS LIKE '%2%' AND cod_ens ='" & Left(Me.cmbListaModal, 3) & "'"
        strMalos = "DIAS LIKE '%4%' AND cod_ens ='" & Left(Me.cmbListaModal, 3) & "'"
    ElseIf Me.optModoVer.Item(1).Value Then
    ElseIf Me.optModoVer.Item(2).Value Then
        strCons = "MID(DIAS," & str(Val(Right(Me.cmbSelVision.Text, 2))) & ",1)='2' AND cod_ens ='" & Left(Me.cmbListaModal, 3) & "'"
        strMalos = "MID(DIAS," & str(Val(Right(Me.cmbSelVision.Text, 2))) & ",1)='4' AND cod_ens ='" & Left(Me.cmbListaModal, 3) & "'"
    End If
    
    rsBase.Open "SELECT * FROM CAL_X_CUR WHERE " & strCons, conn
    While Not rsBase.EOF
        Me.List3.AddItem rsBase("COD_ENS") & " - " & rsBase("NUM_GRA") & "º " & rsBase("LET_CUR")
        rsBase.MoveNext
    Wend
    rsBase.Close
    
    rsBase.Open "SELECT * FROM CAL_X_CUR WHERE " & strMalos, conn
    While Not rsBase.EOF
        Me.List4.AddItem rsBase("COD_ENS") & " - " & rsBase("NUM_GRA") & "º " & rsBase("LET_CUR")
        rsBase.MoveNext
    Wend
    rsBase.Close
End Sub


Private Function MesCortoLargo(MesCorto As String) As String
    Select Case MesCorto
        Case Is = "ENE"
            MesCortoLargo = "Enero"
        Case Is = "FEB"
            MesCortoLargo = "Febrero"
        Case Is = "MAR"
            MesCortoLargo = "Marzo"
        Case Is = "ABR"
            MesCortoLargo = "Abril"
        Case Is = "MAY"
            MesCortoLargo = "Mayo"
        Case Is = "JUN"
            MesCortoLargo = "Junio"
        Case Is = "JUL"
            MesCortoLargo = "Julio"
        Case Is = "AGO"
            MesCortoLargo = "Agosto"
        Case Is = "SEP"
            MesCortoLargo = "Septiembre"
        Case Is = "OCT"
            MesCortoLargo = "Octubre"
        Case Is = "NOV"
            MesCortoLargo = "Noviembre"
        Case Is = "DIC"
            MesCortoLargo = "Diciembre"
    End Select
End Function

Private Function MesToNumero(Nombre_del_Mes As String) As Integer
    Dim NMes As Integer
    Select Case UCase(Nombre_del_Mes)
        Case Is = "ENERO"
            NMes = 1
        Case Is = "FEBRERO"
            NMes = 2
        Case Is = "MARZO"
            NMes = 3
        Case Is = "ABRIL"
            NMes = 4
        Case Is = "MAYO"
            NMes = 5
        Case Is = "JUNIO"
            NMes = 6
        Case Is = "JULIO"
            NMes = 7
        Case Is = "AGOSTO"
            NMes = 8
        Case Is = "SEPTIEMBRE"
            NMes = 9
        Case Is = "OCTUBRE"
            NMes = 10
        Case Is = "NOVIEMBRE"
            NMes = 11
        Case Is = "DICIEMBRE"
            NMes = 12
    End Select
    MesToNumero = NMes
End Function
