VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{B68EC213-82B3-11D5-85C7-000083628378}#3.3#0"; "CoolFlex.ocx"
Object = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Begin VB.Form Form_MatriReserv 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Matrículas de Alumnos antiguos y Tipos de pago Próximo Año"
   ClientHeight    =   7140
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   11520
   Icon            =   "Form_MatriReserv.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7140
   ScaleWidth      =   11520
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame_Botones 
      BorderStyle     =   0  'None
      Height          =   495
      Left            =   7080
      TabIndex        =   20
      Top             =   6120
      Width           =   2775
      Begin VB.CommandButton Btn_Gra_cap 
         Caption         =   "Grabar"
         Enabled         =   0   'False
         Height          =   375
         Left            =   0
         TabIndex        =   22
         Top             =   120
         Width           =   1215
      End
      Begin VB.CommandButton Btn_limpiar 
         Caption         =   "Limpiar"
         Height          =   375
         Left            =   1440
         TabIndex        =   21
         Top             =   120
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Seleccione un curso"
      ForeColor       =   &H00FF0000&
      Height          =   1215
      Left            =   0
      TabIndex        =   5
      Top             =   0
      Width           =   11535
      Begin VB.CheckBox chk_Solo_Nomat 
         Caption         =   "Listar solo los NO Matriculados"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4440
         TabIndex        =   19
         Top             =   720
         Width           =   3135
      End
      Begin VB.PictureBox Picture1 
         Height          =   375
         Left            =   1560
         ScaleHeight     =   315
         ScaleWidth      =   2475
         TabIndex        =   17
         Top             =   720
         Width           =   2535
         Begin VB.Label lbl_fecha 
            Alignment       =   2  'Center
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   0
            TabIndex        =   18
            Top             =   0
            Width           =   2535
         End
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Conf. Impresora"
         Height          =   375
         Left            =   9600
         TabIndex        =   14
         Top             =   240
         Width           =   1455
      End
      Begin VB.CommandButton BtnGenRep 
         Caption         =   "Generar Reporte"
         Enabled         =   0   'False
         Height          =   375
         Left            =   9600
         TabIndex        =   13
         Top             =   720
         Width           =   1455
      End
      Begin VB.Frame Frame3 
         ForeColor       =   &H00FF0000&
         Height          =   975
         Left            =   7800
         TabIndex        =   11
         Top             =   120
         Width           =   1335
         Begin VB.OptionButton OptDesMAt 
            Caption         =   "Impresora"
            Height          =   255
            Index           =   1
            Left            =   120
            TabIndex        =   15
            Top             =   600
            Width           =   1095
         End
         Begin VB.OptionButton OptDesMAt 
            Caption         =   "Pantalla"
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   12
            Top             =   240
            Value           =   -1  'True
            Width           =   975
         End
      End
      Begin VB.ComboBox Cmb_Let_Cur 
         Enabled         =   0   'False
         Height          =   315
         Left            =   6840
         TabIndex        =   2
         Top             =   360
         Width           =   615
      End
      Begin VB.ComboBox Cmb_Grado 
         Enabled         =   0   'False
         Height          =   315
         Left            =   4920
         TabIndex        =   1
         Top             =   360
         Width           =   615
      End
      Begin VB.ComboBox Cmb_Cod_ens 
         Height          =   315
         Left            =   1560
         TabIndex        =   0
         Top             =   360
         Width           =   2595
      End
      Begin VB.Label Label3 
         Caption         =   "Fecha del sistema"
         Height          =   195
         Left            =   120
         TabIndex        =   16
         Top             =   720
         Width           =   1335
      End
      Begin VB.Label Tipo 
         Caption         =   "Tipo de enseñanza"
         Height          =   195
         Left            =   120
         TabIndex        =   8
         Top             =   360
         Width           =   1455
      End
      Begin VB.Label Label1 
         Caption         =   "Nivel"
         Height          =   195
         Left            =   4440
         TabIndex        =   7
         Top             =   360
         Width           =   615
      End
      Begin VB.Label Label2 
         Caption         =   "Letra - curso"
         Height          =   195
         Left            =   5880
         TabIndex        =   6
         Top             =   360
         Width           =   1095
      End
      Begin VB.Line Line3 
         BorderColor     =   &H80000003&
         X1              =   7665
         X2              =   7665
         Y1              =   120
         Y2              =   1200
      End
      Begin VB.Line Line4 
         BorderColor     =   &H00FFFFFF&
         X1              =   7680
         X2              =   7680
         Y1              =   120
         Y2              =   1200
      End
   End
   Begin VB.CommandButton Btn_Sal_Cap 
      Caption         =   "Salir"
      Enabled         =   0   'False
      Height          =   375
      Left            =   9960
      TabIndex        =   3
      Top             =   6240
      Width           =   1215
   End
   Begin ProgBarProzent.ProgBar ProgBar1 
      Height          =   375
      Left            =   120
      TabIndex        =   10
      Top             =   6240
      Width           =   6855
      _ExtentX        =   12091
      _ExtentY        =   661
   End
   Begin MSComDlg.CommonDialog CmDialog1 
      Left            =   120
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin CoolFlexGrid.CoolFlex CoolFlex1 
      Height          =   4695
      Index           =   0
      Left            =   0
      TabIndex        =   9
      Top             =   1320
      Visible         =   0   'False
      Width           =   11535
      _ExtentX        =   20346
      _ExtentY        =   8281
   End
   Begin VB.Label lbl_Num_Alu 
      Height          =   255
      Left            =   120
      TabIndex        =   4
      Top             =   6720
      Width           =   2055
   End
