VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Begin VB.Form FormCertAnual 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Certificado "
   ClientHeight    =   7050
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10485
   Icon            =   "FormCertAnual.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7050
   ScaleWidth      =   10485
   ShowInTaskbar   =   0   'False
   Begin ProgBarProzent.ProgBar ProgBar1 
      Height          =   375
      Left            =   120
      TabIndex        =   25
      Top             =   6480
      Width           =   10215
      _ExtentX        =   18018
      _ExtentY        =   661
   End
   Begin VB.Frame Frame1 
      Caption         =   "Seleccione un 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          =   5415
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   10215
      Begin VB.Frame FrmAlumno 
         Caption         =   "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          =   1455
         Left            =   2880
         TabIndex        =   17
         Top             =   240
         Width           =   5295
         Begin VB.ListBox lst_nom_alu 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   480
            Left            =   960
            TabIndex        =   18
            Top             =   600
            Visible         =   0   'False
            Width           =   4095
         End
         Begin VB.TextBox txt_cur_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   21
            Top             =   1080
            Width           =   735
         End
         Begin VB.TextBox txt_nom_alu 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   20
            Top             =   360
            Width           =   4095
         End
         Begin VB.TextBox txt_rut_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   19
            Top             =   720
            Width           =   1455
         End
         Begin VB.Label Label14 
            Caption         =   "Curso"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   240
            TabIndex        =   24
            Top             =   1080
            Width           =   495
         End
         Begin VB.Label Label13 
            Caption         =   "Rut"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   240
            TabIndex        =   23
            Top             =   720
            Width           =   495
         End
         Begin VB.Label Label12 
            Caption         =   "Alumno"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   240
            TabIndex        =   22
            Top             =   360
            Width           =   735
         End
      End
      Begin VB.Frame FrmCurso 
         Caption         =   "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          =   1455
         Left            =   2880
         TabIndex        =   9
         Top             =   240
         Width           =   5295
         Begin VB.ComboBox CmbModalidad 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   2040
            Style           =   2  'Dropdown List
            TabIndex        =   12
            Top             =   360
            Width           =   2955
         End
         Begin VB.ComboBox Cmb_Grado 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   2040
            Style           =   2  'Dropdown List
            TabIndex        =   11
            Top             =   720
            Width           =   615
         End
         Begin VB.ComboBox Cmb_Let_Cur 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   2040
            Style           =   2  'Dropdown List
            TabIndex        =   10
            Top             =   1080
            Width           =   615
         End
         Begin VB.Label Label4 
            Caption         =   "Tipo de enseñanza"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   240
            TabIndex        =   15
            Top             =   360
            Width           =   1455
         End
         Begin VB.Label Label5 
            Caption         =   "Grado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   240
            TabIndex        =   14
            Top             =   720
            Width           =   615
         End
         Begin VB.Label Label6 
            Caption         =   "Letra Curso"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   240
            TabIndex        =   13
            Top             =   1080
            Width           =   1095
         End
      End
      Begin VB.CommandButton BtnGrabaMatriz 
         Caption         =   "Guarda Matriz"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2880
         TabIndex        =   33
         Top             =   4800
         Visible         =   0   'False
         Width           =   1455
      End
      Begin VB.CommandButton btn_otro_alu 
         Caption         =   "Otro Alumno"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   8520
         TabIndex        =   26
         Top             =   1320
         Width           =   1455
      End
      Begin VB.Frame Frame2 
         ForeColor       =   &H00FF0000&
         Height          =   615
         Left            =   240
         TabIndex        =   6
         Top             =   240
         Width           =   2415
         Begin VB.OptionButton OptOptCur 
            Caption         =   "Curso"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   8
            Top             =   240
            Width           =   1095
         End
         Begin VB.OptionButton OptInd 
            Caption         =   "Individual"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   1200
            TabIndex        =   7
            Top             =   240
            Value           =   -1  'True
            Width           =   1095
         End
      End
      Begin VB.Frame Frame3 
         ForeColor       =   &H00FF0000&
         Height          =   615
         Left            =   240
         TabIndex        =   3
         Top             =   1080
         Width           =   2415
         Begin VB.OptionButton OptDesPan 
            Caption         =   "Pantalla"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   5
            Top             =   240
            Value           =   -1  'True
            Width           =   975
         End
         Begin VB.OptionButton OptDesImp 
            Caption         =   "Impresora"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   1200
            TabIndex        =   4
            Top             =   240
            Width           =   1095
         End
      End
      Begin VB.CommandButton BtnGenRep 
         Caption         =   "Generar Reportes"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   8520
         TabIndex        =   2
         Top             =   840
         Width           =   1455
      End
      Begin VB.CommandButton BtnConfImp 
         Caption         =   "Conf. Impresora"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   8520
         TabIndex        =   1
         Top             =   360
         Width           =   1455
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
         Height          =   2895
         Left            =   120
         TabIndex        =   16
         Top             =   1800
         Width           =   9975
         _ExtentX        =   17595
         _ExtentY        =   5106
         _Version        =   393216
         Cols            =   4
         FixedCols       =   0
         GridLines       =   3
         FormatString    =   $"FormCertAnual.frx":2A8B2
         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
      End
      Begin MSComDlg.CommonDialog CmDialog1 
         Left            =   4800
         Top             =   4800
         _ExtentX        =   847
         _ExtentY        =   847
         _Version        =   393216
      End
      Begin VB.Label Label2 
         Caption         =   "%"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2400
         TabIndex        =   37
         Top             =   4800
         Width           =   135
      End
      Begin VB.Label LblPGrel 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   7560
         TabIndex        =   36
         Top             =   4920
         Width           =   375
      End
      Begin VB.Label LblRelPalabras 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   8640
         TabIndex        =   35
         Top             =   4920
         Width           =   1335
      End
      Begin VB.Label LblPGpalabras 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   8760
         TabIndex        =   34
         Top             =   4920
         Width           =   1335
      End
      Begin VB.Label Lblasistencia 
         Caption         =   "__"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2160
         TabIndex        =   32
         Top             =   4800
         Width           =   375
      End
      Begin VB.Label Label3 
         Caption         =   "Porcentaje de asistencia"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   31
         Top             =   4800
         Width           =   1935
      End
      Begin VB.Label LblReligion 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   8040
         TabIndex        =   30
         Top             =   4920
         Width           =   375
      End
      Begin VB.Label Label1 
         Caption         =   "Religión (Optativo) "
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   6000
         TabIndex        =   29
         Top             =   5040
         Width           =   1335
      End
      Begin VB.Label LblPG 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   7680
         TabIndex        =   28
         Top             =   4920
         Width           =   375
      End
      Begin VB.Label LblPromedio 
         Caption         =   "Promedio General"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   6000
         TabIndex        =   27
         Top             =   4800
         Width           =   1575
      End
   End
   Begin VB.Label LblModalidad 
      Caption         =   "_"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4320
      TabIndex        =   43
      Top             =   5640
      Width           =   3375
   End
   Begin VB.Label LblObsFin 
      Caption         =   "_"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1680
      TabIndex        =   42
      Top             =   6000
      Width           =   8535
   End
   Begin VB.Label Label8 
      Caption         =   "Observaciones:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   41
      Top             =   6120
      Width           =   1215
   End
   Begin VB.Label LblCurso 
      Caption         =   "_"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2880
      TabIndex        =   40
      Top             =   5640
      Width           =   1335
   End
   Begin VB.Label LblSitFin 
      Caption         =   "_"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1680
      TabIndex        =   39
      Top             =   5640
      Width           =   1095
   End
   Begin VB.Label Label7 
      Caption         =   "En concecuencia,"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   38
      Top             =   5640
      Width           =   1335
   End
