VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Object = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Begin VB.Form formMenCur 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Ingresos Por Cursos"
   ClientHeight    =   6135
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   11040
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6135
   ScaleWidth      =   11040
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Begin TabDlg.SSTab SSTab1 
      Height          =   5775
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   10815
      _ExtentX        =   19076
      _ExtentY        =   10186
      _Version        =   393216
      Tab             =   2
      TabHeight       =   520
      TabCaption(0)   =   "Simple"
      TabPicture(0)   =   "frmMenCur.frx":0000
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "ProgBar1"
      Tab(0).Control(1)=   "MSFlexGrid1"
      Tab(0).Control(2)=   "Frame1"
      Tab(0).Control(3)=   "Frame2"
      Tab(0).Control(4)=   "btnCanMencur"
      Tab(0).Control(5)=   "btnRptMenCur"
      Tab(0).ControlCount=   6
      TabCaption(1)   =   "Distribuido"
      TabPicture(1)   =   "frmMenCur.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "Command3"
      Tab(1).Control(1)=   "Command2"
      Tab(1).Control(2)=   "Frame4"
      Tab(1).Control(3)=   "Frame3"
      Tab(1).Control(4)=   "MSFlexGrid2"
      Tab(1).Control(5)=   "ProgBar2"
      Tab(1).ControlCount=   6
      TabCaption(2)   =   "Ideal - Real - Pagado"
      TabPicture(2)   =   "frmMenCur.frx":0038
      Tab(2).ControlEnabled=   -1  'True
      Tab(2).Control(0)=   "lblValMenIRP"
      Tab(2).Control(0).Enabled=   0   'False
      Tab(2).Control(1)=   "Label10"
      Tab(2).Control(1).Enabled=   0   'False
      Tab(2).Control(2)=   "ProgBar3"
      Tab(2).Control(2).Enabled=   0   'False
      Tab(2).Control(3)=   "MSFlexGrid3"
      Tab(2).Control(3).Enabled=   0   'False
      Tab(2).Control(4)=   "btnRptIRP"
      Tab(2).Control(4).Enabled=   0   'False
      Tab(2).Control(5)=   "btnCanIRP"
      Tab(2).Control(5).Enabled=   0   'False
      Tab(2).Control(6)=   "Frame6"
      Tab(2).Control(6).Enabled=   0   'False
      Tab(2).Control(7)=   "btnVerIRP"
      Tab(2).Control(7).Enabled=   0   'False
      Tab(2).ControlCount=   8
      Begin VB.CommandButton btnVerIRP 
         Caption         =   "-->"
         Enabled         =   0   'False
         Height          =   255
         Left            =   6360
         TabIndex        =   46
         Top             =   600
         Width           =   375
      End
      Begin VB.Frame Frame6 
         Caption         =   "Curso"
         ForeColor       =   &H00FF0000&
         Height          =   855
         Left            =   120
         TabIndex        =   37
         Top             =   480
         Width           =   6015
         Begin VB.ComboBox CmbLetCur_IRP 
            Enabled         =   0   'False
            Height          =   315
            Left            =   4920
            Style           =   2  'Dropdown List
            TabIndex        =   40
            Top             =   360
            Width           =   975
         End
         Begin VB.ComboBox CmbGrado_IRP 
            Enabled         =   0   'False
            Height          =   315
            Left            =   3120
            Style           =   2  'Dropdown List
            TabIndex        =   39
            Top             =   360
            Width           =   1455
         End
         Begin VB.ComboBox CmbCodEns_IRP 
            Height          =   315
            Left            =   240
            Style           =   2  'Dropdown List
            TabIndex        =   38
            Top             =   360
            Width           =   2475
         End
         Begin VB.Line Line12 
            BorderColor     =   &H00FFFFFF&
            X1              =   4695
            X2              =   4695
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line11 
            BorderColor     =   &H00FFFFFF&
            X1              =   2895
            X2              =   2895
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line10 
            BorderColor     =   &H00808080&
            X1              =   4680
            X2              =   4680
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line9 
            BorderColor     =   &H00808080&
            X1              =   2880
            X2              =   2880
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Label Label14 
            Caption         =   "Tipo de enseñanza"
            Height          =   195
            Left            =   1320
            TabIndex        =   43
            Top             =   120
            Width           =   1455
         End
         Begin VB.Label Label13 
            Caption         =   "Grado"
            Height          =   195
            Left            =   4080
            TabIndex        =   42
            Top             =   120
            Width           =   495
         End
         Begin VB.Label Label12 
            Caption         =   "Letra - curso"
            Height          =   195
            Left            =   4920
            TabIndex        =   41
            Top             =   120
            Width           =   975
         End
      End
      Begin VB.CommandButton btnCanIRP 
         Caption         =   "Cancelar"
         Height          =   375
         Left            =   7800
         TabIndex        =   36
         Top             =   5160
         Width           =   1335
      End
      Begin VB.CommandButton btnRptIRP 
         Caption         =   "Generar Reporte"
         Enabled         =   0   'False
         Height          =   375
         Left            =   9240
         TabIndex        =   35
         Top             =   5160
         Width           =   1335
      End
      Begin VB.CommandButton Command3 
         Caption         =   "Generar Reporte"
         Enabled         =   0   'False
         Height          =   375
         Left            =   -65760
         TabIndex        =   34
         Top             =   5160
         Width           =   1335
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Cancelar"
         Height          =   375
         Left            =   -67200
         TabIndex        =   33
         Top             =   5160
         Width           =   1335
      End
      Begin VB.Frame Frame4 
         Caption         =   "Curso"
         ForeColor       =   &H00FF0000&
         Height          =   855
         Left            =   -68760
         TabIndex        =   25
         Top             =   480
         Width           =   4335
         Begin VB.CommandButton Command1 
            Caption         =   "-->"
            Enabled         =   0   'False
            Height          =   255
            Left            =   3720
            TabIndex        =   28
            Top             =   360
            Width           =   375
         End
         Begin VB.ComboBox cmbMesGen 
            Enabled         =   0   'False
            Height          =   315
            Index           =   3
            Left            =   240
            TabIndex        =   27
            Text            =   "Combo1"
            Top             =   360
            Width           =   1575
         End
         Begin VB.ComboBox cmbMesGen 
            Enabled         =   0   'False
            Height          =   315
            Index           =   2
            Left            =   2040
            TabIndex        =   26
            Text            =   "Combo1"
            Top             =   360
            Width           =   1575
         End
         Begin VB.Label Label9 
            Caption         =   "Desde"
            Height          =   195
            Left            =   1320
            TabIndex        =   30
            Top             =   120
            Width           =   495
         End
         Begin VB.Label Label8 
            Caption         =   "Hasta"
            Height          =   195
            Left            =   3120
            TabIndex        =   29
            Top             =   120
            Width           =   495
         End
      End
      Begin VB.Frame Frame3 
         Caption         =   "Curso"
         ForeColor       =   &H00FF0000&
         Height          =   855
         Left            =   -74880
         TabIndex        =   18
         Top             =   480
         Width           =   6015
         Begin VB.ComboBox Combo3 
            Enabled         =   0   'False
            Height          =   315
            Left            =   4920
            Style           =   2  'Dropdown List
            TabIndex        =   21
            Top             =   360
            Width           =   975
         End
         Begin VB.ComboBox Combo2 
            Enabled         =   0   'False
            Height          =   315
            Left            =   3120
            Style           =   2  'Dropdown List
            TabIndex        =   20
            Top             =   360
            Width           =   1455
         End
         Begin VB.ComboBox Combo1 
            Height          =   315
            Left            =   240
            Style           =   2  'Dropdown List
            TabIndex        =   19
            Top             =   360
            Width           =   2475
         End
         Begin VB.Line Line8 
            BorderColor     =   &H00FFFFFF&
            X1              =   4695
            X2              =   4695
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line7 
            BorderColor     =   &H00FFFFFF&
            X1              =   2895
            X2              =   2895
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line6 
            BorderColor     =   &H00808080&
            X1              =   4680
            X2              =   4680
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line3 
            BorderColor     =   &H00808080&
            X1              =   2880
            X2              =   2880
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Label Label7 
            Caption         =   "Tipo de enseñanza"
            Height          =   195
            Left            =   1320
            TabIndex        =   24
            Top             =   120
            Width           =   1455
         End
         Begin VB.Label Label6 
            Caption         =   "Grado"
            Height          =   195
            Left            =   4080
            TabIndex        =   23
            Top             =   120
            Width           =   495
         End
         Begin VB.Label Label5 
            Caption         =   "Letra - curso"
            Height          =   195
            Left            =   4920
            TabIndex        =   22
            Top             =   120
            Width           =   975
         End
      End
      Begin VB.CommandButton btnRptMenCur 
         Caption         =   "Generar Reporte"
         Enabled         =   0   'False
         Height          =   375
         Left            =   -65760
         TabIndex        =   17
         Top             =   5160
         Width           =   1335
      End
      Begin VB.CommandButton btnCanMencur 
         Caption         =   "Cancelar"
         Height          =   375
         Left            =   -67200
         TabIndex        =   16
         Top             =   5160
         Width           =   1335
      End
      Begin VB.Frame Frame2 
         Caption         =   "Meses"
         ForeColor       =   &H00FF0000&
         Height          =   855
         Left            =   -68760
         TabIndex        =   8
         Top             =   480
         Width           =   4335
         Begin VB.ComboBox cmbMesGen 
            Enabled         =   0   'False
            Height          =   315
            Index           =   1
            Left            =   2040
            TabIndex        =   11
            Text            =   "Combo1"
            Top             =   360
            Width           =   1575
         End
         Begin VB.ComboBox cmbMesGen 
            Enabled         =   0   'False
            Height          =   315
            Index           =   0
            Left            =   240
            TabIndex        =   10
            Text            =   "Combo1"
            Top             =   360
            Width           =   1575
         End
         Begin VB.CommandButton btnVerMencur 
            Caption         =   "-->"
            Enabled         =   0   'False
            Height          =   255
            Left            =   3720
            TabIndex        =   9
            Top             =   360
            Width           =   375
         End
         Begin VB.Label Label4 
            Caption         =   "Hasta"
            Height          =   195
            Left            =   3120
            TabIndex        =   13
            Top             =   120
            Width           =   495
         End
         Begin VB.Label Label3 
            Caption         =   "Desde"
            Height          =   195
            Left            =   1320
            TabIndex        =   12
            Top             =   120
            Width           =   495
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "Curso"
         ForeColor       =   &H00FF0000&
         Height          =   855
         Left            =   -74880
         TabIndex        =   1
         Top             =   480
         Width           =   6015
         Begin VB.ComboBox Cmb_Cod_ens 
            Height          =   315
            Left            =   240
            Style           =   2  'Dropdown List
            TabIndex        =   4
            Top             =   360
            Width           =   2475
         End
         Begin VB.ComboBox Cmb_Grado 
            Enabled         =   0   'False
            Height          =   315
            Left            =   3120
            Style           =   2  'Dropdown List
            TabIndex        =   3
            Top             =   360
            Width           =   1455
         End
         Begin VB.ComboBox Cmb_Let_Cur 
            Enabled         =   0   'False
            Height          =   315
            Left            =   4920
            Style           =   2  'Dropdown List
            TabIndex        =   2
            Top             =   360
            Width           =   975
         End
         Begin VB.Label Label2 
            Caption         =   "Letra - curso"
            Height          =   195
            Left            =   4920
            TabIndex        =   7
            Top             =   120
            Width           =   975
         End
         Begin VB.Label Label1 
            Caption         =   "Grado"
            Height          =   195
            Left            =   4080
            TabIndex        =   6
            Top             =   120
            Width           =   495
         End
         Begin VB.Label Tipo 
            Caption         =   "Tipo de enseñanza"
            Height          =   195
            Left            =   1320
            TabIndex        =   5
            Top             =   120
            Width           =   1455
         End
         Begin VB.Line Line1 
            BorderColor     =   &H00808080&
            X1              =   2880
            X2              =   2880
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line2 
            BorderColor     =   &H00808080&
            X1              =   4680
            X2              =   4680
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line4 
            BorderColor     =   &H00FFFFFF&
            X1              =   2895
            X2              =   2895
            Y1              =   120
            Y2              =   840
         End
         Begin VB.Line Line5 
            BorderColor     =   &H00FFFFFF&
            X1              =   4695
            X2              =   4695
            Y1              =   120
            Y2              =   840
         End
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
         Height          =   3615
         Left            =   -74880
         TabIndex        =   14
         Top             =   1440
         Width           =   10515
         _ExtentX        =   18547
         _ExtentY        =   6376
         _Version        =   393216
         Cols            =   3
         ForeColorSel    =   16777215
         Enabled         =   0   'False
      End
      Begin ProgBarProzent.ProgBar ProgBar1 
         Height          =   375
         Left            =   -74880
         TabIndex        =   15
         Top             =   5160
         Width           =   7575
         _ExtentX        =   13361
         _ExtentY        =   661
         Appearance      =   0
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid2 
         Height          =   3615
         Left            =   -74880
         TabIndex        =   31
         Top             =   1440
         Width           =   10515
         _ExtentX        =   18547
         _ExtentY        =   6376
         _Version        =   393216
         Cols            =   3
         ForeColorSel    =   16777215
         Enabled         =   0   'False
      End
      Begin ProgBarProzent.ProgBar ProgBar2 
         Height          =   375
         Left            =   -74880
         TabIndex        =   32
         Top             =   5160
         Width           =   7575
         _ExtentX        =   13361
         _ExtentY        =   661
         Appearance      =   0
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid3 
         Height          =   3615
         Left            =   120
         TabIndex        =   44
         Top             =   1440
         Width           =   10515
         _ExtentX        =   18547
         _ExtentY        =   6376
         _Version        =   393216
         Rows            =   3
         Cols            =   3
         FixedRows       =   2
         FixedCols       =   0
         ForeColorSel    =   16777215
         Enabled         =   0   'False
      End
      Begin ProgBarProzent.ProgBar ProgBar3 
         Height          =   375
         Left            =   120
         TabIndex        =   45
         Top             =   5160
         Width           =   7575
         _ExtentX        =   13361
         _ExtentY        =   661
         Appearance      =   0
      End
      Begin VB.Label Label10 
         Caption         =   "Valor Mensualidad :"
         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            =   8040
         TabIndex        =   48
         Top             =   1080
         Width           =   1695
      End
      Begin VB.Label lblValMenIRP 
         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            =   9840
         TabIndex        =   47
         Top             =   1080
         Width           =   735
      End
   End