End
Attribute VB_Name = "Form_MatriReserv"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim resmatri() As String
Dim Modificado As Boolean
Dim LosNoMat As Boolean
Dim Fila As Long
Sub IniciaGrilla()
'me.CoolFlex1(1).FixedCols
CoolFlex1(1).EditEnable = True
'******** Encabezado **********
Me.CoolFlex1(1).Rows = 3
Me.CoolFlex1(1).FixedRows = 1
Me.CoolFlex1(1).Clear
With CoolFlex1(1)
    .Row = 0
    .Col = 0: .Text = "RUN"
    .Col = 1: .Text = "Nombre Alumno"
    .Col = 2: .Text = "Teléfono"
    .Col = 3: .Text = "Reservó"
    .Col = 4: .Text = "Matrícula"
    .Col = 5: .Text = "Beca Comp."
    .Col = 6: .Text = "Media Beca"
    .Col = 7: .Text = "Cuponera"
    .Col = 8: .Text = "Cheques"
    .Col = 9: .Text = "P.A.C."
    .Col = 10: .Text = "Contado"
    .Col = 11: .Text = "Nombre Apoderado"
    
    .ColType 4, eCheckbox
    .ColType 5, eCheckbox
    .ColType 6, eCheckbox
    .ColType 7, eCheckbox
    .ColType 8, eCheckbox
    .ColType 9, eCheckbox
    .ColType 10, eCheckbox
    .ColType 11, eTextbox
    '.Row = 1
    '.Col = 4: .Text = "":
    '.Col = 5: .Text = ""
    '.Col = 6: .Text = ""
    '.Col = 7: .Text = ""
    '.Col = 8: .Text = ""
    '.Col = 9: .Text = ""
End With

End Sub

Public Sub GenRep()
On Error GoTo controler
'**************************************
Set RS = New ADODB.Recordset
RS.CursorLocation = adUseClient
a = "select nom_est, dir_est, localidad_est from establecimientos"
RS.Open a, conn
If RS.RecordCount <> 0 Then
Form_main.CrystalReport.Formulas(0) = "NomCol = '" & RS(0) & "'"
Form_main.CrystalReport.Formulas(1) = "DirCol = '" & RS(1) & "'"
Form_main.CrystalReport.Formulas(2) = "ComunaCol = '" & RS(2) & "'"
End If
RS.Close
CodModalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.Cmb_Cod_ens.Text & "'", conn)
cod_des = devuelvecampo("codigos_ensenanza", "", "cod_des", "cod_ens ='" & CodModalidad & "'", conn)
Form_main.CrystalReport.WindowTitle = "Estadística de Reservas"
Form_main.CrystalReport.Formulas(3) = "TipEns = '" & Me.Cmb_Cod_ens & "'"

If cod_des = "K" Or cod_des = "PK" Then
    Form_main.CrystalReport.Formulas(4) = "Curso = '" & cod_des & " " & Me.Cmb_Let_Cur & "'"
Else
    Form_main.CrystalReport.Formulas(4) = "Curso = '" & Me.Cmb_Grado & " " & Me.Cmb_Let_Cur & "'"
End If
Form_main.CrystalReport.Formulas(5) = "Hora = '" & Time() & "'"
Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
Form_main.CrystalReport.Action = 1
Call LimpiaFormulas(Form_main.CrystalReport, 30)
'******************************************
Exit Sub
controler:
Resume Next

End Sub

Private Sub Btn_Gra_cap_Click()
'On Error GoTo controler
Dim CodigoEns As String
Dim RS As ADODB.Recordset
Set RS = New ADODB.Recordset
'Cod_Ens = devuelvecampo("CODIGOS_ENSENANZA", "", "COD_ENS", "DES_ENS ='" & Me.Cmb_Cod_ens & "'")
'ord_ens = devuelvecampo("CODIGOS_ENSENANZA", "", "COD_ENS", "DES_ENS ='" & Me.Cmb_Cod_ens & "'")
RS.Open "select cod_ens, num_gra_max, ord_ens,cod_des from codigos_ensenanza where DES_ENS ='" & Me.Cmb_Cod_ens & "'", conn
If RS.RecordCount > 0 Then
    Cod_Ens = RS("cod_ens")
    ord_ens = RS("ord_ens")
    ngramax = RS("num_gra_max")
    cod_des = RS("cod_des")
End If
RS.Close

If Val(Me.Cmb_Grado) < Val(ngramax) Then
    CodigoEns = Cod_Ens
ElseIf Val(Me.Cmb_Grado) = Val(ngramax) And UCase(cod_des) <> "EM" Then
    CodigoEns = devuelvecampo("CODIGOS_ENSENANZA", "", "COD_ENS", "ord_ens ='" & Val(ord_ens) + 1 & "'", conn)
End If
NumGra = Me.Cmb_Grado

    If Not (CompruebaValoresParaMatricula(CodigoEns, NumGra, Val(Anno) + 1, conn)) Then
        MsgBox "NO SE PUEDE REALIZAR EL PROCESO PUES NO ESTA DEFINIDO EL ARANCEL DEL AÑO " & (Val(Anno) + 1) & " EN ESTE NIVEL.", vbCritical + vbOKOnly, "ALERTA"
        Exit Sub
    End If
    