End
Attribute VB_Name = "FormCertAnual"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CodModalidad, NumGra, LetCur, CodDes, DecEva, DecPlanYpro As String
Public Sub GenRep()
'On Error GoTo controler
'****** Decretos de evaluacion y planes de estudio **********
For numformula = 0 To 25
Form_main.CrystalReport.Formulas(numformula) = ""
Next numformula


Select Case CodModalidad
Case "110": DecEva = "511 de 1997"
Case "310"
    If NumGra = "1" Or NumGra = "2" Then
        DecEva = "112 de 1999"
    Else
        DecEva = "83 de 2001"
    End If
End Select

Select Case CodModalidad
Case "110"
    Select Case NumGra
        Case "1": DecPlanYpro = "545  de 1996"
        Case "2": DecPlanYpro = "545  de 1996"
        Case "3": DecPlanYpro = "552  de 1997"
        Case "4": DecPlanYpro = "552  de 1997"
        Case "5": DecPlanYpro = "220  de 1999"
        Case "6": DecPlanYpro = "81  de 2000"
        Case "7": DecPlanYpro = "481 de 2000"
        Case "8": DecPlanYpro = "92  de 2002"
    
    End Select
Case "310"
    Select Case NumGra
        Case "1": DecPlanYpro = "77  de  1999"
        Case "2": DecPlanYpro = "83  de 2000"
        Case "3": DecPlanYpro = "27 de 2001"
        Case "4": DecPlanYpro = "102 de 2002"
    End Select
End Select

'************************************************************


Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
a = "select nom_est, localidad_est, rdb, num_res_rec_ofi_est, nom_dir, ape_pat_dir, ape_mat_dir, fec_res_rec_ofi_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) = "ComunaCol = '" & rs(1) & "'"
Form_main.CrystalReport.Formulas(2) = "RBD = '" & rs!RDB & "'"
Form_main.CrystalReport.Formulas(3) = "Numres = '" & rs!num_res_rec_ofi_est & " de " & Year(rs!fec_res_rec_ofi_est) & "'"
Form_main.CrystalReport.Formulas(4) = "Nomdir = '" & rs(5) & " " & rs(6) & " " & rs(4) & "'"
Form_main.CrystalReport.Formulas(5) = "Regin = 'Metropolitana'"
Form_main.CrystalReport.Formulas(6) = "Provincia = 'Santiago'"
Form_main.CrystalReport.Formulas(7) = "AnnoEscolar = '" & Anno & "'"
End If
rs.Close

a = "select p.ape1_prof, p.ape2_prof, p.noms_prof from profesores p, cursos c where p.rut_prof = c.rut_prof and c.cod_ens='" & CodModalidad & "' and c.num_gra ='" & NumGra & "' and c.let_cur ='" & LetCur & "'"
rs.CursorLocation = adUseClient
rs.Open a, conn
If rs.RecordCount > 0 Then
Form_main.CrystalReport.Formulas(8) = "NomProf = '" & rs(0) & " " & rs(1) & " " & rs(2) & "'"
End If
rs.Close

modalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_ens = '" & CodModalidad & "'", conn)

Form_main.CrystalReport.WindowTitle = "Certificado Anual de Estudio"