End
Attribute VB_Name = "formMenCur"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CodModalidad, Ngrado As String
Dim Rscuotas As ADODB.Recordset


Public Function TraeMensualidad(Ci_alu As String, Mes As String) As Long()
'## Esta funcion en tregando el CI_alu y el mes devuelve ###
'## - Mensualid                                          ###
'## - Descuento                                          ###
'## ### ### ### ### ### ### ### ### ### ### ### ### ###  ###

'Dim RsMensualidad As ADODB.Recordset
'Dim MesCounter As Integer
'Dim MesConsulta As Integer
'Set RsMensualidad = New ADODB.Recordset
'RsMensualidad .CursorLocation = adUseClient

'For MesCounter = Val(Mes) To 3 Step -1
'    a = "select * from cuotas_x_alu where ci_alu ='" & Ci_alu & "' and mes_cuota ='" & MesConsulta & "'"
'    RsMensualidad.Open a, conn
'    If RsMensualidad.RecordCount > 0 Then
'        Dim Mensualidad(4)
'        Mensualidad(0) = RsMensualidad!cuota_sis
'        Mensualidad(1) = RsMensualidad!cuota_alu
'        Mensualidad(2) = RsMensualidad!exe_alu
'        Mensualidad(3) = RsMensualidad!mes_cuota
'        RsMensualidad.Close
'        Exit For
'    Else
'        RsMensualidad.Close
'    End If
'Next MesCounter