conn.BeginTrans
For i = 1 To CoolFlex1(1).Rows - 1
    With CoolFlex1(1)
    'Debug.Print
                'Aquí pregunto por las opciones chequeadas
                Estado = resmatri(i, 5)
                C4 = IIf(.TextMatrix(i, 4) = "C", 1, 0)
                C5 = IIf(.TextMatrix(i, 5) = "C", 1, 0)
                C6 = IIf(.TextMatrix(i, 6) = "C", 1, 0)
                C7 = IIf(.TextMatrix(i, 7) = "C", 1, 0)
                C8 = IIf(.TextMatrix(i, 8) = "C", 1, 0)
                C9 = IIf(.TextMatrix(i, 9) = "C", 1, 0)
                C10 = IIf(.TextMatrix(i, 10) = "C", 1, 0)
                C11 = .TextMatrix(i, 11)
                If Estado = "0" And C4 = "1" Then
                    ' Aqui matricula un alumno para el proximo año.
                     conn.Execute "INSERT INTO MATRICULAS(" & _
                    "CI_ALU, ACTIVO_ALU, NUM_MAT, FEC_MAT, FEC_RETIRO, RESERVA, CANCELADO, OBS_CANCELADO, COD_ENS, NUM_GRA, DESTINO_RETIRO, OBS_RETIRO, COD_JOR, OBS_RES, COD_SIT, COD_OBS_FIN, ANNO_MAT, IND_BECA, IND_MBECA, IND_CUP, IND_CHEQ, IND_PAC, IND_CONT) " & _
                    "values(" & _
                    "'" & Me.CoolFlex1(1).TextMatrix(i, 0) & "', " & _
                    "'SI', " & _
                    "'0', " & _
                    "'" & InvierteFecha(CDate(Me.lbl_fecha.Caption), "R") & "', " & _
                    "'1111-11-11', " & _
                    "'0', " & _
                    "'0', " & _
                    "null, " & _
                    "'" & CodigoEns & "', '" & NumGra & "', " & _
                    "null, " & _
                    "null, " & _
                    "'" & resmatri(i, 3) & "' , " & _
                    "null, " & _
                    "null, " & _
                    "null, " & _
                    "'" & Val(Anno) + 1 & "', " & _
                    "'" & C5 & "', " & _
                    "'" & C6 & "', " & _
                    "'" & C7 & "', " & _
                    "'" & C8 & "', " & _
                    "'" & C9 & "', " & _
                    "'" & C10 & "')"
                    ' Detalles del alumno
                    RecalculaCuota_Alu Me.CoolFlex1(1).TextMatrix(i, 0), Val(Anno) + 1, conn
                ElseIf Estado = "1" And C4 = "1" Then
                    ' Aquí actualiza la forma de pago
                    a = "UPDATE MATRICULAS Set ind_beca = '" & C5 & "' , ind_mbeca = '" & C6 & "' , ind_cup = '" & C7 & "' , ind_cheq = '" & C8 & "' ,ind_pac = '" & C9 & "', ind_cont = '" & C10 & "' WHERE CI_ALU ='" & .TextMatrix(i, 0) & "' and fec_mat = '" & InvierteFecha(CDate(resmatri(i, 2)), "R") & "' and activo_alu='SI'"
                    conn.Execute a
                    RecalculaCuota_Alu Me.CoolFlex1(1).TextMatrix(i, 0), Val(Anno) + 1, conn
                ElseIf Estado = "1" And C4 = "0" Then
                    ' Aqui retira al alumno matriculado.
                    conn.Execute "delete from matriculas where CI_ALU = '" & .TextMatrix(i, 0) & "' and fec_mat = '" & InvierteFecha(CDate(resmatri(i, 2)), "R") & "' and activo_alu= 'SI'"
                    RecalculaCuota_Alu_Retiro Me.CoolFlex1(1).TextMatrix(i, 0), Date, conn, Val(Anno) + 1
                    RecalculaCuota_Alu Me.CoolFlex1(1).TextMatrix(i, 0), Val(Anno) + 1, conn
                End If
                
                'conn.Execute "UPDATE MATRICULAS Set OBS_RES ='" & CoolFlex1.TextMatrix(i, 3) & "' WHERE CI_ALU ='" & .TextMatrix(i, 0) & "'"
                
    End With
Next i


'******************** En esta sección actualizo el array de estados*************
CodModalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.Cmb_Cod_ens.Text & "'", conn)
Set RS = New ADODB.Recordset
Set rsaux = New ADODB.Recordset
RS.CursorLocation = adUseClient
rsaux.CursorLocation = adUseClient
a = "SELECT P.CI_ALU, P.NOM_ALU, P.APE_PAT_ALU, P.APE_MAT_ALU, M.FEC_MAT, M.RESERVA, M.IND_CUP, M.IND_CHEQ, M.IND_PAC, M.IND_BECA, M.IND_MBECA, P.FON_ALU, M.COD_JOR, M.ANNO_MAT " & _
    "FROM POSTULANTES P, ALU_X_CUR AC, MATRICULAS M " & _
    "WHERE P.CI_ALU = M.CI_ALU AND M.CI_ALU = AC.CI_ALU AND M.ACTIVO_ALU = 'SI' AND P.CI_ALU = AC.CI_ALU AND AC.COD_ENS ='" & CodModalidad & "' AND " & _
    "AC.NUM_GRA ='" & Me.Cmb_Grado & "' AND " & _
    "AC.ACTIVO_ALU ='SI' AND " & _
    "AC.fec_cam ='1111-11-11' AND " & _
    "AC.LET_CUR ='" & Me.Cmb_Let_Cur & "' AND ISNULL(M.ANNO_MAT)" & _
    "ORDER BY APE_PAT_ALU ASC, APE_MAT_ALU ASC, NOM_ALU ASC"

RS.Open a, conn
'Indice = 1
If RS.RecordCount > 0 Then

'***********************************************************************
'* inicializa la barra de progreso                                     *
'***********************************************************************
nmax = RS.RecordCount
'Dim resmatri()
ReDim resmatri(nmax, 5) ' Dimensiono matriz para llenar indicadores invisibles
  With ProgBar1
    .ShowProgress 0
    .MaxValue = nmax
    .Richtung = mDir
    .ProgressStyle = mStyle
    .ShowProzent = 1
    .Zusatztext = "%"
    .ShowProgress 0
  End With
'***********************************************************************
     
     
     RS.MoveLast
     RS.MoveFirst
     
     i = 1
     While Not RS.EOF
        'Aquí almaceno en el array  el rut, la fecha matrícula y el cod. de jornada.
        resmatri(i, 1) = RS("ci_alu"): resmatri(i, 2) = RS("fec_mat"): resmatri(i, 3) = RS("cod_jor")
        rsaux.Open "select ind_cup, ind_cheq, ind_pac, ind_beca, ind_mbeca from matriculas where anno_mat = '" & Val(Anno) + 1 & "' and ci_alu ='" & RS("ci_alu") & "'", conn
        If rsaux.RecordCount > 0 Then
            resmatri(i, 5) = "1"
        Else
            resmatri(i, 5) = "0"
         End If
        rsaux.Close
        RS.MoveNext
        i = i + 1
        ProgBar1.ShowProgress i
        DoEvents
      Wend
    ProgBar1.ShowProgress 100
    
Me.BtnGenRep.Enabled = True
Me.Btn_Gra_cap.Enabled = True
Me.Btn_Sal_Cap.Enabled = True

End If
RS.Close
'***********************

'Call Command1_Click
 conn.CommitTrans
 MsgBox "Los datos han sido grabados satisfactoriamente", vbInformation + vbOKOnly, "Mensaje de Gescol"
 'Me.CoolFlex1.Clear
 Me.BtnGenRep.Enabled = True
 Me.Btn_Gra_cap.Enabled = False
 Me.Btn_Sal_Cap.Enabled = True
        

