VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "MSCOMCTL.OCX"
Object = "{00025600-0000-0000-C000-000000000046}#4.6#0"; "crystl32.ocx"
Begin VB.Form Form_Listado_Alumnos 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Listado de Alumnos"
   ClientHeight    =   2700
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   5085
   Icon            =   "Form_Listado_Alumnos.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2700
   ScaleWidth      =   5085
   Begin Crystal.CrystalReport cr 
      Left            =   2880
      Top             =   360
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   262150
   End
   Begin VB.CommandButton cmd_Salir 
      Caption         =   "Salir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   3600
      Picture         =   "Form_Listado_Alumnos.frx":2A8B2
      Style           =   1  'Graphical
      TabIndex        =   10
      Top             =   1440
      Width           =   1335
   End
   Begin VB.CommandButton cmd_Imprimir 
      Caption         =   "Imprimir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   3600
      Picture         =   "Form_Listado_Alumnos.frx":2AED8
      Style           =   1  'Graphical
      TabIndex        =   9
      Top             =   480
      Width           =   1335
   End
   Begin VB.Frame Frame1 
      Caption         =   "Seleccione 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          =   2415
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3375
      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            =   240
         TabIndex        =   1
         Top             =   1920
         Value           =   1  'Checked
         Visible         =   0   'False
         Width           =   735
      End
      Begin MSComctlLib.ImageCombo IC_Ensenanza 
         Height          =   345
         Left            =   1200
         TabIndex        =   2
         Top             =   840
         Width           =   2055
         _ExtentX        =   3625
         _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            =   1200
         TabIndex        =   3
         Top             =   1320
         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_Nivel"
      End
      Begin MSComctlLib.ImageCombo IC_Letra 
         Height          =   345
         Left            =   1200
         TabIndex        =   4
         Top             =   1800
         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_Letra"
      End
      Begin MSComctlLib.ImageCombo IC_Agno 
         Height          =   345
         Left            =   1200
         TabIndex        =   5
         Top             =   360
         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.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            =   240
         TabIndex        =   8
         Top             =   360
         Width           =   855
      End
      Begin VB.Label Label2 
         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            =   240
         TabIndex        =   7
         Top             =   840
         Width           =   855
      End
      Begin VB.Label Label3 
         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            =   240
         TabIndex        =   6
         Top             =   1320
         Width           =   615
      End
   End
End
Attribute VB_Name = "Form_Listado_Alumnos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd_imprimir_Click()
    Dim curso, nivel, Cod_Ens As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql, est, dir, conv As String
    var_sql = "SELECT nom_est,dir_est FROM establecimientos"
    objRS.Open var_sql, conn
    var_sql = "drop table if exists temp_convenios;"
    conn.Execute var_sql
    If Not objRS.EOF Then
        est = objRS("nom_est")
        dir = objRS("dir_est")
    End If
    objRS.Close
    'IC_Agno IC_Ensenanza IC_Nivel IC_Letra
    Select Case IC_Ensenanza.Text
            Case Is = "Play Group"
                Cod_Ens = "111"
                nivel = "K"
            Case Is = "Educación Parvularia"
                Cod_Ens = "010"
                nivel = "K"
            Case Is = "Educación General Básica"
                Cod_Ens = "110"
                nivel = "EB"
            Case Is = "Educación Media H/C niños y jóvenes"
                Cod_Ens = "310"
                nivel = "EM"
            Case Is = "Otros Tipos (Pre Kinder)"
                Cod_Ens = "996"
                nivel = "PK"
    End Select
    
    curso = IC_Nivel.Text & " " & IC_Letra.Text & " " & nivel
                
    var_sql = "create table temp_convenios type = MyISAM" _
            & " SELECT p.ci_alu,concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as nom_alu,dire_alu,comuna,fon_alu" _
            & " FROM postulantes p,alu_x_cur axc,codigos__geograficos cg" _
            & " where p.ci_alu = axc.ci_alu and p.cod_geo = cg.cod_geo and" _
            & " axc.agno = " & IC_Agno.Text & " and activo_alu = 'SI' and" _
            & " axc.cod_ens = '" & Cod_Ens _
            & "' and axc.num_gra = " & IC_Nivel.Text & " and let_cur = '" & IC_Letra.Text & "'"
    conn.Execute var_sql
                 
    Call LimpiaFormulas(cr, 30)
    cr.ReportFileName = App.Path & "\Rpt\datos_alumnos.rpt"
        
    cr.Formulas(3) = "nom_est = '" & est & "'"
    cr.Formulas(4) = "dir_est = '" & dir & "'"
    cr.Formulas(5) = "curso = '" & curso & "'"
    cr.Destination = crptToWindow
    
    cr.Action = 1
End Sub

Private Sub cmd_salir_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    ' Setear el combo años.
    Me.Top = 0
    Me.Left = 0
    IC_Letra.Text = ""
    IC_Letra.ComboItems.Clear
    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 IC_Nivel_Click()
    '  If Check_Letra.Value = 1 Then
        IC_Letra.Enabled = True
        Call Set_IC_Letra
   ' End If
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 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
        ' Llenar Siguiente Combo.
        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
        ' Llenar Siguiente Combo.
        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 = 2005 To (Anno)
'        IC_Agno.ComboItems.Add i, , str(i + 2004)
'    Next i
'    Set IC_Agno.SelectedItem = IC_Agno.ComboItems.Item(i - 1)
'    ErrorStatus = False
    
    agno = IIf(Year(Date) < 2005, 2005, Year(Date))
    IC_Agno.ComboItems.Clear
    For i = 1 To (agno - 2004)
        IC_Agno.ComboItems.Add i, , str(i + 2004)
    Next i
    Set IC_Agno.SelectedItem = IC_Agno.ComboItems.Item(i - 1)
    ErrorStatus = False
    
    ' Llenar combo enseñanza
    IC_Ensenanza.Enabled = True
    IC_Nivel.Enabled = False
    IC_Letra.Enabled = False
    Call Set_IC_Ensenanza
End Sub


