VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form Form_Modificar_Matricula 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Modificar Matrícula"
   ClientHeight    =   4140
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10980
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Form_Modificar_Matricula.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4140
   ScaleWidth      =   10980
   Begin VB.ListBox lst_Rut 
      Height          =   1320
      Left            =   5280
      TabIndex        =   9
      Top             =   720
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.ListBox lst_Alumnos 
      Height          =   1320
      Left            =   960
      TabIndex        =   3
      Top             =   720
      Visible         =   0   'False
      Width           =   3615
   End
   Begin VB.Frame Frame_Apo_Caja 
      Caption         =   "Datos del Alumno"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   855
      Left            =   120
      TabIndex        =   4
      Top             =   120
      Width           =   6735
      Begin VB.TextBox txt_NombreCompleto 
         Height          =   285
         Left            =   840
         TabIndex        =   8
         Top             =   360
         Width           =   3615
      End
      Begin VB.TextBox txt_RutBusqueda 
         Height          =   285
         Left            =   5160
         TabIndex        =   7
         Top             =   360
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "Nombre"
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "RUT"
         Height          =   255
         Left            =   4680
         TabIndex        =   5
         Top             =   360
         Width           =   615
      End
   End
   Begin VB.CommandButton btn_Cancelar 
      Caption         =   "Cancelar"
      Height          =   735
      Left            =   9600
      Picture         =   "Form_Modificar_Matricula.frx":2A8B2
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   240
      Width           =   1215
   End
   Begin VB.CommandButton btnOtroAlumno 
      Caption         =   "Otro Alumno"
      Height          =   735
      Left            =   8280
      Picture         =   "Form_Modificar_Matricula.frx":2AC1A
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   240
      Width           =   1215
   End
   Begin VB.CommandButton btn_Ver 
      Caption         =   "Ver"
      Height          =   735
      Left            =   6960
      Picture         =   "Form_Modificar_Matricula.frx":2B16F
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   240
      Width           =   1215
   End
   Begin VB.Frame Form1 
      Caption         =   "Datos de Matrícula"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2895
      Left            =   120
      TabIndex        =   10
      Top             =   1080
      Width           =   10695
      Begin MSComCtl2.DTPicker DTPicker1 
         Height          =   375
         Left            =   1800
         TabIndex        =   20
         Top             =   600
         Width           =   2775
         _ExtentX        =   4895
         _ExtentY        =   661
         _Version        =   393216
         Enabled         =   0   'False
         Format          =   103088129
         CurrentDate     =   41263
         MaxDate         =   55153
         MinDate         =   36161
      End
      Begin VB.ComboBox Combo3 
         Enabled         =   0   'False
         Height          =   330
         ItemData        =   "Form_Modificar_Matricula.frx":2B6E6
         Left            =   6840
         List            =   "Form_Modificar_Matricula.frx":2B702
         TabIndex        =   18
         Top             =   1320
         Width           =   2775
      End
      Begin VB.ComboBox Combo2 
         Enabled         =   0   'False
         Height          =   330
         ItemData        =   "Form_Modificar_Matricula.frx":2B71E
         Left            =   6840
         List            =   "Form_Modificar_Matricula.frx":2B72E
         TabIndex        =   17
         Top             =   600
         Width           =   2775
      End
      Begin VB.ComboBox Combo1 
         Enabled         =   0   'False
         Height          =   330
         ItemData        =   "Form_Modificar_Matricula.frx":2B7A1
         Left            =   1800
         List            =   "Form_Modificar_Matricula.frx":2B7AE
         TabIndex        =   16
         Top             =   1320
         Width           =   2775
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Guardar"
         Enabled         =   0   'False
         Height          =   855
         Left            =   9000
         Picture         =   "Form_Modificar_Matricula.frx":2B7C8
         Style           =   1  'Graphical
         TabIndex        =   11
         Top             =   1800
         Width           =   1455
      End
      Begin VB.Label Label7 
         Caption         =   "Es módulo permite modificar la última matrícula activa del alumno seleccionado"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   375
         Left            =   240
         TabIndex        =   19
         Top             =   2400
         Width           =   6975
      End
      Begin VB.Label Label6 
         Caption         =   "Grado"
         Height          =   375
         Left            =   5160
         TabIndex        =   15
         Top             =   1320
         Width           =   1215
      End
      Begin VB.Label Label5 
         Caption         =   "Nivel de enseñanza"
         Height          =   375
         Left            =   5160
         TabIndex        =   14
         Top             =   600
         Width           =   2415
      End
      Begin VB.Label Label4 
         Caption         =   "Jornada"
         Height          =   495
         Left            =   240
         TabIndex        =   13
         Top             =   1320
         Width           =   2175
      End
      Begin VB.Label Label3 
         Caption         =   "Fecha de Matrícula"
         Height          =   255
         Left            =   240
         TabIndex        =   12
         Top             =   600
         Width           =   2295
      End
   End