Exit Sub
controler:
MsgBox Err.Description, vbCritical + vbOKOnly, "Error número :" & Err.Number
conn.RollbackTrans
MsgBox "Los datos no fueron grabados.", vbCritical + vbOKOnly, "Mensaje de Gescol"
End Sub

Private Sub Btn_Limpiar_Click()
Me.Cmb_Cod_ens = ""
Me.Cmb_Grado = ""
Me.Cmb_Let_Cur = ""
Me.BtnGenRep.Enabled = False
Me.Btn_Gra_cap.Enabled = False
Me.CoolFlex1(1).Rows = 2
Me.CoolFlex1(1).Clear
Me.chk_Solo_Nomat.Value = 0
End Sub

Private Sub Btn_Sal_Cap_Click()
Unload Me
End Sub

Private Sub BtnGenRep_Click()
'If Me.OptOptUno.Value = True Then
'    'If MsgBox("Esta acción guardará en la base de datos los cambios realizados . ¿Desea continuar?", vbYesNo + vbQuestion) = vbYes Then
        Call Btn_Gra_cap_Click
'        'Form_main.CrystalReport.ReportFileName = DirAplicacion + "rpt\reservas.rpt"
        
columnasnum = Me.CoolFlex1(1).Cols
Call CreaBD(DirAplicacion & "\GesTemp.mdb")
Set Rendim = DBEngine.Workspaces(0).OpenDatabase(DirAplicacion & "\GesTemp.mdb")
'If LosNoMat Then
    Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Detalles", "12,10")
'Else
'    Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Detalles", "11,10")
'End If
For R = 1 To Me.CoolFlex1(1).Rows - 1
    detal = "": ins = "": horiz = ""
    For t = 0 To Me.CoolFlex1(1).Cols - 1
        If Me.CoolFlex1(1).TextMatrix(R, t) = "" Then
            detal = detal & "Null , "
            'horiz = horiz & "'____________________________________' ,"
        ElseIf Me.CoolFlex1(1).TextMatrix(R, t) = "C" Then
            detal = detal & "'*' , "
        ElseIf Me.CoolFlex1(1).TextMatrix(R, t) = "U" Then
            detal = detal & "Null , "
        Else
        '******* CONTROLAR APOSTROFES ********
                Nombre = Me.CoolFlex1(1).TextMatrix(R, t)
                If Nombre <> "" Then
                    Pos = InStr(1, Nombre, "'")
                    If Pos <> 0 Then
                        nombre1 = Mid(Nombre, 1, Pos) & "'" & Mid(Nombre, Pos + 1, Len(Nombre))
                        Nombre = nombre1
                    End If
                End If
'******* fin CONTROLAR APOSTROFES ********
            detal = detal & "'" & Nombre & "' , "
            'horiz = horiz & "'____________________________________' ,"
        End If
        ins = ins & "C" & CStr(t + 1) & ", "
    Next t
    ins = Left(ins, Len(ins) - 2): ins = "(" & ins & ")"
    detal = Left(detal, Len(detal) - 2): detal = "(" & detal & ")"
    'horiz = Left(horiz, Len(horiz) - 2): horiz = "(" & horiz & ")"
    a = "insert into Detalles " & ins & " values " & detal
    Rendim.Execute a
    'horiz = Left(horiz, Len(horiz) - 2): horiz = "(" & horiz & ")"
'    a = "insert into Detalles " & ins & " values " & detal
'    Rendim.Execute a
    'b = "insert into Detalles " & ins & " values " & horiz
    'If R >= 1 Then
    '    Rendim.Execute b
    'End If
Next R
Rendim.Close
    If Me.chk_Solo_Nomat.Value = 0 Then
        Titulo = "CONTROL DE MATRÍCULA  Y TIPOS DE PAGO ALUMNOS ANTIGUOS"
    Else
        Titulo = "CONTROL DE ALUMNOS ANTIGUOS NO MATRICULADOS"
    End If
    
    Nombrecol = devuelvecampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
    Direccol = devuelvecampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
    ComunaCol = devuelvecampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
    Form_main.CrystalReport.WindowTitle = Titulo
    Form_main.CrystalReport.Formulas(0) = "nomcol = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "dircol = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacol = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & Titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
    Form_main.CrystalReport.Formulas(5) = "Tipens = '" & Me.Cmb_Cod_ens.Text & "'"
    Form_main.CrystalReport.Formulas(6) = "Curso = '" & Me.Cmb_Grado & " " & Me.Cmb_Let_Cur & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\MatFinal.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
'    Kill (DirAplicacion + "GesTemp.mdb")

End Sub

Private Sub Cmb_Cod_ens_Click()

If Len(Me.Cmb_Cod_ens) <> 0 Then
CoolFlex1(1).Clear
 Nivel = devuelvecampo("codigos_ensenanza", "des_ens", "num_gra_max", "des_ens = " & "'" & Me.Cmb_Cod_ens.Text & "'", conn)
 Cmb_Grado.Enabled = True
 Cmb_Grado.Clear
 Me.ProgBar1.ShowProgress 0
 Me.Btn_Gra_cap.Enabled = False
 Me.BtnGenRep.Enabled = False
 For t = 1 To Val(Nivel)
    Cmb_Grado.AddItem t
 Next t
End If

End Sub

Private Sub Cmb_Cod_ens_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub Cmb_Grado_Click()
Cmb_Let_Cur.Clear
'CoolFlex1(1).Clear
CodModalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.Cmb_Cod_ens.Text & "'", conn)
Ngrado = Me.Cmb_Grado.Text
Me.ProgBar1.ShowProgress 0
Me.Btn_Gra_cap.Enabled = False
Me.BtnGenRep.Enabled = False
Call llenacombo(Cmb_Let_Cur, "cursos", "let_cur", "where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "'", conn)
'btn_carga_asignaturas_Click
Me.Cmb_Let_Cur.Enabled = True

End Sub

Private Sub Cmb_Grado_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub Cmb_let_cur_Click()
Call Command1_Click
End Sub

Private Sub Command1_Click()
Dim Indice As Integer
Call IniciaGrilla
'******** FIN Encabezado **********

CodModalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.Cmb_Cod_ens.Text & "'", conn)