Set Rscuotas = New ADODB.Recordset
Rscuotas.CursorLocation = adUseClient
Dim MesCuota As Integer
MesCuota = Val(Mes)
        While MesCuota > 2
            a = "select * from cuotas_x_alu where ci_alu ='" & Ci_alu & "' and mes_cuota ='" & FillconStr(str(MesCuota), 2, "0", "IZQ") & "'"
            Rscuotas.Open a, conn
            If Rscuotas.RecordCount > 0 Then
                Dim Mensualidad(4) As Long
                'MSFlexGrid1.TextMatrix(alumno, 7) = IIf(Not IsNull(Rscuotas!cuota_alu) Or Rscuotas!cuota_alu <> 0, Rscuotas!cuota_alu, Rscuotas!cuota_sis)
                'MSFlexGrid1.TextMatrix(alumno, 6) = Rscuotas!exe_alu

                Mensualidad(0) = IIf(Not IsNull(Rscuotas!cuota_sis) Or Rscuotas!cuota_sis <> 0, Rscuotas!cuota_sis, 0)
                Mensualidad(1) = IIf(Not IsNull(Rscuotas!cuota_alu) Or Rscuotas!cuota_alu <> 0, Rscuotas!cuota_alu, 0)
                Mensualidad(2) = IIf(Not IsNull(Rscuotas!exe_alu) Or Rscuotas!exe_alu <> 0, Rscuotas!exe_alu, 0)
                Mensualidad(3) = Rscuotas!mes_cuota
                MesCuota = 0
            Else
                MesCuota = MesCuota - 1
            End If
            Rscuotas.Close
        Wend
TraeMensualidad = Mensualidad
End Function

Private Sub btnCanMencur_Click()
Unload formMenCur
End Sub


Private Sub btnRptIRP_Click()
On Error GoTo controler
Call LimpiaFormulas(Form_main.CrystalReport, 15)
'mesinitemp = Me.cmbMesGen(0).ListIndex
'mesfintemp = Me.cmbMesGen(1).ListIndex
Me.SSTab1.Enabled = False
If Me.CmbGrado_IRP.ListIndex = 0 Then 'todos los niveles
    For Niveles = 1 To Me.CmbGrado_IRP.ListCount - 1
        Me.CmbGrado_IRP.ListIndex = Niveles
        For cursos = 1 To Me.CmbLetCur_IRP.ListCount - 1
            Me.CmbLetCur_IRP.ListIndex = cursos
            'Me.cmbMesGen(0).ListIndex = mesinitemp
            'Me.cmbMesGen(1).ListIndex = mesfintemp
            Call btnVerIRP_Click
            '**** escribe el curso en la formula del RPT
            Select Case CodModalidad
                Case "996"
                    curso_des = "PK " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
                Case "010"
                    curso_des = "K " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
                Case "110", "310"
                    curso_des = Me.CmbGrado_IRP & " " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
            End Select
            '*******************************************
            
            Form_main.CrystalReport.Formulas(5) = "curso = '" & curso_des & "'"
            Form_main.CrystalReport.Formulas(6) = "totalu = '" & Me.MSFlexGrid3.Rows - 4 & "'"
            Form_main.CrystalReport.Formulas(7) = "valmen = '" & Me.lblValMenIRP & "'"

            'Form_main.CrystalReport.Formulas(6) = "mes = '(" & Left(cmbMesGen(1), 3) & ")'"
            Form_main.CrystalReport.Destination = crptToPrinter
            Call GrillaToRPT(MSFlexGrid3, "ingcur_irp.rpt", "INGRESOS POR CURSO - IDEAL REAL PAGADO")
        Next cursos
    Next Niveles
Else
    If Me.CmbLetCur_IRP.ListIndex = 0 Then 'todos los cursos del nivel seleccionado
        For cursos = 1 To Me.CmbLetCur_IRP.ListCount - 1
            Me.CmbLetCur_IRP.ListIndex = cursos
            'Me.cmbMesGen(0).ListIndex = mesinitemp
            'Me.cmbMesGen(1).ListIndex = mesfintemp
            Call btnVerIRP_Click
            '**** escribe el curso en la formula del RPT
            Select Case CodModalidad
                Case "996"
                    curso_des = "PK " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
                Case "010"
                    curso_des = "K " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
                Case "110", "310"
                    curso_des = Me.CmbGrado_IRP & " " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
            End Select
            '*******************************************
            
            Form_main.CrystalReport.Formulas(5) = "curso = '" & curso_des & "'"
            Form_main.CrystalReport.Formulas(6) = "totalu = '" & Me.MSFlexGrid3.Rows - 4 & "'"
            Form_main.CrystalReport.Formulas(7) = "valmen = '" & Me.lblValMenIRP & "'"

            'Form_main.CrystalReport.Formulas(6) = "mes = '(" & Left(cmbMesGen(1), 3) & ")'"
            Form_main.CrystalReport.Destination = crptToPrinter
            Call GrillaToRPT(MSFlexGrid3, "ingcur_irp.rpt", "INGRESOS POR CURSO - IDEAL REAL PAGADO")
        Next cursos
    Else ' solo el curso del nivel seleccionado
            '**** escribe el curso en la formula del RPT
            Select Case CodModalidad
                Case "996"
                    curso_des = "PK " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
                Case "010"
                    curso_des = "K " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
                Case "110", "310"
                    curso_des = Me.CmbGrado_IRP & " " & Me.CmbLetCur_IRP & " - " & Me.CmbCodEns_IRP
            End Select
            '*******************************************
            Form_main.CrystalReport.Formulas(5) = "curso = '" & curso_des & "'"
            Form_main.CrystalReport.Formulas(6) = "totalu = '" & Me.MSFlexGrid3.Rows - 4 & "'"
            Form_main.CrystalReport.Formulas(7) = "valmen = '" & Me.lblValMenIRP & "'"
            'Form_main.CrystalReport.Formulas(6) = "mes = '(" & Left(cmbMesGen(1), 3) & ")'"
            Form_main.CrystalReport.Destination = crptToWindow
            Call GrillaToRPT(MSFlexGrid3, "ingcur_irp.rpt", "INGRESOS POR CURSO - IDEAL REAL PAGADO")
    End If
End If
Me.SSTab1.Enabled = True
Exit Sub
controler:
MsgBox "Error " & Err.Number & ", " & Err.Description
formMenCur.Hide
Unload formMenCur

End Sub