End
Attribute VB_Name = "Form_Modificar_Matricula"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim REC1 As ADODB.Recordset
Dim QRY1 As String
Private Sub Btn_Cancelar_Click()
    Unload Me
End Sub

Public Sub Btn_Ver_Click()

Set REC1 = New ADODB.Recordset

    If txt_RutBusqueda <> "" Then
        txt_RutBusqueda.Locked = True
        txt_NombreCompleto.Locked = True
        habilita_controles
        lst_Alumnos.Visible = False
        btn_Ver.Enabled = False
    End If
    
    Set REC1 = New ADODB.Recordset
    
    QRY1 = "SELECT * FROM matriculas m, codigos_ensenanza c, jornadas j WHERE ci_alu = '" & txt_RutBusqueda.Text & "' AND activo_alu = 'SI' AND m.cod_ens = c.cod_ens AND m.cod_jor = j.cod_jor order by anno_mat desc limit 1"
    REC1.Open QRY1, conn

    If REC1.EOF Then
        MsgBox "No se encontraron matrículas válidas para el alumno seleccionado", vbInformation, "GesCol"
        Call btnOtroAlumno_Click
        Exit Sub
    End If
    
    DTPicker1.Value = REC1("FEC_MAT")
    
If REC1("DES_JOR") = "Tarde" Then
    Combo1.ListIndex = 0
End If
If REC1("DES_JOR") = "Mañana" Then
    Combo1.ListIndex = 1
End If
If REC1("DES_JOR") = "J.E.C." Then
    Combo1.ListIndex = 2
End If


If REC1("DES_ENS") = "Educación Parvularia" Then
    Combo2.ListIndex = 0
    Call item_unico
End If

If REC1("DES_ENS") = "Educación General Básica" Then
    Combo2.ListIndex = 1
    
    Combo3.Clear
    Combo3.AddItem ("1")
    Combo3.AddItem ("2")
    Combo3.AddItem ("3")
    Combo3.AddItem ("4")
    Combo3.AddItem ("5")
    Combo3.AddItem ("6")
    Combo3.AddItem ("7")
    Combo3.AddItem ("8")
    
    Call buscar_item
End If

If REC1("DES_ENS") = "Educación Media H/C niños y jóvenes" Then
    Combo2.ListIndex = 2
    
    Combo3.Clear
    Combo3.AddItem ("1")
    Combo3.AddItem ("2")
    Combo3.AddItem ("3")
    Combo3.AddItem ("4")
    
    Call buscar_item
End If

If REC1("DES_ENS") = "Otros Tipos (Pre Kinder)" Then
    Combo2.ListIndex = 3
    Call item_unico
End If

If REC1("DES_ENS") = "Play Group" Then
    Combo2.AddItem ("Play Group")
    Combo2.ListIndex = 4
    Call item_unico
End If
    
End Sub
Private Sub item_unico()
    Combo3.Clear
    Combo3.AddItem (1)
    Combo3.ListIndex = 0
End Sub

Private Sub buscar_item()
    If REC1("NUM_GRA") = "1" Then
    Combo3.ListIndex = 0
    End If
    If REC1("NUM_GRA") = "2" Then
    Combo3.ListIndex = 1
    End If
    If REC1("NUM_GRA") = "3" Then
    Combo3.ListIndex = 2
    End If
    If REC1("NUM_GRA") = "4" Then
    Combo3.ListIndex = 3
    End If
    If REC1("NUM_GRA") = "5" Then
    Combo3.ListIndex = 4
    End If
    If REC1("NUM_GRA") = "6" Then
    Combo3.ListIndex = 5
    End If
    If REC1("NUM_GRA") = "7" Then
    Combo3.ListIndex = 6
    End If
    If REC1("NUM_GRA") = "8" Then
    Combo3.ListIndex = 7
    End If
