VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
Begin VB.Form Form_ingreso_deserciones 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Ingreso Deserciones"
   ClientHeight    =   8730
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   12090
   Icon            =   "Form_ingreso_deserciones.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   8730
   ScaleWidth      =   12090
   Begin VB.Frame Frame_agregar 
      Caption         =   "Ingrese motivo deserción"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   3735
      Left            =   1920
      TabIndex        =   0
      Top             =   2880
      Width           =   7335
      Begin VB.TextBox txt_curso 
         Height          =   285
         Left            =   1800
         TabIndex        =   28
         Top             =   1200
         Width           =   1335
      End
      Begin VB.TextBox txt_rut 
         Height          =   285
         Left            =   1800
         Locked          =   -1  'True
         TabIndex        =   7
         Top             =   240
         Width           =   1335
      End
      Begin VB.TextBox txt_nombre 
         Height          =   285
         Left            =   1800
         Locked          =   -1  'True
         TabIndex        =   6
         Top             =   720
         Width           =   5175
      End
      Begin VB.TextBox txt_motivo 
         Height          =   855
         Left            =   1800
         MultiLine       =   -1  'True
         TabIndex        =   5
         Top             =   1680
         Width           =   5175
      End
      Begin VB.CommandButton cmdPlanEst 
         Caption         =   "&Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Index           =   1
         Left            =   5520
         Picture         =   "Form_ingreso_deserciones.frx":2A8B2
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   4440
         Width           =   1215
      End
      Begin VB.CommandButton cmdPlanEst 
         Caption         =   "&Aceptar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Index           =   0
         Left            =   4200
         Picture         =   "Form_ingreso_deserciones.frx":2AC1A
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   4440
         Width           =   1215
      End
      Begin VB.CommandButton cmd_cerrar 
         Caption         =   "&Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   4680
         Picture         =   "Form_ingreso_deserciones.frx":2B0C9
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   2640
         Width           =   1215
      End
      Begin VB.CommandButton cmd_grabar 
         Caption         =   "Grabar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   1440
         Picture         =   "Form_ingreso_deserciones.frx":2B431
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   2640
         Width           =   1215
      End
      Begin VB.Label Label4 
         Caption         =   "Rut."
         Height          =   255
         Left            =   240
         TabIndex        =   11
         Top             =   240
         Width           =   975
      End
      Begin VB.Label Label5 
         Caption         =   "Nombre"
         Height          =   375
         Left            =   240
         TabIndex        =   10
         Top             =   680
         Width           =   1095
      End
      Begin VB.Label Label6 
         Caption         =   "Curso"
         Height          =   255
         Left            =   240
         TabIndex        =   9
         Top             =   1240
         Width           =   1455
      End
      Begin VB.Label Label7 
         Caption         =   "Motivo"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   1680
         Width           =   1455
      End
   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          =   1095
      Left            =   120
      TabIndex        =   17
      Top             =   120
      Width           =   11655
      Begin VB.CommandButton Command1 
         Caption         =   "Ver"
         Height          =   375
         Left            =   10680
         TabIndex        =   19
         Top             =   480
         Width           =   735
      End
      Begin VB.CheckBox Check_Letra 
         Caption         =   "Letra"
         ForeColor       =   &H00000000&
         Height          =   195
         Left            =   9360
         TabIndex        =   18
         Top             =   240
         Value           =   1  'Checked
         Visible         =   0   'False
         Width           =   1095
      End
      Begin MSComctlLib.ImageCombo IC_Ensenanza 
         Height          =   345
         Left            =   1440
         TabIndex        =   20
         Top             =   480
         Width           =   6615
         _ExtentX        =   11668
         _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            =   8160
         TabIndex        =   21
         Top             =   480
         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            =   9360
         TabIndex        =   22
         Top             =   480
         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            =   240
         TabIndex        =   23
         Top             =   480
         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 
         Alignment       =   2  'Center
         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        =   26
         Top             =   240
         Width           =   495
      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            =   1440
         TabIndex        =   25
         Top             =   240
         Width           =   975
      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            =   8040
         TabIndex        =   24
         Top             =   240
         Width           =   615
      End
   End
   Begin VB.CommandButton cmd_salir 
      Caption         =   "Salir"
      Height          =   855
      Index           =   0
      Left            =   9000
      Picture         =   "Form_ingreso_deserciones.frx":2B8E0
      Style           =   1  'Graphical
      TabIndex        =   16
      Top             =   7560
      Width           =   1575
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Exportar Excel"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   1320
      Picture         =   "Form_ingreso_deserciones.frx":2BF06
      Style           =   1  'Graphical
      TabIndex        =   15
      Top             =   7560
      Width           =   1575
   End
   Begin VB.Frame Frame2 
      Caption         =   "Listado de alumnos"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   5895
      Left            =   120
      TabIndex        =   12
      Top             =   1320
      Width           =   11655
      Begin VB.CommandButton cmdEdSectores 
         Caption         =   "Nueva"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   795
         Index           =   3
         Left            =   10560
         Picture         =   "Form_ingreso_deserciones.frx":2C4EC
         Style           =   1  'Graphical
         TabIndex        =   13
         Top             =   240
         Width           =   855
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
         Height          =   4455
         Left            =   120
         TabIndex        =   14
         Top             =   1200
         Width           =   11415
         _ExtentX        =   20135
         _ExtentY        =   7858
         _Version        =   393216
      End
   End
   Begin ComctlLib.ProgressBar pgBar 
      Height          =   255
      Left            =   120
      TabIndex        =   27
      Top             =   7200
      Width           =   11655
      _ExtentX        =   20558
      _ExtentY        =   450
      _Version        =   327682
      Appearance      =   1
   End