Form_main.CrystalReport.Formulas(9) = "Modalidad = '" & modalidad & "'"
Form_main.CrystalReport.Formulas(10) = "NomAlu = '" & Me.txt_nom_alu & "'"
Form_main.CrystalReport.Formulas(11) = "RunAlu = '" & Me.txt_rut_alu & "'"
Form_main.CrystalReport.Formulas(12) = "Curso = '" & NumGra & "º " & LetCur & " de " & modalidad & "'"
Form_main.CrystalReport.Formulas(13) = "DecEva = '" & DecEva & "'"
Form_main.CrystalReport.Formulas(14) = "Hora = '" & Time() & "'"
Form_main.CrystalReport.Formulas(15) = "Decreto = '" & DecPlanYpro & "'"

Form_main.CrystalReport.Formulas(16) = "PgAnual = '" & Me.LblPG & "'"
Form_main.CrystalReport.Formulas(17) = "PgAnualPalabras = '" & Me.LblPGpalabras & "'"
Form_main.CrystalReport.Formulas(18) = "PgRel = '" & Me.LblReligion & "'"
Form_main.CrystalReport.Formulas(19) = "PgRelPalabras = '" & Me.LblRelPalabras & "'"


Form_main.CrystalReport.Formulas(20) = "Asis = '" & Me.Lblasistencia & "'"
Form_main.CrystalReport.Formulas(21) = "sitFin = '" & Me.LblSitFin & "'"
Form_main.CrystalReport.Formulas(22) = "CursoProm = '" & Me.lblCurso & " " & Me.LblModalidad & "'"
Form_main.CrystalReport.Formulas(23) = "Observacionessit = '" & Me.LblObsFin & "'"
Form_main.CrystalReport.Formulas(24) = "Fecha = '" & "Santiago, " & Format(Date, "d") & " de " & Format(Date, "mmmm") & " de " & Format(Date, "yyyy") & "'"

 Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\cert_alu.rpt"
'Form_main.CrystalReport.ReplaceSelectionFormula ("{matriculas.FEC_MAT}  >= date( " & fechainicio & ") and {matriculas.FEC_MAT} <= date( " & fechafin & ")")
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_otro_alu_Click()
Me.Lblasistencia = "__"
Me.lblCurso = ""
Me.LblModalidad = ""
Me.LblObsFin = ""
Me.LblPG = ""
Me.LblPGpalabras = ""
Me.LblPGrel = ""
Me.LblReligion = ""
Me.LblRelPalabras = ""
Me.LblSitFin = ""

Me.txt_nom_alu.Text = ""
Me.txt_rut_alu.Text = ""
Me.txt_cur_alu = ""
Me.txt_nom_alu.Enabled = True
Me.txt_nom_alu.SetFocus
Me.btn_otro_alu.Enabled = False
Me.MSFlexGrid1.Clear
Me.MSFlexGrid1.FormatString = "Sector de aprendizaje                     |Subsector de aprendizaje                                         |^ Calificación final|^ Calificación final              "
Busqueda = 1
Me.MSFlexGrid1.Rows = 2
Me.MSFlexGrid1.Cols = 4
End Sub

Private Sub BtnConfImp_Click()
CmDialog1.CancelError = False
CmDialog1.PrinterDefault = True
CmDialog1.Flags = cdlPDPrintSetup
CmDialog1.ShowPrinter

End Sub

Private Sub BtnGenRep_Click()
Dim CodModalidad As String

If Me.OptDesImp.Value = True Then Form_main.CrystalReport.Destination = crptToPrinter
If Me.OptDesPan.Value = True Then Form_main.CrystalReport.Destination = crptToWindow
If Me.OptInd.Value = True Then
    Call GenRep
Else
'########## Imprime todo el curso ############
Dim MatrizAlumnos()
    Me.FrmCurso.Visible = False
    Me.FrmAlumno.Visible = True
alumno = 0
a = "select p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, p.ci_alu, a.fec_mat, a.cod_ens, a.num_gra, a.let_cur from  postulantes p, alu_x_cur a where p.ci_alu = a.ci_alu and a.activo_alu='SI' and a.cod_ens = '" & CodModalidad & " ' and a.num_gra = '" & Me.Cmb_Grado & "' and a.let_cur ='" & Me.Cmb_let_cur & "' order by ape_pat_alu, ape_mat_alu, nom_alu"
    MSFlexGrid1.Enabled = True
rs.CursorLocation = adUseClient
rs.Open a, conn
If rs.RecordCount > 0 Then
    ReDim MatrizAlumnos(rs.RecordCount, 7)
    For i = 0 To rs.RecordCount - 1
        MatrizAlumnos(i, 0) = rs(0) 'ape_pat_alu
        MatrizAlumnos(i, 1) = rs(1) 'ape_mat_alu
        MatrizAlumnos(i, 2) = rs(2) 'nom_alu
        MatrizAlumnos(i, 3) = rs(3) 'ci_alu
        MatrizAlumnos(i, 4) = rs(4) 'fec_mat
        MatrizAlumnos(i, 5) = rs(5) 'cod_ens
        MatrizAlumnos(i, 6) = rs(6) 'num_gra
        MatrizAlumnos(i, 7) = rs(7) 'let_cur
        rs.MoveNext
    Next i
    
nmax = rs.RecordCount
rs.Close
End If



For i = 0 To nmax - 1
       
    CodDes = devuelvecampo("codigos_ensenanza", "", "cod_des", "cod_ens = '" & MatrizAlumnos(i, 5) & "'", conn)
    CodModalidad = MatrizAlumnos(i, 5)
    Me.txt_nom_alu = MatrizAlumnos(i, 0) & "  " & MatrizAlumnos(i, 1) & "  " & MatrizAlumnos(i, 2)
    Me.txt_rut_alu = MatrizAlumnos(i, 3)
    Me.txt_cur_alu = MatrizAlumnos(i, 6) & MatrizAlumnos(i, 7) & " - " & MatrizAlumnos(i, 5)
    NumGra = MatrizAlumnos(i, 6)
    LetCur = MatrizAlumnos(i, 7)