Private Sub btnRptMenCur_Click()
On Error GoTo controler
mesinitemp = Me.cmbMesGen(0).ListIndex
mesfintemp = Me.cmbMesGen(1).ListIndex
If Me.Cmb_Grado.ListIndex = 0 Then 'todos los niveles
    For Niveles = 1 To Me.Cmb_Grado.ListCount - 1
        Me.Cmb_Grado.ListIndex = Niveles
        For cursos = 1 To Me.Cmb_Let_Cur.ListCount - 1
            Me.Cmb_Let_Cur.ListIndex = cursos
            Me.cmbMesGen(0).ListIndex = mesinitemp
            Me.cmbMesGen(1).ListIndex = mesfintemp
            Call btnVerMencur_Click
            '**** escribe el curso en la formula del RPT
            Select Case CodModalidad
                Case "996"
                    curso_des = "PK " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
                Case "010"
                    curso_des = "K " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
                Case "110", "310"
                    curso_des = Me.Cmb_Grado & " " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
            End Select
            '*******************************************
            Call LimpiaFormulas(Form_main.CrystalReport, 15)
            Form_main.CrystalReport.Formulas(5) = "curso = '" & curso_des & "'"
            Form_main.CrystalReport.Formulas(6) = "mes = '(" & Left(cmbMesGen(1), 3) & ")'"
            Form_main.CrystalReport.Destination = crptToPrinter
            Call GrillaToRPT(MSFlexGrid1, "ingcur.rpt", "INGRESOS POR CURSO - (" & Me.cmbMesGen(0) & " a " & Me.cmbMesGen(1) & ")")
        Next cursos
    Next Niveles
Else
    If Me.Cmb_Let_Cur.ListIndex = 0 Then 'todos los cursos del nivel seleccionado
        For cursos = 1 To Me.Cmb_Let_Cur.ListCount - 1
            Me.Cmb_Let_Cur.ListIndex = cursos
            Me.cmbMesGen(0).ListIndex = mesinitemp
            Me.cmbMesGen(1).ListIndex = mesfintemp
            Call btnVerMencur_Click
            '**** escribe el curso en la formula del RPT
            Select Case CodModalidad
                Case "996"
                    curso_des = "PK " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
                Case "010"
                    curso_des = "K " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
                Case "110", "310"
                    curso_des = Me.Cmb_Grado & " " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
            End Select
            '*******************************************
            Call LimpiaFormulas(Form_main.CrystalReport, 15)
            Form_main.CrystalReport.Formulas(5) = "curso = '" & curso_des & "'"
            Form_main.CrystalReport.Formulas(6) = "mes = '(" & Left(cmbMesGen(1), 3) & ")'"
            Form_main.CrystalReport.Destination = crptToPrinter
            Call GrillaToRPT(MSFlexGrid1, "ingcur.rpt", "INGRESOS POR CURSO - (" & Me.cmbMesGen(0) & " a " & Me.cmbMesGen(1) & ")")
        Next cursos
    Else ' solo el curso del nivel seleccionado
            '**** escribe el curso en la formula del RPT
            Select Case CodModalidad
                Case "996"
                    curso_des = "PK " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
                Case "010"
                    curso_des = "K " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
                Case "110", "310"
                    curso_des = Me.Cmb_Grado & " " & Me.Cmb_Let_Cur & " - " & Me.Cmb_Cod_ens
            End Select
            '*******************************************
            Call LimpiaFormulas(Form_main.CrystalReport, 15)
            Form_main.CrystalReport.Formulas(5) = "curso = '" & curso_des & "'"
            Form_main.CrystalReport.Formulas(6) = "mes = '(" & Left(cmbMesGen(1), 3) & ")'"
        Call GrillaToRPT(MSFlexGrid1, "ingcur.rpt", "INGRESOS POR CURSO - (" & Me.cmbMesGen(0) & " a " & Me.cmbMesGen(1) & ")")
    End If
End If
Exit Sub
controler:
MsgBox "Error " & Err.Number & ", " & Err.Description
formMenCur.Hide
Unload formMenCur
End Sub