'SELECT P.CI_ALU, P.NOM_ALU, P.APE_PAT_ALU, P.APE_MAT_ALU, AC.FEC_MAT, M.RESERVA FROM POSTULANTES P, ALU_X_CUR AC, MATRICULAS M WHERE P.CI_ALU = M.CI_ALU AND M.CI_ALU = AC.CI_ALU AND M.ACTIVO_ALU = 'SI' AND   P.CI_ALU = AC.CI_ALU AND AC.COD_ENS ='110' AND AC.NUM_GRA ='1' AND AC.ACTIVO_ALU ='SI' AND AC.fec_cam ='1111-11-11' AND AC.LET_CUR ='A' ORDER BY APE_PAT_ALU ASC, APE_MAT_ALU ASC, NOM_ALU ASC

Set RS = New ADODB.Recordset
Set rsaux = New ADODB.Recordset
RS.CursorLocation = adUseClient
rsaux.CursorLocation = adUseClient                                                    ' los indicadores que estan abajo no cuentan ind_cheq, ind_pac, ind_cup etc.....

'               0           1           2           3           4           5           6           7           8           9           10          11          12          13
a = "SELECT P.CI_ALU, P.NOM_ALU, P.APE_PAT_ALU, P.APE_MAT_ALU, M.FEC_MAT, M.RESERVA, M.IND_CUP, M.IND_CHEQ, M.IND_PAC, M.IND_BECA, M.IND_MBECA, P.FON_ALU, M.COD_JOR, M.ANNO_MAT " & _
    "FROM POSTULANTES P, ALU_X_CUR AC, MATRICULAS M " & _
    "WHERE P.CI_ALU = M.CI_ALU AND M.CI_ALU = AC.CI_ALU AND M.ACTIVO_ALU = 'SI' AND P.CI_ALU = AC.CI_ALU AND AC.COD_ENS ='" & CodModalidad & "' AND " & _
    "AC.NUM_GRA ='" & Me.Cmb_Grado & "' AND " & _
    "AC.ACTIVO_ALU ='SI' AND " & _
    "AC.fec_cam ='1111-11-11' AND " & _
    "AC.LET_CUR ='" & Me.Cmb_Let_Cur & "' AND (M.ANNO_MAT ='" & Anno & "' or isnull(M.ANNO_MAT)) " & _
    "ORDER BY APE_PAT_ALU ASC, APE_MAT_ALU ASC, NOM_ALU ASC"

'a = "SELECT P.CI_ALU, P.NOM_ALU, P.APE_PAT_ALU, P.APE_MAT_ALU, M.FEC_MAT, M.RESERVA, P.FON_ALU, M.COD_JOR, M.ANNO_MAT , M_" & _
    "FROM POSTULANTES P, ALU_X_CUR AC, MATRICULAS M " & _
    "WHERE P.CI_ALU = M.CI_ALU AND M.CI_ALU = AC.CI_ALU AND M.ACTIVO_ALU = 'SI' AND P.CI_ALU = AC.CI_ALU AND AC.COD_ENS ='" & CodModalidad & "' AND " & _
    "AC.NUM_GRA ='" & Me.Cmb_Grado & "' AND " & _
    "AC.ACTIVO_ALU ='SI' AND " & _
    "AC.fec_cam ='1111-11-11' AND " & _
    "AC.LET_CUR ='" & Me.Cmb_Let_Cur & "' AND (M.ANNO_MAT ='" & Anno & "' or isnull(M.ANNO_MAT)) " & _
    "ORDER BY APE_PAT_ALU ASC, APE_MAT_ALU ASC, NOM_ALU ASC"

RS.Open a, conn
'Indice = 1
If RS.RecordCount > 0 Then

'***********************************************************************
'* inicializa la barra de progreso                                     *
'***********************************************************************
nmax = RS.RecordCount
ReDim resmatri(nmax, 5) ' Dimensiono matriz para llenar indicadores invisibles
  With ProgBar1
    .ShowProgress 0
    .MaxValue = nmax
    .Richtung = mDir
    .ProgressStyle = mStyle
    .ShowProzent = 1
    .Zusatztext = "%"
    .ShowProgress 0
  End With