Let_Cur = MatrizAlumnos(i, 7)
'llena grilla con subsectores y notas
a = "select p.ci_alu, ss.ord_asi, s.nom_sec, ss.nom_asi, p.pg, ss.cod_sec, ss.cod_asi  from promedios p, sectores s, subsectores ss where s.cod_sec = ss.cod_sec and p.cod_ens=ss.cod_ens and p.num_gra=ss.num_gra and p.ci_alu ='" & txt_rut_alu & "' and p.cod_sec=ss.cod_sec and p.cod_asi=ss.cod_asi and p.cod_ens='" & CodModalidad & "' and p.num_gra='" & Left(txt_cur_alu, 1) & "' and letra_curso ='" & Let_Cur & "' order by p.ci_alu, ord_asi"
RsAux.Open a, conn
If RsAux.RecordCount > 0 Then ' rsaux
    
    '***********************************************************************
    '* inicializa la barra de progreso                                     *
    '***********************************************************************
   
    With ProgBar1
        .MaxValue = nmax
        .Richtung = mDir
        .ProgressStyle = mStyle
        .ShowProzent = 1
        .Zusatztext = "%"
        .ShowProgress 0
    End With
    '***********************************************************************
       
    MSFlexGrid1.Rows = RsAux.RecordCount + 1
    'While Not rs.EOF
    
    For asignatura = 1 To RsAux.RecordCount
        MSFlexGrid1.Col = 0
        MSFlexGrid1.Row = asignatura
        MSFlexGrid1.CellAlignment = 1
        If RsAux(5) <> Cod_sec_religion And RsAux(6) <> Cod_asi_religion Then
            MSFlexGrid1.TextMatrix(asignatura, 0) = RsAux(2)
            MSFlexGrid1.TextMatrix(asignatura, 1) = RsAux(3)
            
            If IsNull(RsAux(4)) Then
                MSFlexGrid1.TextMatrix(asignatura, 2) = "EX"
                MSFlexGrid1.TextMatrix(asignatura, 3) = "EXIMIDO(A)"
            Else
                If Len(Trim(str(RsAux(4)))) < 3 And RsAux(4) >= 1 Then
                    MSFlexGrid1.TextMatrix(asignatura, 2) = Format(RsAux(4), "#.0")
                Else
                    If Len(Trim(str(RsAux(4)))) = 3 And RsAux(4) > 0 Then
                        MSFlexGrid1.TextMatrix(asignatura, 2) = RsAux(4)
                    Else
                        MSFlexGrid1.TextMatrix(asignatura, 2) = ""
                    End If
                End If
                If MSFlexGrid1.TextMatrix(asignatura, 2) <> "EX" Then MSFlexGrid1.TextMatrix(asignatura, 3) = NotasEnPalabras(MSFlexGrid1.TextMatrix(asignatura, 2))
            End If
        Else
        
            If RsAux(5) = Cod_sec_religion And RsAux(6) = Cod_asi_religion Then
                If IsNull(RsAux(4)) Then
                    LblPGrel = "EX"
                    Me.LblRelPalabras.Caption = "EXIMIDO(A)"
                Else
                    If Len(Trim(str(RsAux(4)))) < 3 And RsAux(4) >= 1 Then
                        LblPGrel = Format(RsAux(4), "#.0")
                    Else
                        If Len(Trim(str(RsAux(4)))) = 3 And RsAux(4) > 0 Then
                        LblPGrel = RsAux(4)
                    Else
                        LblPGrel = "EX"
                        Me.LblRelPalabras.Caption = "EXIMIDO(A)"
                    End If
                End If
            End If

                Select Case RsAux(4) * 10
            
                    Case 10 To 39
                        LblReligion.Caption = "I"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                    Case 40 To 49
                        LblReligion.Caption = "S"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                    Case 50 To 59
                        LblReligion.Caption = "B"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                    Case 60 To 70
                        LblReligion.Caption = "MB"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                End Select
                Me.MSFlexGrid1.Rows = Me.MSFlexGrid1.Rows - 1
            End If
        End If
        'notas con palabras
         'MSFlexGrid1.TextMatrix(asignatura, 3) = NotasEnPalabras(MSFlexGrid1.TextMatrix(asignatura, 2))
        '******************
        
        RsAux.MoveNext
    Next asignatura