End Sub

Private Sub btnOtroAlumno_Click()
    txt_RutBusqueda.Locked = False
    txt_NombreCompleto.Locked = False
    btn_Ver.Enabled = True
    limpia_controles
    desabilita_controles
    lst_Rut.Visible = False
    lst_Alumnos.Visible = False
    
    If (REC1 Is Nothing) Then
    Else
        REC1.Close
    End If
    
End Sub

Private Sub Combo2_Click()
'Educación Parvularia
If Combo2.ListIndex = 0 Then
    Call item_unico
End If

'Educación General Básica
If Combo2.ListIndex = 1 Then
    
    Combo3.Clear
    Combo3.AddItem ("1")
    Combo3.AddItem ("2")
    Combo3.AddItem ("3")
    Combo3.AddItem ("4")
    Combo3.AddItem ("5")
    Combo3.AddItem ("6")
    Combo3.AddItem ("7")
    Combo3.AddItem ("8")
    
    Combo3.ListIndex = 0
End If

'Educación Media H/C niños y jóvenes
If Combo2.ListIndex = 2 Then
    
    Combo3.Clear
    Combo3.AddItem ("1")
    Combo3.AddItem ("2")
    Combo3.AddItem ("3")
    Combo3.AddItem ("4")
    
    Combo3.ListIndex = 0
End If

'Otros Tipos (Pre Kinder)
If Combo2.ListIndex = 3 Then
    Call item_unico
End If

'Play Group
If Combo2.ListIndex = 4 Then
    Call item_unico
End If
End Sub

Private Sub Command1_Click()

a0 = Format(DTPicker1.Value, "yyyy-mm-dd")

If Combo1.ListIndex = 0 Then
    a1 = "3"
End If
If Combo1.ListIndex = 1 Then
    a1 = "2"
End If
If Combo1.ListIndex = 2 Then
    a1 = "1"
End If

'Educación Parvularia
If Combo2.ListIndex = 0 Then
    a2 = "010"
End If

'Educación General Básica
If Combo2.ListIndex = 1 Then
    a2 = "110"
End If

'Educación Media H/C niños y jóvenes
If Combo2.ListIndex = 2 Then
    a2 = "310"
End If

'Otros Tipos (Pre Kinder)
If Combo2.ListIndex = 3 Then
    a2 = "996"
End If

'Play Group
If Combo2.ListIndex = 4 Then
    a2 = "111"
End If

    a = "UPDATE matriculas SET fec_mat = '" & a0 & "', cod_ens = '" & a2 & "', num_gra = '" & Combo3.Text & "', cod_jor = '" & a1 & "'" _
        & " WHERE ci_alu = '" & REC1("CI_ALU") & "' AND activo_alu = 'SI' AND num_mat = '" & REC1("NUM_MAT") & "' AND anno_mat = '" & REC1("ANNO_MAT") & "'"
    conn.Execute a
    
MsgBox "La información de matricula ha sido modificada", vbInformation, "GesCol"

Call btnOtroAlumno_Click

End Sub

Private Sub Form_Load()
    CentrarForma Me
End Sub

Private Sub lst_Alumnos_dblClick()
    'Dim dig As String
    'dig = digito(lst_Alumnos.ItemData(lst_Alumnos.ListIndex))
    'Dim Rut As String
    Dim varsql As String
    'Rut = lst_Alumnos.ItemData(lst_Alumnos.ListIndex) & "-" & dig
    
    Dim objRS As ADODB.Recordset
    varsql = "SELECT ci_alu" _
           & " FROM postulantes where concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) = '" _
           & lst_Alumnos.Text & "'"

    Set objRS = New ADODB.Recordset
    objRS.Open varsql, conn
    If Not objRS.EOF Then
        txt_NombreCompleto.Text = lst_Alumnos.Text
        txt_RutBusqueda.Text = objRS("ci_alu")
    End If
    objRS.Close
    lst_Rut.Clear
    lst_Rut.Visible = False
    If txt_RutBusqueda.Text <> "" And txt_NombreCompleto.Text <> "" Then
        txt_RutBusqueda.Locked = True
        txt_NombreCompleto.Locked = True
    End If
