VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_Consulta_Notas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Consulta de Notas"
   ClientHeight    =   7020
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   17520
   Icon            =   "Form_Consulta_Notas.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7020
   ScaleWidth      =   17520
   Begin MSHierarchicalFlexGridLib.MSHFlexGrid msflex_notas 
      Height          =   5535
      Left            =   120
      TabIndex        =   10
      Top             =   1320
      Width           =   17175
      _ExtentX        =   30295
      _ExtentY        =   9763
      _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.Frame Frame1 
      Caption         =   "Selección por Curso"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1095
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   17175
      Begin VB.ComboBox cb_evaluaciones 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   9960
         TabIndex        =   12
         Top             =   600
         Width           =   3495
      End
      Begin VB.CommandButton Btn_Ver_Lista 
         Caption         =   "Ver"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   735
         Left            =   16080
         Picture         =   "Form_Consulta_Notas.frx":2A8B2
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   240
         Width           =   975
      End
      Begin MSComctlLib.ImageCombo IC_Ensenanza 
         Height          =   345
         Left            =   1320
         TabIndex        =   3
         Top             =   600
         Width           =   3375
         _ExtentX        =   5953
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         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
         Locked          =   -1  'True
         Text            =   "IC_Ensenanza"
      End
      Begin MSComctlLib.ImageCombo IC_Nivel 
         Height          =   345
         Left            =   6240
         TabIndex        =   4
         Top             =   240
         Width           =   975
         _ExtentX        =   1720
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         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
         Locked          =   -1  'True
         Text            =   "IC_Nivel"
      End
      Begin MSComctlLib.ImageCombo IC_Letra 
         Height          =   345
         Left            =   6240
         TabIndex        =   5
         Top             =   600
         Width           =   975
         _ExtentX        =   1720
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         Enabled         =   0   'False
         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
         Locked          =   -1  'True
         Text            =   "IC_Letra"
      End
      Begin MSComctlLib.ImageCombo IC_Agno 
         Height          =   345
         Left            =   1320
         TabIndex        =   6
         Top             =   240
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         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
         Locked          =   -1  'True
         Text            =   "IC_Agno"
      End
      Begin VB.CheckBox Check_Letra 
         Caption         =   "Letra"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   195
         Left            =   7320
         TabIndex        =   2
         Top             =   720
         Value           =   1  'Checked
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.ComboBox cb_Asignatura 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   9960
         TabIndex        =   11
         Top             =   240
         Width           =   3495
      End
      Begin VB.Label Label6 
         Caption         =   "Evaluación"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   8880
         TabIndex        =   15
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label Label4 
         Caption         =   "Asignatura"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   8880
         TabIndex        =   13
         Top             =   360
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   360
         Width           =   855
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Caption         =   "Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   120
         TabIndex        =   8
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label3 
         Alignment       =   2  'Center
         Caption         =   "Nivel"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   5400
         TabIndex        =   7
         Top             =   360
         Width           =   615
      End
      Begin VB.Label Label5 
         Caption         =   "Letra"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   5520
         TabIndex        =   14
         Top             =   720
         Width           =   615
      End
   End