'***********************************************************************
     
     
     RS.MoveLast
     RS.MoveFirst
     
     i = 1
     While Not RS.EOF
       ''Aquí almaceno en el array  el rut, la fecha matrícula y el cod. de jornada.
       'resmatri(i, 1) = rs(0): resmatri(i, 2) = rs(4): resmatri(i, 3) = rs(12)
      
       CoolFlex1(1).Rows = i + 1
       CoolFlex1(1).Row = i
       CoolFlex1(1).Col = 0: CoolFlex1(1).Text = RS("CI_ALU")
       Nombre = RS("APE_PAT_ALU") & "  " & RS("APE_MAT_ALU") & "  " & RS("NOM_ALU")
       If Len(Nombre) > 33 Then Nombre = Left(Nombre, 33)
       CoolFlex1(1).Col = 1: CoolFlex1(1).Text = Nombre
       CoolFlex1(1).Col = 2
      
       If IsNull(RS(11)) Then
            CoolFlex1(1).Text = ""
            Else
            CoolFlex1(1).TextMatrix(i, 2) = RS(11)
       End If
      
       CoolFlex1(1).Col = 3
       CoolFlex1(1).Text = IIf(IsNull(RS(5)) Or RS(5) <> 1, "NO", "SI")
              
       'TRAIGO LOS DATOS DEL AÑO PROXIMO
       rsaux.Open "select ind_cup, ind_cheq, ind_pac, ind_beca, ind_mbeca, ind_cont, fec_mat from matriculas where anno_mat = '" & Val(Anno) + 1 & "' and ci_alu ='" & RS("ci_alu") & "'", conn
       If rsaux.RecordCount > 0 And Me.chk_Solo_Nomat.Value = False Then
            'Aquí almaceno en el array  el rut, la fecha matrícula y el cod. de jornada.
            resmatri(i, 1) = RS("ci_alu"): resmatri(i, 2) = RS("fec_mat"): resmatri(i, 3) = RS("cod_jor")
           
            CoolFlex1(1).Rows = i + 1
            CoolFlex1(1).Row = i
            CoolFlex1(1).Col = 0: CoolFlex1(1).Text = RS("CI_ALU")
            Nombre = RS("APE_PAT_ALU") & "  " & RS("APE_MAT_ALU") & "  " & RS("NOM_ALU")
            If Len(Nombre) > 33 Then Nombre = Left(Nombre, 33)
            CoolFlex1(1).Col = 1: CoolFlex1(1).Text = Nombre
            CoolFlex1(1).Col = 2
       
            If IsNull(RS("fon_alu")) Then
                CoolFlex1(1).Text = ""
            Else
                CoolFlex1(1).TextMatrix(i, 2) = RS("fon_alu")
            End If
       
            CoolFlex1(1).Col = 3
            CoolFlex1(1).Text = IIf(IsNull(RS("reserva")) Or RS("reserva") <> 1, "NO", "SI")
            resmatri(i, 5) = "1"
            resmatri(i, 2) = rsaux("fec_mat")
            CoolFlex1(1).Col = 4: CoolFlex1(1).Text = "C" ' marco el chekbox de matricula
            
            CoolFlex1(1).Col = 5
            CoolFlex1(1).Text = IIf(IsNull(rsaux("ind_beca")) Or rsaux("ind_beca") <> 1, "U", "C")
            
            CoolFlex1(1).Col = 6
            CoolFlex1(1).Text = IIf(IsNull(rsaux("ind_mbeca")) Or rsaux("ind_mbeca") <> 1, "U", "C")
            
            CoolFlex1(1).Col = 7
            CoolFlex1(1).Text = IIf(IsNull(rsaux("ind_cup")) Or rsaux("ind_cup") <> 1, "U", "C")
            
            CoolFlex1(1).Col = 8
            CoolFlex1(1).Text = IIf(IsNull(rsaux("ind_cheq")) Or rsaux("ind_cheq") <> 1, "U", "C")
            
            CoolFlex1(1).Col = 9
            CoolFlex1(1).Text = IIf(IsNull(rsaux("ind_pac")) Or rsaux("ind_pac") <> 1, "U", "C")
            
            CoolFlex1(1).Col = 10
            CoolFlex1(1).Text = IIf(IsNull(rsaux("ind_cont")) Or rsaux("ind_cont") <> 1, "U", "C")
            'Aquí mostrar el tipo de pago actual
            'en la columna Nº 11
            
            rsinforme.CursorLocation = adUseClient
            rsinforme.Open "select a.noms_apo, a.ape1_apo, a.ape2_apo from apoderados a, apo_x_alu ap, postulantes p where p.ci_alu=ap.ci_alu and ap.rut_apo=a.rut_apo and p.ci_alu = '" & RS("CI_ALU") & "'", conn
            If rsinforme.RecordCount > 0 Then
                CoolFlex1(1).Col = 11
                CoolFlex1(1).Text = Trim(rsinforme(0)) & " " & Trim(rsinforme(1)) & " " & Trim(rsinforme(2))
            End If
            rsinforme.Close
            i = i + 1
        ElseIf rsaux.RecordCount <= 0 Then
               'Aquí almaceno en el array  el rut, la fecha matrícula y el cod. de jornada.
            resmatri(i, 1) = RS("ci_alu"): resmatri(i, 2) = RS("fec_mat"): resmatri(i, 3) = RS("cod_jor")
           
            CoolFlex1(1).Rows = i + 1
            CoolFlex1(1).Row = i
            CoolFlex1(1).Col = 0: CoolFlex1(1).Text = RS("CI_ALU")
            Nombre = RS("APE_PAT_ALU") & "  " & RS("APE_MAT_ALU") & "  " & RS("NOM_ALU")
            If Len(Nombre) > 33 Then Nombre = Left(Nombre, 33)
            CoolFlex1(1).Col = 1: CoolFlex1(1).Text = Nombre
            CoolFlex1(1).Col = 2
            If IsNull(RS("fon_alu")) Then
                CoolFlex1(1).Text = ""
            Else
                CoolFlex1(1).TextMatrix(i, 2) = RS("fon_alu")
            End If
            CoolFlex1(1).Col = 3
            CoolFlex1(1).Text = IIf(IsNull(RS("reserva")) Or RS("reserva") <> 1, "NO", "SI")
            Me.CoolFlex1(1).Col = 4
            CoolFlex1(1).Text = "U"
            resmatri(i, 5) = "0"
            rsinforme.CursorLocation = adUseClient
            rsinforme.Open "select a.noms_apo, a.ape1_apo, a.ape2_apo from apoderados a, apo_x_alu ap, postulantes p where p.ci_alu=ap.ci_alu and ap.rut_apo=a.rut_apo and p.ci_alu = '" & RS("CI_ALU") & "'", conn
            If rsinforme.RecordCount > 0 Then
                CoolFlex1(1).Col = 11
                CoolFlex1(1).Text = Trim(rsinforme(0)) & " " & Trim(rsinforme(1)) & " " & Trim(rsinforme(2))
            End If
            rsinforme.Close
            i = i + 1
        End If
       rsaux.Close
       RS.MoveNext
       
       ProgBar1.ShowProgress i
       DoEvents
    Wend
    ProgBar1.ShowProgress 100
    
Me.BtnGenRep.Enabled = True
Me.Btn_Gra_cap.Enabled = True
Me.Btn_Sal_Cap.Enabled = True

End If
Me.lbl_Num_Alu.Caption = "Alumnos en el curso :" & i
RS.Close
End Sub

Private Sub Command4_Click()
'**************************************
' Variables Boletin
'**************************************
Dim color As String
Dim NomCol, DirCol, ComunaCol As String
Set RS = New ADODB.Recordset
RS.CursorLocation = adUseClient
a = "select nom_est, dir_est, localidad_est from establecimientos"
RS.Open a, conn
If RS.RecordCount <> 0 Then
NomCol = RS(0)
DirCol = RS(1)
ComunaCol = RS(2)
End If
RS.Close
'**************************************
   
   
   Dim BdBoletin As Database
   Dim RsContenido As Recordset
   Dim RsTotales As Recordset
   'RsContenido As ADODB.Recordset
   Set BdBoletin = OpenDatabase(DirAplicacion & "\GesTempBoletin.mdb")
   Set RsContenido = BdBoletin.OpenRecordset("SELECT * FROM Contenido")
   Set RsTotales = BdBoletin.OpenRecordset("SELECT * FROM Totales")
        