End Sub

Private Sub lst_Alumnos_LostFocus()
    lst_Alumnos.Visible = False
End Sub

Private Sub lst_Rut_DblClick()
    txt_RutBusqueda.Text = lst_Rut.Text
    lst_Rut.Visible = False
    Dim objRS As ADODB.Recordset
    Dim varsql As String
    varsql = "SELECT ape_pat_alu,ape_mat_alu,nom_alu" _
           & " FROM postulantes where ci_alu='" & txt_RutBusqueda.Text & "'"

    Set objRS = New ADODB.Recordset
        objRS.Open varsql, conn
    If Not objRS.EOF Then
        txt_NombreCompleto.Text = objRS("ape_pat_alu") & " " & objRS("ape_mat_alu") & " " & objRS("nom_alu")
    End If
    objRS.Close
    lst_Alumnos.Visible = False
    lst_Rut.Clear
    If txt_RutBusqueda.Text <> "" And txt_NombreCompleto.Text <> "" Then
        txt_RutBusqueda.Locked = True
        txt_NombreCompleto.Locked = True
    End If
End Sub

Private Sub txt_NombreCompleto_Change()
    If txt_NombreCompleto.Text <> "" Then
    Dim varsql As String
    'lst_Rut.Visible = False
    Dim objRC As ADODB.Recordset
    Dim rut As Long
    Set objRS = New ADODB.Recordset
    varsql = "SELECT distinct p.CI_ALU,APE_PAT_ALU,APE_MAT_ALU,NOM_ALU" _
           & " FROM postulantes p,matriculas m" _
           & " where concat(APE_PAT_ALU,' ',ape_mat_alu,' ',nom_alu) LIKE '" & txt_NombreCompleto.Text & "%'" _
           & " and p.ci_alu = m.ci_alu" _
           & " order by ape_pat_alu,ape_mat_alu,nom_alu"
    objRS.Open varsql, conn
    lst_Alumnos.Clear
    If Not objRS.EOF Then
        lst_Alumnos.Visible = True
    End If
    While Not objRS.EOF
        lst_Alumnos.AddItem objRS("APE_PAT_ALU") & " " & objRS("APE_MAT_ALU") & " " & objRS("NOM_ALU")
        rut = Mid(objRS("CI_ALU"), 1, 8)
        lst_Alumnos.ItemData(lst_Alumnos.NewIndex) = rut
        objRS.MoveNext
    Wend
    objRS.Close
    End If
End Sub
Private Sub txt_NombreCompleto_KeyPress(KeyAscii As Integer)
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub txt_RutBusqueda_Change()
    If txt_RutBusqueda.Text <> "" Then
    Dim varsql As String
    lst_Rut.Visible = False
    lst_Alumnos.Visible = False
    Dim objRC As ADODB.Recordset
    Dim rut As Long
    Set objRS = New ADODB.Recordset
    varsql = "SELECT distinct m.CI_ALU" _
           & " FROM postulantes p,matriculas m" _
           & " where p.CI_ALU LIKE '" & txt_RutBusqueda & "%'" _
           & " and p.ci_alu = m.ci_alu"
    objRS.Open varsql, conn
    lst_Rut.Clear
    If Not objRS.EOF Then
        lst_Rut.Visible = True
    End If
    While Not objRS.EOF
        lst_Rut.AddItem objRS("CI_ALU")
        objRS.MoveNext
    Wend
    objRS.Close
    End If
End Sub

Public Sub limpia_controles()
    txt_NombreCompleto.Text = ""
    txt_RutBusqueda.Text = ""
    Combo1.Text = ""
    Combo2.Text = ""
    Combo3.Text = ""
End Sub

Private Sub habilita_controles()
    DTPicker1.Enabled = True
    Combo1.Enabled = True
    Combo2.Enabled = True
    Combo3.Enabled = True
    Command1.Enabled = True
End Sub

Private Sub desabilita_controles()
    DTPicker1.Enabled = False
    Combo1.Enabled = False
    Combo2.Enabled = False
    Combo3.Enabled = False
    Command1.Enabled = False
End Sub