End
Attribute VB_Name = "Form_Consulta_Notas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Btn_Ver_Lista_Click()
    Dim asi As Integer
    Dim cod_eva As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    
    
    If IC_Agno.Text = "" Or IC_Ensenanza.Text = "" Or IC_Nivel.Text = "" _
       Or IC_Letra.Text = "" Or cb_Asignatura.Text = "" Or cb_evaluaciones.Text = "" Then
        Exit Sub
    End If
    
    var_sql = "select cod_asi from subsectores" _
            & " where nom_asi = '" & cb_Asignatura.Text & "' and cod_ens = '" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' and num_gra = " & IC_Nivel.Text
    objRS.Open var_sql, conn
    asi = objRS("cod_asi")
    objRS.Close
    
    var_sql = "select cod_eva,des_eva from evaluaciones" _
            & " where des_eva = '" & cb_evaluaciones.Text & "'"
    objRS.Open var_sql, conn
    cod_eva = objRS("cod_eva")
    objRS.Close
        
    var_sql = "select p1.ci_alu as 'R.U.T.',nombre,notas1 as 'Primer Semestre',notas2 as 'Segundo Semestre' from" _
            & " (select p.ci_alu,concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as nombre," _
            & "concat(IF(MID(nota,1,2) = '', '    ', MID(nota,1,2)),' - ',IF(MID(nota,3,2) = '', '    ', MID(nota,3,2)),' - ',IF(MID(nota,5,2) = '', '    '," _
            & " MID(nota,5,2)),' - ',IF(MID(nota,7,2) = '', '    ', MID(nota,7,2)),' - ',IF(MID(nota,9,2) = '', '    ', MID(nota,9,2)),' - ',IF(MID(nota,11,2) = '', '    ', MID(nota,11,2)),' - ',IF(MID(nota,13,2) = '', '    ', MID(nota,13,2)),' - ',IF(MID(nota,15,2) = '', '    ', MID(nota,15,2)),' - ',IF(MID(nota,17,2) = '', '    ', MID(nota,17,2)),' - ',IF(MID(nota,19,2) = '', '    ', MID(nota,19,2)),' - ',IF(MID(nota,21,2) = '', '    ', MID(nota,21,2)),' - ',IF(MID(nota,23,2) = '', '    ', MID(nota,23,2)),' - ') as notas1" _
            & " from notas n,alu_x_cur axc,postulantes p" _
            & " where n.agno = axc.agno and n.cod_ens = axc.cod_ens and" _
            & " n.num_gra = axc.num_gra and n.letra_curso = axc.let_cur and" _
            & " n.ci_alu = axc.ci_alu And cod_asi = " & asi & " And num_per = 0" _
            & " and axc.agno = " & IC_Agno.Text & " and axc.cod_ens = '" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' and axc.num_gra = " & IC_Nivel.Text _
            & " and let_cur = '" & IC_Letra.Text & "' and cod_eva = " & cod_eva & " and activo_alu = 'SI' and axc.ci_alu = p.ci_alu AND axc.activo_alu = 'SI'" _
            & " ORDER BY ape_pat_alu, ape_mat_alu, nom_alu limit 100) as p1," _
            & " (select p.ci_alu,concat(IF(MID(nota,1,2) = '', '    ', MID(nota,1,2)),' - ',IF(MID(nota,3,2) = '', '    ', MID(nota,3,2)),' - ',IF(MID(nota,5,2) = '', '    '," _
            & " MID(nota,5,2)),' - ',IF(MID(nota,7,2) = '', '    ', MID(nota,7,2)),' - ',IF(MID(nota,9,2) = '', '    ', MID(nota,9,2)),' - ',IF(MID(nota,11,2) = '', '    ', MID(nota,11,2)),' - ',IF(MID(nota,13,2) = '', '    ', MID(nota,13,2)),' - ',IF(MID(nota,15,2) = '', '    ', MID(nota,15,2)),' - ',IF(MID(nota,17,2) = '', '    ', MID(nota,17,2)),' - ',IF(MID(nota,19,2) = '', '    ', MID(nota,19,2)),' - ',IF(MID(nota,21,2) = '', '    ', MID(nota,21,2)),' - ',IF(MID(nota,23,2) = '', '    ', MID(nota,23,2)),' - ') as notas2" _
            & " from notas n,alu_x_cur axc,postulantes p" _
            & " where n.agno = axc.agno and n.cod_ens = axc.cod_ens and" _
            & " n.num_gra = axc.num_gra and n.letra_curso = axc.let_cur and" _
            & " n.ci_alu = axc.ci_alu And cod_asi = " & asi & " And num_per = 1" _
            & " and axc.agno = " & IC_Agno.Text & " and axc.cod_ens = '" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' and axc.num_gra = " & IC_Nivel.Text _
            & " and let_cur = '" & IC_Letra.Text & "' and cod_eva = " & cod_eva & " and activo_alu = 'SI' and axc.ci_alu = p.ci_alu" _
            & " limit 100) p2" _
            & " Where p1.ci_alu = p2.ci_alu ORDER BY nombre"
            
    objRS.Open var_sql, conn
    Call Rec2Grid(objRS, msflex_notas, True)
    objRS.Close
End Sub