Private Sub btnVerIRP_Click()
    On Error GoTo controler:
    Me.SSTab1.Enabled = False
    Me.btnCanMencur.Enabled = False
    Me.btnRptMenCur.Enabled = False
    alumno = 0
    a = "select p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, p.ci_alu, M.IND_BECA, M.IND_MBECA, ar.mensual, M.IND_CONT, M.IND_CUP, M.IND_CHEQ, M.IND_PAC from  postulantes p, alu_x_cur a, MATRICULAS M, arancel ar where M.CI_ALU = p.CI_ALU AND M.cod_ens = ar.cod_ens and p.ci_alu = a.ci_alu and M.activo_alu='SI' and a.cod_ens = '" & CodModalidad & "' and a.num_gra = '" & Ngrado & "' and a.let_cur ='" & Me.CmbLetCur_IRP & "' order by ape_pat_alu, ape_mat_alu, nom_alu"
    MSFlexGrid3.Enabled = True
    Set Rs = New ADODB.Recordset
    Rs.CursorLocation = adUseClient
    Set Rscuotas = New ADODB.Recordset
    Rscuotas.CursorLocation = adUseClient
    Dim MesCuota As Integer
    Dim mensualidades(4)
    Dim pagadoAux() As Long
    Dim TP As String
    Dim Totales() As Long
    Rs.Open a, conn
    If Rs.RecordCount > 0 Then
    ReDim Totales(10, 2)
    
    Me.lblValMenIRP.Caption = Rs(6)
    
    
        
        With ProgBar3
            .ShowProgress 0
            .MaxValue = Rs.RecordCount
            .Richtung = mDir
            .ProgressStyle = mStyle
            .ShowProzent = 1
            .Zusatztext = "%"
            .ShowProgress 0
        End With
        MSFlexGrid3.Rows = 2
        For alumno = 2 To Rs.RecordCount
            TP = "--"
            If Rs(7) = 1 Then TP = "CO"
            If Rs(8) = 1 Then TP = "CU"
            If Rs(9) = 1 Then TP = "CH"
            If Rs(10) = 1 Then TP = "PA"
            
            'If Rs(3) = "19856200-9" Then MsgBox "ok"
            MSFlexGrid3.AddItem ""
            MSFlexGrid3.Col = 0
            MSFlexGrid3.Row = alumno
            MSFlexGrid3.CellAlignment = 1
            MSFlexGrid3.TextMatrix(alumno, 0) = alumno - 1
            MSFlexGrid3.TextMatrix(alumno, 1) = Rs(3)
            MSFlexGrid3.TextMatrix(alumno, 2) = Rs(0) & " " & Rs(1) & " " & Rs(2)
            MSFlexGrid3.TextMatrix(alumno, 3) = IIf(Rs(4) = 1, "B", "") & IIf(Rs(5) = 1, "MB", "")
            MSFlexGrid3.TextMatrix(alumno, 4) = TP
            
            '********** trae cuota para cada mes del año desde la base de datos ***********
            cEL = 0
            For Mes = 3 To 12
                cEL = cEL + 2
                Mensualidad = TraeMensualidad(Rs(3), Trim(str(Mes)))
                MSFlexGrid3.TextMatrix(alumno, cEL + 3) = IIf(Mensualidad(1) <> 0, Mensualidad(1), Mensualidad(0))
                pagadoAux = Pagado(Rs(3), Trim(str(Mes)), Trim(str(Mes)))
                MSFlexGrid3.TextMatrix(alumno, cEL + 4) = pagadoAux(0)
                
                'Totales(Mes - 3, 0) = Totales(Mes - 3, 0) + Val(MSFlexGrid3.TextMatrix(alumno, CEL + 3))
                'Totales(Mes - 3, 1) = Totales(Mes - 3, 0) + Val(MSFlexGrid3.TextMatrix(alumno, CEL + 4))
            Next Mes
                        
            
            
            'MesCuota = Me.cmbMesGen(1).ListIndex + 3
            'Mensualidad = TraeMensualidad(Rs(3), Me.cmbMesGen(1).ListIndex + 2)
            'MSFlexGrid3.TextMatrix(alumno, 7) = IIf(Mensualidad(1) <> 0, Mensualidad(1), Mensualidad(0))
            'MSFlexGrid3.TextMatrix(alumno, 6) = IIf(Trim(MSFlexGrid3.TextMatrix(alumno, 7)) = "0", MSFlexGrid3.TextMatrix(alumno, 5), Mensualidad(2))
                    
            'While MesCuota > 2
            '    a = "select * from cuotas_x_alu where ci_alu ='" & Rs(3) & "' and mes_cuota ='" & FillconStr(str(MesCuota), 2, "0", "IZQ") & "'"
            '    Rscuotas.Open a, conn
            '    If Rscuotas.RecordCount > 0 Then
            '        MSFlexGrid3.TextMatrix(alumno, 7) = IIf(Not IsNull(Rscuotas!cuota_alu) Or Rscuotas!cuota_alu <> 0, Rscuotas!cuota_alu, Rscuotas!cuota_sis)
            '        MSFlexGrid3.TextMatrix(alumno, 6) = Rscuotas!exe_alu
            '        MesCuota = 0
            '    Else
            '        MesCuota = MesCuota - 1
            '    End If
            '    Rscuotas.Close
            'Wend
            '*****************************************************************************
            'pagadoAux = Pagado(Rs(3), Me.cmbMesGen(0).ListIndex + 2, Me.cmbMesGen(1).ListIndex + 2)
            'MSFlexGrid3.TextMatrix(alumno, 8) = pagadoAux(0)
            
            Me.ProgBar3.ShowProgress alumno
            DoEvents
            
            Rs.MoveNext
        Next alumno
        Me.MSFlexGrid3.AddItem ""
        
        For i = 0 To Me.MSFlexGrid3.Cols - 1
            Me.MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 1, i) = "====================================="
        Next i
        Me.MSFlexGrid3.AddItem ""
        Me.MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 1, 3) = "TOT."
        Me.MSFlexGrid3.Row = Me.MSFlexGrid3.Rows - 1
        Me.MSFlexGrid3.Col = 3
        Me.MSFlexGrid3.CellFontBold = True
        Me.MSFlexGrid3.AddItem ""
        Me.MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 1, 3) = "% MORO."
        Me.MSFlexGrid3.Row = Me.MSFlexGrid3.Rows - 1
        Me.MSFlexGrid3.Col = 3
        Me.MSFlexGrid3.CellFontBold = True
        
        
        '******* TOTALES ***********
            For c = 5 To Me.MSFlexGrid3.Cols - 1
                For f = 2 To Me.MSFlexGrid3.Rows - 4
                    MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 2, c) = Val(MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 2, c)) + Val(MSFlexGrid3.TextMatrix(f, c))
                Next f
            Next c
          
          cEL = 0
            For Mes = 3 To 12
                cEL = cEL + 2
                MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 1, cEL + 3) = Format(Abs((Val(MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 2, cEL + 3 + 1)) / Val(MSFlexGrid3.TextMatrix(Me.MSFlexGrid3.Rows - 2, cEL + 3)) - 1)), "#.## %")
            Next Mes
        
        '******************************
        
        Me.ProgBar3.ShowProgress Me.ProgBar3.MaxValue
    End If
    Rs.Close
    Me.btnCanIRP.Enabled = True
    Me.btnRptIRP.Enabled = True
    Me.SSTab1.Enabled = True
Exit Sub
controler:
MsgBox "Error " & Err.Number & ", " & Err.Description
formMenCur.Hide
Unload formMenCur
End Sub

Private Sub btnVerMencur_Click()
On Error GoTo controler
    Me.btnCanMencur.Enabled = False
    Me.btnRptMenCur.Enabled = False
    alumno = 0
    a = "select p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, p.ci_alu, M.IND_BECA, M.IND_MBECA, ar.mensual from  postulantes p, alu_x_cur a, MATRICULAS M, arancel ar where M.CI_ALU = p.CI_ALU AND M.cod_ens = ar.cod_ens and p.ci_alu = a.ci_alu and M.activo_alu='SI' and a.cod_ens = '" & CodModalidad & " ' and a.num_gra = '" & Ngrado & "' and a.let_cur ='" & Me.Cmb_Let_Cur & "' order by ape_pat_alu, ape_mat_alu, nom_alu"
    MSFlexGrid1.Enabled = True
    Set Rs = New ADODB.Recordset
    Rs.CursorLocation = adUseClient
    Set Rscuotas = New ADODB.Recordset
    Rscuotas.CursorLocation = adUseClient
    Dim MesCuota As Integer
    Dim mensualidades(4)
    Dim pagadoAux() As Long
    Rs.Open a, conn
    If Rs.RecordCount > 0 Then
        With ProgBar1
            .ShowProgress 0
            .MaxValue = Rs.RecordCount
            .Richtung = mDir
            .ProgressStyle = mStyle
            .ShowProzent = 1
            .Zusatztext = "%"
            .ShowProgress 0
        End With
        MSFlexGrid1.Rows = 1
        For alumno = 1 To Rs.RecordCount
            If Rs(3) = "17708583-9" Then MsgBox "ok"
            MSFlexGrid1.AddItem ""
            MSFlexGrid1.Col = 0
            MSFlexGrid1.Row = alumno
            MSFlexGrid1.CellAlignment = 1
            MSFlexGrid1.TextMatrix(alumno, 0) = alumno
            MSFlexGrid1.TextMatrix(alumno, 1) = Rs(3)
            MSFlexGrid1.TextMatrix(alumno, 2) = Rs(0) & " " & Rs(1) & " " & Rs(2)
            MSFlexGrid1.TextMatrix(alumno, 3) = IIf(Rs(4) = 1, "SI", "NO")
            MSFlexGrid1.TextMatrix(alumno, 4) = IIf(Rs(5) = 1, "SI", "NO")
            MSFlexGrid1.TextMatrix(alumno, 5) = Rs(6)
            '********** trae cuota para el mes indicado desde la base de datos ***********
            'MesCuota = Me.cmbMesGen(1).ListIndex + 3
            Mensualidad = TraeMensualidad(Rs(3), Me.cmbMesGen(1).ListIndex + 2)
            MSFlexGrid1.TextMatrix(alumno, 7) = IIf(Mensualidad(1) <> 0, Mensualidad(1), Mensualidad(0))
            MSFlexGrid1.TextMatrix(alumno, 6) = IIf(Trim(MSFlexGrid1.TextMatrix(alumno, 7)) = "0", MSFlexGrid1.TextMatrix(alumno, 5), Mensualidad(2))
                    
            'While MesCuota > 2
            '    a = "select * from cuotas_x_alu where ci_alu ='" & Rs(3) & "' and mes_cuota ='" & FillconStr(str(MesCuota), 2, "0", "IZQ") & "'"
            '    Rscuotas.Open a, conn
            '    If Rscuotas.RecordCount > 0 Then
            '        MSFlexGrid1.TextMatrix(alumno, 7) = IIf(Not IsNull(Rscuotas!cuota_alu) Or Rscuotas!cuota_alu <> 0, Rscuotas!cuota_alu, Rscuotas!cuota_sis)
            '        MSFlexGrid1.TextMatrix(alumno, 6) = Rscuotas!exe_alu
            '        MesCuota = 0
            '    Else
            '        MesCuota = MesCuota - 1
            '    End If
            '    Rscuotas.Close
            'Wend
            '*****************************************************************************
            pagadoAux = Pagado(Rs(3), Me.cmbMesGen(0).ListIndex + 2, Me.cmbMesGen(1).ListIndex + 2)
            MSFlexGrid1.TextMatrix(alumno, 8) = pagadoAux(0)
            
            Me.ProgBar1.ShowProgress alumno
            DoEvents
            
            Rs.MoveNext
        Next alumno
        Me.ProgBar1.ShowProgress Me.ProgBar1.MaxValue
    End If
    Rs.Close
    Me.btnCanMencur.Enabled = True
    Me.btnRptMenCur.Enabled = True