End
Attribute VB_Name = "Form_ingreso_deserciones"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Rec2Grid(ByRef REC As ADODB.Recordset, ByRef grid As Object, Optional ByVal Numeracion As Boolean = True)
    grid.Clear
    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)
        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
            'progreso.Value = i
            grid.TextMatrix(i, 0) = i
            grid.ColWidth(0) = IIf(Numeracion, IIf(TextWidth(grid.TextMatrix(i, 0)) + 100 > grid.ColWidth(0), TextWidth(grid.TextMatrix(i, 0)) + 100, 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)) + 100 > grid.ColWidth(j), TextWidth(grid.TextMatrix(i, j)) + 100, grid.ColWidth(j))
            Next j
            REC.MoveNext
        Next i
    Else
        grid.Cols = 2
        grid.Rows = 2
    End If
End Sub

Private Sub cmd_limpiar_Click()
    limpiar
End Sub

Private Sub cmd_grabar_Click()
'    var_sql = "INSERT INTO observaciones(ci_alu,fecha,agno,cod_tip_obs,observacion)" _
'            & " VALUES('" & txt_rut.Text & "',NOW()," & Trim(IC_Agno.SelectedItem.Text) _
'            & "," & Mid(cb_observacion.Text, 1, 1) & ",'" & txt_observacion.Text & "');"
    var_sql = "UPDATE matriculas SET motivo_desercion = '" & UCase(IIf(Len(txt_motivo.Text) < 6, "SIN REGISTRAR", txt_motivo.Text)) & "' WHERE anno_mat = " & MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1) _
            & " AND ci_alu = '" & txt_rut.Text & "'"
    conn.Execute var_sql
'    cb_observacion.Text = "0 - Positivas"
'    txt_observacion.Text = ""
    Frame_agregar.Visible = False
    Command1_Click
End Sub

Private Sub cmd_cerrar_Click()
    'cb_observacion.Text = "0 - Positivas"
    'txt_observacion.Text = ""
    Frame_agregar.Visible = False
End Sub

Private Sub cmd_salir_Click(Index As Integer)
    Unload Me
End Sub

Private Sub cmdEdSectores_Click(Index As Integer)
    MSFlexGrid1_DblClick
End Sub

Private Sub cmdPlanEst_Click(Index As Integer)
    var_sql = "INSERT INTO observaciones(ci_alu,fecha,agno,cod_tip_obs,observacion)" _
            & " VALUES('" & txt_rut.Text & "',NOW()," & Trim(IC_Agno.SelectedItem.Text) _
            & "," & cb_observacion.Text & ",'" & txt_observacion.Text & "');"
    conn.Execute var_sql
End Sub

Private Sub Command1_Click()
   Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim varsql As String