Call BtnGrabaMatriz_Click
End If
RsAux.Close
    
    PGstr = devuelvecampo("promedios", "", "AVG(PG)", "ci_alu ='" & Me.txt_rut_alu & "' and cod_sec <> '" & Cod_sec_religion & "' and cod_asi <> '" & Cod_asi_religion & "' and not isnull(pg)and pg > 0 group by ci_alu", conn)
    PGstr = Format(PGstr, "#0.0")
    
    If Len(PGstr) < 3 And Val(PGstr) >= 1 Then
        PG = CDbl(Format(PGstr, "#.0"))
    Else
        If Len(PGstr) = 3 And Val(PGstr) >= 1 Then
            PG = CDbl(PGstr)
        Else
            PG = 0
        End If
    End If
    
    
    'If Val(PGstr) > 0 Then
    '    PG = Format(CDbl(PGstr), "#0.0000") 'CDbl(PGstr)
    '    'fraccion = Val(Right(Format(PG, "#0.00"), 2))
    '    If Val(Right(Format(PG, "#0.00"), 2)) >= 90 Then ' si fraccion >= 90
    '        PG = Format(Format(PG, "."), "0.0")
    '    Else
    '        PG = Format(PG, "#0.0") 'Redondea a la decima 5.55 ->5.6
    '    End If
    'Else
    '    PG = 0
    'End If
    Me.LblPG = Format(PG, "#.0")
    'notas con palabras
     Me.LblPGpalabras = NotasEnPalabras(LblPG)
    '******************
    'CodEns = devuelvecampo("codigos_ensenanza", "", "cod_ens", "cod_des ='" & Right(Trim(Me.txt_cur_alu), 2) & "'")
    Me.Lblasistencia = CalcAsis(Me.txt_rut_alu, CodModalidad, Left(Trim(Me.txt_cur_alu), 1), Mid(Trim(Me.txt_cur_alu), 2, 1), Anno, conn)
    
    
    Me.LblSitFin = devuelvecampo("matriculas m, situaciones_fin sf", "", "sf.des_sit", "m.ci_alu ='" & Me.txt_rut_alu & "' and m.cod_sit = sf.cod_sit", conn)
    sit_fin = devuelvecampo("matriculas m, situaciones_fin", "", "cod_int_sit", "des_sit ='" & LblSitFin & "'", conn)
    Me.LblObsFin = devuelvecampo("matriculas m, obserbaciones_fin of", "", "of.des_obs_fin", "m.ci_alu ='" & Me.txt_rut_alu & "' and m.cod_obs_fin = of.cod_obs_fin", conn)
    cod_obs = devuelvecampo("obserbaciones_fin of", "", "of.cod_obs_fin", "of.des_obs_fin ='" & Me.LblObsFin & "'", conn)
    Me.LblObsFin = Me.LblObsFin & " - " & cod_obs
    Select Case sit_fin
    
    Case "PA"
        If CodDes = "EB" Then
            Select Case NumGra
                Case "1"
                    lblCurso = "Segundo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "2"
                    lblCurso = "Tercer Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "3"
                    lblCurso = "Cuarto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "4"
                    lblCurso = "Quinto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "5"
                    lblCurso = "Sexto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "6"
                    lblCurso = "Séptimo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "7"
                    lblCurso = "Octavo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "8"
                    lblCurso = "Primer Año de " '"1" & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
            End Select
        Else
            Select Case NumGra
                Case "1"
                    lblCurso = "Segundo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
                Case "2"
                    lblCurso = "Tercer Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
                Case "3"
                    lblCurso = "Cuarto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
                Case "4"
                    Me.LblSitFin = "opta"
                    lblCurso = "a"
                    Me.LblModalidad = "Licencia de Enseñanza Media Humanístico Científica"
            End Select
        End If
    Case "RE"
        Select Case NumGra
            Case "1"
                lblCurso = "Primer Año de " '"1" & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'")
            Case "2"
                lblCurso = "Segundo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "3"
                lblCurso = "Tercer Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "4"
                lblCurso = "Cuarto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "5"
                lblCurso = "Quinto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "6"
                lblCurso = "Sexto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "7"
                lblCurso = "Séptimo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "8"
                lblCurso = "Octavo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
        End Select
        
        'Me.LblCurso = Numgra & " " & LetCur & " de"
        Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_ens = '" & CodModalidad & "'", conn)
    End Select
    Call GenRep
    Me.Lblasistencia = "__"
    Me.lblCurso = ""
    Me.LblModalidad = ""
    Me.LblObsFin = ""
    Me.LblPG = ""
    Me.LblPGpalabras = ""
    Me.LblPGrel = ""
    Me.LblReligion = ""
    Me.LblRelPalabras = ""
    Me.LblSitFin = ""
    Me.txt_nom_alu.Text = ""
    Me.txt_rut_alu.Text = ""
    Me.txt_cur_alu = ""
    Me.MSFlexGrid1.Clear
    Me.MSFlexGrid1.FormatString = "Sector de aprendizaje                     |Subsector de aprendizaje                                         |^ Calificación final|^ Calificación final              "

    
    ProgBar1.ShowProgress i
    DoEvents
    
Next i
    Me.FrmCurso.Visible = True
    Me.FrmAlumno.Visible = False
    ProgBar1.ShowProgress nummax

' ########## FIN Imprime todo el curso ############
End If

End Sub

Private Sub BtnGrabaMatriz_Click()
'***********************************************************************
'* Guarda matriz en base de datos temporal GesTem.mdb en el directorio *
'* de la aplicacion                                                    *
'***********************************************************************

Call CreaBD(DirAplicacion & "\GesTemp.mdb")
Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "cert_alu", "5,10")

Dim dbsTemp As Database
Dim rsTemp As Recordset
Dim CamposInsert, ValoresInsert As String
Set dbsTemp = OpenDatabase(DirAplicacion & "\GesTemp.mdb")
Set rsTemp = dbsTemp.OpenRecordset("cert_alu", dbOpenDynaset)

ValoresInsert = ""
CamposInsert = ""
For i = 0 To Me.MSFlexGrid1.Cols - 1 + 1 ' +1 un id_linea (f)para ordenar los registros
    CamposInsert = CamposInsert & "C" & i + 1 & ", "
Next i
CamposInsert = "(" & Mid(CamposInsert, 1, Len(CamposInsert) - 2) & ")"
ValoresInsert = ""
For f = 1 To Me.MSFlexGrid1.Rows - 1
        ValoresInsert = ""

        For i = 0 To Me.MSFlexGrid1.Cols - 1
            If Len(Trim(Me.MSFlexGrid1.TextMatrix(f, i))) = 0 Then
                contenido = "Null" & ", "
            Else
                contenido = "'" & Me.MSFlexGrid1.TextMatrix(f, i) & "', "
            End If
            ValoresInsert = ValoresInsert & contenido
        Next i
        ' +1 un id_linea (f)para ordenar los registros
        ValoresInsert = "(" & "'" & FillconCero(Trim(str(f)), 2) & "', " & Mid(ValoresInsert, 1, Len(ValoresInsert) - 2) & ")"
        dbsTemp.Execute "INSERT INTO cert_alu" & CamposInsert & " values" & Trim(ValoresInsert)