Exit Sub
controler:
MsgBox "Error " & Err.Number & ", " & Err.Description
formMenCur.Hide
Unload formMenCur

End Sub

Private Sub Cmb_Cod_ens_Click()
If Len(Me.Cmb_Cod_ens) <> 0 Then
 CodModalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.Cmb_Cod_ens.Text & "'", conn)
 Nivel = devuelvecampo("codigos_ensenanza", "des_ens", "num_gra_max", "des_ens = " & "'" & Me.Cmb_Cod_ens.Text & "'", conn)
 Cmb_Grado.Enabled = True
 Cmb_Grado.Clear
 For t = 1 To Val(Nivel)
    Cmb_Grado.AddItem t
 Next t
End If
Me.Cmb_Grado.AddItem "Todos", 0
Cmb_Let_Cur.Clear
Me.cmbMesGen(0).ListIndex = 0
Me.cmbMesGen(1).ListIndex = 0
Me.cmbMesGen(0).Enabled = False
Me.cmbMesGen(1).Enabled = False
Me.btnVerMencur.Enabled = False
Me.MSFlexGrid1.Rows = 1

End Sub

Private Sub Cmb_Grado_Change()
Ngrado = Me.Cmb_Grado.Text
Cmb_Let_Cur.Clear
Me.cmbMesGen(0).ListIndex = 0
Me.cmbMesGen(1).ListIndex = 0