Private Sub cmd_Salir_Click()
Unload Me
End Sub

Private Sub Form_Load()
    Dim I As Integer
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    var_sql = "select cod_eva,des_eva from evaluaciones"
    objRS.Open var_sql, conn
    I = 0
    While Not objRS.EOF
        cb_evaluaciones.AddItem objRS("des_eva"), I
        I = I + 1
        objRS.MoveNext
    Wend
    objRS.Close
    cb_evaluaciones.ListIndex = 0
    Call Set_IC_Agno
End Sub

Private Sub IC_Agno_Click()
     IC_Ensenanza.Enabled = True
    Set_IC_Ensenanza
End Sub

Private Sub IC_Ensenanza_Click()
     IC_Nivel.Enabled = True
    Call Set_IC_Nivel
End Sub

Private Sub Set_IC_Ensenanza()
    Dim REC As ADODB.Recordset
    Dim QRY As String
    
    QRY = "SELECT DISTINCT m.cod_ens, ce.des_ens FROM matriculas as m, codigos_ensenanza as ce WHERE ce.cod_ens <> '996' and ce.cod_ens <> '010' and m.cod_ens=ce.cod_ens AND m.anno_mat=" & IC_Agno.SelectedItem.Text & " ORDER BY ce.ord_ens;"
    Set REC = New ADODB.Recordset
    REC.Open QRY, conn
    
    IC_Ensenanza.ComboItems.Clear
    If REC.RecordCount > 0 Then
        REC.MoveFirst
        For I = 1 To REC.RecordCount
            IC_Ensenanza.ComboItems.Add I, "K" & Format(REC!Cod_Ens, "000"), REC!des_ens
            REC.MoveNext
        Next I
        Set IC_Ensenanza.SelectedItem = IC_Ensenanza.ComboItems.Item(1)
        ErrorStatus = False
        IC_Nivel.Enabled = True
        IC_Letra.Enabled = False
        Call Set_IC_Nivel
    Else
        ErrorStatus = True
        IC_Ensenanza.Enabled = False
        IC_Nivel.Enabled = False
        IC_Letra.Enabled = False
    End If
    REC.Close
End Sub

Private Sub Set_IC_Nivel()
    Dim REC As ADODB.Recordset
    Dim QRY As String

    QRY = "SELECT DISTINCT m.num_gra FROM matriculas as m WHERE m.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND m.anno_mat=" & IC_Agno.SelectedItem.Text & " ORDER BY m.num_gra;"
    Set REC = New ADODB.Recordset
    REC.Open QRY, conn
    
    IC_Nivel.ComboItems.Clear
    If REC.RecordCount > 0 Then
        REC.MoveFirst
        For I = 1 To REC.RecordCount
            IC_Nivel.ComboItems.Add I, , str(REC!Num_Gra)
            REC.MoveNext
        Next I
        Set IC_Nivel.SelectedItem = IC_Nivel.ComboItems.Item(1)
        ErrorStatus = False
        If Check_Letra.Value = 1 Then
            IC_Letra.Enabled = True
            Call Set_IC_Letra
        End If
    Else
        ErrorStatus = True
        IC_Nivel.Enabled = False
        IC_Letra.Enabled = False
    End If
    REC.Close
End Sub

Private Sub Set_IC_Letra()
    Dim REC As ADODB.Recordset
    Dim QRY As String
    
    If Check_Letra.Value = 1 Then
        IC_Letra.ComboItems.Clear
        IC_Letra.Text = ""
        QRY = "SELECT DISTINCT m.let_cur FROM alu_x_cur as m WHERE m.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND m.agno=" & Trim(IC_Agno.SelectedItem.Text) & " AND m.num_gra='" & Trim(IC_Nivel.SelectedItem.Text) & "' ORDER BY m.num_gra;"
        Set REC = New ADODB.Recordset
        REC.Open QRY, conn
        If REC.RecordCount > 0 Then
            REC.MoveFirst
            For I = 1 To REC.RecordCount
                IC_Letra.ComboItems.Add I, , REC!Let_Cur
                REC.MoveNext
            Next I
            Set IC_Letra.SelectedItem = IC_Letra.ComboItems.Item(1)
            ErrorStatus = False
            ' Llenar Siguiente Combo.
        Else
            ErrorStatus = True
            Check_Letra.Value = 0
            IC_Letra.Enabled = False
        End If
        REC.Close
    Else
        ErrorStatus = False
        IC_Letra.Enabled = False
    End If