If RsContenido.RecordCount <> 0 Then
        Open "C:\Documents and Settings\ADMINISTRADOR\Escritorio\Bol_EstIns.htm" For Output As #1
        '**************************************
        ' Encabezado Documento
        '**************************************
        Print #1, "<html>"
        Print #1, "<head>"
        Print #1, "<meta http-equiv='Content-Language' content='es'>"
        Print #1, "<meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>"
        Print #1, "<meta name='GENERATOR' content='Microsoft FrontPage 4.0'>"
        Print #1, "<meta name='ProgId' content='FrontPage.Editor.Document'>"
        Print #1, "<title>Boletín&nbsp; - Estadísticas de Inscritos 2004</title>"
        Print #1, "</head>"
        Print #1, "<body bgcolor='#C0C0C0'>"
        Print #1, "<div align='center'>"
        Print #1, "<center>"
        Print #1, "<table border='1' width='100%'>"
            Print #1, "<tr>"
            Print #1, "<td width='100%' bgcolor='#000080' bordercolorlight='#800000' bordercolor='#FFFFFF'>"
                Print #1, "<p align='center'><font color='#FFFFFF'><b><font size='5'>Boletín&nbsp; - Estadísticas"
                Print #1, "de Inscritos 2004</font></b><br><font size='4'>" & NomCol & "</font>"
                Print #1, "</font>"
            Print #1, "</td>"
            Print #1, "</tr>"
        Print #1, "</table>"
        Print #1, "</center>"
        Print #1, "</div>"
        Print #1, "<p align='left'><font color='#800000'>Fecha&nbsp;&nbsp; : " & Date & "<br>Hora&nbsp;&nbsp;&nbsp;&nbsp; : " & Time & "</font></p>"
        Print #1, "<hr>"
        Print #1, "<div align='center'>"
        Print #1, "<center>"
        Print #1, "<table border='1' width='100%' cellspacing='3' bordercolorlight='#FFFFFF'>"
            Print #1, "<tr>"
            Print #1, "<td width='14%' align='center' rowspan='2' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'>"
            Print #1, "<p align='center'><b><font color='#FFFFFF'>Curso</font></b></td>"
            Print #1, "<td width='14%' align='center' colspan='3' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><b><font color='#FFFFFF'>Inscritos</font></b></td>"
            Print #1, "<td width='14%' align='center' colspan='3' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><b><font color='#FFFFFF'>Aceptados</font></b></td>"
            Print #1, "<td width='14%' align='center' colspan='3' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><b><font color='#FFFFFF'>Pendientes</font></b></td>"
            Print #1, "<td width='14%' align='center' colspan='3' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><b><font color='#FFFFFF'>Reprobados</font></b></td>"
            Print #1, "<td width='14%' align='center' colspan='3' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><b><font color='#FFFFFF'>Ausentes</font></b></td>"
            Print #1, "<td width='14%' align='center' colspan='3' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><b><font color='#FFFFFF'>Matriculados</font></b></td>"
            Print #1, "</tr>"
            Print #1, "<tr>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>H</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>M</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>T</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>H</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>M</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>T</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>H</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>M</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>T</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>H</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>M</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>T</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>H</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>M</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>T</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>H</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>M</font></td>"
            Print #1, "<td width='5%' align='center' bgcolor='#000080' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>T</font></td>"
            Print #1, "</tr>"
        Print #1, "</center>"
        Print #1, "<!--  DETALLE -->"
        While Not RsContenido.EOF
        R = R + 1
        '#C0C0C0'
            If R Mod 3 = 0 Then
                color = "'#C0C0C0'"
            Else
                color = "'#99CCFF'"
            End If
          Print #1, "<tr>"
            Print #1, "<td width='14%' bgcolor=" & color & "align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'>"
            Print #1, "<p align='left'><font color='#800000'>" & RsContenido(0) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(1) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(2) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(3) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(4) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(5) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(6) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(7) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(8) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(9) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(10) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(11) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(12) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(13) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(14) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(15) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(16) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(17) & "</font></td>"
            Print #1, "<td width='5%' bgcolor=" & color & " align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#800000'>" & RsContenido(18) & "</font></td>"
          Print #1, "</tr>"
            
            'Debug.Print RsContenido(1)
            
            RsContenido.MoveNext
        Wend
        
        Print #1, "<!--  TOTALES -->"
        Print #1, "<tr>"
            Print #1, "<td width='14%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'>"
            Print #1, "<p align='center'><font color='#FFFFFF'><b>Totales</b></font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(1) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(2) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(3) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(4) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(5) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(6) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(7) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(8) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(9) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(10) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(11) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(12) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(13) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(14) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(15) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(16) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(17) & "</font></td>"
            Print #1, "<td width='5%' bgcolor='#000080' align='center' bordercolor='#FFFFFF' bordercolorlight='#800000'><font color='#FFFFFF'>" & RsTotales(18) & "</font></td>"
        Print #1, "</tr>"
        Print #1, "</table>"
        Print #1, "</center>"
        Print #1, "</div>"
        Print #1, "<hr>"
        Print #1, "<p align='center'><font size='1' color='#800000'>Reporte generado por GesCol Ver. 1.0</font></p>"
        Print #1, "</body>"
        Print #1, "</html>"

        Close #1
End If

RsContenido.Close
BdBoletin.Close
End Sub

Private Sub Cmb_Let_Cur_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub Cmb_Tipos_pago_Click()
'Me.CoolFlex1(1).TextMatrix(Fila, 11) = Me.Cmb_Tipos_pago.Text
Me.Frame1.Enabled = True
Me.Frame_Botones.Enabled = True
Me.CoolFlex1(1).GridEnabled = True
End Sub