Next f
Set dbsTemp = Nothing

End Sub

Private Sub Cmb_Grado_Click()
CodModalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.CmbModalidad & "'", conn)
Ngrado = Me.Cmb_Grado.Text
Cmb_let_cur.Clear
'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_let_cur_Click()
Me.BtnGenRep.Enabled = True
End Sub

Private Sub cmbModalidad_Click()

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


End Sub


Private Sub Form_Load()
CentrarForma Me
Busqueda = 1
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
Set RsAux = New ADODB.Recordset
RsAux.CursorLocation = adUseClient
Call llenacombo(Me.CmbModalidad, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)

MSFlexGrid1.MergeCells = flexMergeRestrictRows
MSFlexGrid1.MergeRow(0) = True

End Sub

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

Private Sub lst_nom_alu_Click()
Dim CodModalidad As String

LblRelPalabras.Caption = ""
Indi = 0
Busqueda = 0
'comu = acomunas(lst_nom_alu.ListIndex)
'respaldo a = "select p.ci_alu, p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, ac.cod_ens, ac.num_gra, ac.letra_curso  from postulantes p, alu_x_cur ac, where p.ci_alu = ac.ci_alu and ac.activo_alu ='SI' and p.ci_alu ='" & Trim(Left(Me.lst_nom_alu.Text, 10)) & "' order by ape_pat_alu, ape_mat_alu, nom_alu"  ' 19643340-6'
a = "select p.ci_alu, p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, ac.cod_ens, ac.num_gra, ac.let_cur  from postulantes p, alu_x_cur ac where p.ci_alu = ac.ci_alu and ac.activo_alu ='SI' and p.ci_alu ='" & Trim(Left(Me.lst_nom_alu.Text, 10)) & "' order by ape_pat_alu, ape_mat_alu, nom_alu"  ' 19643340-6'
RsAux.Open a, conn
'rsaux.Close
'a = "SELECT * FROM codigos__geograficos where comuna = " & "'" & comu & "'"

'rs.CursorLocation = adUseClient
If RsAux.RecordCount > 0 Then
    CodDes = devuelvecampo("codigos_ensenanza", "", "cod_des", "cod_ens = '" & RsAux(4) & "'", conn)
    CodModalidad = RsAux(4)
    Me.txt_nom_alu = RsAux!ape_pat_alu & "  " & RsAux!ape_mat_alu & "  " & RsAux!Nom_Alu
    Me.txt_rut_alu = RsAux!ci_alu
    Me.txt_cur_alu = RsAux!Num_Gra & RsAux!Let_Cur & " - " & CodDes
    NumGra = RsAux!Num_Gra
    LetCur = RsAux!Let_Cur
RsAux.Close
End If
Me.lst_nom_alu.Visible = False
Let_Cur = Mid(txt_cur_alu, InStr(txt_cur_alu, "-") - 2, 1)
'llena grilla con subsectores y notas
a = "select p.ci_alu, ss.ord_asi, s.nom_sec, ss.nom_asi, p.pg, ss.cod_sec, ss.cod_asi  from promedios p, sectores s, subsectores ss where s.cod_sec = ss.cod_sec and p.cod_ens=ss.cod_ens and p.num_gra=ss.num_gra and p.ci_alu ='" & txt_rut_alu & "' and p.cod_sec=ss.cod_sec and p.cod_asi=ss.cod_asi and p.cod_ens='" & CodModalidad & "' and p.num_gra='" & Left(txt_cur_alu, 1) & "' and letra_curso ='" & Let_Cur & "' order by p.ci_alu, ord_asi"
RsAux.Open a, conn
If RsAux.RecordCount > 0 Then ' rsaux
    
    '***********************************************************************
    '* inicializa la barra de progreso                                     *
    '***********************************************************************
    nmax = RsAux.RecordCount
    With ProgBar1
        .MaxValue = nmax
        .Richtung = mDir
        .ProgressStyle = mStyle
        .ShowProzent = 1
        .Zusatztext = "%"
        .ShowProgress 0
    End With
    '***********************************************************************
       
    MSFlexGrid1.Rows = RsAux.RecordCount + 1
    'While Not rs.EOF
    
    For asignatura = 1 To RsAux.RecordCount
        MSFlexGrid1.Col = 0
        MSFlexGrid1.Row = asignatura
        MSFlexGrid1.CellAlignment = 1
        If RsAux(5) <> Cod_sec_religion And RsAux(6) <> Cod_asi_religion Then
            MSFlexGrid1.TextMatrix(asignatura, 0) = RsAux(2)
            MSFlexGrid1.TextMatrix(asignatura, 1) = RsAux(3)
            If IsNull(RsAux(4)) Or RsAux(4) < 1 Then
                MSFlexGrid1.TextMatrix(asignatura, 2) = "EX"
                MSFlexGrid1.TextMatrix(asignatura, 3) = "EXIMIDO(A)"
            Else
                If Len(Trim(str(RsAux(4)))) < 3 And RsAux(4) >= 1 Then
                    MSFlexGrid1.TextMatrix(asignatura, 2) = Format(RsAux(4), "#.0")
                Else
                    If Len(Trim(str(RsAux(4)))) = 3 And RsAux(4) > 0 Then
                        MSFlexGrid1.TextMatrix(asignatura, 2) = RsAux(4)
                    Else
                        MSFlexGrid1.TextMatrix(asignatura, 2) = ""
                    End If
                End If
            End If
            If MSFlexGrid1.TextMatrix(asignatura, 2) <> "EX" Then MSFlexGrid1.TextMatrix(asignatura, 3) = NotasEnPalabras(MSFlexGrid1.TextMatrix(asignatura, 2))
        Else
        
            If RsAux(5) = Cod_sec_religion And RsAux(6) = Cod_asi_religion Then
                If IsNull(RsAux(4)) Then
                    LblPGrel = "EX"
                    Me.LblRelPalabras.Caption = "EXIMIDO(A)"
                Else
                    If Len(Trim(str(RsAux(4)))) < 3 And RsAux(4) >= 1 Then
                        LblPGrel = Format(RsAux(4), "#.0")
                    Else
                        If Len(Trim(str(RsAux(4)))) = 3 And RsAux(4) > 0 Then
                        LblPGrel = RsAux(4)
                    Else
                        LblPGrel = "EX"
                        Me.LblRelPalabras.Caption = "EXIMIDO(A)"
                    End If
                End If
            End If

                Select Case RsAux(4) * 10
            
                    Case 10 To 39
                        LblReligion.Caption = "I"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                    Case 40 To 49
                        LblReligion.Caption = "S"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                    Case 50 To 59
                        LblReligion.Caption = "B"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                    Case 60 To 70
                        LblReligion.Caption = "MB"
                        Me.LblRelPalabras.Caption = NotasEnPalabras(LblReligion.Caption)
                End Select
                Me.MSFlexGrid1.Rows = Me.MSFlexGrid1.Rows - 1
            End If
        End If
        'notas con palabras
         'MSFlexGrid1.TextMatrix(asignatura, 3) = NotasEnPalabras(MSFlexGrid1.TextMatrix(asignatura, 2))
        '******************
        
        RsAux.MoveNext
    Next asignatura