'    varsql = "SELECT curso,rut_alumno,alumno,direccion_alumno,d.comuna,telefono_alumno,correo_alumno," _
'           & "rut_apoderado , Apoderado, direccion_apoderado, cg.Comuna, telefono_apoderado, celular_apoderado, telefono_empresa, telefono_adicional_1" _
'           & ",telefono_adicional_2,correo_apoderado FROM " _
'           & " (SELECT CONCAT(c.num_gra,' ',c.let_cur,' ',CAST(IF(c.cod_ens = '111','PlayGroup',IF(c.cod_ens = '996','Pre-Kinder',IF(c.cod_ens = '010','Kinder',IF(c.cod_ens = '110','Basico',IF(c.cod_ens = '310','Media','Otro'))))) AS CHAR)) AS curso" _
'           & ",c.ci_alu AS rut_alumno,CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) AS alumno,dire_alu AS direccion_alumno,comuna,fon_alu AS telefono_alumno,email_alu AS correo_alumno," _
'           & "a.rut_apo AS rut_apoderado,CONCAT(ape1_apo,' ',ape2_apo,' ',noms_apo) AS apoderado,dir_apo AS direccion_apoderado,comuna_apo,fon_c_apo AS telefono_apoderado,cel_apo AS celular_apoderado,empresa_fon AS telefono_empresa,telefono_adicional_1" _
'           & ",telefono_adicional_2,email AS correo_apoderado" _
'           & " FROM alu_x_cur c,postulantes p,apo_x_alu a,apoderados ap,codigos__geograficos cg" _
'           & " Where c.ci_alu = p.ci_alu And c.agno = " & Trim(IC_Agno.SelectedItem.Text) & " And c.agno = a.agno And c.ci_alu = a.ci_alu" _
'           & " AND a.rut_apo = ap.rut_apo AND p.cod_geo = cg.cod_geo AND c.activo_alu = 'SI'" _
'           & " AND c.cod_ens = '" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND c.num_gra = " & Trim(IC_Nivel.SelectedItem.Text) & " AND c.let_cur = '" & IC_Letra.Text & "') AS d" _
'           & " Left Join" _
'           & " codigos__geograficos cg" _
'           & " ON d.comuna_apo = cg.cod_geo order by alumno"
'''    varsql = "SELECT a.*,positivas as 'A. Pos',negativas as 'A. Neg.',disciplinarias as 'C. Disc.',condicionales as 'Cond.',ca as 'Comp. Acad.',cm as 'Canc. de Mat.' FROM " _
'''           & "(SELECT CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) AS alumno, p.ci_alu" _
'''           & " FROM postulantes p, alu_x_cur a, matriculas m" _
'''           & " WHERE p.ci_alu = a.ci_alu AND a.ci_alu=m.ci_alu AND a.fec_mat=m.fec_mat AND a.activo_alu='SI' AND a.cod_ens = '" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "'" _
'''           & " AND a.num_gra = '" & Trim(IC_Nivel.SelectedItem.Text) & "' AND a.let_cur ='" & IC_Letra.Text & "' AND a.agno = " & Trim(IC_Agno.SelectedItem.Text) & " AND a.agno=m.anno_mat" _
'''           & " ORDER BY a.fec_ing_curso, m.num_mat, p.ape_pat_alu, p.ape_mat_alu, p.nom_alu) AS a" _
'''           & " LEFT JOIN (SELECT ci_alu,SUM(IF(cod_tip_obs = 0,1,0)) AS positivas,SUM(IF(cod_tip_obs = 1,1,0)) AS negativas,SUM(IF(cod_tip_obs = 2,1,0)) AS disciplinarias," _
'''           & " SUM(IF(cod_tip_obs = 3,1,0)) AS condicionales,SUM(IF(cod_tip_obs = 4,1,0)) AS ca,SUM(IF(cod_tip_obs = 5,1,0)) AS cm FROM observaciones" _
'''           & " Where agno = " & Trim(IC_Agno.SelectedItem.Text) & "" _
'''           & " GROUP BY ci_alu" _
'''           & " ) AS ann" _
'''           & " ON a.ci_alu = ann.ci_alu"
    
    varsql = "SELECT c.agno,CONCAT(c.num_gra,' ',c.let_cur,' ',ce.cod_des) AS curso,c.ci_alu,CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) AS alumno,UCASE(motivo_desercion) AS motivo_desercion," _
            & "a.rut_apo,CONCAT(ape1_apo,' ',ape2_apo,' ',noms_apo) AS apoderado,dir_apo AS dirección,fon_c_apo AS telefono,cel_apo AS celular," _
            & "empresa_fon As telefono_empresa, email, telefono_adicional_1, telefono_adicional_2" _
            & " FROM alu_x_cur c,postulantes p,codigos_ensenanza ce,apo_x_alu axa,apoderados a,matriculas m " _
            & " Where c.ci_alu = m.ci_alu AND c.agno = m.anno_mat AND c.ci_alu = p.ci_alu And c.Cod_Ens = ce.Cod_Ens And c.ci_alu = axa.ci_alu And c.agno = axa.agno And axa.rut_apo = a.rut_apo" _
            & " and c.num_gra = '" & Trim(IC_Nivel.SelectedItem.Text) & "' and c.let_cur = '" & IC_Letra.Text & "' and c.cod_ens = '" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "'" _
            & " AND c.agno = " & (Trim(IC_Agno.SelectedItem.Text) - 1) & " AND c.activo_alu = 'SI' AND c.ci_alu NOT IN" _
            & " (SELECT ci_alu FROM alu_x_cur WHERE agno = " & Trim(IC_Agno.SelectedItem.Text) & " AND activo_alu = 'SI')" _
            & " AND NOT (c.num_gra = 4 AND c.cod_ens = '310')" _
            & " ORDER BY c.cod_ens,c.num_gra,c.let_cur,alumno;"

    
    objRS.Open varsql, conn
    If Not objRS.EOF Then
        Call Rec2Grid(objRS, MSFlexGrid1, True)
       ' msflex_alumnos.ColSel = 5
    End If
    objRS.Close