Private Sub CoolFlex1_CellCheckBoxClick(Index As Integer, ColIndex As Long, Value As Integer)
If Value = 1 Then
    If (ColIndex >= 5 And ColIndex <= 10) And (UCase(Me.CoolFlex1(1).TextMatrix(Me.CoolFlex1(1).Row, 4)) = "U") Then
            'If UCase(Me.CoolFlex1(1).TextMatrix(Me.CoolFlex1(1).Row, 3)) = "NO" Then
                MsgBox ("Imposible realizar esta operación" & Chr(13) & "Alumno No matriculado")
                Me.CoolFlex1(1).Col = ColIndex
                Me.CoolFlex1(1).Text = "U"
                'TextMatrix(Me.CoolFlex1(1).Row, ColIndex) = "U"
    'ElseIf ColIndex = 4 And UCase(Me.CoolFlex1(1).TextMatrix(Me.CoolFlex1(1).Row, 3)) = "NO" Then
    '    MsgBox ("Imposible realizar esta operación" & Chr(13) & "No tiene matrícula reservada")
    '    Me.CoolFlex1(1).Col = ColIndex
    '    Me.CoolFlex1(1).Text = "U"
    End If
    
    If ColIndex = 5 Then
        Me.CoolFlex1(1).Col = 6: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 7: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 8: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 9: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 10: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = ColIndex
    ElseIf ColIndex = 6 Then
        Me.CoolFlex1(1).Col = 5: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = ColIndex
    ElseIf ColIndex = 7 Then
        Me.CoolFlex1(1).Col = 5: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 8: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 9: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 10: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = ColIndex
    ElseIf ColIndex = 8 Then
        Me.CoolFlex1(1).Col = 5: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 7: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 9: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 10: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = ColIndex
    ElseIf ColIndex = 9 Then
        Me.CoolFlex1(1).Col = 5: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 7: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 8: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 10: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = ColIndex
    ElseIf ColIndex = 10 Then
        Me.CoolFlex1(1).Col = 5: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 7: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 8: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 9: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = ColIndex
    End If


ElseIf ColIndex = 4 Then
        Me.CoolFlex1(1).Col = 5: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 6: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 7: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 8: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 9: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 10: Me.CoolFlex1(1).Text = "U"
        Me.CoolFlex1(1).Col = 4: Me.CoolFlex1(1).Col = ColIndex
End If
End Sub
Private Sub CoolFlex1_CellComboBoxChange(Index As Integer, ColIndex As Long)
Modificado = True
Me.BtnGenRep.Enabled = False
Me.Btn_Gra_cap.Enabled = True
End Sub

Private Sub CoolFlex1_Click(Index As Integer)
'If index = 1 And Me.CoolFlex1(1).Col = 11 Then 'And Muestra Then
'    'Me.Cmb_Tipos_pago.ListIndex = -1
'    Fila = Me.CoolFlex1(1).Row
'    Me.Frame1.Enabled = False
'    Me.Frame_Botones.Enabled = False
'    Me.CoolFlex1(1).GridEnabled = False
'    Me.Frame_Tipos_Pago.Visible = True
'End If
End Sub

Private Sub CoolFlex1_GotFocus(Index As Integer)
Modificado = True
Me.BtnGenRep.Enabled = False
Me.Btn_Gra_cap.Enabled = True
End Sub

Private Sub Form_Load()
Modificado = False
Load Me.CoolFlex1(1)
CoolFlex1(1).Clear
'CoolFlex1(1).EditTextLenght = 0
CoolFlex1(1).EditEnable = False
CoolFlex1(1).Cols = 12
CoolFlex1(1).Rows = 3
Me.CoolFlex1(1).Visible = True
With CoolFlex1(1)
.FixedCols = 4
.FixedRows = 1
.ColWidth(0) = 950 'RUT
.ColWidth(1) = 3300 'NOMBRE
.ColWidth(2) = 800 'FONO
.ColWidth(3) = 700  'RESERVA
.ColWidth(4) = 780  'MATRICULA
.ColWidth(5) = 780  'Beca Completa
.ColWidth(6) = 780  'Media Beca
.ColWidth(7) = 780  'Cuponera
.ColWidth(8) = 780  'Cheques
.ColWidth(9) = 780  'P.A.C.
.ColWidth(10) = 780  'CONTADO
.ColWidth(11) = 3300 ' Nombre apoderado
End With
Me.lbl_fecha.Caption = Date
Me.Btn_Gra_cap.Enabled = False
'Call Iniciagrilla
CentrarForma Me
Set RS = New ADODB.Recordset
RS.CursorLocation = adUseClient
Set rsinforme = New ADODB.Recordset
rsinforme.CursorLocation = adUseClient
'********* Llena combos ****************
Call llenacombo(Form_MatriReserv.Cmb_Cod_ens, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
End Sub


Private Sub Form_Unload(Cancel As Integer)
Call menuhabilitado(True)
End Sub

'************ SQL ESTADISTICA ***************
'* SELECT AC.COD_ENS, AC.NUM_GRA, AC.LET_CUR,MO.COD_DES, COUNT(M.RESERVA) AS MATRICULA, COUNT(M.RESERVA)-sum(M.RESERVA) AS SIN_RES, sum(M.RESERVA) AS CON_RES FROM POSTULANTES P, ALU_X_CUR AC, MATRICULAS M, CODIGOS_ENSENANZA MO WHERE P.CI_ALU = M.CI_ALU AND M.CI_ALU = AC.CI_ALU AND M.ACTIVO_ALU = 'SI' AND P.CI_ALU = AC.CI_ALU     AND AC.ACTIVO_ALU ='SI' AND AC.fec_cam ='1111-11-11' AND AC.COD_ENS=MO.COD_ENS   GROUP BY AC.COD_ENS, AC.NUM_GRA, AC.LET_CUR  ORDER BY AC.COD_ENS ASC, AC.NUM_GRA ASC, AC.LET_CUR ASC
'********************************************
Private Sub OptDesMAt_Click(Index As Integer)
If Index = 1 Then
    Form_main.CrystalReport.Destination = crptToPrinter
ElseIf Index = 0 Then
    Form_main.CrystalReport.Destination = crptToWindow
End If
End Sub