Me.MSFlexGrid1.Rows = 1
   Call llenacombo(formMenCur.Cmb_Let_Cur, "cursos", "let_cur", "where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "'", conn)
Me.Cmb_Let_Cur.AddItem "Todos", 0
Me.Cmb_Let_Cur.Enabled = True

If Me.Cmb_Grado.ListIndex = 0 Then
    Me.Cmb_Let_Cur.ListIndex = 0
    Me.Cmb_Let_Cur.Enabled = False
    Me.btnVerMencur.Enabled = False
Else
    Me.cmbMesGen(0).Enabled = False
    Me.cmbMesGen(1).Enabled = False
    Me.btnRptMenCur.Enabled = False
End If

End Sub

Private Sub Cmb_Grado_Click()
Ngrado = Me.Cmb_Grado.Text
Cmb_Let_Cur.Clear
Me.cmbMesGen(0).ListIndex = 0
Me.cmbMesGen(1).ListIndex = 0

Me.MSFlexGrid1.Rows = 1
   Call llenacombo(formMenCur.Cmb_Let_Cur, "cursos", "let_cur", "where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "'", conn)
Me.Cmb_Let_Cur.AddItem "Todos", 0
Me.Cmb_Let_Cur.Enabled = True

If Me.Cmb_Grado.ListIndex = 0 Then
    Me.Cmb_Let_Cur.ListIndex = 0
    Me.Cmb_Let_Cur.Enabled = False
    Me.btnVerMencur.Enabled = False
Else
    Me.cmbMesGen(0).Enabled = False
    Me.cmbMesGen(1).Enabled = False
    Me.btnRptMenCur.Enabled = False
End If
End Sub

Private Sub Cmb_Let_Cur_Change()
Me.cmbMesGen(0).Enabled = True
Me.cmbMesGen(1).Enabled = True
Me.MSFlexGrid1.Rows = 1
End Sub

Private Sub Cmb_Let_Cur_Click()
Me.btnRptMenCur.Enabled = False
Me.cmbMesGen(0).ListIndex = 0
Me.cmbMesGen(1).ListIndex = 0
Me.cmbMesGen(0).Enabled = True
Me.cmbMesGen(1).Enabled = True
Me.btnVerMencur.Enabled = False
Me.MSFlexGrid1.Rows = 1
End Sub


Private Sub CmbCodEns_IRP_Click()
If Len(CmbCodEns_IRP) <> 0 Then
 CodModalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.CmbCodEns_IRP.Text & "'", conn)
 Nivel = devuelvecampo("codigos_ensenanza", "des_ens", "num_gra_max", "des_ens = " & "'" & Me.CmbCodEns_IRP.Text & "'", conn)
Me.CmbGrado_IRP.Enabled = True
 CmbGrado_IRP.Clear
 For t = 1 To Val(Nivel)
    CmbGrado_IRP.AddItem t
 Next t
End If
CmbGrado_IRP.AddItem "Todos", 0
CmbLetCur_IRP.Clear
'Me.cmbMesGen(0).ListIndex = 0
'Me.cmbMesGen(1).ListIndex = 0
'Me.cmbMesGen(0).Enabled = False
'Me.cmbMesGen(1).Enabled = False
Me.btnVerIRP.Enabled = False
Me.MSFlexGrid3.Rows = 2

End Sub


Private Sub CmbGrado_IRP_Click()


If Me.CmbGrado_IRP.ListIndex = 0 Then
    'Me.btnRptIRP.Enabled = True
    'Me.btnVerIRP.Enabled = False
    CmbLetCur_IRP.Clear
    CmbLetCur_IRP.AddItem "Todos"
    Me.CmbLetCur_IRP.ListIndex = 0
    Me.CmbLetCur_IRP.Enabled = False
Else
    CmbLetCur_IRP.Clear
    Call llenacombo(formMenCur.CmbLetCur_IRP, "cursos", "let_cur", "where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "'", conn)
    
    Ngrado = Me.CmbGrado_IRP.Text
    Me.CmbLetCur_IRP.AddItem "Todos", 0
    Me.CmbLetCur_IRP.Enabled = True
    
    Me.btnRptIRP.Enabled = False
End If
Me.MSFlexGrid3.Rows = 2
End Sub


Private Sub CmbLetCur_IRP_Click()
If Me.CmbLetCur_IRP.ListIndex = 0 Then
    Me.btnRptIRP.Enabled = True
    Me.btnVerIRP.Enabled = False
Else
    Me.btnRptIRP.Enabled = False
    Me.btnVerIRP.Enabled = True
End If



Me.MSFlexGrid3.Rows = 2

End Sub


Private Sub cmbMesGen_Change(Index As Integer)
If cmbMesGen(1) = "Seleccione Mes" Then Exit Sub
alumno = 0
a = "select p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, p.ci_alu, M.IND_BECA, M.IND_MBECA, ar.mensual from  postulantes p, alu_x_cur a, MATRICULAS M, arancel ar where M.CI_ALU = p.CI_ALU AND M.cod_ens = ar.cod_ens and p.ci_alu = a.ci_alu and M.activo_alu='SI' and a.cod_ens = '" & CodModalidad & " ' and a.num_gra = '" & Ngrado & "' and a.let_cur ='" & Me.Cmb_Let_Cur & "' order by ape_pat_alu, ape_mat_alu, nom_alu"
MSFlexGrid1.Enabled = True
Set Rs = New ADODB.Recordset
Rs.CursorLocation = adUseClient
Set Rscuotas = New ADODB.Recordset
Rscuotas.CursorLocation = adUseClient
Dim MesCuota As Integer

Rs.Open a, conn
If Rs.RecordCount > 0 Then

    MSFlexGrid1.Rows = 1
    For alumno = 1 To Rs.RecordCount
        MSFlexGrid1.AddItem ""
        MSFlexGrid1.Col = 0
        MSFlexGrid1.Row = alumno
        MSFlexGrid1.CellAlignment = 1
        MSFlexGrid1.TextMatrix(alumno, 0) = alumno
        MSFlexGrid1.TextMatrix(alumno, 1) = Rs(3)
        MSFlexGrid1.TextMatrix(alumno, 2) = Rs(0) & " " & Rs(1) & " " & Rs(2)
        MSFlexGrid1.TextMatrix(alumno, 3) = IIf(Rs(4) = 1, "SI", "NO")
        MSFlexGrid1.TextMatrix(alumno, 4) = IIf(Rs(5) = 1, "SI", "NO")
        '********** trae cuota para el mes indicado desde la base de datos ***********
        MesCuota = Me.cmbMesGen(1).ListIndex + 3
        
        While MesCuota > 2
            a = "select * from cuotas_x_alu where ci_alu ='" & Rs(3) & "' and mes_cuota ='" & FillconStr(str(MesCuota), 2, "0", "IZQ") & "'"
            Rscuotas.Open a, conn
            If Rscuotas.RecordCount > 0 Then
                MSFlexGrid1.TextMatrix(alumno, 6) = Rscuotas!cuota_sis
                MSFlexGrid1.TextMatrix(alumno, 7) = Rscuotas!exe_alu
                MesCuota = 0
            Else
                MesCuota = MesCuota - 1
            End If
            Rscuotas.Close
        Wend
        '*****************************************************************************
        Rs.MoveNext
    Next alumno
End If
Rs.Close

End Sub
Private Sub cmbMesGen_Click(Index As Integer)

'If Index = 1 Then 'index
'End If 'Index
If Len(Trim(Me.Cmb_Cod_ens)) = 0 Then Exit Sub

If cmbMesGen(0) = "Seleccione Mes" Or cmbMesGen(1) = "Seleccione Mes" Then
    Me.btnRptMenCur.Enabled = False
    Me.btnVerMencur.Enabled = False
    Exit Sub
End If

If Me.cmbMesGen(0).ListIndex > Me.cmbMesGen(1).ListIndex Then
    MsgBox "El interbalo de meses es erroneo"
    Me.btnRptMenCur.Enabled = False
    Exit Sub
End If
If Me.cmbMesGen(0) = "Seleccione Mes" Or Me.cmbMesGen(1) = "Seleccione Mes" Then
    MsgBox "Debe seleccionar mes de inicio y mes de fin."
    Me.btnRptMenCur.Enabled = False
    Exit Sub
End If

If Me.Cmb_Grado.ListIndex = 0 Or Me.Cmb_Let_Cur.ListIndex = 0 Then
    Me.btnRptMenCur.Enabled = True
    Me.btnVerMencur.Enabled = False
Else
    Me.btnVerMencur.Enabled = True
End If
End Sub

Private Sub Form_Load()
Me.SSTab1.Tab = 0
Me.MSFlexGrid1.Rows = 1
Me.MSFlexGrid1.Cols = 9
Me.SSTab1.TabVisible(1) = False
Call IniGrid(MSFlexGrid1)
Set Rs = New ADODB.Recordset
Rs.CursorLocation = adUseClient
'********* Llena combos ****************
Cmb_Cod_ens.Clear
'If CodPerfil = "#UTP#" Or CodPerfil = "#ADM#" Or CodPerfil = "#GES03#" Then
    Call llenacombo(formMenCur.Cmb_Cod_ens, "codigos_ensenanza ce", "distinct ce.des_ens", "order by ce.ord_ens", conn)
'Else
'    Call llenacombo(formMenCur.Cmb_Cod_ens, "codigos_ensenanza ce, asi_x_cur_prof ap", "distinct ce.des_ens", "where ce.cod_ens = ap.cod_ens and ap.rut_prof ='" & RutGlobal & "' order by ce.ord_ens", conn)
'End If
For i = 0 To 1
    
    With cmbMesGen(i)
        .Clear
        'Me.cmbMesGen.AddItem "Enero"
        'Me.cmbMesGen.AddItem "Febrero"
        .AddItem "Seleccione Mes"
        .AddItem "Marzo"
        .AddItem "Abril"
        .AddItem "Mayo"
        .AddItem "Junio"
        .AddItem "Julio"
        .AddItem "Agosto"
        .AddItem "Septiembre"
        .AddItem "Octubre"
        .AddItem "Noviembre"
        .AddItem "Diciembre"
        .ListIndex = 0
    End With
Next i

End Sub
Public Sub IniGrid(Grilla As String)
    With MSFlexGrid1
        .Clear
        .Rows = 1
        .ColAlignment(3) = 4
        .ColAlignment(4) = 4
        .TextMatrix(0, 0) = "": .ColWidth(0) = 300
        .TextMatrix(0, 1) = "RUT": .ColWidth(1) = 950
        .TextMatrix(0, 2) = "NOMBRE": .ColWidth(2) = 3500
        .TextMatrix(0, 3) = "BECA": .ColWidth(3) = 900
        .TextMatrix(0, 4) = "1/2 BECA": .ColWidth(4) = 900
        .TextMatrix(0, 5) = "$ MENS.": .ColWidth(5) = 800
        .TextMatrix(0, 6) = "DESCTO.": .ColWidth(6) = 800
        .TextMatrix(0, 7) = "CUOTA": .ColWidth(7) = 800
        .TextMatrix(0, 8) = "PAGADO": .ColWidth(8) = 800
        '.TextMatrix(0, 9) = "ACUMUL.": .ColWidth(9) = 800
    End With
End Sub
Public Sub IniGrid_IRP()
    With MSFlexGrid3
        .Clear
        .Rows = 2
        .MergeCells = flexMergeRestrictRows
        
        .MergeRow(0) = True
        .MergeCells = flexMergeRestrictColumns
        .MergeCol(0) = True
        .MergeCol(1) = True
        .MergeCol(2) = True
        .MergeCol(3) = True
        .MergeCol(4) = True

        For i = 0 To Me.MSFlexGrid3.Cols - 1
            If i <> 2 Then .ColAlignment(i) = 4
        Next i
        .TextMatrix(0, 0) = " ": .ColWidth(0) = 300
        .TextMatrix(0, 1) = "RUT": .ColWidth(1) = 950
        .TextMatrix(0, 2) = "NOMBRE": .ColWidth(2) = 3500
        .TextMatrix(0, 3) = "BECA": .ColWidth(3) = 900
        .TextMatrix(0, 4) = "TP": .ColWidth(4) = 300
        .TextMatrix(1, 0) = " ": .ColWidth(0) = 300
        .TextMatrix(1, 1) = "RUT": .ColWidth(1) = 950
        .TextMatrix(1, 2) = "NOMBRE": .ColWidth(2) = 3500
        .TextMatrix(1, 3) = "BECA": .ColWidth(3) = 900
        .TextMatrix(1, 4) = "TP": .ColWidth(4) = 300

        
        .TextMatrix(0, 5) = "MARZO": .ColWidth(5) = 800
        .TextMatrix(0, 6) = "MARZO": .ColWidth(6) = 800
        .TextMatrix(0, 7) = "ABRIL": .ColWidth(7) = 800
        .TextMatrix(0, 8) = "ABRIL": .ColWidth(8) = 800
        .TextMatrix(0, 9) = "MAYO": .ColWidth(9) = 800
        .TextMatrix(0, 10) = "MAYO": .ColWidth(10) = 800
        .TextMatrix(0, 11) = "JUNIO": .ColWidth(11) = 800
        .TextMatrix(0, 12) = "JUNIO": .ColWidth(12) = 800
        .TextMatrix(0, 13) = "JULIO": .ColWidth(13) = 800
        .TextMatrix(0, 14) = "JULIO": .ColWidth(14) = 800
        .TextMatrix(0, 15) = "AGOSTO": .ColWidth(15) = 800
        .TextMatrix(0, 16) = "AGOSTO": .ColWidth(16) = 800
        .TextMatrix(0, 17) = "SEPTIEM.": .ColWidth(17) = 800
        .TextMatrix(0, 18) = "SEPTIEM.": .ColWidth(18) = 800
        .TextMatrix(0, 19) = "OCTUB.": .ColWidth(19) = 800
        .TextMatrix(0, 20) = "OCTUB.": .ColWidth(20) = 800
        .TextMatrix(0, 21) = "NOVIEM.": .ColWidth(21) = 800
        .TextMatrix(0, 22) = "NOVIEM.": .ColWidth(22) = 800
        .TextMatrix(0, 23) = "DICIEM.": .ColWidth(23) = 800
        .TextMatrix(0, 24) = "DICIEM": .ColWidth(24) = 800
        
        For i = 5 To 24
            If (i \ 2) * 2 = i Then
                .TextMatrix(1, i) = "PAGADO": .ColWidth(i) = 800
            Else
                .TextMatrix(1, i) = "REAL": .ColWidth(i) = 800
            End If
        Next i
    End With
End Sub

Public Function Pagado(Ci_alu As String, MesIni As Integer, mesFin As Integer) As Long()
Dim pagadoAux(2) As Long
Dim RsPagado As ADODB.Recordset
Set RsPagado = New ADODB.Recordset
RsPagado.CursorLocation = adUseClient

If MesIni = mesFin Then
    critmes = " and month(a.fecha_venc)='" & mesFin & "'"
    campo_monto = "p.monto"
Else
    campo_monto = "sum(p.monto)"
    critmes = " and month(a.fecha_venc)>='" & MesIni & "' and month(a.fecha_venc)<='" & mesFin & "'"
End If

a = "SELECT " & campo_monto & " FROM  anualidad_x_apo a ,pagos p where a.rut_apo=p.rut_apo and a.id_cuota=p.id_cuota " & critmes & " and p.ci_alu='" & Ci_alu & "' order by p.id_cuota"
RsPagado.Open a, conn

If RsPagado.RecordCount > 0 Then
    pagadoAux(0) = IIf(IsNull(RsPagado(0)), 0, RsPagado(0))
End If
Pagado = pagadoAux
End Function
Public Sub GrillaToRPT(Grilla As MSFlexGrid, NomREp As String, Titulo As String)
'***********************************************************************
'* Guarda matriz en base de datos temporal GesTem.mdb en el directorio *
'* de la aplicacion                                                    *
'***********************************************************************
Call CreaBD(DirAplicacion & "temp.mdb")
Call CreaTabla(DirAplicacion & "temp.mdb", "T", Grilla.Cols & ",10")
Dim dbsTemp As Database
Dim rsTemp As Recordset
Dim CamposInsert, ValoresInsert As String
Set dbsTemp = OpenDatabase(DirAplicacion & "temp.mdb")
'Set rsTemp = dbsTemp.OpenRecordset("T", dbOpenDynaset)

'Grilla.Col = 0
'Grilla.Row = 0
'Grilla.CellAlignment = 4
        
ValoresInsert = ""
CamposInsert = ""
For c = 1 To Grilla.Cols
CamposInsert = CamposInsert & "C" & c & ", "
Next c
CamposInsert = "(" & Mid(CamposInsert, 1, Len(CamposInsert) - 2) & ")"
    For f = Grilla.FixedRows To Grilla.Rows - 1
        ValoresInsert = ""
        
        
        For i = 0 To Grilla.Cols - 1
            If InStr(1, Grilla.TextMatrix(f, i), "'") > 0 Then
                contenido = "'" & Replace(IIf(Trim(Grilla.TextMatrix(f, i)) = "", " ", Grilla.TextMatrix(f, i)), "'", "''") & "', "
            Else
                contenido = "'" & IIf(Trim(Grilla.TextMatrix(f, i)) = "", " ", Grilla.TextMatrix(f, i)) & "', "
            End If
            ValoresInsert = ValoresInsert & contenido
        Next i
        'contenido = "'" & Grilla.TextMatrix(f, i) & "', "
        'ValoresInsert = ValoresInsert & contenido
        
        'For camposNull = 1 To 9 - i
        '    contenido = "'N/D', "
        '    ValoresInsert = ValoresInsert & contenido
        'Next camposNull
        
        ValoresInsert = "(" & Mid(ValoresInsert, 1, Len(ValoresInsert) - 2) & ")"
        dbsTemp.Execute "INSERT INTO " & "T" & CamposInsert & " values" & Trim(ValoresInsert)
    Next f

Set dbsTemp = Nothing
'************ IMPRIMIR *************
    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) = "nombrecolegio = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "direccioncolegio = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacolegio = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\" & NomREp
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "temp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & Titulo & "'"
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    'CrystalReport.ReplaceSelectionFormula ("")
End Sub

Private Sub MSFlexGrid6_Click()

End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
If SSTab1.Tab = 0 Then
Set Rs = New ADODB.Recordset
Rs.CursorLocation = adUseClient
'********* Llena combos ****************
Me.MSFlexGrid1.Rows = 1
Me.MSFlexGrid1.Cols = 9
Call IniGrid(MSFlexGrid1)
Cmb_Cod_ens.Clear
Call llenacombo(formMenCur.Cmb_Cod_ens, "codigos_ensenanza ce", "distinct ce.des_ens", "order by ce.ord_ens", conn)
For i = 0 To 1
    With cmbMesGen(i)
        .Clear
        .AddItem "Seleccione Mes"
        .AddItem "Marzo"
        .AddItem "Abril"
        .AddItem "Mayo"
        .AddItem "Junio"
        .AddItem "Julio"
        .AddItem "Agosto"
        .AddItem "Septiembre"
        .AddItem "Octubre"
        .AddItem "Noviembre"
        .AddItem "Diciembre"
        .ListIndex = 0
    End With
Next i
End If

If Me.SSTab1.Tab = 2 Then
    Me.CmbGrado_IRP.Clear
    Me.CmbGrado_IRP.Enabled = False
    Me.CmbLetCur_IRP.Clear
    Me.CmbLetCur_IRP.Enabled = False
    Me.btnRptIRP.Enabled = False
    Me.btnVerIRP.Enabled = False
    
    Me.MSFlexGrid3.Rows = 2
    Me.MSFlexGrid3.Cols = 25
    Call IniGrid_IRP
    Set Rs = New ADODB.Recordset
    Rs.CursorLocation = adUseClient
    '********* Llena combos ****************
    CmbCodEns_IRP.Clear
    Call llenacombo(Me.CmbCodEns_IRP, "codigos_ensenanza ce", "distinct ce.des_ens", "order by ce.ord_ens", conn)
End If
End Sub