Call BtnGrabaMatriz_Click
End If
RsAux.Close
    
    PGstr = devuelvecampo("promedios", "", "AVG(PG)", "ci_alu ='" & Me.txt_rut_alu & "' and cod_sec <> '" & Cod_sec_religion & "' and cod_asi <> '" & Cod_asi_religion & "' and not isnull(pg)and pg > 0 group by ci_alu", conn)
    PGstr = Format(PGstr, "#0.0")
    
    If Len(PGstr) < 3 And Val(PGstr) >= 1 Then
        PG = CDbl(Format(PGstr, "#.0"))
    Else
        If Len(PGstr) = 3 And Val(PGstr) >= 1 Then
            PG = CDbl(PGstr)
        Else
            PG = 0
        End If
    End If
    
    
    'If Val(PGstr) > 0 Then
    '    PG = Format(CDbl(PGstr), "#0.0000") 'CDbl(PGstr)
    '    'fraccion = Val(Right(Format(PG, "#0.00"), 2))
    '    If Val(Right(Format(PG, "#0.00"), 2)) >= 90 Then ' si fraccion >= 90
    '        PG = Format(Format(PG, "."), "0.0")
    '    Else
    '        PG = Format(PG, "#0.0") 'Redondea a la decima 5.55 ->5.6
    '    End If
    'Else
    '    PG = 0
    'End If
    Me.LblPG = Format(PG, "#.0")
    'notas con palabras
     Me.LblPGpalabras = NotasEnPalabras(LblPG)
    
    Me.Lblasistencia = CalcAsis(Me.txt_rut_alu, CodModalidad, Left(Trim(Me.txt_cur_alu), 1), Mid(Trim(Me.txt_cur_alu), 2, 1), Anno, conn)
    Me.LblSitFin = devuelvecampo("matriculas m, situaciones_fin sf", "", "sf.des_sit", "m.ci_alu ='" & Me.txt_rut_alu & "' and m.cod    _sit = sf.cod_sit", conn)
    sit_fin = devuelvecampo("matriculas m, situaciones_fin", "", "cod_int_sit", "des_sit ='" & LblSitFin & "'", conn)
    Me.LblObsFin = devuelvecampo("matriculas m, obserbaciones_fin of", "", "of.des_obs_fin", "m.ci_alu ='" & Me.txt_rut_alu & "' and m.cod_obs_fin = of.cod_obs_fin", conn)
    cod_obs = devuelvecampo("obserbaciones_fin of", "", "of.cod_obs_fin", "of.des_obs_fin ='" & Me.LblObsFin & "'", conn)
    Me.LblObsFin = Me.LblObsFin & " - " & cod_obs
    Select Case sit_fin
    
    Case "PA"
        If CodDes = "EB" Then
            Select Case NumGra
                Case "1"
                    lblCurso = "Segundo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "2"
                    lblCurso = "Tercer Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "3"
                    lblCurso = "Cuarto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "4"
                    lblCurso = "Quinto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "5"
                    lblCurso = "Sexto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "6"
                    lblCurso = "Séptimo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "7"
                    lblCurso = "Octavo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'", conn)
                Case "8"
                    lblCurso = "Primer Año de " '"1" & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
            End Select
        Else
            Select Case NumGra
                Case "1"
                    lblCurso = "Segundo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
                Case "2"
                    lblCurso = "Tercer Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
                Case "3"
                    lblCurso = "Cuarto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                    Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'", conn)
                Case "4"
                    Me.LblSitFin = "opta"
                    lblCurso = "a"
                    Me.LblModalidad = "Licencia de Enseñanza Media Humanístico Científica"
            End Select
        End If
    Case "RE"
        Select Case NumGra
            Case "1"
                lblCurso = "Primer Año de " '"1" & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EM'")
            Case "2"
                lblCurso = "Segundo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "3"
                lblCurso = "Tercer Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "4"
                lblCurso = "Cuarto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "5"
                lblCurso = "Quinto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "6"
                lblCurso = "Sexto Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "7"
                lblCurso = "Séptimo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
            Case "8"
                lblCurso = "Octavo Año de " 'str(Val(numgra) + 1) & " " & LetCur & " de"
                'Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_des = 'EB'")
        End Select
        
        'Me.LblCurso = Numgra & " " & LetCur & " de"
        Me.LblModalidad = devuelvecampo("codigos_ensenanza", "", "des_ens", "cod_ens = '" & CodModalidad & "'", conn)
    End Select
    
    
    
    Me.txt_nom_alu.Enabled = False
    Me.btn_otro_alu.Enabled = True