End Sub

Private Sub Command2_Click()
    
    Dim ApExcel As Variant
    Set ApExcel = CreateObject("Excel.application")
    ApExcel.Workbooks.Add
          
    For i = 1 To Me.MSFlexGrid1.Cols - 1
        ApExcel.Cells(1, i).Font.Size = 12
        ApExcel.Cells(1, i).Font.Bold = True
        ApExcel.Cells(1, i).Formula = Me.MSFlexGrid1.TextMatrix(0, i)
    Next i
    pgBar.Min = 0
    pgBar.Max = MSFlexGrid1.Rows
    pgBar.Value = pgBar.Min
    For i = 1 To MSFlexGrid1.Rows - 1

         For j = 1 To MSFlexGrid1.Cols - 1
            ApExcel.Cells((i + 1), j).Formula = MSFlexGrid1.TextMatrix(i, j)
        
        pgBar.Value = i - 1
        Next j
    Next i
            
    ApExcel.Visible = True
    ApExcel.Range("a1:q1").Borders.color = RGB(255, 0, 0)
    Set ApExcel = Nothing

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
    Frame_agregar.Visible = False
    
'    cb_observacion.AddItem "0 - Anotaciones Positivas"
'    cb_observacion.AddItem "1 - Anotaciones Negativas"
'    cb_observacion.AddItem "2 - Compromiso Disciplinario"
'    cb_observacion.AddItem "3 - Condicionalidad"
'    cb_observacion.AddItem "4 - Compromiso Academico"
'    cb_observacion.AddItem "5 - Cancelacion de Matricula"
'    cb_observacion = "0 - Positivas"
    
    ' Limpiar textos
    'txt_nom_alu.Text = ""
    'txt_rut_alu.Text = ""
    'txt_nom_apo.Text = ""
    'txt_rut_apo.Text = ""
    'Mostrar opcion de curso al iniciar
    'Option1(0).Value = True
    'MuestraFrame ("curso")
    ErrorStatus = False

End Sub

Private Sub IC_Agno_Click()
    IC_Ensenanza.Enabled = True
    Set_IC_Ensenanza
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 IC_Ensenanza_Click()
    IC_Nivel.Enabled = True
    Call Set_IC_Nivel
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 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_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 Check_Letra_Click()
    If Check_Letra.Value = 0 Then
        IC_Letra.Enabled = False
    ElseIf Check_Letra.Value = 1 And Not (ErrorStatus) And IC_Ensenanza.Enabled And IC_Nivel.Enabled Then
        IC_Letra.Enabled = True
        Call Set_IC_Letra
    Else
        Check_Letra.Value = 0
        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)
        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

Private Sub limpiar()
    frame_profesores.Caption = ""
    grid.ClearStructure
    grid.Rows = 2
    grid_alumnos.ClearStructure
    grid_alumnos.Rows = 2
    Frame1.Enabled = True
End Sub

Private Sub MSFlexGrid1_DblClick()

    Frame_agregar.Visible = True
    txt_rut.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3)
    txt_nombre.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4)
    txt_curso.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
    txt_motivo.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5)
'    Frame2.Enabled = False
'    Frame3.Enabled = False
'    Frame6.Enabled = False
'    Frame4.Enabled = False
'    Frame5.Enabled = False
'    cmd_CambiarEstado.Enabled = False
'    lbl_datos.Visible = False
'    cb_datos.Visible = False



End Sub