End Sub

Private Sub Set_IC_Agno()
    Dim agno As Integer
    
    agno = IIf(Year(Date) < 2005, 2005, Year(Date))
    IC_Agno.ComboItems.Clear
    For I = 1 To (agno - 2004) + 1
        IC_Agno.ComboItems.Add I, , str(I + 2004)
    Next I
    Set IC_Agno.SelectedItem = IC_Agno.ComboItems.Item(I - 2)
    ErrorStatus = False
    IC_Ensenanza.Enabled = True
    IC_Nivel.Enabled = False
    IC_Letra.Enabled = False
    Call Set_IC_Ensenanza
    
End Sub

Private Sub IC_Letra_Change()
    IC_Letra_Click
End Sub

Private Sub IC_Letra_Click()
    Dim I As Integer
    Dim var_sql As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    var_sql = "select n.cod_asi,nom_asi" _
            & " from notas n,subsectores s" _
            & " where n.agno = " & IC_Agno.Text & " and n.cod_ens = '" _
            & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' and n.letra_curso = '" & IC_Letra.Text _
            & "' and n.num_gra = " & IC_Nivel.Text _
            & " and n.cod_ens = s.cod_ens and n.num_gra = s.num_gra and n.cod_asi = s.cod_asi" _
            & " group by n.cod_asi"
    objRS.Open var_sql, conn
    cb_Asignatura.Clear
    I = 0
    While Not objRS.EOF
        cb_Asignatura.AddItem objRS("nom_asi"), I
        I = I + 1
        objRS.MoveNext
    Wend
    objRS.Close
    If I > 0 Then
        If Mid(IC_Ensenanza.SelectedItem.Key, 2) <> "010" And Mid(IC_Ensenanza.SelectedItem.Key, 2) <> "996" Then
            cb_Asignatura.ListIndex = 0
        End If
    End If
    
End Sub

Private Sub IC_Nivel_Click()
     If Check_Letra.Value = 1 Then
        IC_Letra.Enabled = True
        Call Set_IC_Letra
    End If
End Sub

Private Sub Rec2Grid(ByRef REC As ADODB.Recordset, ByRef grid As Object, Optional ByVal Numeracion As Boolean = True)
    grid.ClearStructure
    If REC.RecordCount > 0 Then
        grid.Cols = REC.Fields.count + 1
        grid.Rows = REC.RecordCount + 1
        grid.FixedCols = 1
        grid.FixedRows = 1
        grid.TextMatrix(0, 0) = "Nº"
        grid.ColWidth(0) = IIf(Numeracion, TextWidth(grid.TextMatrix(0, 0)) + 100, 0) 'Columna de Numeros
        
        For I = 1 To REC.Fields.count
            grid.TextMatrix(0, I) = UCase(REC.Fields(I - 1).Name)
            grid.ColWidth(I) = TextWidth(grid.TextMatrix(0, I)) + 100
        Next I
        REC.MoveFirst
        
        
        For I = 1 To REC.RecordCount
            grid.TextMatrix(I, 0) = I
            
            grid.ColWidth(0) = IIf(Numeracion, IIf(TextWidth(grid.TextMatrix(I, 0)) + 500 > grid.ColWidth(0), TextWidth(grid.TextMatrix(I, 0)) + 500, grid.ColWidth(0)), 0)
            
            For j = 1 To REC.Fields.count
                grid.TextMatrix(I, j) = IIf(IsNull(REC(j - 1)), "Null", REC(j - 1))
                grid.ColWidth(j) = IIf(TextWidth(grid.TextMatrix(I, j)) + 500 > grid.ColWidth(j), TextWidth(grid.TextMatrix(I, j)) + 500, grid.ColWidth(j))
                
                
                grid.ColAlignment(j) = 1
            Next j
            REC.MoveNext
        Next I
        
    Else
        grid.Cols = 2
        grid.Rows = 2
    End If
End Sub