Me.BtnGenRep.Enabled = True
End Sub

Private Sub OptInd_Click()
If Me.OptInd.Value = True Then
    Me.FrmCurso.Visible = False
    Me.FrmAlumno.Visible = True
End If

End Sub

Private Sub OptInd_GotFocus()
If Me.OptInd.Value = True Then
    Me.FrmCurso.Visible = False
    Me.FrmAlumno.Visible = True
End If

End Sub

Private Sub OptOptCur_Click()
If Me.OptOptCur.Value = True Then
    Me.FrmCurso.Visible = True
    Me.FrmAlumno.Visible = False
End If
End Sub

Private Sub OptOptCur_GotFocus()
If Me.OptOptCur.Value = True Then
    Me.FrmCurso.Visible = True
    Me.FrmAlumno.Visible = False
End If

End Sub

Private Sub txt_nom_alu_Change()
If Busqueda = 1 Then
rs.CursorLocation = adUseClient
lst_nom_alu.Clear
If Not ((Chr(KeyAscii) >= "A" And Chr(KeyAscii) <= "Z") Or (Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z")) Then
    KeyAscii = 0
    If Len(Trim(Me.txt_nom_alu.Text)) <> 0 Then
      Criterio = "'" + Me.txt_nom_alu.Text + Consulta + "%'"
       
       a = "select p.ci_alu, p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, ac.cod_ens, ac.num_gra, ac.let_cur  from postulantes p, alu_x_cur ac where p.ci_alu = ac.ci_alu and p.ape_pat_alu like " & Criterio & " order by ape_pat_alu, ape_mat_alu, nom_alu" 'and ac.activo_alu ='SI'and p.ci_alu ='19643340-6'"
       rs.Open a, conn
        lst_nom_alu.Visible = False
        If rs.RecordCount > 0 Then
            'ReDim acomunas(rs.RecordCount)
            Indi = 0
            X = 0
            While Not rs.EOF
                lst_nom_alu.AddItem rs(0) & " - " & rs(1) & "  " & rs(2) & "  " & rs(3)
                'acomunas(X) = rs("comuna")
                lst_nom_alu.Visible = True
                rs.MoveNext
                X = X + 1
            Wend
        End If
        rs.Close
    Else
    lst_nom_alu.Visible = False
    End If
End If
End If

End Sub

Private Sub txt_nom_alu_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
    
    txt_nom_alu.Text = ""
    lst_nom_alu.Visible = False
    Me.txt_rut_alu = ""
    Me.txt_cur_alu = ""
    KeyAscii = 0

ElseIf ((Chr(KeyAscii) >= "A" And Chr(KeyAscii) <= "Z") Or (Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z")) Then Exit Sub
ElseIf (Chr(KeyAscii) >= "0" And Chr(KeyAscii) <= "9") Then Exit Sub
ElseIf KeyAscii = 8 Then Exit Sub
ElseIf KeyAscii = 32 Then Exit Sub
ElseIf Me.txt_nom_alu.Text = "" Then
        If KeyAscii = 37 Then Exit Sub
End If
    KeyAscii = 0: Exit Sub

End Sub

Public Function NotasEnPalabras(Nota As String) As String
        'notas con palabras
Select Case Nota
Case "I"
    NotasEnPalabras = "Insuficiente"
    Exit Function
Case "S"
    NotasEnPalabras = "Suficiente"
    Exit Function
Case "B"
    NotasEnPalabras = "Bueno"
    Exit Function
Case "MB"
    NotasEnPalabras = "Muy Bueno"
    Exit Function
End Select

        d1 = ""
        d2 = ""
        Select Case Left(Nota, 1)
            Case "1"
                d1 = "Uno"
            Case "2"
                d1 = "Dos"
            Case "3"
                d1 = "Tres"
            Case "4"
                d1 = "Cuatro"
            Case "5"
                d1 = "Cinco"
            Case "6"
                d1 = "Seis"
            Case "7"
                d1 = "Siete"
        End Select
        
        Select Case Right(Nota, 1)
            Case "0"
                d2 = "Cero"
            Case "1"
                d2 = "Uno"
            Case "2"
                d2 = "Dos"
            Case "3"
                d2 = "Tres"
            Case "4"
                d2 = "Cuatro"
            Case "5"
                d2 = "Cinco"
            Case "6"
                d2 = "Seis"
            Case "7"
                d2 = "Siete"
            Case "8"
                d2 = "Ocho"
            Case "9"
                d2 = "Nueve"
        End Select
        
        NotasEnPalabras = d1 & ", " & d2
        '******************

End Function

Private Sub txt_rut_alu_Change()
If Trim(txt_rut_alu) <> "" Then

End If
End Sub
