VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "MSCOMCTL.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_InformesFnza 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   12480
   ClientLeft      =   -150
   ClientTop       =   240
   ClientWidth     =   22110
   Icon            =   "Form_InformesFnza.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   12480
   ScaleWidth      =   22110
   Begin VB.Frame Frame_PCursos_Anual 
      Caption         =   "Estados de Pago por 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          =   4815
      Left            =   120
      TabIndex        =   0
      Top             =   7560
      Width           =   7335
      Begin VB.Frame Frame1 
         Caption         =   "Tipo de Reporte"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   2655
         Left            =   1800
         TabIndex        =   3
         Top             =   1080
         Width           =   1815
         Begin VB.OptionButton Option1 
            Caption         =   "MINEDUC Libre Dispocición"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   615
            Index           =   3
            Left            =   120
            TabIndex        =   122
            Top             =   960
            Width           =   1575
         End
         Begin VB.CheckBox check_incluir_informe_cuota_inicial 
            Caption         =   "Anexo Cuota Inicial"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   116
            Top             =   2160
            Width           =   1575
         End
         Begin VB.OptionButton Option1 
            Caption         =   "MINEDUC Socio-Economica"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   0
            Left            =   120
            TabIndex        =   6
            Top             =   600
            Value           =   -1  'True
            Width           =   1575
         End
         Begin VB.OptionButton Option1 
            Caption         =   "Colegio"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   120
            TabIndex        =   5
            Top             =   240
            Width           =   1575
         End
         Begin VB.OptionButton Option1 
            Caption         =   "Finanzas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   2
            Left            =   120
            TabIndex        =   4
            Top             =   600
            Visible         =   0   'False
            Width           =   1575
         End
      End
      Begin VB.Frame Frame7 
         Caption         =   "Resumenes"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   2655
         Left            =   5400
         TabIndex        =   124
         Top             =   1080
         Width           =   1815
         Begin VB.OptionButton Option2 
            Caption         =   "Estadisticas Comportamiento"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   3
            Left            =   120
            TabIndex        =   129
            Top             =   1680
            Width           =   1455
         End
         Begin VB.OptionButton Option2 
            Caption         =   "Estadisticas Pagos"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   2
            Left            =   120
            TabIndex        =   128
            Top             =   1200
            Width           =   1455
         End
         Begin VB.OptionButton Option2 
            Caption         =   "Morosidad Colegio"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   1
            Left            =   120
            TabIndex        =   127
            Top             =   720
            Width           =   1455
         End
         Begin VB.OptionButton Option2 
            Caption         =   "Morosidad por Curso"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   0
            Left            =   120
            TabIndex        =   126
            Top             =   240
            Width           =   1455
         End
         Begin VB.CommandButton Command1 
            Caption         =   "Generar Resumen"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   125
            Top             =   2160
            Width           =   1575
         End
      End
      Begin VB.CommandButton btn_can_cursos 
         Caption         =   "Cerrar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5520
         TabIndex        =   123
         Top             =   480
         Width           =   1575
      End
      Begin VB.ComboBox cmb_modalidad 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1560
         TabIndex        =   13
         Top             =   480
         Width           =   3735
      End
      Begin VB.ListBox lst_cursos 
         Height          =   2535
         Left            =   120
         Style           =   1  'Checkbox
         TabIndex        =   12
         Top             =   1200
         Width           =   1575
      End
      Begin VB.CheckBox chk_todos_cursos 
         Caption         =   "Todos los cursos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   11
         Top             =   3720
         Width           =   1695
      End
      Begin VB.ComboBox Combo1 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   120
         Style           =   2  'Dropdown List
         TabIndex        =   7
         Top             =   480
         Width           =   1335
      End
      Begin VB.Frame Frame_Prog 
         Height          =   615
         Left            =   120
         TabIndex        =   1
         Top             =   4080
         Width           =   7095
         Begin VB.Label Label2 
            Alignment       =   2  'Center
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FF0000&
            Height          =   255
            Left            =   120
            TabIndex        =   2
            Top             =   240
            Width           =   6855
         End
      End
      Begin VB.Frame Frame5 
         Height          =   2655
         Left            =   3600
         TabIndex        =   8
         Top             =   1080
         Width           =   1695
         Begin VB.CommandButton btn_rep_cursos 
            Caption         =   "Generar Reporte"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   68
            Top             =   2160
            Width           =   1455
         End
         Begin VB.OptionButton opt_destino_cartola 
            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
            Index           =   0
            Left            =   240
            TabIndex        =   10
            Top             =   600
            Value           =   -1  'True
            Width           =   1095
         End
         Begin VB.OptionButton opt_destino_cartola 
            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
            Index           =   1
            Left            =   240
            TabIndex        =   9
            Top             =   1320
            Width           =   1095
         End
      End
      Begin VB.Label Label8 
         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
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   1560
         TabIndex        =   16
         Top             =   240
         Width           =   1695
      End
      Begin VB.Label Label7 
         Caption         =   "Cursos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   255
         Left            =   120
         TabIndex        =   15
         Top             =   960
         Width           =   855
      End
      Begin VB.Label Label1 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   120
         TabIndex        =   14
         Top             =   240
         Width           =   735
      End
   End
   Begin VB.Frame Frame_ConsBol 
      Caption         =   "Consulta de Boletas Emitidas"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   7335
      Left            =   120
      TabIndex        =   69
      Top             =   120
      Width           =   12615
      Begin VB.Frame Frame8 
         Caption         =   "Imprimir"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   3015
         Left            =   10680
         TabIndex        =   131
         Top             =   240
         Width           =   1815
         Begin VB.CommandButton btn_impri_boletas 
            Caption         =   "Imprimir"
            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          =   855
            Left            =   120
            Picture         =   "Form_InformesFnza.frx":2A8B2
            Style           =   1  'Graphical
            TabIndex        =   136
            Top             =   1920
            Width           =   1455
         End
         Begin VB.OptionButton opt_nulas 
            Caption         =   "Nulas"
            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        =   135
            Top             =   1560
            Width           =   1095
         End
         Begin VB.OptionButton opt_noemitidas 
            Caption         =   "No Emitidas"
            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        =   134
            Top             =   1080
            Width           =   1215
         End
         Begin VB.OptionButton opt_emitidas 
            Caption         =   "Emitidas"
            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        =   133
            Top             =   600
            Width           =   1215
         End
         Begin VB.OptionButton opt_todas 
            Caption         =   "Todas"
            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        =   132
            Top             =   240
            Value           =   -1  'True
            Width           =   1455
         End
      End
      Begin VB.Frame Frm_CambFolioBlta 
         Caption         =   "Cambiar Folio Boleta"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1575
         Left            =   4080
         TabIndex        =   117
         Top             =   4560
         Visible         =   0   'False
         Width           =   3255
         Begin VB.TextBox Text_FolioBlta 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   420
            Left            =   1320
            TabIndex        =   120
            Top             =   360
            Width           =   1575
         End
         Begin VB.CommandButton Btn_CamFolioBlta 
            Caption         =   "Cambiar Folio"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   495
            Left            =   240
            TabIndex        =   119
            Top             =   960
            Width           =   1215
         End
         Begin VB.CommandButton Command3 
            Caption         =   "Cancelar"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   495
            Left            =   1800
            TabIndex        =   118
            Top             =   960
            Width           =   1215
         End
         Begin VB.Label Label22 
            Caption         =   "Folio"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   12
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   480
            TabIndex        =   121
            Top             =   480
            Width           =   855
         End
      End
      Begin VB.Frame Frame_Run 
         Caption         =   "Por Rut"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1215
         Left            =   7200
         TabIndex        =   84
         Top             =   240
         Width           =   3375
         Begin VB.TextBox TextRun 
            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            =   1800
            TabIndex        =   114
            Top             =   720
            Width           =   1455
         End
         Begin VB.OptionButton OptionApo 
            Caption         =   "del Apoderado"
            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          =   195
            Left            =   360
            TabIndex        =   112
            Top             =   600
            Value           =   -1  'True
            Width           =   1695
         End
         Begin VB.CheckBox Chk_Run 
            Caption         =   "Usar opción"
            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        =   111
            Top             =   240
            Width           =   1215
         End
         Begin VB.OptionButton OptionAlu 
            Caption         =   "del Alumno"
            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          =   255
            Left            =   360
            TabIndex        =   113
            Top             =   840
            Width           =   1335
         End
      End
      Begin MSComctlLib.ProgressBar ProgressBar_bol 
         Height          =   255
         Left            =   2160
         TabIndex        =   101
         Top             =   6840
         Width           =   10335
         _ExtentX        =   18230
         _ExtentY        =   450
         _Version        =   393216
         Appearance      =   1
         Min             =   1e-4
         Scrolling       =   1
      End
      Begin VB.Frame Frame_Rangos 
         Caption         =   "Por Folios"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   855
         Left            =   120
         TabIndex        =   95
         Top             =   1080
         Width           =   4935
         Begin VB.CheckBox Chk_Folio 
            Caption         =   "Usar opción"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   120
            TabIndex        =   109
            Top             =   240
            Width           =   1215
         End
         Begin VB.TextBox Txt_FolioFIN_Cons 
            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            =   3360
            MaxLength       =   8
            TabIndex        =   97
            Text            =   "0"
            Top             =   480
            Width           =   1455
         End
         Begin VB.TextBox Txt_FolioINI_Cons 
            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            =   1320
            MaxLength       =   8
            TabIndex        =   96
            Text            =   "0"
            Top             =   480
            Width           =   1455
         End
         Begin VB.Label Label15 
            Caption         =   "Desde"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   720
            TabIndex        =   98
            Top             =   480
            Width           =   615
         End
         Begin VB.Label Label18 
            Caption         =   "Hasta"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   2880
            TabIndex        =   99
            Top             =   480
            Width           =   495
         End
      End
      Begin VB.Frame Frame_PorMontos 
         Caption         =   "Por Montos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   855
         Left            =   120
         TabIndex        =   90
         Top             =   2040
         Width           =   4935
         Begin VB.CheckBox Chk_Monto 
            Caption         =   "Usar opción"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   120
            TabIndex        =   108
            Top             =   240
            Width           =   1215
         End
         Begin VB.TextBox Txt_Monto_Ini 
            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            =   1320
            MaxLength       =   7
            TabIndex        =   92
            Text            =   "0"
            Top             =   480
            Width           =   1455
         End
         Begin VB.TextBox Txt_Monto_Fin 
            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            =   3360
            MaxLength       =   7
            TabIndex        =   91
            Text            =   "0"
            Top             =   480
            Width           =   1455
         End
         Begin VB.Label Label13 
            Caption         =   "Desde"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   720
            TabIndex        =   94
            Top             =   480
            Width           =   615
         End
         Begin VB.Label Label12 
            Caption         =   "Hasta"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   2880
            TabIndex        =   93
            Top             =   480
            Width           =   495
         End
      End
      Begin VB.Frame Frame_Fechas 
         Caption         =   "Por Fechas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   855
         Left            =   120
         TabIndex        =   85
         Top             =   3000
         Width           =   4935
         Begin VB.CheckBox Chk_Fecha 
            Caption         =   "Usar opción"
            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        =   110
            Top             =   240
            Width           =   1215
         End
         Begin MSComCtl2.DTPicker Dtp_Fec_Ini 
            Height          =   300
            Left            =   1320
            TabIndex        =   86
            Top             =   480
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   529
            _Version        =   393216
            Enabled         =   0   'False
            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
            Format          =   49807361
            CurrentDate     =   38353
            MinDate         =   38292
         End
         Begin MSComCtl2.DTPicker Dtp_Fec_Fin 
            Height          =   300
            Left            =   3480
            TabIndex        =   87
            Top             =   480
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   529
            _Version        =   393216
            Enabled         =   0   'False
            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
            Format          =   49807361
            CurrentDate     =   38353
            MinDate         =   38292
         End
         Begin VB.Label Label11 
            Caption         =   "Desde"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   720
            TabIndex        =   89
            Top             =   480
            Width           =   855
         End
         Begin VB.Label Label10 
            Caption         =   "Hasta"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   2880
            TabIndex        =   88
            Top             =   480
            Width           =   495
         End
      End
      Begin VB.Frame Frame_BuscarPor 
         Caption         =   "Buscar por"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1815
         Left            =   5160
         TabIndex        =   76
         Top             =   2040
         Width           =   1935
         Begin VB.OptionButton Opt_TipoBus 
            Caption         =   "Fecha Emisión"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   120
            TabIndex        =   80
            Top             =   360
            Width           =   1335
         End
         Begin VB.OptionButton Opt_TipoBus 
            Caption         =   "Fecha Pago Cuota"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   2
            Left            =   120
            TabIndex        =   79
            Top             =   720
            Value           =   -1  'True
            Width           =   1695
         End
         Begin VB.OptionButton Opt_TipoBus 
            Caption         =   "Fecha Venc. Cuota"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   3
            Left            =   120
            TabIndex        =   78
            Top             =   1080
            Width           =   1695
         End
         Begin VB.OptionButton Opt_TipoBus 
            Caption         =   "Fecha Anulación"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   4
            Left            =   120
            TabIndex        =   77
            Top             =   1440
            Width           =   1575
         End
      End
      Begin VB.Frame Frame_Tipo_Colegio 
         Height          =   735
         Left            =   120
         TabIndex        =   75
         Top             =   240
         Width           =   4935
         Begin MSComctlLib.ImageCombo Cmb_Colegios 
            Height          =   345
            Left            =   840
            TabIndex        =   102
            Top             =   240
            Width           =   3975
            _ExtentX        =   7011
            _ExtentY        =   609
            _Version        =   393216
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Locked          =   -1  'True
            Text            =   "Cmb_Colegios"
         End
         Begin MSComctlLib.ImageCombo Cmb_Agno 
            Height          =   345
            Left            =   3840
            TabIndex        =   104
            Top             =   240
            Visible         =   0   'False
            Width           =   975
            _ExtentX        =   1720
            _ExtentY        =   609
            _Version        =   393216
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Locked          =   -1  'True
            Text            =   "Cmb_Agno"
         End
         Begin VB.Label Label21 
            Caption         =   "Año"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   3480
            TabIndex        =   105
            Top             =   240
            Visible         =   0   'False
            Width           =   495
         End
         Begin VB.Label Label20 
            Caption         =   "Colegio"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   103
            Top             =   240
            Width           =   735
         End
      End
      Begin VB.CommandButton Btn_Cons_Bol 
         Caption         =   "Consultar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   9120
         Picture         =   "Form_InformesFnza.frx":2AE0F
         Style           =   1  'Graphical
         TabIndex        =   72
         Top             =   1560
         Width           =   1455
      End
      Begin VB.CommandButton Btn_Cancelar 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9120
         TabIndex        =   71
         Top             =   2640
         Width           =   1455
      End
      Begin VB.ListBox Lst_Campos_Grilla 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1980
         ItemData        =   "Form_InformesFnza.frx":2B498
         Left            =   7200
         List            =   "Form_InformesFnza.frx":2B49A
         Style           =   1  'Checkbox
         TabIndex        =   70
         Top             =   1800
         Width           =   1815
      End
      Begin VB.Frame Frame_Grilla_Cons 
         Caption         =   "Resultados de la Consulta"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   2775
         Left            =   120
         TabIndex        =   73
         Top             =   3960
         Width           =   12375
         Begin MSFlexGridLib.MSFlexGrid Grd_Cons 
            Height          =   2415
            Left            =   120
            TabIndex        =   74
            TabStop         =   0   'False
            Top             =   240
            Width           =   12135
            _ExtentX        =   21405
            _ExtentY        =   4260
            _Version        =   393216
            Cols            =   16
            FocusRect       =   0
            FillStyle       =   1
            SelectionMode   =   1
            FormatString    =   $"Form_InformesFnza.frx":2B49C
            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
      End
      Begin VB.Frame Frame_Opciones 
         Caption         =   "Opciones"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1695
         Left            =   5160
         TabIndex        =   81
         Top             =   240
         Width           =   1935
         Begin MSComctlLib.ImageCombo Cmb_Estado_Bol 
            Height          =   345
            Left            =   120
            TabIndex        =   107
            Top             =   1200
            Width           =   1695
            _ExtentX        =   2990
            _ExtentY        =   609
            _Version        =   393216
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Locked          =   -1  'True
            Text            =   "Cmb_Estado_Bol"
         End
         Begin MSComctlLib.ImageCombo Cmb_Procedencia 
            Height          =   345
            Left            =   120
            TabIndex        =   106
            Top             =   480
            Width           =   1695
            _ExtentX        =   2990
            _ExtentY        =   609
            _Version        =   393216
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Locked          =   -1  'True
            Text            =   "Cmb_Procedencia"
         End
         Begin VB.Label Label9 
            Caption         =   "Procedencia"
            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        =   83
            Top             =   240
            Width           =   1335
         End
         Begin VB.Label Label6 
            Caption         =   "Estado"
            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        =   82
            Top             =   960
            Width           =   1335
         End
      End
      Begin VB.Label Label23 
         Caption         =   "Mostrar Campos:"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   255
         Left            =   7200
         TabIndex        =   130
         Top             =   1560
         Width           =   1455
      End
      Begin VB.Label Num_Fol_Fal 
         Caption         =   "0"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1680
         TabIndex        =   115
         Top             =   6840
         Width           =   495
      End
      Begin VB.Label Lbl_FolFal 
         Caption         =   "Folios Faltantes"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   100
         Top             =   6840
         Width           =   1335
      End
   End
   Begin VB.Frame Frame_Folios_Notrat 
      Caption         =   "Folios No tratados por el Sistema"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1935
      Left            =   11880
      TabIndex        =   57
      Top             =   7560
      Width           =   4215
      Begin VB.Frame Frame6 
         Height          =   975
         Left            =   120
         TabIndex        =   65
         Top             =   840
         Width           =   1455
         Begin VB.OptionButton Opt_Destino_FoliosNotrat 
            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
            Index           =   1
            Left            =   120
            TabIndex        =   67
            Top             =   600
            Width           =   1215
         End
         Begin VB.OptionButton Opt_Destino_FoliosNotrat 
            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
            Index           =   0
            Left            =   120
            TabIndex        =   66
            Top             =   240
            Value           =   -1  'True
            Width           =   1215
         End
      End
      Begin VB.CommandButton BTN_Genera_Reporte_Folios_faltantes 
         Caption         =   "Generar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   1680
         Picture         =   "Form_InformesFnza.frx":2B551
         Style           =   1  'Graphical
         TabIndex        =   59
         Top             =   960
         Width           =   1095
      End
      Begin VB.CommandButton BTN_Cancelar_Folios 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   2880
         Picture         =   "Form_InformesFnza.frx":2B936
         Style           =   1  'Graphical
         TabIndex        =   58
         Top             =   960
         Width           =   1215
      End
      Begin MSComctlLib.ImageCombo IC4 
         Height          =   345
         Left            =   960
         TabIndex        =   60
         Top             =   360
         Width           =   3135
         _ExtentX        =   5530
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "ImageCombo3"
      End
      Begin VB.Label Label5 
         Caption         =   "Colegio"
         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        =   61
         Top             =   360
         Width           =   855
      End
   End
   Begin VB.Frame Frame_CredyAbonos 
      Caption         =   "Informe de Créditos y Abonos"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   7095
      Left            =   12960
      TabIndex        =   17
      Top             =   120
      Width           =   10935
      Begin MSHierarchicalFlexGridLib.MSHFlexGrid Grd_Datos_CyA 
         Height          =   4095
         Index           =   0
         Left            =   120
         TabIndex        =   35
         Top             =   2160
         Width           =   10695
         _ExtentX        =   18865
         _ExtentY        =   7223
         _Version        =   393216
         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
         _NumberOfBands  =   1
         _Band(0).Cols   =   2
      End
      Begin VB.Frame Frame_Establecimiento 
         Caption         =   "Establecimiento"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1215
         Left            =   120
         TabIndex        =   18
         Top             =   240
         Width           =   4935
         Begin VB.ComboBox Cmb_Colegio_Cup 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   2280
            Style           =   2  'Dropdown List
            TabIndex        =   25
            Top             =   240
            Width           =   2535
         End
         Begin VB.ComboBox Cmb_Part_Cup 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   2280
            Style           =   2  'Dropdown List
            TabIndex        =   24
            Top             =   720
            Width           =   2535
         End
         Begin VB.CheckBox Chk_Empresa 
            Caption         =   "Empresa oficial"
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   0
            Left            =   120
            Style           =   1  'Graphical
            TabIndex        =   23
            TabStop         =   0   'False
            Top             =   240
            Width           =   1935
         End
         Begin VB.TextBox Txt_CodConvBci 
            Alignment       =   1  'Right Justify
            Height          =   285
            Left            =   3600
            Locked          =   -1  'True
            TabIndex        =   22
            Top             =   240
            Width           =   735
         End
         Begin VB.CheckBox Chk_Empresa 
            Caption         =   "Empresa Alternativa"
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   1
            Left            =   120
            Style           =   1  'Graphical
            TabIndex        =   21
            TabStop         =   0   'False
            Top             =   720
            Width           =   1935
         End
         Begin VB.TextBox Txt_Cod_Pac 
            Alignment       =   1  'Right Justify
            Height          =   285
            Left            =   2880
            Locked          =   -1  'True
            TabIndex        =   20
            Top             =   720
            Width           =   735
         End
         Begin VB.TextBox Txt_CodConvBci_Part 
            Alignment       =   1  'Right Justify
            Height          =   285
            Left            =   3720
            Locked          =   -1  'True
            TabIndex        =   19
            Top             =   750
            Width           =   735
         End
      End
      Begin VB.Frame Frame_Criterios 
         Caption         =   "Periodo"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1215
         Left            =   5160
         TabIndex        =   26
         Top             =   240
         Width           =   5655
         Begin VB.ComboBox Cmb_Mes 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            ItemData        =   "Form_InformesFnza.frx":2BC9E
            Left            =   1320
            List            =   "Form_InformesFnza.frx":2BCC9
            Style           =   2  'Dropdown List
            TabIndex        =   30
            Top             =   240
            Width           =   2055
         End
         Begin VB.ComboBox Cmb_del_dia 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            ItemData        =   "Form_InformesFnza.frx":2BD32
            Left            =   1320
            List            =   "Form_InformesFnza.frx":2BD96
            Style           =   2  'Dropdown List
            TabIndex        =   29
            Top             =   600
            Width           =   735
         End
         Begin VB.ComboBox Cmb_al_dia 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            ItemData        =   "Form_InformesFnza.frx":2BE16
            Left            =   2640
            List            =   "Form_InformesFnza.frx":2BE7A
            Style           =   2  'Dropdown List
            TabIndex        =   28
            Top             =   600
            Width           =   735
         End
         Begin VB.ComboBox Cmb_anho 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            ItemData        =   "Form_InformesFnza.frx":2BEFA
            Left            =   3840
            List            =   "Form_InformesFnza.frx":2BEFC
            Style           =   2  'Dropdown List
            TabIndex        =   27
            Top             =   240
            Width           =   855
         End
         Begin VB.Label Label19 
            Caption         =   "Año"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   3480
            TabIndex        =   34
            Top             =   240
            Width           =   615
         End
         Begin VB.Label Label17 
            Caption         =   "Al"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   2280
            TabIndex        =   33
            Top             =   600
            Width           =   375
         End
         Begin VB.Label Label16 
            Caption         =   "Del"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   960
            TabIndex        =   32
            Top             =   600
            Width           =   375
         End
         Begin VB.Label Label14 
            Caption         =   "Mes de Pago"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   31
            Top             =   240
            Width           =   1335
         End
      End
      Begin VB.Frame Frame2 
         Height          =   615
         Left            =   6000
         TabIndex        =   36
         Top             =   6360
         Width           =   4815
         Begin VB.CommandButton Btn_Gen_Rep_CyA 
            Caption         =   "Generar Reporte"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   3360
            TabIndex        =   40
            Top             =   160
            Width           =   1455
         End
         Begin VB.OptionButton opt_destino_CyA 
            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
            Index           =   0
            Left            =   360
            TabIndex        =   38
            Top             =   260
            Width           =   1095
         End
         Begin VB.OptionButton opt_destino_CyA 
            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
            Index           =   1
            Left            =   1800
            TabIndex        =   37
            Top             =   260
            Width           =   1095
         End
      End
      Begin VB.Frame Frame_Bot_CyA 
         Height          =   615
         Left            =   120
         TabIndex        =   39
         Top             =   1440
         Width           =   4935
         Begin VB.OptionButton Opt_TipoCyA 
            Caption         =   "Simple"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   2760
            TabIndex        =   42
            Top             =   240
            Width           =   1455
         End
         Begin VB.OptionButton Opt_TipoCyA 
            Caption         =   "Detallado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   720
            TabIndex        =   41
            Top             =   240
            Visible         =   0   'False
            Width           =   1455
         End
      End
      Begin VB.Frame Frame3 
         Height          =   615
         Left            =   5160
         TabIndex        =   43
         Top             =   1440
         Width           =   5655
         Begin VB.CommandButton Btn_CyA_Cancelar 
            Caption         =   "Cancelar"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   3840
            TabIndex        =   46
            Top             =   120
            Width           =   1455
         End
         Begin VB.CommandButton Btn_CyA_Generar 
            Caption         =   "Consultar"
            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        =   45
            Top             =   160
            Width           =   1455
         End
         Begin VB.CommandButton btn_CyA_Limpiar 
            Caption         =   "Limpiar"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   2160
            TabIndex        =   44
            Top             =   160
            Width           =   1455
         End
      End
      Begin MSHierarchicalFlexGridLib.MSHFlexGrid Grd_Datos_CyA 
         Height          =   4095
         Index           =   1
         Left            =   120
         TabIndex        =   47
         Top             =   2160
         Width           =   10695
         _ExtentX        =   18865
         _ExtentY        =   7223
         _Version        =   393216
         _NumberOfBands  =   1
         _Band(0).Cols   =   2
      End
   End
   Begin VB.Frame Frame_Libro_Boletas 
      Caption         =   "Libro de Boletas"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2535
      Left            =   7560
      TabIndex        =   48
      Top             =   7560
      Width           =   4215
      Begin VB.Frame Frame4 
         Height          =   975
         Left            =   120
         TabIndex        =   62
         Top             =   1440
         Width           =   1455
         Begin VB.OptionButton Opt_Destino_LibroBol 
            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
            Index           =   1
            Left            =   120
            TabIndex        =   64
            Top             =   600
            Width           =   1215
         End
         Begin VB.OptionButton Opt_Destino_LibroBol 
            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
            Index           =   0
            Left            =   120
            TabIndex        =   63
            Top             =   240
            Value           =   -1  'True
            Width           =   1215
         End
      End
      Begin VB.CommandButton btn_lib_bol 
         Caption         =   "Generar"
         Default         =   -1  'True
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   1680
         Picture         =   "Form_InformesFnza.frx":2BEFE
         Style           =   1  'Graphical
         TabIndex        =   50
         Top             =   1560
         Width           =   1095
      End
      Begin VB.CommandButton Btn_Cancelar_Libro_Boletas 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   2880
         Picture         =   "Form_InformesFnza.frx":2C2E3
         Style           =   1  'Graphical
         TabIndex        =   49
         Top             =   1560
         Width           =   1215
      End
      Begin MSComctlLib.ImageCombo IC3 
         Height          =   345
         Left            =   960
         TabIndex        =   51
         Top             =   960
         Width           =   3135
         _ExtentX        =   5530
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "ImageCombo3"
      End
      Begin MSComctlLib.ImageCombo IC2 
         Height          =   345
         Left            =   960
         TabIndex        =   52
         Top             =   480
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "ImageCombo2"
      End
      Begin MSComctlLib.ImageCombo IC1 
         Height          =   345
         Left            =   3120
         TabIndex        =   53
         Top             =   480
         Width           =   975
         _ExtentX        =   1720
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "ImageCombo1"
      End
      Begin VB.Label lab_agno 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2640
         TabIndex        =   56
         Top             =   480
         Width           =   495
      End
      Begin VB.Label Label4 
         Caption         =   "Mes"
         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        =   55
         Top             =   480
         Width           =   735
      End
      Begin VB.Label Label3 
         Caption         =   "Colegio"
         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        =   54
         Top             =   1080
         Width           =   855
      End
   End
End
Attribute VB_Name = "Form_InformesFnza"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 Dim Anuevocurso(), AColegios(), APartic()
 Dim Particular As Boolean
 Dim IndAColegios As Long, IndAPartic As Integer
 Dim FilaCyA As Long
 Dim NomEmpresa, CodEmpresa As String, NgrillaCyA As Integer
 Dim TipoAlu As String
 Dim RsCya As ADODB.Recordset
 
 Dim BotonCancelar As Integer
 
 'Dim REC As ADODB.Recordset
 'Dim REC_cancelar As ADODB.Recordset

Private Sub Btn_CamFolioBlta_Click()
    Dim accion_detalle As String
    Dim MyRow As Integer
    Dim FolioActual As Long
    Dim FolioNuevo As Long
    Dim FolioBlta As Long
    Dim BLT As ADODB.Recordset
    Dim REC As ADODB.Recordset
    Dim CMD As ADODB.Command
    Dim QRY As String
    Dim Affected As Integer
    
    'MsgBox "STOP, MARIO, STOP!", vbOKOnly + vbCritical, "DEBUG"
    MyRow = Grd_Cons.Row
    FolioActual = val(Grd_Cons.TextMatrix(MyRow, 1))
    FolioNuevo = val(Text_FolioBlta.Text)
    
    If Not (FolioActual = FolioNuevo) Then
        FolioBlta = val(Grd_Cons.TextMatrix(MyRow, 13))
        Set BLT = New ADODB.Recordset
        QRY = "Select * From fnza_boletas Where folio_blta=" & FolioBlta & " AND folio_blta_fisico=" & FolioActual & ";"
        BLT.Open QRY, conn
        If BLT.RecordCount > 0 Then
            BLT.MoveFirst
            Set REC = New ADODB.Recordset
            QRY = "SELECT * FROM fnza_boletas WHERE folio_blta_fisico=" & FolioNuevo & ";"
            REC.Open QRY, conn
            If REC.RecordCount = 0 Then
                Set CMD = New ADODB.Command
                CMD.ActiveConnection = conn
                CMD.CommandType = adCmdText
                ' Actualizacion boleta 2004
                If BLT("estado_blta") = "2004" Then
                    QRY = "UPDATE gescol2004.pagos SET folio='" & FolioNuevo & "' WHERE folio+0=" & FolioActual & ";"
                    CMD.CommandText = QRY
                    CMD.Execute Affected
                    QRY = "UPDATE gescol2004.bol_apo_x_alu SET folio='" & FolioNuevo & "' WHERE folio+0=" & FolioActual & ";"
                    CMD.CommandText = QRY
                    CMD.Execute Affected
                    If Not (Affected > 0) Then
                        MsgBox "No se logro actualizar la información del año 2004. La operación ah sido cancelada", vbOKOnly + vbCritical, "FALLO DE ACTUALIZACION"
                        Frm_CambFolioBlta.Visible = False
                        Frame_Grilla_Cons.Enabled = True
                        Btn_Cons_Bol.Enabled = True
                        Exit Sub
                    End If
                End If
                ' Actualización libro de boletas
                QRY = "UPDATE fnza_boletas SET folio_blta_fisico=" & FolioNuevo & " WHERE folio_blta=" & FolioBlta & " AND folio_blta_fisico=" & FolioActual & ";"
                CMD.CommandText = QRY
                CMD.Execute Affected
                If Affected > 0 Then
                    accion_detalle = "La boleta con folio " & FolioActual & " a cambiado a " _
                                   & FolioNuevo
                    Call Inserta_Vitacora_Finanza(Grd_Cons.TextMatrix(Grd_Cons.Row, 5), _
                    Grd_Cons.TextMatrix(Grd_Cons.Row, 4), "Consulta boletas cambio de folio físico", _
                    accion_detalle, 0, 0)
                    Grd_Cons.TextMatrix(MyRow, 1) = FolioNuevo
                    Grd_Cons.Refresh
                Else
                    MsgBox "Ocurrio una falla al actualizar folio de la boleta.", vbCritical, "ALERTA DE ANOMALIA"
                End If
            Else
                MsgBox "El Folio ingresado ya existe.", vbOKOnly + vbCritical, "FOLIO REPETIDO"
            End If
            REC.Close
        End If
        BLT.Close
    End If
    Frm_CambFolioBlta.Visible = False
    Frame_Grilla_Cons.Enabled = True
    Btn_Cons_Bol.Enabled = True
End Sub

Private Sub btn_can_cursos_Click()
    Unload Me
End Sub

Private Sub btn_Cancelar_Click()
    'REC_cancelar.MoveLast
    'REC_cancelar.Close
    'Unload Me
    'Exit Sub
    
    BotonCancelar = 1
    
End Sub

Private Sub BTN_Cancelar_Folios_Click()
    Unload Me
End Sub

Private Sub Btn_Cancelar_Libro_Boletas_Click()
    Unload Me
End Sub

Private Sub Btn_Cons_Bol_Click()
'On Error GoTo Controlerror

If (Chk_Folio.Value <> 0 Or Chk_Monto.Value <> 0 Or Chk_Fecha.Value <> 0 Or Chk_Run.Value <> 0) Then

    Dim Fecha As Boolean
    Dim Run As Boolean
    Dim monto As Boolean
    Dim Folio As Boolean
    Dim REC_cancelar As ADODB.Recordset
    Dim QRY_P1 As String
    Dim QRY_P2 As String
    Dim QRY_P3 As String
    Dim QRY_TT As String
    Dim Wh_Fecha As String
    Dim Wh_Run As String
    Dim Wh_Monto As String
    Dim Wh_Folio As String
    Dim Wh_Colegio As String
    Dim Wh_Agno As String
    Dim Wh_Procedencia As String
    Dim Wh_Estado As String
    Dim CountFolio As Long
    Dim Fol_Fal As Long
    
    BotonCancelar = 0
    btn_impri_boletas.Enabled = False
    
    Fol_Fal = 0
    ' CONSTRUYO LAS WHERE CLAUSES
    Wh_Folio = IIf((Chk_Folio.Value = 1), " AND fb.folio_blta_fisico>=" & val(Txt_FolioINI_Cons.Text) & " AND fb.folio_blta_fisico<=" & val(Txt_FolioFIN_Cons.Text) & " ", "")
    Wh_Monto = IIf((Chk_Monto.Value = 1), " AND fb.monto_blta>=" & val(Txt_Monto_Ini.Text) & " AND fb.monto_blta<=" & val(Txt_Monto_Fin.Text) & " ", "")
    
    If Chk_Fecha.Value = 1 Then
        If Opt_TipoBus(1) Then
            Wh_Fecha = " AND fb.fecha_blta>='" & Format(Dtp_Fec_Ini.Value, "yyyy-mm-dd") & "' AND fb.fecha_blta<='" & Format(Dtp_Fec_Fin.Value, "yyyy-mm-dd") & "' "
        ElseIf Opt_TipoBus(2) Then
            Wh_Fecha = " AND fb.fecha_pago>='" & Format(Dtp_Fec_Ini.Value, "yyyy-mm-dd") & "' AND fb.fecha_pago<='" & Format(Dtp_Fec_Fin.Value, "yyyy-mm-dd") & "' "
        ElseIf Opt_TipoBus(3) Then
            Wh_Fecha = " AND venc_ini<='" & Format(Dtp_Fec_Ini.Value, "yyyy-mm-dd") & "' AND venc_fin>='" & Format(Dtp_Fec_Fin.Value, "yyyy-mm-dd") & "' "
        ElseIf Opt_TipoBus(4) Then
            Wh_Fecha = " AND fecha_blta>='" & Format(Dtp_Fec_Ini.Value, "yyyy-mm-dd") & "' AND fecha_blta<='" & Format(Dtp_Fec_Fin.Value, "yyyy-mm-dd") & "' AND estado_blta='nula' "
        End If
    Else
        Wh_Fecha = ""
    End If
    
    If Chk_Run.Value = 1 Then
        If OptionAlu.Value Then
            Wh_Run = " AND fb.run_alu='" & TextRun.Text & "' "
        ElseIf OptionApo.Value Then
            Wh_Run = " AND fb.run_apo='" & TextRun.Text & "' "
        Else
            ' Error asi que ninguno.
            Wh_Run = ""
        End If
    Else
        ' Ninguno
        Wh_Run = ""
    End If
    
    Wh_Colegio = IIf((Cmb_Colegios.SelectedItem.Key = "all"), "", " AND fb.colegio='" & Cmb_Colegios.SelectedItem.Key & "' ")
    
    Wh_Agno = " AND (YEAR(fb.fecha_blta)=" & Cmb_Agno.SelectedItem.Text & " OR YEAR(fb.fecha_pago)=" & Cmb_Agno.SelectedItem.Text & ") "
    Wh_Procedencia = IIf(Cmb_Procedencia.SelectedItem.Key = "all", "", " AND proc_pago='" & Cmb_Procedencia.SelectedItem.Key & "' ")
    Wh_Estado = IIf((Cmb_Estado_Bol.SelectedItem.Key = "all"), "", IIf((Cmb_Estado_Bol.SelectedItem.Key = "2oo4"), " AND fb.estado_blta='2004' ", " AND fb.estado_blta='" & Cmb_Estado_Bol.SelectedItem.Key & "' "))
    
    QRY_P1 = "SELECT lib.* FROM (" & _
                "SELECT fb.folio_blta, fb.run_apo, fb.run_alu, mvto.proc_pago, fb.fecha_blta, fb.folio_blta_fisico, fb.estado_blta, mvto.estado_pago, fb.colegio," _
              & "sum(mvto.monto_pago) as 'monto', min(mvto.fech_venc_cptos) as 'venc_ini', max(mvto.fech_venc_cptos) as 'venc_fin', mvto.tipo_pago, fb.usuario_ingreso, fb.fecha_ingreso " & _
                "FROM fnza_boletas as fb, fnza_dtll_mvto as dtmv, fnza_movimientos_mensualidad as mvto " & _
                "WHERE fb.estado_blta='aprb' and fb.tipo_doc = 'blta' AND fb.folio_blta=dtmv.folio_blta AND dtmv.folio_mvto=mvto.folio_mvto " & _
                Wh_Run & Wh_Folio & Wh_Monto & Wh_Colegio & Wh_Estado & _
                IIf(Opt_TipoBus(3) Or Opt_TipoBus(4), "", Wh_Fecha) & _
                "GROUP BY fb.folio_blta " & _
             ") as lib"
    
    QRY_P2 = "SELECT ant.* FROM (" & _
                "SELECT fb.folio_blta, fb.run_apo, fb.run_alu, if(baa.procedencia=2,'icup','caja') as 'proc_pago', fb.fecha_blta, fb.folio_blta_fisico, fb.estado_blta," _
              & "if(baa.nula=0,'aprb','erro') as 'estado_pago', fb.colegio, sum(baa.monto_total) as 'monto',min(baa.fec_ven_cuota) as 'venc_ini', max(baa.fec_ven_cuota) as 'venc_fin', 'S/I ' as 'tipo_pago' " & _
                " , fb.usuario_ingreso, fb.fecha_ingreso  FROM fnza_boletas as fb, bol_apo_x_alu as baa " & _
                "WHERE fb.estado_blta='2004' AND fb.tipo_doc = 'blta' AND baa.ci_alu=fb.run_alu AND baa.rut_apo=fb.run_apo AND baa.fec_emision=fb.fecha_blta AND baa.folio + 0=fb.folio_blta_fisico " & _
                Wh_Run & Wh_Folio & Wh_Monto & Wh_Colegio & Wh_Estado & _
                IIf(Opt_TipoBus(3) Or Opt_TipoBus(4), "", Wh_Fecha) & _
                "GROUP BY fb.folio_blta" & _
             ") as ant"
    
    QRY_P3 = "SELECT nul.* FROM (" & _
                "SELECT fb.folio_blta, fb.run_apo, fb.run_alu, 'caja' as 'proc_pago', fb.fecha_pago as 'fecha_blta', fb.folio_blta_fisico, fb.estado_blta, 'nula' as 'estado_pago'," _
              & "fb.colegio, if(fb.monto_blta is null,0,0) as 'monto', '0001-01-01' as 'venc_ini', '0001-01-01' as 'venc_fin', 'Null' as 'tipo_pago' " & _
                " , fb.usuario_ingreso, fb.fecha_ingreso FROM fnza_boletas as fb " & _
                "WHERE fb.estado_blta='nula' and fb.tipo_doc = 'blta' " & _
                Wh_Run & Wh_Folio & Wh_Monto & Wh_Colegio & Wh_Estado & _
                IIf(Opt_TipoBus(3) Or Opt_TipoBus(4), "", Wh_Fecha) & _
             ") as nul"
    
    conn.Execute "SET collation_connection = latin1_spanish_ci;"
        QRY_TT = "SELECT b.* FROM ( " & _
                    QRY_P1 & " UNION " & QRY_P3 & _
                 " ) AS b WHERE 1=1 " & _
                 Wh_Procedencia & _
                 IIf(Opt_TipoBus(3) Or Opt_TipoBus(4), Wh_Fecha, "") & _
                 "ORDER BY b.folio_blta_fisico;"
    
    Grd_Cons.Clear
    Grd_Cons.Rows = 2
    Grd_Cons.Cols = 2
    Grd_Cons.FormatString = "Nº | Folio Boleta |^Estado |^Colegio |^Apoderado |^  Alumno  |^Procedencia |^ Fecha Blta. |> Monto Bol. |^ Venc. Inic. |^ Venc. Final |^Folio Interno|^Tipo Pago|^Usuario Ingreso|^Fecha Ingreso"
    MuestraColumnasBoletasSeleccionadas
       
    Set REC_cancelar = New ADODB.Recordset
    REC_cancelar.Open QRY_TT, conn
    'a = 10
    If REC_cancelar.RecordCount > 0 Then
        REC_cancelar.MoveFirst
        If (Chk_Folio.Value = 1 And Chk_Fecha.Value = 0 And Chk_Run.Value = 0 And Chk_Monto.Value = 0 And Cmb_Estado_Bol.SelectedItem.Key = "all" And Cmb_Procedencia.SelectedItem.Key = "all") Then
            CountFolio = 1
            Fol_Fal = 0
            If val(Txt_FolioINI_Cons) > val(Txt_FolioFIN_Cons) Then Exit Sub
            ProgressBar_bol.Min = 0
            ProgressBar_bol.Value = ProgressBar_bol.Min
            ProgressBar_bol.Max = val(Txt_FolioFIN_Cons) - val(Txt_FolioINI_Cons) + 1
            For FOL = val(Txt_FolioINI_Cons) To val(Txt_FolioFIN_Cons)
                If Not (REC_cancelar.EOF) Then
                    If val(REC_cancelar!folio_blta_fisico) = FOL Then
                        'If REC_cancelar!folio_blta_fisico = 86055 Then MsgBox "here"
                        Grd_Cons.AddItem CountFolio & Chr(9) & REC_cancelar!folio_blta_fisico & Chr(9) & TraduceEstadoBlta(REC_cancelar!estado_blta, conn) & Chr(9) & REC_cancelar!colegio & Chr(9) & REC_cancelar!run_apo & Chr(9) _
                        & REC_cancelar!run_alu & Chr(9) & TraduceProcPago(REC_cancelar!proc_pago, conn) & Chr(9) & REC_cancelar!fecha_blta & Chr(9) & REC_cancelar!monto & Chr(9) & REC_cancelar!venc_ini & Chr(9) & REC_cancelar!venc_fin & Chr(9) & REC_cancelar!folio_blta & Chr(9) & REC_cancelar!tipo_pago & Chr(9) & REC_cancelar!usuario_ingreso & Chr(9) & Format(REC_cancelar!fecha_ingreso, "DD/MM/YYYY"), CountFolio
                        ' Seleccionar la linea
                        Grd_Cons.Row = CountFolio
                        Grd_Cons.Col = 1
                        Grd_Cons.RowSel = CountFolio
                        Grd_Cons.ColSel = Grd_Cons.Cols - 1
'                        If REC_cancelar!estado_dtll = "clda" Then
'                            Grd_Cons.CellBackColor = &HC0FFC0
'                        ElseIf REC_cancelar!estado_dtll = "cred" Then
'                            Grd_Cons.CellBackColor = &HC0C0FF
'                        ElseIf REC_cancelar!estado_dtll = "abon" Then
'                            Grd_Cons.CellBackColor = &HC0FFFF
'                        ElseIf REC_cancelar!estado_blta = "nula" Then
'                            Grd_Cons.CellBackColor = &HFFC0FF
'                        ElseIf REC_cancelar!estado_blta = "devo" Then
'                            Grd_Cons.CellBackColor = &HFFFFC0
'                        End If
                        
                        
                        If TraduceEstadoBlta(REC_cancelar!estado_blta, conn) = "Cancelada" Then
                            Grd_Cons.CellBackColor = &HC0FFC0
                        ElseIf TraduceEstadoBlta(REC_cancelar!estado_blta, conn) = "Anulada" Then
                            Grd_Cons.CellBackColor = &HFFC0FF
                        ElseIf TraduceEstadoBlta(REC_cancelar!estado_blta, conn) = "Pandiente" Then
                            Grd_Cons.CellBackColor = &HFFFFC0
                        End If

                        REC_cancelar.MoveNext
                    Else
                        Grd_Cons.AddItem CountFolio & Chr(9) & FOL & Chr(9) & "No Emitida", CountFolio
                        Fol_Fal = Fol_Fal + 1
                    End If
                Else
                    Grd_Cons.AddItem CountFolio & Chr(9) & FOL & Chr(9) & "No Emitida", CountFolio
                    Fol_Fal = Fol_Fal + 1
                End If
                ProgressBar_bol.Value = CountFolio
                CountFolio = CountFolio + 1
                DoEvents
            Next FOL
            Grd_Cons.Row = CountFolio
            Grd_Cons.Col = 1
            Grd_Cons.RowSel = CountFolio
            Grd_Cons.ColSel = Grd_Cons.Cols - 1
        Else
            REC_cancelar.MoveFirst
            ProgressBar_bol.Min = 0
            ProgressBar_bol.Value = ProgressBar_bol.Min
            ProgressBar_bol.Max = REC_cancelar.RecordCount
            

        
            For i = 1 To REC_cancelar.RecordCount
            
            
                Grd_Cons.AddItem i & Chr(9) & REC_cancelar!folio_blta_fisico & Chr(9) & TraduceEstadoBlta(REC_cancelar!estado_blta, conn) & Chr(9) & REC_cancelar!colegio & Chr(9) & REC_cancelar!run_apo & Chr(9) & REC_cancelar!run_alu & Chr(9) & TraduceProcPago(REC_cancelar!proc_pago, conn) & Chr(9) & REC_cancelar!fecha_blta & Chr(9) & REC_cancelar!monto & Chr(9) & REC_cancelar!venc_ini & Chr(9) & REC_cancelar!venc_fin & Chr(9) & REC_cancelar!folio_blta & Chr(9) & REC_cancelar!tipo_pago & Chr(9) & REC_cancelar!usuario_ingreso & Chr(9) & Format(REC_cancelar!fecha_ingreso, "DD/MM/YYYY"), i
                        Grd_Cons.Row = i
                        Grd_Cons.Col = 1
                        Grd_Cons.RowSel = i
                        Grd_Cons.ColSel = Grd_Cons.Cols - 1
'                        If REC_cancelar!estado_dtll = "clda" Then
'                            Grd_Cons.CellBackColor = &HC0FFC0
'                        ElseIf REC_cancelar!estado_dtll = "cred" Then
'                            Grd_Cons.CellBackColor = &HC0C0FF
'                        ElseIf REC_cancelar!estado_dtll = "abon" Then
'                            Grd_Cons.CellBackColor = &HC0FFFF
'                        ElseIf REC_cancelar!estado_blta = "nula" Then
'                            Grd_Cons.CellBackColor = &HFFC0FF
'                        ElseIf REC_cancelar!estado_blta = "devo" Then
'                            Grd_Cons.CellBackColor = &HFFFFC0
'                        End If

                        If TraduceEstadoBlta(REC_cancelar!estado_blta, conn) = "Cancelada" Then
                            Grd_Cons.CellBackColor = &HC0FFC0
                        ElseIf TraduceEstadoBlta(REC_cancelar!estado_blta, conn) = "Anulada" Then
                            Grd_Cons.CellBackColor = &HFFC0FF
                        ElseIf TraduceEstadoBlta(REC_cancelar!estado_blta, conn) = "Pandiente" Then
                            Grd_Cons.CellBackColor = &HFFFFC0
                        End If

                ProgressBar_bol.Value = i
                REC_cancelar.MoveNext
                DoEvents
                
            If BotonCancelar = 1 Then
                'ProgressBar_bol.Value = REC_cancelar.RecordCount
                btn_impri_boletas.Enabled = True
                Exit Sub
                'Unload Me
            End If
            
            Next i
                      
            Grd_Cons.Row = i
            Grd_Cons.Col = 1
            Grd_Cons.RowSel = i
            Grd_Cons.ColSel = Grd_Cons.Cols - 1
        End If
    Else
        If (Chk_Folio.Value = 1 And Chk_Fecha.Value = 0 And Chk_Run.Value = 0 And Chk_Monto.Value = 0 And Cmb_Estado_Bol.SelectedItem.Key = "all" And Cmb_Procedencia.SelectedItem.Key = "all") Then
            CountFolio = 1
            Fol_Fal = 0
            If val(Txt_FolioINI_Cons) > val(Txt_FolioFIN_Cons) Then Exit Sub
            ProgressBar_bol.Min = 0
            ProgressBar_bol.Value = ProgressBar_bol.Min
            ProgressBar_bol.Max = val(Txt_FolioFIN_Cons) - val(Txt_FolioINI_Cons) + 1
            For FOL = val(Txt_FolioINI_Cons) To val(Txt_FolioFIN_Cons)
                Grd_Cons.AddItem CountFolio & Chr(9) & FOL & Chr(9) & "No Emitida", CountFolio
                ProgressBar_bol.Value = CountFolio
                CountFolio = CountFolio + 1
                Fol_Fal = Fol_Fal + 1
            Next FOL
            DoEvents
        End If
    End If
    
    REC_cancelar.Close
    Num_Fol_Fal.Caption = str(Fol_Fal)
    btn_impri_boletas.Enabled = True
Else
    MsgBox "Seleccione una opción de busqueda"
End If

'Controlerror:
'    If Err.Number = 0 Then
'    Else
'    If Err.Number = -2147467259 Then
'        MsgBox "Imposible realizar consulta ya los tipos de datos no coinciden. Comuniquese con soporte.", vbExclamation + vbOKOnly, "Mensaje de GesCol"
'    Else
'        MsgBox Err.Description & vbCrLf & Err.Source & vbCrLf & Err.Number, vbExclamation + vbOKOnly, "ANOMALIA"
'    End If
'    End If
End Sub

Private Sub Btn_CyA_Cancelar_Click()
Unload Me
End Sub

Private Sub Btn_CyA_Generar_Click()
Dim MesVencim  As Integer
If CodEmpresa <> "" And NomEmpresa <> "" And Me.Cmb_Mes <> "" Then
    If IsDate(Me.Cmb_anho & "/" & Me.Cmb_Mes.ItemData(Me.Cmb_Mes.ListIndex) & "/" & Me.Cmb_del_dia.Text) And IsDate(Me.Cmb_anho & "/" & Me.Cmb_Mes.ItemData(Me.Cmb_Mes.ListIndex) & "/" & Me.Cmb_al_dia.Text) Then
        'Creo Tabla Temporal
        If TablaTemp Then
            'Traigo información bancaria
            If DatosExternos Then
                Set RsCya = New ADODB.Recordset
                RsCya.CursorLocation = adUseClient
                'Recorro información bancaria (Cupones pagados en el banco)
                FilaCyA = 0
                'RsCya.Open "select concat(a.ape1_apo, ' ' , a.ape2_apo, ' ' , a.noms_apo) as nomapo, t.rut_cli, t.fech_rec, t.fech_ven, t.agno, t.num_cup, t.monto  from TMP_PAGOS_BANCO t, apoderados a where t.rut_cli=a.rut_apo order by fech_rec, rut_cli, fech_ven", conn
                RsCya.Open "select concat(a.ape1_apo, ' ' , a.ape2_apo, ' ' , a.noms_apo) as nomapo, t.rut_cli, t.fech_rec, t.fech_ven, t.agno, t.num_cup, t.monto  from TMP_PAGOS_BANCO t, apoderados a where t.rut_cli=a.rut_apo order by t.fech_rec, t.fech_ven", conn
                If RsCya.RecordCount > 0 Then
                    Select Case Me.Opt_TipoCyA(0).Value
                        Case 0: Call Cya_Simple   ' Lleno Grilla Simple
                        Case 1: Call Cya_Detall(RsCya)   'Lleno Grilla Detallado
                    End Select
                End If
                RsCya.Close: Set RsCya = Nothing
            Else
                MsgBox ("No fue posible Rescatar los Datos de Cupones Pagados")
                Exit Sub
            End If
        Else
            MsgBox ("No fue posible almacenar información bancaria. Vuelva a intentarlo.")
            Exit Sub
        End If
    Else
        MsgBox ("Fecha(s) no válida(s)")
    End If
Else
    MsgBox ("Faltan opciones por seleccionar")
End If
End Sub

Private Sub btn_CyA_Limpiar_Click()
Unload Me
MenuInformesFnza = "credyabonos"
Load Form_InformesFnza
End Sub

Private Sub Btn_Gen_Rep_CyA_Click()
Call ReporteCyA(NgrillaCyA)
End Sub

Private Sub BTN_Genera_Reporte_Folios_faltantes_Click()
    Dim REC As ADODB.Recordset
    Dim CMD As ADODB.Command
    Dim QR As String
    Dim BolIni As Double, BolFin As Double
    Dim sw_nl As Boolean
    Dim InterIni As Double
    Dim InterFin As Double
    Dim Inter As String
    
    Set REC = New ADODB.Recordset
    Set CMD = New ADODB.Command
    
    CMD.ActiveConnection = conn
    CMD.CommandType = adCmdText
    ' Borrado de TEMPORAL de Folios Faltantes antiguo.
    QR = "DROP TABLE IF EXISTS fnza_libro_folios_faltantes;"
    CMD.CommandText = QR
    CMD.Execute
    'Temporal para string de Folios Faltantes
    QR = "CREATE TABLE fnza_libro_folios_faltantes (num bigint NOT NULL AUTO_INCREMENT, colegio varchar(15) NOT NULL default '', intervalo varchar(255) NOT NULL default '', PRIMARY KEY  (`num`) ) ENGINE=MyISAM;"
    CMD.CommandText = QR
    CMD.Execute
    
    ' Folios inicial y final
    QR = "SELECT min(folio_blta_fisico) as min_bol, max(folio_blta_fisico) as max_bol FROM fnza_boletas WHERE colegio='" & IC4.SelectedItem.Key & "' and tipo_doc = 'blta' GROUP BY colegio;"
    REC.Open QR, conn
    If REC.RecordCount = 0 Then
        MsgBox "No hay folios de boletas registradas en este colegio", vbOKOnly + vbInformation, "ALERTA DE SISTEMA"
        REC.Close
        Exit Sub
    End If
    REC.MoveFirst
    BolIni = REC!min_bol
    BolFin = REC!max_bol
    REC.Close
    
    ' Selecciono los folios ocupados
    QR = "SELECT folio_blta_fisico, colegio FROM fnza_boletas WHERE colegio='" & IC4.SelectedItem.Key & "' and tipo_doc = 'blta' Order by folio_blta_fisico;"
    REC.Open QR, conn
    If REC.RecordCount = 0 Then
        MsgBox "No existen Boletas registradas en este Colegio.", vbOKOnly + vbInformation, "ALERTA DE SISTEMA"
        Exit Sub
    End If
    sw_nl = False
    For Folio = BolIni To BolFin
        If (Folio = REC!folio_blta_fisico) Then
            If sw_nl Then
               QR = "INSERT INTO fnza_libro_folios_faltantes(colegio, intervalo) VALUES ('" & IC4.SelectedItem.Key & "','" & Inter & "')"
               CMD.CommandText = QR
               CMD.Execute
               sw_nl = False
            End If
            REC.MoveNext
        Else
            If Not (sw_nl) Then
                InterIni = Folio
                InterFin = Folio
                sw_nl = True
            Else
                InterFin = Folio
            End If
            Inter = InterIni & " a " & InterFin
        End If
    Next Folio
    Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\fnza_libro_folios_faltantes.rpt"
    Form_main.CrystalReport.WindowTitle = "Libro de Folios Faltantes"
    LimpiaFormulas Form_main.CrystalReport, 20
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Destination = crptToWindow
    Form_main.CrystalReport.Action = 1
End Sub

Private Sub btn_impri_boletas_Click()
    Dim accion_detalle As String
    If MsgBox("¿Desea Imprimir Reporte?", vbYesNo, "Consulta de Boletas") = vbYes Then
        Call CreaBD(DirAplicacion & "\rpt\gestempbol.mdb")
        Call CreaTabla(DirAplicacion & "\rpt\gestempbol.mdb", "Detalles_Bol", str(Grd_Cons.Cols) & ",10")
        Call RptGrillaText(Grd_Cons, Grd_Cons.Rows - 2, "\rpt\gestempbol.mdb", "Detalles_Bol")
        ' Llamar al Reporte
        Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\fnza_consulta_boletas.rpt"
        Form_main.CrystalReport.WindowTitle = "Consulta de Boletas"
        LimpiaFormulas Form_main.CrystalReport, 20
        Form_main.CrystalReport.WindowState = crptMaximized
        'Form_main.CrystalReport.ReplaceSelectionFormula ("")
        
        If opt_todas.Value = True Then
            Form_main.CrystalReport.ReplaceSelectionFormula ("")
            Form_main.CrystalReport.Formulas(1) = "titulo = '" & "Informe Consulta de Boletas Emitidas General" & "'"
        End If
        If opt_emitidas.Value = True Then
            Form_main.CrystalReport.ReplaceSelectionFormula ("{Detalles_Bol.C3}='" & "Cancelada" & "'")
            Form_main.CrystalReport.Formulas(1) = "titulo = '" & "Informe Consulta de Boletas Emitidas" & "'"
        End If
        If opt_noemitidas.Value = True Then
            Form_main.CrystalReport.ReplaceSelectionFormula ("{Detalles_Bol.C3}='" & "No Emitida" & "'")
            Form_main.CrystalReport.Formulas(1) = "titulo = '" & "Informe Consulta de Boletas No Emitidas" & "'"
        End If
        If opt_nulas.Value = True Then
            Form_main.CrystalReport.ReplaceSelectionFormula ("{Detalles_Bol.C3}='" & "Anulada" & "'")
            Form_main.CrystalReport.Formulas(1) = "titulo = '" & "Informe Consulta de Boletas Nulas" & "'"
        End If
            
        Form_main.CrystalReport.Destination = crptToWindow
        Form_main.CrystalReport.Action = 1
        Exit Sub
    End If
    If MsgBox("¿Desea imprimir estas boletas?", vbYesNo, "Reimprimir?") = vbNo Then Exit Sub
    Dim OkImprimir As String
    OkImprimir = InputBox("Ingrese Código de reimpresión", "Reimprimir boletas", "")
    If OkImprimir = "proceso.ct00.2005" Then
            
        Dim MArancel As String, MExencion As Long, MPagado As Long, MTotal As Long, MCuota  As Long
        Dim MCPadres As String, MAportes As String, MOtros As String, MParcial As Long
        Dim FEmision As String, NomApo As String, RutApoBol As String, NomAlu As String, curso As String
        Dim suma As String, Mensual As String, MesBoleta As String, EnPalabras As clsNum2Let
        Dim Agno_Bol As Integer
        Dim iniPrinter As String
        Dim ResetPrinter As String
        Dim FormFeed As String
        Dim FinRow As Integer
        Dim NA As Integer
        
        Set EnPalabras = New clsNum2Let
        FinRow = Grd_Cons.Rows - 2
        
        'Open "c:\boletas.txt" For Output As 1
        NA = FreeFile
        Open "LPT1:" For Output As #NA
        iniPrinter = Chr(27) + Chr(67) + Chr(51) + Chr(13) + Chr(27) + Chr(74) + Chr(120)
        ResetPrinter = Chr(27) + "@"
        FormFeed = Chr(12)
        
        
        For MyRow = 1 To FinRow
            Agno_Bol = Year(Grd_Cons.TextMatrix(MyRow, 11))
            NomApo = Left(DevuelveCampo("apoderados", "", "concat(ape1_apo,' ',ape2_apo,' ',noms_apo) as nombre", "rut_apo='" & Grd_Cons.TextMatrix(MyRow, 4) & "'", conn), 31)          ' Nombre del apoderado
            RutApoBol = Grd_Cons.TextMatrix(MyRow, 4)
            Pagado = val(Grd_Cons.TextMatrix(MyRow, 8))    ' Monto a pagar
            EnPalabras.Numero = val(Pagado)                 ' Monto a pagar
            NomAlu = DevuelveCampo("postulantes", "", "concat(nom_alu,' ',ape_pat_alu,' ',ape_mat_alu) as nombre", "ci_alu='" & Grd_Cons.TextMatrix(MyRow, 5) & "'", conn) ' Nombre del alumno
            curso = CursoBoleta(Grd_Cons.TextMatrix(MyRow, 5), val(Agno_Bol)) '#func year,ci# curso
            MesBoleta = BoletaDH(Grd_Cons.TextMatrix(MyRow, 5), Grd_Cons.TextMatrix(MyRow, 11), Grd_Cons.TextMatrix(MyRow, 12)) '#func 11,12# mes de la boleta
            FEmision = Grd_Cons.TextMatrix(MyRow, 7)        'fecha de emision de la boleta
            MCuota = val(Pagado)                            '*monto cuota
            MArancel = val(Pagado) + val(Grd_Cons.TextMatrix(MyRow, 9)) '* a pagar
            MExencion = val(Grd_Cons.TextMatrix(MyRow, 9))  '*exenciones
            MParcial = val(Pagado)                          '*Monto Parcial
            MCPadres = 0                                    ' monto centro de padres
            MAportes = 0                                    ' monto de aportes voluntarios
            MOtros = 0                                      ' monto otros
            MTotal = val(Pagado)                            '*Monto total
            
            Print #NA, Chr(15) & _
            vbCrLf + vbCrLf + vbCrLf & _
            vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
            vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
            vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
            vbCrLf + vbCrLf & _
            vbCrLf + Space(21) + NomApo + Space(11) + RutApoBol & _
            vbCrLf + vbCrLf + Space(21) + NomAlu & _
            vbCrLf + vbCrLf + Space(21) + MesBoleta + Space(37) + curso & _
            vbCrLf + vbCrLf + Space(21) + CStr(Pagado) + Space(19) + EnPalabras.ALetra & _
            vbCrLf + vbCrLf + vbCrLf + vbCrLf + Space(51) + CStr(Agno_Bol) + Space(15) + vbCrLf & _
            vbCrLf + vbCrLf + Space(50) + CStr(MArancel) & _
            vbCrLf + vbCrLf + Space(51) + CStr(MExencion) + Space(20 - Len(CStr(MExencion)) + 1) + CStr(MParcial) & _
            vbCrLf + vbCrLf + Space(72) + CStr(MAportes) & _
            vbCrLf + vbCrLf + Space(72) + CStr(MCPadres) & _
            vbCrLf + vbCrLf + Space(72) + CStr(MOtros) & _
            vbCrLf + vbCrLf + Space(72) + CStr(MTotal) & _
            vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + Space(20) + FEmision & _
            vbCrLf + vbCrLf + vbCrLf + vbCrLf
        'Inserta log
        accion_detalle = "La boleta con folio fisico " & Grd_Cons.TextMatrix(MyRow, 1) & " a sido reimpresa"
        Call Inserta_Vitacora_Finanza(Grd_Cons.TextMatrix(MyRow, 5), Grd_Cons.TextMatrix(MyRow, 4), _
             "Consulta boletas reimpresión de boletas", accion_detalle, 0, 0)
        'Fin de log
        Next MyRow
        Print #NA, ResetPrinter
        Close NA
        MsgBox "Fin de la impresión.", vbInformation, "Fin"
    End If
End Sub

Private Sub btn_lib_bol_Click()
On Error GoTo Controlerror
    Libro_boletas_reporte IC2.SelectedItem.Index, val(IC1.SelectedItem.Text), IC3.SelectedItem.Key, conn, Form_main.CrystalReport
    Exit Sub
Controlerror:
    MsgBox Err.Description & vbCrLf & Err.Source & vbCrLf & Err.Number, vbExclamation + vbOKOnly, "ANOMALIA"
End Sub

Private Sub btn_rep_cursos_Click()
If Me.lst_cursos.SelCount > 0 And Me.cmb_modalidad.Text <> "" Then
    GeneraCartolaAnual
Else
    MsgBox ("Faltan opciones por seleccionar")
End If
End Sub

Private Sub Chk_Empresa_Click(Index As Integer)
Select Case Index
    Case 0
        If Me.Chk_Empresa(Index).Value Then
            Me.Chk_Empresa(1).Value = 0
            Particular = False
        Else
            Me.Chk_Empresa(1).Value = 1
            Particular = True
        End If
        'Me.Chk_Empresa(1).Value = IIf(Me.Chk_Empresa(Index).Value = 0, 1, 0)
    
    Case 1
        If Me.Chk_Empresa(Index).Value Then
            Me.Chk_Empresa(0).Value = 0
            Particular = True
        Else
            Me.Chk_Empresa(0).Value = 1
            Particular = False
        End If
        'Me.Chk_Empresa(0).Value = IIf(Me.Chk_Empresa(Index).Value = 0, 1, 0)
End Select
'Particular = IIf(Index = 0, False, True)
Me.Txt_CodConvBci = DevuelveCampo("hist_cod_colegio", "", "cod_conv_bci", "colegio ='" & AColegios(IndAColegios) & "'", conn)
Me.Txt_CodConvBci_Part = DevuelveCampo("hist_cod_colegio", "", "cod_conv_bci", "colegio ='" & APartic(IndAPartic) & "'", conn)
'Me.Txt_Cod_Pac = IIf(Particular, devuelvecampo("hist_cod_colegio", "", "cod_pac", "colegio ='" & APartic(IndAPartic) & "'", conn), devuelvecampo("hist_cod_colegio", "", "cod_pac", "colegio ='" & AColegios(IndAColegios) & "'", conn))
NomEmpresa = IIf(Particular, Me.Cmb_Part_Cup, Me.Cmb_Colegio_Cup)
CodEmpresa = IIf(Particular, APartic(IndAPartic), AColegios(IndAColegios))
If Particular Then
    Me.Cmb_Colegio_Cup.BackColor = &H80000005
    Me.Cmb_Part_Cup.BackColor = &HC0FFFF
    TipoAlu = "PK": CodConvBci = Me.Txt_CodConvBci_Part
Else
    Me.Cmb_Colegio_Cup.BackColor = &HC0FFFF
    Me.Cmb_Part_Cup.BackColor = &H80000005
    TipoAlu = "BOS": CodConvBci = Me.Txt_CodConvBci
End If
End Sub

Private Sub Chk_Fecha_Click()
    If Chk_Fecha.Value = 1 Then
        Dtp_Fec_Ini.Enabled = True
        Dtp_Fec_Fin.Enabled = True
        Frame_BuscarPor.Enabled = True
    Else
        Dtp_Fec_Ini.Enabled = False
        Dtp_Fec_Fin.Enabled = False
        Frame_BuscarPor.Enabled = False
    End If
End Sub

Private Sub Chk_Folio_Click()
    If Chk_Folio.Value = 1 Then
        Txt_FolioINI_Cons.Enabled = True
        Txt_FolioFIN_Cons.Enabled = True
    Else
        Txt_FolioINI_Cons.Enabled = False
        Txt_FolioFIN_Cons.Enabled = False
    End If
End Sub

Private Sub Chk_Monto_Click()
    If Chk_Monto.Value = 1 Then
        Txt_Monto_Ini.Enabled = True
        Txt_Monto_Fin.Enabled = True
    Else
        Txt_Monto_Ini.Enabled = False
        Txt_Monto_Fin.Enabled = False
    End If
End Sub

Private Sub Chk_Run_Click()
    If Chk_Run.Value = 1 Then
        OptionAlu.Enabled = True
        OptionApo.Enabled = True
        TextRun.Enabled = True
    Else
        OptionAlu.Enabled = False
        OptionApo.Enabled = False
        TextRun.Enabled = False
    End If
End Sub

Private Sub chk_todos_cursos_Click()
If Me.chk_todos_cursos.Value Then
    For t = 0 To Me.lst_cursos.ListCount - 1
        Me.lst_cursos.Selected(t) = True
    Next t
Else
    For t = 0 To Me.lst_cursos.ListCount - 1
        Me.lst_cursos.Selected(t) = False
        Me.lst_cursos.ListIndex = 0
    Next t
End If
End Sub

Private Sub Cmb_Colegio_Cup_Click()
IndAColegios = Me.Cmb_Colegio_Cup.ListIndex
If IndAColegios >= 0 Then
    Me.Chk_Empresa(0).Enabled = True
    Me.Chk_Empresa(1).Enabled = True
Else
    Me.Chk_Empresa(0).Enabled = False
    Me.Chk_Empresa(1).Enabled = False
End If
Me.Cmb_Part_Cup.Clear
Call llenacomboconarreglo(Cmb_Part_Cup, "hist_cod_colegio where length(colegio)>6 and left(colegio,6)='" & AColegios(IndAColegios) & "'", "nombre", "colegio", APartic, conn)
If Me.Cmb_Part_Cup.ListCount > 0 Then
    Me.Cmb_Part_Cup.ListIndex = 0
End If
End Sub

Private Sub cmb_modalidad_Click()
'Dim RS As ADODB.Recordset

Set rs = New ADODB.Recordset
modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_modalidad.Text & "'", conn)
rs.CursorLocation = adUseClient
rs.Open "SELECT num_gra, let_cur FROM CURSOS where cod_ens ='" & modalidad & "' and agno=" & Combo1.Text & " ORDER BY NUM_GRA,let_cur", conn
If rs.RecordCount > 0 Then
    ReDim Anuevocurso(rs.RecordCount, 2)
    Me.lst_cursos.Clear
    Me.chk_todos_cursos.Value = 0
    c = 0
    While Not rs.EOF
        lst_cursos.AddItem rs("num_gra") + " " + rs("LET_CUR")
        Anuevocurso(c, 1) = rs("num_gra")
        Anuevocurso(c, 2) = rs("let_cur")
        rs.MoveNext
        c = c + 1
    Wend
    End If
rs.Close
Set rs = Nothing

End Sub

Private Sub GeneraCartolaAnual()
Dim RC As ADODB.Recordset
Dim CMD As ADODB.Command
Dim QR As String
Dim QrCreate As String
Dim Ngrado As String, letra As String, SelCursos As String, modalidad As String, Con As Integer
Dim Meses(3 To 12) As String
Dim agno As Integer
Dim RegAffected As Long
Dim ReporteRpt As String

Meses(3) = "Marzo"
Meses(4) = "Abril"
Meses(5) = "Mayo"
Meses(6) = "Junio"
Meses(7) = "Julio"
Meses(8) = "Agosto"
Meses(9) = "Septiembre"
Meses(10) = "Octubre"
Meses(11) = "Noviembre"
Meses(12) = "Diciembre"
agno = val(Combo1.Text)
RegAffected = 1
Con = 0
SelCursos = ""
Me.Frame_PCursos_Anual.Enabled = False

If Me.lst_cursos.SelCount > 0 And Me.cmb_modalidad.Text <> "" Then
    Label2.Caption = "Seleccionando Cursos."
    Label2.Refresh
    modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_modalidad.Text & "'", conn)
    For t = 0 To Me.lst_cursos.ListCount - 1
        If Me.lst_cursos.Selected(t) Then
            Con = t
        End If
    Next t
    For t = 0 To Me.lst_cursos.ListCount - 1
        If Me.lst_cursos.Selected(t) Then
            Ngrado = Anuevocurso(t, 1)
            letra = Anuevocurso(t, 2)
            If t = Con Then
                SelCursos = SelCursos & "(ac.num_gra  = '" & Ngrado & "' and ac.let_cur = '" & letra & "' and ac.cod_ens ='" & modalidad & "')"
            Else
                SelCursos = SelCursos & "(ac.num_gra  = '" & Ngrado & "' and ac.let_cur = '" & letra & "' and ac.cod_ens ='" & modalidad & "')" & " or "
            End If
        End If
    Next
    SelCursos = "(" & SelCursos & ")"
    
    Label2.Caption = "Borrando Temporales."
    Label2.Refresh
    Set CMD = New ADODB.Command
    CMD.ActiveConnection = conn
    CMD.CommandType = adCmdText
    ' Borro la tabla si ya existe.
    CMD.CommandText = "DROP TABLE IF EXISTS informe_pagos_x_curso;"
    CMD.Execute
    Label2.Caption = "Creando Base del Reporte, espere un momento."
    Label2.Refresh
    ' Creo la tabla temporal
    If Option1(0).Value Or Option1(3).Value Then
        QrCreate = CreatePagosXCursoSub(SelCursos)
    ElseIf Option1(1).Value Then
        QrCreate = CreatePagosXCurso(SelCursos)
    ElseIf Option1(2).Value Then
        QrCreate = CreatePagosXCurso(SelCursos)
    End If
        CMD.CommandText = QrCreate
    CMD.Execute
    ' Verificaciones
    Label2.Caption = "Verificando Base del Reporte. Paso 1"
    Label2.Refresh
    ' Limpio casos raros
    While RegAffected <> 0
    
        conn.Execute "DROP TABLE IF EXISTS temp_dupli;"
        conn.Execute "CREATE TABLE temp_dupli SELECT run_alu FROM informe_pagos_x_curso GROUP BY run_alu,cod_ens,num_gra,let_cur HAVING COUNT(*) > 1"
        conn.Execute "DELETE FROM informe_pagos_x_curso WHERE ct00_fech_pago = '0000-00-00' AND run_alu IN (SELECT run_alu FROM temp_dupli)"
    
        CMD.CommandText = "DELETE tres FROM informe_pagos_x_curso as tres, (SELECT ipc.* FROM (SELECT run_alu, count(run_alu) as veces FROM informe_pagos_x_curso group by run_alu) as uno, informe_pagos_x_curso as ipc WHERE uno.run_alu=ipc.run_alu AND uno.veces>1 ORDER BY ipc.fec_mat LIMIT 1) as cuatro WHERE tres.run_alu=cuatro.run_alu AND tres.fec_mat=cuatro.fec_mat;"
        CMD.Execute RegAffected
    Wend
    Label2.Caption = "Verificando Base del Reporte. Paso 2"
    Label2.Refresh
    ' Le doy llave primaria
    CMD.CommandText = "ALTER TABLE informe_pagos_x_curso ADD Primary Key (run_alu);"
    CMD.Execute
    Label2.Caption = "Verificando Folios de Boletas."
    For i = 3 To 12
        Label2.Caption = "Verificando Folios de Boletas " & Meses(i) & "."
        Label2.Refresh
        ' Limpio los Becados
'        QR = "UPDATE informe_pagos_x_curso SET " & Meses(i) & "_cp='' WHERE " & Meses(i) & "=0;"
'        CMD.CommandText = QR
'        CMD.Execute
        ' Lleno los folios de boletas.
        QR = "UPDATE matriculas m, informe_pagos_x_curso pxc,fnza_detalle_mensualidad fdm, fnza_dtll_mvto mov, fnza_boletas fb SET pxc." & Meses(i) & "_cp=fb.folio_blta_fisico WHERE pxc." & Meses(i) & "_cp<>'' AND fdm.run_alu=pxc.run_alu AND fdm.fech_venc='" & agno & "-" & Format(i, "00") & "-10' AND fdm.folio_dtll=mov.folio_dtll AND mov.folio_blta=fb.folio_blta AND fb.estado_blta<>'nula' AND fb.estado_blta<>'devo' AND fb.tipo_doc = 'blta' and fdm.run_alu = m.ci_alu and fdm.agno = m.anno_mat and fec_retiro = '1111-11-11' and monto_tot_cuota > 0;"
        CMD.CommandText = QR
        CMD.Execute RegAffected
        
        QR = "UPDATE matriculas m, informe_pagos_x_curso pxc,fnza_detalle_mensualidad fdm, fnza_dtll_mvto mov, fnza_boletas fb SET pxc." & Meses(i) & "_cp=fb.folio_blta_fisico WHERE pxc." & Meses(i) & "_cp<>'' AND fdm.run_alu=pxc.run_alu AND fdm.fech_venc='" & agno & "-" & Format(i, "00") & "-10' AND fdm.folio_dtll=mov.folio_dtll AND mov.folio_blta=fb.folio_blta AND fb.estado_blta<>'nula' AND fb.estado_blta<>'devo' AND fb.tipo_doc = 'blta' and fdm.run_alu = m.ci_alu and fdm.agno = m.anno_mat and (date_format(fech_venc,'%m') <= date_format(fec_retiro,'%m') and fec_retiro <> '1111-11-11') and monto_tot_cuota > 0;"
        CMD.CommandText = QR
        CMD.Execute RegAffected
    Next i
    
    'Lleno folios boletas con cero
    For i = 3 To 12
        Label2.Caption = "Verificando Folios de Boletas " & Meses(i) & "."
        Label2.Refresh
        ' Limpio los Becados
'        QR = "UPDATE informe_pagos_x_curso SET " & Meses(i) & "_cp='' WHERE " & Meses(i) & "=0;"
'        CMD.CommandText = QR
'        CMD.Execute
        ' Lleno los folios de boletas.
        QR = "UPDATE informe_pagos_x_curso pxc,fnza_detalle_mensualidad fdm, fnza_dtll_mvto mov, fnza_boletas fb,fnza_movimientos_mensualidad mm,matriculas m SET pxc." & Meses(i) & "_cp=fb.folio_blta_fisico WHERE mov.folio_mvto = mm.folio_mvto and pxc." & Meses(i) & "_cp<>'' AND fdm.run_alu=pxc.run_alu AND fdm.fech_venc='" & agno & "-" & Format(i, "00") & "-10' AND fdm.folio_dtll=mov.folio_dtll AND mov.folio_blta=fb.folio_blta AND fb.estado_blta<>'nula' AND fb.estado_blta<>'devo' AND fb.tipo_doc = 'blta' and monto_pago = 0 and fdm.run_alu = m.ci_alu and fdm.agno = m.anno_mat and fec_retiro = '1111-11-11';"
        CMD.CommandText = QR
        CMD.Execute RegAffected
        
        QR = "UPDATE informe_pagos_x_curso pxc,fnza_detalle_mensualidad fdm, fnza_dtll_mvto mov, fnza_boletas fb,fnza_movimientos_mensualidad mm,matriculas m SET pxc." & Meses(i) & "_cp=fb.folio_blta_fisico WHERE mov.folio_mvto = mm.folio_mvto and pxc." & Meses(i) & "_cp<>'' AND fdm.run_alu=pxc.run_alu AND fdm.fech_venc='" & agno & "-" & Format(i, "00") & "-10' AND fdm.folio_dtll=mov.folio_dtll AND mov.folio_blta=fb.folio_blta AND fb.estado_blta<>'nula' AND fb.estado_blta<>'devo' AND fb.tipo_doc = 'blta' and monto_pago = 0 and fdm.run_alu = m.ci_alu and fdm.agno = m.anno_mat and (date_format(fech_venc,'%m') <= date_format(fec_retiro,'%m') and fec_retiro <> '1111-11-11');"
        CMD.CommandText = QR
        CMD.Execute RegAffected
    Next i
    
    
    
    ' LLENO EL FOLIO DE LA CUOTA INICIAL
    QR = "UPDATE informe_pagos_x_curso pxc,fnza_detalle_mensualidad fdm, fnza_dtll_mvto mov, fnza_boletas fb SET pxc.ct00_boleta=fb.folio_blta_fisico WHERE pxc.ct00_boleta<>'' AND fdm.run_alu=pxc.run_alu AND fdm.concepto='ct00' AND fdm.folio_dtll=mov.folio_dtll AND mov.folio_blta=fb.folio_blta AND fb.estado_blta<>'nula' AND fb.estado_blta<>'devo' AND fb.tipo_doc = 'blta' AND fdm.agno=" & agno & ";"
    CMD.CommandText = QR
    CMD.Execute
           
    'Borro boletas de becados con folio '000000'
'    QR = "update informe_pagos_x_curso set marzo_cp = '' where beca = 100 and (marzo_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set abril_cp = '' where beca = 100 and (abril_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set mayo_cp = '' where beca = 100 and (mayo_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set junio_cp = '' where beca = 100 and (junio_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set julio_cp = '' where beca = 100 and (julio_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set agosto_cp = '' where beca = 100 and (agosto_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set septiembre_cp = '' where beca = 100 and (septiembre_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set octubre_cp = '' where beca = 100 and (octubre_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set noviembre_cp = '' where beca = 100 and (noviembre_cp = '000000')"
'    conn.Execute QR
'    QR = "update informe_pagos_x_curso set diciembre_cp = '' where beca = 100 and (diciembre_cp = '000000')"
'    conn.Execute QR
    
    QR = "update informe_pagos_x_curso set marzo_cp = '' where (marzo_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set abril_cp = '' where (abril_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set mayo_cp = '' where (mayo_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set junio_cp = '' where (junio_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set julio_cp = '' where (julio_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set agosto_cp = '' where (agosto_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set septiembre_cp = '' where (septiembre_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set octubre_cp = '' where (octubre_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set noviembre_cp = '' where (noviembre_cp = '000000')"
    conn.Execute QR
    QR = "update informe_pagos_x_curso set diciembre_cp = '' where (diciembre_cp = '000000')"
    conn.Execute QR
            
       
    For i = 3 To 12
    
        QR = "update informe_pagos_x_curso p," _
        & "fnza_detalle_mensualidad as f set " _
        & Meses(i) & "_exen = if(f.monto_total <> " & Meses(i) & "_exen,0," & Meses(i) & "_exen)" _
        & " Where p.run_alu = f.run_alu And p.Beca = 100 And Mes = " & i & " And f.agno = " & agno
        conn.Execute QR
        
    Next i
        
    
           
    ' ###################
    ' Imprimir el reporte
    ' ###################
    Label2.Caption = "Imprimiendo Reporte."
    Label2.Refresh
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    titulo = "CARTOLA DE PAGOS POR CURSO ANUAL (AGOSTO - DICIEMBRE) " & Combo1.Text
    ' Opciones de Impresion
    If Option1(0).Value Or Option1(3).Value Then
        ReporteRpt = "pagos_por_curso"
    ElseIf Option1(1).Value Then
        ReporteRpt = "pagos_por_curso"
    ElseIf Option1(2).Value Then
        ReporteRpt = "pagos_por_curso_fnza"
    End If
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\" & ReporteRpt & "2.rpt"
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.Formulas(1) = "anno_inf='REGISTRO DE PAGOS MENSUALES AÑO " & Combo1.Text & "'"
    If Option1(0).Value Then
        Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "' AND {informe_pagos_x_curso.tercio}='NO'")
    ElseIf Option1(3).Value Then
        Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "' AND {informe_pagos_x_curso.tercio}='SI'")
    Else
        Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "'")
    End If
    
    'probando
    'hist_cod_colegio1.`COLEGIO` = 'LON001MMC'
'    Form_main.CrystalReport.ReplaceSelectionFormula ("{hist_cod_colegio.COLEGIO}='" & "FAR001MMC" & "'")
'    Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.COLEGIO}='" & "FAR001MMC" & "'")
    
    
    Form_main.CrystalReport.Destination = crptToWindow
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    titulo = "CARTOLA DE PAGOS POR CURSO ANUAL (MARZO - JULIO) " & Combo1.Text
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\" & ReporteRpt & ".rpt"
    Form_main.CrystalReport.Formulas(1) = "anno_inf='REGISTRO DE PAGOS MENSUALES AÑO " & Combo1.Text & "'"
    If Option1(0).Value Then
        Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "' AND {informe_pagos_x_curso.tercio}='NO'")
    ElseIf Option1(3).Value Then
        Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "' AND {informe_pagos_x_curso.tercio}='SI'")
    Else
        Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "'")
    End If
'    'probando
'    Form_main.CrystalReport.ReplaceSelectionFormula ("{hist_cod_colegio.COLEGIO}='" & "FAR001MMC" & "'")
'    Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.COLEGIO}='" & "FAR001MMC" & "'")
    
    
    Form_main.CrystalReport.Destination = crptToWindow
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    ' Cuotas Iniciales
    If check_incluir_informe_cuota_inicial.Value = 1 Then
        titulo = "CARTOLA DE CUOTAS INICIALES " & Combo1.Text
        Form_main.CrystalReport.WindowTitle = titulo
        Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\pagos_por_curso_cuotainicial.rpt"
        Form_main.CrystalReport.Formulas(1) = "tit_anno_inf='REGISTRO DE CUOTAS INICIALES AÑO " & Combo1.Text & "'"
        If Option1(0).Value Then
            Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "' AND {informe_pagos_x_curso.tercio}='NO'")
        ElseIf Option1(3).Value Then
            Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "' AND {informe_pagos_x_curso.tercio}='SI'")
        Else
            Form_main.CrystalReport.ReplaceSelectionFormula ("{informe_pagos_x_curso.cod_ens}='" & modalidad & "'")
        End If
        Form_main.CrystalReport.Destination = crptToWindow
        Form_main.CrystalReport.Action = 1
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        Call LimpiaFormulas(Form_main.CrystalReport, 30)
    End If
End If
Me.Frame_PCursos_Anual.Enabled = True
Label2.Caption = ""
Label2.Refresh
End Sub

Private Sub Command1_Click()
Dim ReporteRpt As String
Dim QrCreate As String
Dim titulo  As String
Dim CMD As ADODB.Command
Dim SelCursos As String
Dim modalidad As String
Dim Con As Integer

    Set CMD = New ADODB.Command
    CMD.ActiveConnection = conn
    CMD.CommandType = adCmdText
    SelCursos = ""
    Con = 0
    
If Me.lst_cursos.SelCount > 0 And Me.cmb_modalidad.Text <> "" And Me.Option2(0).Value Then
    Label2.Caption = "Seleccionando Cursos."
    Label2.Refresh
    modalidad = RetornaCampo("codigos_ensenanza", "cod_ens", "des_ens = '" & Me.cmb_modalidad.Text & "'", conn)
    
    For t = 0 To Me.lst_cursos.ListCount - 1
        If Me.lst_cursos.Selected(t) Then
            Con = t
        End If
    Next t
    
    For t = 0 To Me.lst_cursos.ListCount - 1
        If Me.lst_cursos.Selected(t) Then
            Ngrado = Anuevocurso(t, 1)
            letra = Anuevocurso(t, 2)
            If t = Con Then
                SelCursos = SelCursos & "({alu_x_cur.num_gra} = '" & Ngrado & "' AND {alu_x_cur.let_cur} = '" & letra & "' AND {alu_x_cur.cod_ens} = '" & modalidad & "')"
            Else
                SelCursos = SelCursos & "({alu_x_cur.num_gra} = '" & Ngrado & "' AND {alu_x_cur.let_cur} = '" & letra & "' AND {alu_x_cur.cod_ens} = '" & modalidad & "')" & " OR "
            End If
        End If
    Next
    
    SelCursos = "(" & SelCursos & ") AND {alu_x_cur.agno}=" & Me.Combo1.Text
    
    ReporteRpt = "fnza_informe_morosidad_curso.rpt"
    titulo = "INFORME DE MOROSIDAD POR CURSO"
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\" & ReporteRpt
    Form_main.CrystalReport.ReplaceSelectionFormula (SelCursos)
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    
ElseIf Me.Option2(1).Value Then
    'Morosidad del Colegio
    ReporteRpt = "fnza_informe_morosidad_colegio.rpt"
    titulo = "INFORME DE MOROSIDAD COLEGIO"
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\" & ReporteRpt
    Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.agno}=" & Me.Combo1.Text & "")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    
ElseIf Me.Option2(2).Value Then
    ReporteRpt = "pagos_por_curso_fnza"
    ' Resumen de Estadísticas
    CMD.CommandText = "DROP TABLE IF EXISTS informe_pagos_x_curso_est;"
    CMD.Execute
    Label2.Caption = "Creando Base del Resumen Estadisticas, espere un momento."
    Label2.Refresh
    QrCreate = CreatePagosXCursoEst(val(Me.Combo1.Text))
    CMD.CommandText = QrCreate
    CMD.Execute
    titulo = "CARTOLA DE PAGOS POR CURSO ANUAL (ESTADISTICAS)"
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\" & ReporteRpt & "_estadisticas.rpt"
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    
ElseIf Me.Option2(3).Value Then
    ReporteRpt = "pagos_por_curso_fnza"
    CMD.CommandText = "DROP TABLE IF EXISTS informe_pagos_x_curso_comp;"
    CMD.Execute
    ' Resumen de Comportamiento de Pagos
    Label2.Caption = "Creando Base del Resumen Comportamiento, espere un momento."
    Label2.Refresh
    QrCreate = CreatePagosXCursoComp(val(Me.Combo1.Text))
    CMD.CommandText = QrCreate
    CMD.Execute
    titulo = "CARTOLA DE PAGOS POR CURSO ANUAL (COMPORTAMIENTO)"
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\" & ReporteRpt & "_comportamiento.rpt"
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
End If
    Label2.Caption = ""
    Label2.Refresh
End Sub

Private Sub Command3_Click()
    Frm_CambFolioBlta.Visible = False
    Frame_Grilla_Cons.Enabled = True
    Btn_Cons_Bol.Enabled = True
End Sub

Private Sub Form_Load()
BotonCancelar = 0

'''' Cambio el colegio de la boleta de corporación a colegio respectivo
var_sql = "UPDATE fnza_boletas,(SELECT valor FROM cfg WHERE param = 'CODBC') c SET colegio = valor" _
            & " WHERE colegio = 'COR001'"
conn.Execute var_sql

If MenuInformesFnza = "ppcursoanual" Then
    Label2.Caption = ""
    Me.Caption = "Pagos Por Curso"
    Me.Height = Frame_PCursos_Anual.Height + 465
    Me.Width = Frame_PCursos_Anual.Width
    Me.Frame_PCursos_Anual.Top = 0
    Me.Frame_PCursos_Anual.Left = 0
    Call HideFrameFinanzas
    Me.Frame_PCursos_Anual.Visible = True
    Call LlenaCombo(cmb_modalidad, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
    Me.opt_destino_cartola(0).Value = True
    LlenaComboAgno
    
ElseIf MenuInformesFnza = "credyabonos" Then
    Me.Caption = "Créditos y Abonos"
    Label2.Caption = ""
    Me.Height = Me.Frame_CredyAbonos.Height + 465
    Me.Width = Me.Frame_CredyAbonos.Width
    Me.Frame_CredyAbonos.Top = 0
    Me.Frame_CredyAbonos.Left = 0
    Call HideFrameFinanzas
    Me.Frame_CredyAbonos.Visible = True
    Me.opt_destino_cartola(0).Value = True
    Call llenacomboconarreglo(Cmb_Colegio_Cup, "hist_cod_colegio where length(colegio)=6 ", "nombre", "colegio", AColegios, conn)
    LlenaComboAgno_CredyAbonos
    Me.Opt_TipoCyA(1).Value = True
    Me.opt_destino_CyA(0).Value = True
    
ElseIf MenuInformesFnza = "libroboletas" Then
    Me.Caption = "Libro de Boletas"
    Me.Height = Me.Frame_Libro_Boletas.Height + 465
    Me.Width = Me.Frame_Libro_Boletas.Width
    Me.Frame_Libro_Boletas.Top = 0
    Me.Frame_Libro_Boletas.Left = 0
    Call HideFrameFinanzas
    Me.Frame_Libro_Boletas.Visible = True
    Me.Opt_Destino_LibroBol(0).Value = True
    Load_Combos_Libro_boletas
    
ElseIf MenuInformesFnza = "foliosnotrat" Then
    Me.Caption = "Comprobación de Folios"
    Me.Height = Me.Frame_Folios_Notrat.Height + 465
    Me.Width = Me.Frame_Folios_Notrat.Width
    Me.Frame_Folios_Notrat.Top = 0
    Me.Frame_Folios_Notrat.Left = 0
    Call HideFrameFinanzas
    Me.Frame_Folios_Notrat.Visible = True
    Me.Opt_Destino_FoliosNotrat(0).Value = True
    Load_Combos_Folios_Faltantes
    
ElseIf MenuInformesFnza = "consultaboletas" Then
    ' Formato de la ventana de consulta de boletas
    Me.Caption = "Consulta de Boletas"
    Me.Height = Me.Frame_ConsBol.Height + 465
    Me.Width = Me.Frame_ConsBol.Width
    Me.Frame_ConsBol.Top = 0
    Me.Frame_ConsBol.Left = 0
    Me.Top = 0
    Me.Left = 0
    Call HideFrameFinanzas
    Me.Frame_ConsBol.Visible = True
    ' Load de la ventana.
    LlenaCmbColegios Cmb_Colegios, True, conn
    'Cmb_Colegios.Text = "Todos"
    LlenaCmbProcedencia conn
    LlenaCmbEstado conn
    LlenaCmbAgno 2005, Cmb_Agno
    'Cmb_Agno.Text = Anno
    Cmb_Agno.SelectedItem.Text = Year(Date)
    LlenaListaColumBoletas
    Dtp_Fec_Ini = Format(Date, "yyyy-mm-dd")
    Dtp_Fec_Fin = Format(Date, "yyyy-mm-dd")
    'MsgBox Format(Date, "yyyy-mm-dd")
    
    Me.Show
End If

End Sub

Function CreatePagosXCurso(ByRef cursos As String) As String

CreatePagosXCurso = "CREATE TABLE informe_pagos_x_curso TYPE=MyISAM " & _
                    "SELECT ini.*, if(dic.monto_tot_cuota<=dic.monto_abono,'000000','') as diciembre_cp, if (dic.monto_abono>dic.monto_tot_cuota, dic.monto_tot_cuota, dic.monto_abono) as 'diciembre', (dic.monto_exen_hno+dic.monto_exen_bca+dic.monto_exen_desc+dic.monto_exen_conv+dic.monto_exen_tipo_pago) as 'diciembre_exen', 0+0 as 'diciembre_otros' FROM ( " & _
                    "SELECT ini.*, if(nov.monto_tot_cuota<=nov.monto_abono,'000000','') as noviembre_cp, if (nov.monto_abono>nov.monto_tot_cuota, nov.monto_tot_cuota, nov.monto_abono) as 'noviembre', (nov.monto_exen_hno+nov.monto_exen_bca+nov.monto_exen_desc+nov.monto_exen_conv+nov.monto_exen_tipo_pago) as 'noviembre_exen', 0+0 as 'noviembre_otros' FROM ( " & _
                    "SELECT ini.*, if(oct.monto_tot_cuota<=oct.monto_abono,'000000','') as octubre_cp, if (oct.monto_abono>oct.monto_tot_cuota, oct.monto_tot_cuota, oct.monto_abono) as 'octubre', (oct.monto_exen_hno+oct.monto_exen_bca+oct.monto_exen_desc+oct.monto_exen_conv+oct.monto_exen_tipo_pago) as 'octubre_exen', 0+0 as 'octubre_otros' FROM ( " & _
                    "SELECT ini.*, if(sep.monto_tot_cuota<=sep.monto_abono,'000000','') as septiembre_cp, if (sep.monto_abono>sep.monto_tot_cuota, sep.monto_tot_cuota, sep.monto_abono) as 'septiembre', (sep.monto_exen_hno+sep.monto_exen_bca+sep.monto_exen_desc+sep.monto_exen_conv+sep.monto_exen_tipo_pago) as 'septiembre_exen', 0+0 as 'septiembre_otros' FROM ( " & _
                    "SELECT ini.*, if(ago.monto_tot_cuota<=ago.monto_abono,'000000','') as agosto_cp, if (ago.monto_abono>ago.monto_tot_cuota, ago.monto_tot_cuota, ago.monto_abono) as 'agosto', (ago.monto_exen_hno+ago.monto_exen_bca+ago.monto_exen_desc+ago.monto_exen_conv+ago.monto_exen_tipo_pago) as 'agosto_exen', 0+0 as 'agosto_otros' FROM ( " & _
                    "SELECT ini.*, if(jul.monto_tot_cuota<=jul.monto_abono,'000000','') as julio_cp, if (jul.monto_abono>jul.monto_tot_cuota, jul.monto_tot_cuota, jul.monto_abono) as 'julio', (jul.monto_exen_hno+jul.monto_exen_bca+jul.monto_exen_desc+jul.monto_exen_conv+jul.monto_exen_tipo_pago) as 'julio_exen', 0+0 as 'julio_otros' FROM ( " & _
                    "SELECT ini.*, if(jun.monto_tot_cuota<=jun.monto_abono,'000000','') as junio_cp, if (jun.monto_abono>jun.monto_tot_cuota, jun.monto_tot_cuota, jun.monto_abono) as 'junio', (jun.monto_exen_hno+jun.monto_exen_bca+jun.monto_exen_desc+jun.monto_exen_conv+jun.monto_exen_tipo_pago) as 'junio_exen', 0+0 as 'junio_otros' FROM ( " & _
                    "SELECT ini.*, if(may.monto_tot_cuota<=may.monto_abono,'000000','') as mayo_cp, if (may.monto_abono>may.monto_tot_cuota,may.monto_tot_cuota, may.monto_abono) as 'mayo', (may.monto_exen_hno+may.monto_exen_bca+may.monto_exen_desc+may.monto_exen_conv+may.monto_exen_tipo_pago) as 'mayo_exen', 0+0 as 'mayo_otros' FROM ( " & _
                    "SELECT ini.*, if(abr.monto_tot_cuota<=abr.monto_abono,'000000','') as abril_cp, if (abr.monto_abono>abr.monto_tot_cuota, abr.monto_tot_cuota, abr.monto_abono) as 'abril', (abr.monto_exen_hno+abr.monto_exen_bca+abr.monto_exen_desc+abr.monto_exen_conv+abr.monto_exen_tipo_pago) as 'abril_exen', 0+0 as 'abril_otros' FROM ( " & _
                    "SELECT ini.*, if(mar.monto_tot_cuota<=mar.monto_abono,'000000','') as marzo_cp, if (mar.monto_abono>mar.monto_tot_cuota,mar.monto_tot_cuota, mar.monto_abono) as 'marzo', (mar.monto_exen_hno+mar.monto_exen_bca+mar.monto_exen_desc+mar.monto_exen_conv+mar.monto_exen_tipo_pago) as 'marzo_exen', 0+0 as 'marzo_otros' FROM ( " & _
                        "SELECT inf.*, fdm.fech_pago as ct00_fech_pago, if(fdm.monto_abono>0,'000000','') as ct00_boleta, if (fdm.monto_abono>=fdm.monto_tot_cuota,fdm.monto_tot_cuota,fdm.monto_abono) as ct00_abonado, (fdm.monto_exen_hno+fdm.monto_exen_bca+fdm.monto_exen_desc+fdm.monto_exen_conv+fdm.monto_exen_tipo_pago) as ct00_exencion, 0+0 as ct00_otros FROM ( " & _
                            "SELECT concat(p.ape_pat_alu,' ',p.ape_mat_alu, ' ', p.nom_alu) as alumno, ac.fec_mat, ac.num_gra, ac.let_cur, ac.cod_ens, ac.ci_alu as 'run_alu', left(hcc.colegio,6) as colegio, if(m.ind_beca=1,(100/1),if(m.ind_mbeca=1,(50/1),if((m.tercio='SI'),(m.tercio_por / 1),(0/1)))) as 'Beca', ac.agno, m.tercio " & _
                            "FROM alu_x_cur as ac, postulantes as p, matriculas as m, (select left(cc.colegio,6) as colegio from establecimientos as es, hist_cod_colegio as cc where es.rdb=cc.cod_rbd) as col, hist_cod_colegio as hcc " & _
                            "WHERE (" & cursos & ") AND ac.agno=m.anno_mat AND ac.agno=" & Trim(Combo1.Text) & " AND ac.fec_cam='1111-11-11' AND ac.ci_alu=p.ci_alu AND ac.ci_alu=m.ci_alu AND ac.fec_mat=m.fec_mat AND left(col.colegio,6)=left(hcc.colegio,6) AND ((ac.cod_ens='996' AND length(hcc.colegio)=6) OR (ac.cod_ens<>'996' AND length(hcc.colegio)=6)) ORDER BY ac.num_gra, ac.let_cur, alumno) as inf " & _
                        "LEFT JOIN fnza_detalle_mensualidad as fdm ON inf.run_alu=fdm.run_alu AND fdm.concepto='ct00' AND left(inf.colegio,6)=left(fdm.colegio,6) AND inf.agno=fdm.agno) as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as mar ON ini.run_alu=mar.run_alu AND left(ini.colegio,6)=left(mar.colegio,6) AND ini.agno=mar.agno AND mar.mes=3 AND mar.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as abr ON ini.run_alu=abr.run_alu AND left(ini.colegio,6)=left(abr.colegio,6) AND ini.agno=abr.agno AND abr.mes=4 AND abr.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as may ON ini.run_alu=may.run_alu AND left(ini.colegio,6)=left(may.colegio,6) AND ini.agno=may.agno AND may.mes=5 AND may.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as jun ON ini.run_alu=jun.run_alu AND left(ini.colegio,6)=left(jun.colegio,6) AND ini.agno=jun.agno AND jun.mes=6 AND jun.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as jul ON ini.run_alu=jul.run_alu AND left(ini.colegio,6)=left(jul.colegio,6) AND ini.agno=jul.agno AND jul.mes=7 AND jul.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as ago ON ini.run_alu=ago.run_alu AND left(ini.colegio,6)=left(ago.colegio,6) AND ini.agno=ago.agno AND ago.mes=8 AND ago.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as sep ON ini.run_alu=sep.run_alu AND left(ini.colegio,6)=left(sep.colegio,6) AND ini.agno=sep.agno AND sep.mes=9 AND sep.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as oct ON ini.run_alu=oct.run_alu AND left(ini.colegio,6)=left(oct.colegio,6) AND ini.agno=oct.agno AND oct.mes=10 AND oct.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as nov ON ini.run_alu=nov.run_alu AND left(ini.colegio,6)=left(nov.colegio,6) AND ini.agno=nov.agno AND nov.mes=11 AND nov.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as dic ON ini.run_alu=dic.run_alu AND left(ini.colegio,6)=left(dic.colegio,6) AND ini.agno=dic.agno AND dic.mes=12 AND dic.concepto='esco';"
End Function

Function CreatePagosXCursoSub(ByRef cursos As String) As String

CreatePagosXCursoSub = "CREATE TABLE informe_pagos_x_curso TYPE=MyISAM " & _
                    "SELECT ini.*, if(dic.monto_tot_cuota<=dic.monto_abono,'000000','') as diciembre_cp, if (dic.monto_abono>dic.monto_tot_cuota, dic.monto_tot_cuota, dic.monto_abono) as 'diciembre', (dic.monto_exen_hno+dic.monto_exen_bca+dic.monto_exen_desc+dic.monto_exen_conv+dic.monto_exen_tipo_pago) as 'diciembre_exen', 0+0 as 'diciembre_otros' FROM ( " & _
                    "SELECT ini.*, if(nov.monto_tot_cuota<=nov.monto_abono,'000000','') as noviembre_cp, if (nov.monto_abono>nov.monto_tot_cuota, nov.monto_tot_cuota, nov.monto_abono) as 'noviembre', (nov.monto_exen_hno+nov.monto_exen_bca+nov.monto_exen_desc+nov.monto_exen_conv+nov.monto_exen_tipo_pago) as 'noviembre_exen', 0+0 as 'noviembre_otros' FROM ( " & _
                    "SELECT ini.*, if(oct.monto_tot_cuota<=oct.monto_abono,'000000','') as octubre_cp, if (oct.monto_abono>oct.monto_tot_cuota, oct.monto_tot_cuota, oct.monto_abono) as 'octubre', (oct.monto_exen_hno+oct.monto_exen_bca+oct.monto_exen_desc+oct.monto_exen_conv+oct.monto_exen_tipo_pago) as 'octubre_exen', 0+0 as 'octubre_otros' FROM ( " & _
                    "SELECT ini.*, if(sep.monto_tot_cuota<=sep.monto_abono,'000000','') as septiembre_cp, if (sep.monto_abono>sep.monto_tot_cuota, sep.monto_tot_cuota, sep.monto_abono) as 'septiembre', (sep.monto_exen_hno+sep.monto_exen_bca+sep.monto_exen_desc+sep.monto_exen_conv+sep.monto_exen_tipo_pago) as 'septiembre_exen', 0+0 as 'septiembre_otros' FROM ( " & _
                    "SELECT ini.*, if(ago.monto_tot_cuota<=ago.monto_abono,'000000','') as agosto_cp, if (ago.monto_abono>ago.monto_tot_cuota, ago.monto_tot_cuota, ago.monto_abono) as 'agosto', (ago.monto_exen_hno+ago.monto_exen_bca+ago.monto_exen_desc+ago.monto_exen_conv+ago.monto_exen_tipo_pago) as 'agosto_exen', 0+0 as 'agosto_otros' FROM ( " & _
                    "SELECT ini.*, if(jul.monto_tot_cuota<=jul.monto_abono,'000000','') as julio_cp, if (jul.monto_abono>jul.monto_tot_cuota, jul.monto_tot_cuota, jul.monto_abono) as 'julio', (jul.monto_exen_hno+jul.monto_exen_bca+jul.monto_exen_desc+jul.monto_exen_conv+jul.monto_exen_tipo_pago) as 'julio_exen', 0+0 as 'julio_otros' FROM ( " & _
                    "SELECT ini.*, if(jun.monto_tot_cuota<=jun.monto_abono,'000000','') as junio_cp, if (jun.monto_abono>jun.monto_tot_cuota, jun.monto_tot_cuota, jun.monto_abono) as 'junio', (jun.monto_exen_hno+jun.monto_exen_bca+jun.monto_exen_desc+jun.monto_exen_conv+jun.monto_exen_tipo_pago) as 'junio_exen', 0+0 as 'junio_otros' FROM ( " & _
                    "SELECT ini.*, if(may.monto_tot_cuota<=may.monto_abono,'000000','') as mayo_cp, if (may.monto_abono>may.monto_tot_cuota,may.monto_tot_cuota, may.monto_abono) as 'mayo', (may.monto_exen_hno+may.monto_exen_bca+may.monto_exen_desc+may.monto_exen_conv+may.monto_exen_tipo_pago) as 'mayo_exen', 0+0 as 'mayo_otros' FROM ( " & _
                    "SELECT ini.*, if(abr.monto_tot_cuota<=abr.monto_abono,'000000','') as abril_cp, if (abr.monto_abono>abr.monto_tot_cuota, abr.monto_tot_cuota, abr.monto_abono) as 'abril', (abr.monto_exen_hno+abr.monto_exen_bca+abr.monto_exen_desc+abr.monto_exen_conv+abr.monto_exen_tipo_pago) as 'abril_exen', 0+0 as 'abril_otros' FROM ( " & _
                    "SELECT ini.*, if(mar.monto_tot_cuota<=mar.monto_abono,'000000','') as marzo_cp, if (mar.monto_abono>mar.monto_tot_cuota,mar.monto_tot_cuota, mar.monto_abono) as 'marzo', (mar.monto_exen_hno+mar.monto_exen_bca+mar.monto_exen_desc+mar.monto_exen_conv+mar.monto_exen_tipo_pago) as 'marzo_exen', 0+0 as 'marzo_otros' FROM ( " & _
                        "SELECT inf.*, fdm.fech_pago as ct00_fech_pago, if(fdm.monto_abono>0,'000000','') as ct00_boleta, if (fdm.monto_abono>=fdm.monto_tot_cuota,fdm.monto_tot_cuota,fdm.monto_abono) as ct00_abonado, (fdm.monto_exen_hno+fdm.monto_exen_bca+fdm.monto_exen_desc+fdm.monto_exen_conv+fdm.monto_exen_tipo_pago) as ct00_exencion, 0+0 as ct00_otros FROM ( " & _
                            "SELECT concat(p.ape_pat_alu,' ',p.ape_mat_alu, ' ', p.nom_alu) as alumno, ac.fec_mat, ac.num_gra, ac.let_cur, ac.cod_ens, ac.ci_alu as 'run_alu', hcc.colegio, if(m.ind_beca=1,(100/1),if(m.ind_mbeca=1,(50/1),if((m.tercio='SI'),(m.tercio_por / 1),(0/1)))) as 'Beca', ac.agno, m.tercio " & _
                            "FROM alu_x_cur as ac, postulantes as p, matriculas as m, (select cc.colegio from establecimientos as es, hist_cod_colegio as cc where es.rdb=cc.cod_rbd) as col, hist_cod_colegio as hcc " & _
                            "WHERE (" & cursos & ") AND ac.agno=m.anno_mat AND ac.agno=" & Trim(Combo1.Text) & " AND ac.fec_cam='1111-11-11' AND ac.ci_alu=p.ci_alu AND ac.ci_alu=m.ci_alu AND ac.fec_mat=m.fec_mat AND left(col.colegio,6)=left(hcc.colegio,6) AND ((ac.cod_ens='996' AND length(hcc.colegio)=6) OR (ac.cod_ens<>'996' AND length(hcc.colegio)=6)) ORDER BY ac.num_gra, ac.let_cur, alumno) as inf " & _
                        "LEFT JOIN fnza_detalle_mensualidad as fdm ON inf.run_alu=fdm.run_alu AND fdm.concepto='ct00' AND inf.colegio=fdm.colegio AND inf.agno=fdm.agno " & _
                        "WHERE inf.beca>0 ) as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as mar ON ini.run_alu=mar.run_alu AND ini.colegio=mar.colegio AND ini.agno=mar.agno AND mar.mes=3 AND mar.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as abr ON ini.run_alu=abr.run_alu AND ini.colegio=abr.colegio AND ini.agno=abr.agno AND abr.mes=4 AND abr.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as may ON ini.run_alu=may.run_alu AND ini.colegio=may.colegio AND ini.agno=may.agno AND may.mes=5 AND may.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as jun ON ini.run_alu=jun.run_alu AND ini.colegio=jun.colegio AND ini.agno=jun.agno AND jun.mes=6 AND jun.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as jul ON ini.run_alu=jul.run_alu AND ini.colegio=jul.colegio AND ini.agno=jul.agno AND jul.mes=7 AND jul.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as ago ON ini.run_alu=ago.run_alu AND ini.colegio=ago.colegio AND ini.agno=ago.agno AND ago.mes=8 AND ago.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as sep ON ini.run_alu=sep.run_alu AND ini.colegio=sep.colegio AND ini.agno=sep.agno AND sep.mes=9 AND sep.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as oct ON ini.run_alu=oct.run_alu AND ini.colegio=oct.colegio AND ini.agno=oct.agno AND oct.mes=10 AND oct.concepto='esco') as ini " & _
                    "LEFT JOIN fnza_detalle_mensualidad as nov ON ini.run_alu=nov.run_alu AND ini.colegio=nov.colegio AND ini.agno=nov.agno AND nov.mes=11 AND nov.concepto='esco') as ini LEFT JOIN fnza_detalle_mensualidad as dic ON ini.run_alu=dic.run_alu AND ini.colegio=dic.colegio AND ini.agno=dic.agno AND dic.mes=12 AND dic.concepto='esco';"
End Function

Function CreatePagosXCursoEst(ByVal agno As Integer) As String
'***********************************************************************
'* ¿Se necesita rehacer la consulta y el reporte?                      *
'* El descuento por ajuste y el descuento por mensualidad estan juntos *
'***********************************************************************
CreatePagosXCursoEst = "CREATE TABLE informe_pagos_x_curso_est TYPE=MyISAM SELECT axc.cod_ens, axc.num_gra, axc.agno, count( distinct axc.let_cur) as 'num_cursos', fdm.colegio, fdm.fech_venc, sum(fdm.monto_total>0) as 'num_alu', sum(fdm.monto_exen_bca=fdm.monto_total) as 'beca_completa', sum(fdm.monto_exen_bca=(fdm.monto_total/2)) as 'beca_media', sum(fdm.monto_exen_hno>0) as 'desc_hmno', sum(fdm.monto_exen_conv>0) as 'desc_conv', sum((fdm.monto_exen_desc+fdm.monto_exen_tipo_pago)>0) as 'desc_depo', sum(fdm.monto_abono>0) as 'pagos' " & _
                        "FROM alu_x_cur axc,fnza_detalle_mensualidad fdm WHERE axc.agno=fdm.agno AND axc.agno=" & agno & " AND axc.ci_alu=fdm.run_alu AND axc.fec_cam='1111-11-11' AND (fdm.estado_dtll='clda' OR fdm.estado_dtll='impg' OR fdm.estado_dtll='cred' OR fdm.estado_dtll='abon') AND ( (length(fdm.colegio)=6 and axc.cod_ens<>'996') OR (length(fdm.colegio)>6 and axc.cod_ens='996') ) GROUP BY fdm.colegio, axc.cod_ens, axc.num_gra, fdm.fech_venc order by fdm.fech_venc, fdm.colegio DESC, axc.cod_ens, axc.num_gra;"
End Function

Function CreatePagosXCursoComp(ByVal agno As Integer) As String
'***********************************************************************
'* ¿Se necesita rehacer la consulta y el reporte?                      *
'* El descuento por ajuste y el descuento por mensualidad estan juntos *
'***********************************************************************
CreatePagosXCursoComp = "CREATE TABLE informe_pagos_x_curso_comp TYPE=MyISAM SELECT axc.cod_ens, axc.num_gra, axc.agno, fdm.colegio, fdm.fech_venc, count(fdm.monto_tot_cuota) as 'num_cuotas', sum(fdm.monto_tot_cuota) as 'tot_cuotas', sum(fdm.monto_abono>0) as 'num_abonos', sum(fdm.monto_abono) as 'tot_abonos', ((sum(fdm.monto_abono)/sum(fdm.monto_tot_cuota))*100) as 'porc_pago', ((sum(fdm.monto_abono>0)/count(fdm.monto_tot_cuota))*100) as 'porc_cuota'   FROM fnza_detalle_mensualidad as fdm, alu_x_cur as axc WHERE axc.agno=fdm.agno AND axc.agno=" & agno & " AND axc.ci_alu=fdm.run_alu AND axc.fec_cam='1111-11-11' AND fdm.monto_tot_cuota>0 AND (fdm.estado_dtll='clda' OR fdm.estado_dtll='impg' OR fdm.estado_dtll='cred' OR fdm.estado_dtll='abon') AND ( (length(fdm.colegio)=6 and axc.cod_ens<>'996') OR (length(fdm.colegio)>6 and axc.cod_ens='996') ) GROUP BY fdm.fech_venc, fdm.colegio, axc.cod_ens, axc.num_gra ORDER BY fdm.fech_venc, fdm.colegio DESC, axc.cod_ens, axc.num_gra;"
End Function

Private Sub LlenaComboAgno()
    If Year(Date) < 2005 Then
        Combo1.AddItem ("2005")
    Else
        For i = Year(Date) To 2005 Step -1
            Combo1.AddItem (str(i))
        Next i
    End If
    Flag_sub = True
    Combo1.ListIndex = 0
    Flag_sub = False
End Sub

Private Sub Grd_Cons_DblClick()
    ' permitir cambio de folio a una boleta
    Dim MyRow As Long
    Dim FolioActual As Long
    
    MyRow = Grd_Cons.Row
    FolioActual = val(Grd_Cons.TextMatrix(MyRow, 1))
    Text_FolioBlta.Text = FolioActual
    Frame_Grilla_Cons.Enabled = False
    Btn_Cons_Bol.Enabled = False
    Frm_CambFolioBlta.Visible = True

End Sub

Private Sub Lst_Campos_Grilla_ItemCheck(Item As Integer)
    MuestraColumnasBoletasSeleccionadas
End Sub

Private Sub opt_destino_cartola_Click(Index As Integer)
    Select Case Index
        Case 0: Form_main.CrystalReport.Destination = crptToWindow
    
        Case 1: Form_main.CrystalReport.Destination = crptToPrinter
        
        Case Else: Form_main.CrystalReport.Destination = crptToWindow
    End Select
End Sub
Sub HideFrameFinanzas()
Me.Frame_PCursos_Anual.Visible = False
Me.Frame_CredyAbonos.Visible = False
Me.Frame_Folios_Notrat.Visible = False
Me.Frame_Libro_Boletas.Visible = False
Me.Frame_ConsBol.Visible = False
End Sub
'Conecta y Trae Informacion
Function DatosExternos() As Boolean
    DatosExternos = False
    Dim ServidorExt As String, UsuarioExt As String, PasswordExt As String, BaseDatosExt As String
    ServidorExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "HOST", ""))
    If Len(Trim(ServidorExt)) = 0 Then
        ServidorExt = InputBox("Ingrese dieccion del Servidor externo", "Dirección Servidor")
        IniWrite "GESCOL.INI", "EXTERNO", "HOST", Form_main.EnCrypt_Main.EnCrypt(ServidorExt)
    End If
    UsuarioExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "USUARIO", ""))
    If Len(Trim(UsuarioExt)) = 0 Then
        UsuarioExt = InputBox("Ingrese Nombre de usuario", "Nombre de usuario de conexión")
        IniWrite "GESCOL.INI", "EXTERNO", "USUARIO", Form_main.EnCrypt_Main.EnCrypt(UsuarioExt)
    End If
    
    PasswordExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "PASSWORD", ""))
    If Len(Trim(PasswordExt)) = 0 Then
        PasswordExt = InputBox("Ingrese Password", "Password de conexión")
        IniWrite "GESCOL.INI", "EXTERNO", "PASSWORD", Form_main.EnCrypt_Main.EnCrypt(PasswordExt)
    End If
        
    BaseDatosExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "BASEDATOS", ""))
    If Len(Trim(BaseDatosExt)) = 0 Then
        BaseDatosExt = InputBox("Ingrese Base de datos", "Base de datos Remota")
        IniWrite "GESCOL.INI", "EXTERNO", "BASEDATOS", Form_main.EnCrypt_Main.EnCrypt(BaseDatosExt)
    End If
    If ConectarBD(ConnExt, ServidorExt, BaseDatosExt, UsuarioExt, PasswordExt, False) Then
        Dim SqlExt As String
        Dim RsFuncion As ADODB.Recordset
        Set RsFuncion = New ADODB.Recordset
        RsFuncion.CursorLocation = adUseClient
        
        mes = Me.Cmb_Mes.ItemData(Me.Cmb_Mes.ListIndex)
        FechaDel = InvierteFecha(CDate(Me.Cmb_anho & "/" & mes & "/" & Me.Cmb_del_dia.Text), "R")
        FechaAl = InvierteFecha(CDate(Me.Cmb_anho & "/" & mes & "/" & Me.Cmb_al_dia.Text), "R")
        
        If Not Particular Then
            SqlExt = "select rut_cli, right(cab_bol,4) as 'agno', num_cup, fech_rec, fech_ven, monto, monto_tot, convenio from pagos_bci where fech_rec >= '" & FechaDel & "' and fech_rec <= '" & FechaAl & "' and convenio = " & CLng(Me.Txt_CodConvBci) & " order by fech_rec, rut_cli, fech_ven"
        Else
            SqlExt = "select rut_cli, right(cab_bol,4) as 'agno', num_cup, fech_rec, fech_ven, monto, monto_tot, convenio from pagos_bci where fech_rec >= '" & FechaDel & "' and fech_rec <= '" & FechaAl & "' and convenio = '" & CLng(Me.Txt_CodConvBci_Part) & "' and left(cab_bol,3) = '" & Me.Txt_CodConvBci & "' order by fech_rec, rut_cli, fech_ven"
        End If

        RsFuncion.Open SqlExt, ConnExt
        If RsFuncion.RecordCount > 0 Then
            Form_Progress.Label1.Caption = "Transfiriendo Información Bancaria"
            Form_Progress.Show
            Form_Progress.ProgBar1.MaxValue = RsFuncion.RecordCount - 1
            Form_Progress.ProgBar1.ShowProgress 0
            For h = 0 To RsFuncion.RecordCount - 1
                conn.Execute "replace into TMP_PAGOS_BANCO values('" & RsFuncion!rut_cli & "', " & val(RsFuncion!agno) & " , '" & Format(RsFuncion!fech_rec, "yyyy-mm-dd") & "','" & Format(RsFuncion!fech_ven, "yyyy-mm-dd") & "'," & RsFuncion!num_cup & ", '" & RsFuncion!Convenio & "', " & RsFuncion!monto & ")"
                RsFuncion.MoveNext
                Form_Progress.ProgBar1.ShowProgress h + 0
                Form_Progress.SetFocus
                DoEvents
            Next h
            DatosExternos = True
            Form_Progress.ProgBar1.ShowProgress 0
            Unload Form_Progress
        End If
        RsFuncion.Close
        Set RsFuncion = Nothing
    End If
End Function
Function TablaTemp() As Boolean
On Error GoTo controlerr
conn.Execute "DROP TABLE IF EXISTS `TMP_PAGOS_BANCO`;"
conn.Execute "CREATE TABLE TMP_PAGOS_BANCO" & _
"(" & _
    "RUT_CLI         VARCHAR(10)   not null," & _
    "AGNO            NUMERIC(4)    not null," & _
    "FECH_REC        DATE          not null," & _
    "FECH_VEN        DATE          not null," & _
    "NUM_CUP         NUMERIC(2)    not null," & _
    "CONV_BCI        VARCHAR(3)    not null," & _
    "MONTO           BIGINT(6)     not null," & _
    "primary key (RUT_CLI, AGNO, NUM_CUP)) ENGINE=MyISAM ;"
    Set RsFuncion = New ADODB.Recordset
    RsFuncion.CursorLocation = adUseClient
    RsFuncion.Open "select * from TMP_PAGOS_BANCO", conn
    TablaTemp = True
    RsFuncion.Close
    Set RsFuncion = Nothing
Exit Function
controlerr:
Set RsFuncion = Nothing
TablaTemp = False
End Function

Private Sub LlenaComboAgno_CredyAbonos()
    If Year(Date) < 2005 Then
        Me.Cmb_anho.AddItem ("2005")
    Else
        For i = Year(Date) To 2005 Step -1
            Me.Cmb_anho.AddItem (str(i))
        Next i
    End If
    Flag_sub = True
    Me.Cmb_anho.ListIndex = 0
    Flag_sub = False
End Sub
Sub IniciaGrillaCyA(Index As Integer)
Select Case Index
Case 0
    Me.Grd_Datos_CyA(0).Cols = 13
    Me.Grd_Datos_CyA(0).Rows = 2
    Me.Grd_Datos_CyA(0).FixedCols = 0
    Me.Grd_Datos_CyA(0).Clear
    Me.Grd_Datos_CyA(0).MergeCells = flexMergeRestrictRows
    Me.Grd_Datos_CyA(0).MergeRow(0) = True
    '                                 0       1          2        3         4      5    6    7      8       9         10       11      12
    Me.Grd_Datos_CyA(0).FormatString = "Día |Apoderado |Mes Cuota|Año Cuota|Alumnos|Curso|Base|Beca|Hermanos|Convenio|Descto.|A Pagar|Pagado Banco"
    Me.Grd_Datos_CyA(0).ColWidth(0) = 500
    Me.Grd_Datos_CyA(0).ColWidth(1) = 3000
    Me.Grd_Datos_CyA(0).ColWidth(2) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(3) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(4) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(5) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(6) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(7) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(8) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(9) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(10) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(11) = 1000
    Me.Grd_Datos_CyA(0).ColWidth(12) = 1000
Case 1
    Me.Grd_Datos_CyA(1).Cols = 9
    Me.Grd_Datos_CyA(1).Rows = 2
    Me.Grd_Datos_CyA(1).FixedCols = 0
    Me.Grd_Datos_CyA(1).Clear
    Me.Grd_Datos_CyA(1).MergeCells = flexMergeRestrictRows
    Me.Grd_Datos_CyA(1).MergeRow(0) = True
    '                                    0    1       2        3      4        5     6      7     "
    Me.Grd_Datos_CyA(1).FormatString = "Día |Rut |Apoderado |Cuota|Del Año|A Pagar|Pagado|Crédito|Saldo Pdte."
    Me.Grd_Datos_CyA(1).ColWidth(0) = 400
    Me.Grd_Datos_CyA(1).ColWidth(1) = 1000
    Me.Grd_Datos_CyA(1).ColWidth(2) = 3100
    Me.Grd_Datos_CyA(1).ColWidth(3) = 950
    Me.Grd_Datos_CyA(1).ColWidth(4) = 900
    Me.Grd_Datos_CyA(1).ColWidth(5) = 950
    Me.Grd_Datos_CyA(1).ColWidth(6) = 950
    Me.Grd_Datos_CyA(1).ColWidth(7) = 950
    Me.Grd_Datos_CyA(1).ColWidth(8) = 950
End Select
End Sub

Private Sub opt_destino_CyA_Click(Index As Integer)
If Index = 1 Then
    Form_main.CrystalReport.Destination = crptToPrinter
ElseIf Index = 0 Then
    Form_main.CrystalReport.Destination = crptToWindow
End If
End Sub

Private Sub Opt_Destino_FoliosNotrat_Click(Index As Integer)
    Select Case Index
        Case 0: Form_main.CrystalReport.Destination = crptToWindow
    
        Case 1: Form_main.CrystalReport.Destination = crptToPrinter
        
        Case Else: Form_main.CrystalReport.Destination = crptToWindow
    End Select
End Sub

Private Sub Opt_Destino_LibroBol_Click(Index As Integer)
    Select Case Index
        Case 0: Form_main.CrystalReport.Destination = crptToWindow
    
        Case 1: Form_main.CrystalReport.Destination = crptToPrinter
        
        Case Else: Form_main.CrystalReport.Destination = crptToWindow
    End Select
End Sub

Private Sub Opt_TipoCyA_Click(Index As Integer)
Dim Otroindice As Integer
Otroindice = (Index - 1) * -1
Me.Grd_Datos_CyA(Otroindice).Enabled = False
Me.Grd_Datos_CyA(Otroindice).Visible = False
Me.Grd_Datos_CyA(Index).Visible = True
Me.Grd_Datos_CyA(Index).Enabled = True
NgrillaCyA = Index
Call IniciaGrillaCyA(Index)
End Sub
Sub Cya_Simple()
    Dim MesVencim As Integer, Diferencia As Long, RutApo As String
    Dim Tcredito As Long, Tpendiente As Long, Tpagado As Long, Tapagar As Long
    Form_Progress.Label1.Caption = "Generando Detalles"
    Form_Progress.Show
    Form_Progress.ProgBar1.MaxValue = RsCya.RecordCount - 1
    Form_Progress.ProgBar1.ShowProgress 0
    Tpagado = 0: Tapagar = 0: Tcredito = 0: Tpendiente = 0
    For t = 0 To RsCya.RecordCount - 1
        RutApo = RsCya!rut_cli
        'If RutApo = "15939429-8" Then msbox (RutApo)
        MesVencim = val(RsCya!num_cup) + 2
        If RsCya!agno = 2004 Then ' Trae Cuota 2004
            apagar = Cuota2004(RutApo, MesVencim, TipoAlu, Txt_CodConvBci)
        Else
            apagar = DevuelveCampo("fnza_mensualidad fm", "", "fm.monto_mens", "fm.run_apo='" & RsCya!rut_cli & "' and fm.agno =" & RsCya!agno & " and fm.mes = " & MesVencim & " and fm.colegio ='" & CodEmpresa & "'", conn)
        End If
        Diferencia = val(RsCya!monto) - val(apagar)
        If Diferencia <> 0 Then
            'si hay diferencia imprime
            FilaCyA = FilaCyA + 1
            Me.Grd_Datos_CyA(1).AddItem ""
            Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 0) = Day(RsCya!fech_rec)
            Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 1) = RsCya!rut_cli
            Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 2) = RsCya!NomApo
            Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 3) = MesATexto(MesVencim)
            Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 4) = RsCya!agno
            Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 5) = IIf(apagar = "", "Sin Detalle", apagar)
            Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 6) = RsCya!monto
            'Aquí calculo la diferencia, para determinar abono o crédito a favor del apoderado.
            If Diferencia > 0 Then
                ' A Favor, Crédito
                Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 7) = Diferencia
                Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 8) = 0
            ElseIf Diferencia < 0 Then
                ' En Contra, Abono Saldo Pendiente
                Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 7) = 0
                Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 8) = Diferencia * -1
            Else
                Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 7) = 0
                Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 8) = 0
            End If
        End If
        'Tpagado = Tpagado + Val(Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 5))
        'Tapagar = Tapagar + Val(Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 6))
        'Tcredito = Tcredito + Val(Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 7))
        'Tpendiente = Tpendiente + Val(Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA, 8))
        RsCya.MoveNext
        Form_Progress.ProgBar1.ShowProgress t + 0
        Form_Progress.SetFocus
        DoEvents
    Next t
    'Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA + 1, 5) = Tpagado
    'Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA + 1, 6) = Tapagar
    'Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA + 1, 7) = Tcredito
    'Me.Grd_Datos_CyA(1).TextMatrix(FilaCyA + 1, 8) = Tpendiente
    Form_Progress.ProgBar1.ShowProgress 0
    Unload Form_Progress
End Sub
Sub Cya_Detall(RsCya As ADODB.Recordset)
Dim MesVencim As Integer
Form_Progress.Label1.Caption = "Generando Detalles"
Form_Progress.Show
Form_Progress.ProgBar1.MaxValue = RsCya.RecordCount - 1
Form_Progress.ProgBar1.ShowProgress 0
For t = 0 To RsCya.RecordCount - 1
    FilaCyA = FilaCyA + 1
    Me.Grd_Datos_CyA(0).AddItem ""
    MesVencim = val(rs!num_cup) + 2
    Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 0) = Day(rs!fech_rec)
    Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 1) = rs!NomApo
    Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 2) = MesATexto(MesVencim)
    Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 3) = rs!agno
    Set RsAux = New ADODB.Recordset
    RsAux.CursorLocation = adUseClient
    'Traigo los alumnos del apoderado y sus respectivas mensualidades
    RsAux.Open "SELECT fdm.monto_total, fdm.monto_exen_bca, fdm.monto_exen_hno, fdm.monto_exen_conv, fdm.monto_exen_desc, fdm.monto_exen_tipo_pago, fdm.monto_tot_cuota, concat(p.ape_pat_alu, ' ' , p.ape_mat_alu, ' ' , p.nom_alu) as nomalu FROM fnza_mensualidad fm, fnza_detalle_mensualidad fdm, apoderados a, alu_x_cur ac, postulantes p where fm.folio_mens=fdm.folio_mens and fm.colegio=fdm.colegio and fdm.run_alu=ac.ci_alu and ac.ci_alu=p.ci_alu and fm.run_apo=a.rut_apo and fm.run_apo='" & RsCya!rut_cli & "' and fm.agno =" & RsCya!agno & " and fm.mes = " & MesVencim & " and fdm.colegio ='" & CodEmpresa & "'", conn
    If RsAux.RecordCount > 0 Then
        While Not RsAux.EOF
            FilaCyA = FilaCyA + 1
            Me.Grd_Datos_CyA(0).AddItem ""
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 4) = RsAux!NomAlu
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 5) = "Curso"
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 6) = RsAux!Monto_Total
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 7) = RsAux!monto_exen_bca
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 8) = RsAux!monto_exen_hno
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 9) = RsAux!Monto_Exen_Conv
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 10) = RsAux!monto_exen_desc + RsAux!monto_exen_tipo_pago 'Estos conceptos deben ser separados en el futuro
            Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 11) = RsAux!monto_tot_cuota
            RsAux.MoveNext
        Wend
    End If
    RsAux.Close
    Set RsAux = Nothing
    Me.Grd_Datos_CyA(0).TextMatrix(FilaCyA, 12) = rs!monto
    RsCya.MoveNext
    Form_Progress.ProgBar1.ShowProgress t + 0
    Form_Progress.SetFocus
    DoEvents
Next t
Form_Progress.ProgBar1.ShowProgress 0
Unload Form_Progress
End Sub
Function Cuota2004(RutApo As String, mes As Integer, AluTipo As String, CodConvBci As String) As Long
Dim CuotaApo As Long
Dim Grupo() As String
Grupo = TraeMenAgrup(CodConvBci, RutApo, str(mes), AluTipo, False)
Hijos = val(Grupo(0, 0))
CuotaApo = 0
If Hijos > 0 Then
    For te = 0 To Hijos - 1
        CuotaApo = CuotaApo + val(Grupo(te, 3))
    Next te
End If
Cuota2004 = CuotaApo
End Function
Sub ReporteCyA(IndiceGrd)
    Call CreaBD(DirAplicacion & "\rpt\gestemp.mdb")
    Call CreaTabla(DirAplicacion & "\rpt\gestemp.mdb", "Detalles", "9,10")
    Call RptGrillaTextH(Me.Grd_Datos_CyA(IndiceGrd), Me.Grd_Datos_CyA(IndiceGrd).Rows - 1, "\rpt\gestemp.mdb", "Detalles")
    'Titulo = "INFORME " & Trim(UCase(Me.Opt_TipoCyA(IndiceGrd).Caption)) & " DE CRÉDITOS Y ABONOS "
    titulo = "INFORME DE CRÉDITOS Y ABONOS "
    Nombrecol = DevuelveCampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
    Direccol = DevuelveCampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
    ComunaCol = DevuelveCampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.Formulas(0) = "nomcol = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "dircol = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacol = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "empresa = '" & NomEmpresa & "'"
    Form_main.CrystalReport.Formulas(5) = "anho = '" & Me.Cmb_anho & "'"
    Form_main.CrystalReport.Formulas(6) = "mes = '" & UCase(Me.Cmb_Mes) & "'"
    Form_main.CrystalReport.Formulas(7) = "del = '" & Me.Cmb_del_dia & "'"
    Form_main.CrystalReport.Formulas(8) = "al = '" & Me.Cmb_al_dia & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\CredyAbonos.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\rpt\gestemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 20)
    'Kill (DirAplicacion & "\rpt\gestemp.mdb")

End Sub
Public Function TraeMenAgrup(CodConvenio As String, RutApo As String, mes As String, TipAluBosPk As String, ReCalcular As Boolean) As String()
'#### MUESTRA HERMANOS CON EL VALOR DE CUOTA ####
Dim Pk As Integer
Dim Bos As Integer
Dim j As Integer
Dim Convenio As Boolean
'*** matriz que guarda el valor de la cuota del alumno y el exedente
Dim MenExe() As Long
'*** MenExe(0) Cuota alumno
'*** MenExe(0) Exedente
Dim MatrizHer() As String
Dim TamannoMAtriz As Integer
Dim CritTipAlu As String
Convenio = IIf(IsNull(DevuelveCampo("gescol2004.apoderados", "", "cod_conv", "rut_apo ='" & RutApo & "'", conn)) Or Trim(DevuelveCampo("gescol2004.apoderados", "", "cod_conv", "rut_apo ='" & RutApo & "'", conn)) = "" Or UCase(DevuelveCampo("gescol2004.apoderados", "", "cod_conv", "rut_apo ='" & RutApo & "'", conn)) = "N", False, True)
        Set rs = New ADODB.Recordset
        rs.CursorLocation = adUseClient
        ' ************En esta consulta se trae el apoderado con todos sus pupilos************
        ' *** AQUÍ SE DEBE MANEJAR EL ORDEN DE HERMANOS, DE MAYOR A MENOR POR NIVEL Y CODIGO DE ENSEÑANZA
        If Not (val(mes) > 0 And val(mes) <= 12) Then
                ReDim MatrizHer(0, 1)
                MatrizHer(0, 0) = "ERR"
                MatrizHer(0, 1) = "El argumento " & mes & " de la función AsigMen NO es una fecha válida"
                TraeMenAgrup = MatrizHer
                Exit Function
         End If
            'Esta consulta trae la matrícula actual de un mes.....
                                     '0           1            2             3            4           5         6
            a = "SELECT distinct apa.rut_apo, p.ci_alu, p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, m.anno_mat, ac.cod_ens, co.cod_des, m.ind_beca, m.ind_mbeca, m.num_gra, p.fec_nacalu, m.fec_mat, a.ape1_apo, a.ape2_apo, a.noms_apo, ac.num_gra, ac.let_cur " & _
                "FROM gescol2004.apoderados a, gescol2004.apo_x_alu apa, gescol2004.postulantes p, gescol2004.matriculas m, gescol2004.codigos_ensenanza co, gescol2004.alu_x_cur ac where apa.ci_alu = p.ci_alu and apa.ci_alu = m.ci_alu and m.ci_alu=ac.ci_alu and a.rut_apo=apa.rut_apo and apa.rut_apo ='" & RutApo & "' and " & _
                "m.anno_mat = '2004' and m.cod_ens=co.cod_ens and (month(m.fec_retiro) >= '" & mes & "' or " & _
                "m.fec_retiro = '1111-11-11') and (month(ac.fec_cam) >= '" & mes & "' or ac.fec_cam = '1111-11-11') and m.fec_mat= ac.fec_mat and m.activo_alu=ac.activo_alu " & CritTipAlu & " order by co.ord_ens desc, ac.num_gra desc, p.fec_nacalu Asc"
        rs.Open a, conn
        If rs.RecordCount > 0 Then
            Pk = 0
            Bos = 0
            For j = 1 To rs.RecordCount
                If rs(6) = "996" Then Pk = Pk + 1
                rs.MoveNext
            Next j
            
            rs.MoveFirst
            Bos = rs.RecordCount - Pk
                        If Len(Trim(TipAluBosPk)) > 0 Then
                Select Case TipAluBosPk
                    Case "BOS": TamannoMAtriz = Bos
                    Case "PK": TamannoMAtriz = Pk
                End Select
            Else
                TamannoMAtriz = rs.RecordCount
                CritTipAlu = (rs(6) <> "---")
            End If
            ReDim MatrizHer(TamannoMAtriz, 10)
            If TamannoMAtriz > 0 Then
                m = 0
                For j = 1 To rs.RecordCount
                    If Len(Trim(TipAluBosPk)) > 0 Then
                        Select Case TipAluBosPk
                            Case "BOS": CritTipAlu = (rs(6) <> "996")
                            Case "PK": CritTipAlu = (rs(6) = "996")
                        End Select
                    End If
                    If CritTipAlu Then
                        m = m + 1
                        MatrizHer(m - 1, 0) = TamannoMAtriz
                        MatrizHer(m - 1, 1) = m
                        MatrizHer(m - 1, 2) = rs(1) ' ci_alu
                        If ReCalcular Then ' Si pide ReCalcular cuota
                            '************************************************************
                            '***** Estas líneas son para calcular mensualidad ***********
                            MenExe = CalMenM(CodConvenio, rs(6), rs.RecordCount, Bos, Pk, Convenio, IIf(IsNull(rs(8)) Or Trim(rs(8)) = "" Or Trim(rs(8)) = "0", False, True), IIf(IsNull(rs(9)) Or Trim(rs(9)) = "" Or Trim(rs(9)) = "0", False, True), j)
                            MatrizHer(m - 1, 3) = MenExe(0) 'Cuota
                            MatrizHer(m - 1, 4) = MenExe(1) 'Exención
                        Else ' Si pide traer Cuotas calculadas
                            '************************************************************
                            '***** Estas líneas son para traer mensualidad de cuotas_x_alu*****
                            cuotasexe = TraeCuotaalu2004(rs(1), FillconStr(Trim(mes), 2, "0", "IZQ"))
                            MatrizHer(m - 1, 3) = cuotasexe(0, 1) 'Cuota
                            MatrizHer(m - 1, 4) = cuotasexe(0, 0) 'Exencion
                        End If
                        MatrizHer(m - 1, 5) = rs(6) ' cod_ens
                        MatrizHer(m - 1, 6) = rs(0) ' Rut apoderado
                        MatrizHer(m - 1, 7) = rs(15) & " " & rs(13) & " " & rs(14)  ' Nombre Apoderado
                        MatrizHer(m - 1, 8) = rs(4) & " " & rs(2) & " " & rs(3)   ' Nombre alumno
                        If UCase(rs(7)) = "PK" Or UCase(rs(7)) = "K" Then
                            curso = rs(7) & " " & rs(17)
                        Else
                            curso = rs(10) & " " & rs(17) & " " & rs(7)
                        End If
                        MatrizHer(m - 1, 9) = curso
                        MatrizHer(m - 1, 10) = CStr(DevuelveCampo("gescol2004.arancel", "", "mensual", "cod_ens ='" & rs(6) & "'", conn))
                        'Call InsertAlu(Rs.RecordCount, Bos, Pk, j)   'inserta los hijos del apoderado en la grilla
                    '    rs.MoveNext
                    End If
                    rs.MoveNext
                Next j
            Else
                ReDim MatrizHer(0, 1)
                MatrizHer(0, 0) = "ERR"
                MatrizHer(0, 1) = "No se encontraron alumnos para el apoderado RUT :" & RutApo
            End If
        Else
            ReDim MatrizHer(0, 1)
            MatrizHer(0, 0) = "ERR"
            MatrizHer(0, 1) = "No se encontraron alumnos para el apoderado RUT :" & RutApo
        End If
        rs.Close
        Set rs = Nothing
        TraeMenAgrup = MatrizHer
'#### FIN MUESTRA HERMANOS CON EL VALOR DE CUOTA ####
End Function
Function TraeCuotaalu2004(rutalumno As String, MesCuota As String) As Long()
Dim MatrizVal(1, 2) As Long
Dim FecRetiro As Date
    FecRetiro = DevuelveCampo("gescol2004.matriculas", "", "fec_retiro", "ci_alu ='" & rutalumno & "' order by fec_retiro DESC limit 1", conn)
    MesRetiro = MesRetiroContable2004(FecRetiro)
    If val(MesCuota) > MesRetiro Then
        MatrizVal(0, 0) = 0 ' Exencion
        MatrizVal(0, 1) = 0 ' Cuota
    Else
        Set RsFuncion = New ADODB.Recordset
        RsFuncion.CursorLocation = adUseClient
        'RsFuncion.Open "select cod_bci, cuota_alu, exe_alu, cuota_sis from cuotas_x_alu where ci_alu='" & RutAlumno & "' and  mes_cuota <='" & FillconStr(Mescuota, 2, "0", "IZQ") & "' order by mes_cuota DESC limit 1", conn
        RsFuncion.Open "select cod_bci, cuota_alu, exe_alu, cuota_sis from gescol2004.cuotas_x_alu where ci_alu='" & rutalumno & "' and  mes_cuota <='" & MesCuota & "' order by mes_cuota DESC limit 1", conn
        If RsFuncion.RecordCount > 0 Then
            MatrizVal(0, 0) = IIf(IsNull(RsFuncion!exe_alu), 0, RsFuncion!exe_alu)
            MatrizVal(0, 1) = IIf(IsNull(RsFuncion!cuota_alu), RsFuncion!cuota_sis, RsFuncion!cuota_alu)
        Else
            MatrizVal(0, 0) = 0 ' exencio' cuotan
            MatrizVal(0, 1) = 0
        End If
        RsFuncion.Close
        Set RsFuncion = Nothing
    End If
    TraeCuotaalu2004 = MatrizVal
End Function
Public Function CalMenM(colegio As String, ColoPK As String, NumAluTot As Integer, NumAluBos As Integer, NumAluPK As Integer, Convenio As Boolean, Beca As Boolean, mBeca As Boolean, IdHermano As Integer) As Long()
Dim MenExe(1) As Long
Dim exencion As Long
Dim CalMen As Long
'Dim ValCuota As Long


'## Colegio   - Discriminante de colegio (600, 601, 602...)
'## ColoPK    - Determina si el alumno esta en Kinder a Media o Prekinder para efecto de el tipo de empresa
'## NumAluTot - Total de alumnos hermanos (Tabla)
'## NumAluBos - Total de alumnos Boston (Tabla)
'## NumAluPK  - Total de alumnos en prekinder (Tabla - "Miss Marta o Julio Martínez según sea)"
'Dim mC1yLetras(3) As String
CodConvBci = colegio 'Fuerzo a que entre al Lincoln para probar su funcionamiento
Dim DescuentoConvenio As Single
DescuentoConvenio = IIf(Convenio, 0.7, 1)
Select Case CodConvBci 'Discrimina Colegio

Case "600", "601", "603" 'M A I P U,  F A R F A N A  Y  S A N  M A R T I N
    ValCuota = 21000
    
    Select Case NumAluTot
        Case 1 '1 ###### hermano
            If ColoPK = "996" Then ' Es alumno prekinder - 606
                ValCuota = 25000
                CalMen = 25000 * DescuentoConvenio
                CalMen = IIf(Beca, 25000 * 0, CalMen)
                CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
            Else    ' Es alumno boston - "600", "601" o "603"
                CalMen = 21000 * DescuentoConvenio
                CalMen = IIf(Beca, 21000 * 0, CalMen)
                CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
            End If
        Case 2 '2 ###### hermanos
            If NumAluBos = 2 Then ' 2 alumnos boston
                Select Case IdHermano
                    Case 1 'hermano  mayor
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case 2 'hermano  menor
                        CalMen = 15000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 1 And NumAluPK = 1 Then ' 1 alumnos boston y 1 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 16000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta
                       ValCuota = 25000
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
            If NumAluPK = 2 Then ' 2 alumnos en Miss Marta
                ValCuota = 25000
                Select Case IdHermano
                    Case 1 'Miss Marta 1
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                    Case 2 'Miss Marta 2
                        CalMen = 20000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
            
        
        Case 3 '3 ###### hermanos
            If NumAluBos = 3 Then ' 3 alumnos boston
                Select Case IdHermano
                    Case 1 'hermano  mayor
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case 2, 3 'hermano  medio y menor
                        CalMen = 14000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 2 And NumAluPK = 1 Then ' 2 alumnos boston y 1 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 14000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta
                        ValCuota = 25000
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 1 And NumAluPK = 2 Then ' 1 alumnos boston y 2 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 12000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta
                        ValCuota = 25000
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
            If NumAluPK = 3 Then ' 3 alumnos en Miss Marta
                ValCuota = 25000
                Select Case IdHermano
                    Case 1, 2 ' Miss Marta 1 y Miss Marta 2
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                    Case 3 'Miss Marta 3
                        CalMen = 17000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
        
        Case 4 '4 ###### hermanos
            If NumAluBos = 4 Then ' 4 alumnos boston
                Select Case IdHermano
                    Case 1 'boston  mayor
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case 2, 3, 4 ' boston 2, boston 3 y boston menor
                        CalMen = 15000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 3 And NumAluPK = 1 Then ' 3 alumnos boston y 1 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston - Mayor, medio y menor
                        CalMen = 15000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta
                        ValCuota = 25000
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 2 And NumAluPK = 2 Then ' 2 alumnos boston y 2 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston - MAyor y Menor
                        CalMen = 14000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta - Miss Marta 1 y Miss Marta 2
                        ValCuota = 25000
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 1 And NumAluPK = 3 Then ' 1 alumnos boston y 3 Miss Marta
                Select Case IdHermano
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 6000 * DescuentoConvenio
                        CalMen = IIf(Beca, 21000 * 0, CalMen)
                        CalMen = IIf(mBeca, 21000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta - Miss Marta 1, Miss Marta 2 y Miss Marta 3
                        ValCuota = 25000
                        CalMen = 25000 * DescuentoConvenio
                        CalMen = IIf(Beca, 25000 * 0, CalMen)
                        CalMen = IIf(mBeca, 25000 * 0.5, CalMen)
                End Select
            End If
    'Exencion = ValCuota - CalMen
    End Select

Case "602" 'F L O R I D A
    'EN FLORIDA ONO HAY CONVENIOS ->DescuentoConvenio SIEMPRE ES 1
    ValCuota = 28000
    Select Case NumAluTot
        Case 1 '1 ###### hermano
            If ColoPK = "996" Or ColoPK = "010" Or ColoPK = "110" Or ColoPK = "310" Then ' igual para boston y miss Marta
                CalMen = 28000 * DescuentoConvenio
                CalMen = IIf(Beca, 2800 * 0, CalMen)
                CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
            End If
        Case 2 '2 ###### hermanos
            If NumAluBos = 2 Then ' 2 alumnos boston
                Select Case IdHermano
                    Case 1 'hermano  mayor
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case 2 'hermano  menor
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 1 And NumAluPK = 1 Then ' 1 alumnos boston y 1 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 21000 * DescuentoConvenio '16000 cambio 28-03-2004
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta
                        CalMen = 28000 * DescuentoConvenio '25000 cambio 28-03-2004
                        CalMen = IIf(Beca, 28000 * 0, CalMen) '25000 cambio 28-03-2004
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen) '25000 cambio 28-03-2004
                End Select
            End If
            If NumAluPK = 2 Then ' 2 alumnos en Miss Marta
                Select Case IdHermano
                    Case 1 'Miss Marta 1
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case 2 'Miss Marta 2
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            
        
        Case 3 '3 ###### hermanos
            If NumAluBos = 3 Then ' 3 alumnos boston
                Select Case IdHermano
                    Case 1 'hermano  mayor
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case 2, 3 'hermano  medio y menor
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 2 And NumAluPK = 1 Then ' 2 alumnos boston y 1 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 1 And NumAluPK = 2 Then ' 1 alumnos boston y 2 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 14000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            If NumAluPK = 3 Then ' 3 alumnos en Miss Marta
                Select Case IdHermano
                    Case 1, 2 ' Miss Marta 1 y Miss Marta 2
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case 3 'Miss Marta 3
                        CalMen = 14000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                 End Select
            End If
        
        Case 4 '4 ###### hermanos
            If NumAluBos = 4 Then ' 4 alumnos boston
                Select Case IdHermano
                    Case 1 'boston  mayor
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case 2, 3 ' boston 2, boston 3 y boston menor
                        CalMen = 21000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case 4 ' boston 2, boston 3 y boston menor
                        CalMen = 20000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 3 And NumAluPK = 1 Then ' 3 alumnos boston y 1 Miss Marta
                Select Case ColoPK
                                    
                    Case "010", "110", "310" 'Alumno en Boston - Mayor, medio y menor
                        Select Case IdHermano
                            Case 1, 2
                                CalMen = 21000 * DescuentoConvenio
                                CalMen = IIf(Beca, 28000 * 0, CalMen)
                                CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                            Case 3
                                CalMen = 20000 * DescuentoConvenio
                                CalMen = IIf(Beca, 28000 * 0, CalMen)
                                CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                        End Select
                    Case "996" 'Alumno en Miss Marta
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 2 And NumAluPK = 2 Then ' 2 alumnos boston y 2 Miss Marta
                Select Case ColoPK
                    Case "010", "110", "310" 'Alumno en Boston - MAyor y Menor
                        CalMen = 17000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta - Miss Marta 1 y Miss Marta 2
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
            If NumAluBos = 1 And NumAluPK = 3 Then ' 1 alumnos boston y 3 Miss Marta
                Select Case IdHermano
                    Case "010", "110", "310" 'Alumno en Boston
                        CalMen = 6000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                    Case "996" 'Alumno en Miss Marta - Miss Marta 1, Miss Marta 2 y Miss Marta 3
                        CalMen = 28000 * DescuentoConvenio
                        CalMen = IIf(Beca, 28000 * 0, CalMen)
                        CalMen = IIf(mBeca, 28000 * 0.5, CalMen)
                End Select
            End If
    End Select
Case "604" ' L I N C O L N
    Select Case IdHermano 'NumAluTot
        Case 1 '1 ###### hermano
            Select Case ColoPK
                Case "010"
                    ValCuota = 11500
                    CalMen = 11500
                    CalMen = IIf(Beca, 11500 * 0, CalMen)
                    CalMen = IIf(mBeca, 11500 * 0.5, CalMen)
                Case "110"
                    ValCuota = 12000
                    CalMen = 12000
                    CalMen = IIf(Beca, 12000 * 0, CalMen)
                    CalMen = IIf(mBeca, 12000 * 0.5, CalMen)
                Case "310"
                    ValCuota = 12500
                    CalMen = 12500
                    CalMen = IIf(Beca, 12500 * 0, CalMen)
                    CalMen = IIf(mBeca, 12500 * 0.5, CalMen)
                Case "996"
                    ValCuota = 15000
                    CalMen = 15000
                    CalMen = IIf(Beca, 15000 * 0, CalMen)
                    CalMen = IIf(mBeca, 15000 * 0.5, CalMen)
            End Select
        Case Is > 1 ' ###### 2 O MÁS hermanos
            'a partir del 2° hermano existe un descuento del 50%
            Select Case ColoPK 'Tipo de modalidad
                Case "010"
                    ValCuota = 11500
                    CalMen = 11500 * 0.5
                    CalMen = IIf(Beca, 11500 * 0, CalMen)
                    CalMen = IIf(mBeca, 11500 * 0.5, CalMen)
                Case "110"
                    ValCuota = 12000
                    CalMen = 12000 * 0.5
                    CalMen = IIf(Beca, 12000 * 0, CalMen)
                    CalMen = IIf(mBeca, 12000 * 0.5, CalMen)
                Case "310"
                    ValCuota = 12500
                    CalMen = 12500 * 0.5
                    CalMen = IIf(Beca, 12500 * 0, CalMen)
                    CalMen = IIf(mBeca, 12500 * 0.5, CalMen)
                Case "996"
                    ValCuota = 15000
                    CalMen = 15000
                    'CalMen = CalMen * 0.5
                    CalMen = IIf(Beca, 15000 * 0, CalMen)
                    CalMen = IIf(mBeca, 15000 * 0.5, CalMen)
                    'No estoy seguro si el prekinder tiene descuentos por hermanos                    'si LOS TIENE, dejas el Case "996" tal cual, SI NO, comentas la línea
                    'CalMen = 15000 * 0.5
            End Select
    End Select

End Select 'Lincol
'End Select

MenExe(0) = CalMen
MenExe(1) = ValCuota - CalMen
CalMenM = MenExe
End Function
Function MesRetiroContable2004(FechaRetiro As Date) As Integer ' hasta que mes debe pagar
If Year(FechaRetiro) = "1111" And Month(FechaRetiro) = "11" And Day(FechaRetiro) = "11" Then
    MesRetiroContable2004 = 12
Else
    If Month(FechaRetiro) >= 3 Then
        If Day(FechaRetiro) <= 15 Then
            MesRetiroContable2004 = val(Month(FechaRetiro)) - 1
        Else
            MesRetiroContable2004 = val(Month(FechaRetiro))
        End If
    End If
End If
End Function
Function MesIngresoContable2004(FechaMatricula As Date) As Integer ' Desde que mes debe pagar
'If Year(FechaRetiro) = "1111" And Month(FechaRetiro) = "11" And Day(FechaRetiro) = "11" Then
'    MesRetiroContable2004 = 12
'Else
    If Month(FechaMatricula) >= 2 Then
        If Day(FechaMatricula) <= 15 Then
            MesIngresoContable2004 = val(Month(FechaMatricula))
        Else
            MesIngresoContable2004 = val(Month(FechaMatricula)) + 1
        End If
    End If
'End If
End Function
Function Libro_boletas(ByVal mes As Integer, ByVal agno As Integer, ByVal colegio As String, ByRef CNX As ADODB.Connection) As Boolean
On Error GoTo Controlerror:
    Dim QR As String
    Dim CMD_Libro As ADODB.Command
    Dim MyCol As String
        
    Libro_boletas = False
    
    Set CMD_Libro = New ADODB.Command
    CMD_Libro.ActiveConnection = CNX
    CMD_Libro.CommandType = adCmdText
    
    ' Borrado del LIBRO ANTIGUO.
    QR = "DROP TABLE IF EXISTS fnza_libro_boletas_banco;"
    CMD_Libro.CommandText = QR
    CMD_Libro.Execute
    ' Borrado del LIBRO ANTIGUO.
    QR = "DROP TABLE IF EXISTS fnza_libro_boletas;"
    CMD_Libro.CommandText = QR
    CMD_Libro.Execute
    
    ' Borrado del LIBRO NUEVO.
    QR = "DROP TABLE IF EXISTS fnza_libro_de_boletas;"
    CMD_Libro.CommandText = QR
    CMD_Libro.Execute
    
    ' Creación del LIBRO DE BOLETAS
    QR = "CREATE TABLE fnza_libro_de_boletas TYPE=MyISAM "
    ' Inicio seleccion de registros
    QR = QR & "SELECT boletas.*, if(cajas.nombre is null,'',cajas.nombre) as 'nombre_caja' FROM ( "
    ' Boletas Normales
    QR = QR & "SELECT fecha_blta as fecha, bl.colegio, 'blta' as 'tipo_doc', folio_blta_fisico as 'folio_doc', '' as 'tipo_afec', '' as 'folio_afec', monto_blta as 'entrada', 0 as 'salida', sum(monto_exen_hno + monto_exen_bca + monto_exen_desc + monto_exen_conv + monto_exen_tipo_pago) as 'beca' FROM (SELECT * FROM (SELECT * FROM fnza_boletas WHERE month(fecha_blta)=" & mes & " AND Year(fecha_blta)=" & agno & " AND colegio='" & colegio & "'  AND estado_blta='aprb') as b LEFT JOIN fnza_dtll_mvto as dtmv ON b.folio_blta=dtmv.folio_blta) bl LEFT JOIN fnza_detalle_mensualidad as dt ON bl.folio_dtll=dt.folio_dtll GROUP BY folio_doc"
    QR = QR & " UNION "
    ' Boletas con devoluciones
    QR = QR & "SELECT fecha_blta as fecha, bl.colegio, 'blta' as 'tipo_doc', folio_blta_fisico as 'folio_doc', '' as 'tipo_afec', '' as 'folio_afec', monto_blta as 'entrada', 0 as 'salida', sum(monto_exen_hno + monto_exen_bca + monto_exen_desc + monto_exen_conv + monto_exen_tipo_pago) as 'beca' FROM (SELECT * FROM (SELECT * FROM fnza_boletas WHERE month(fecha_blta)=" & mes & " AND Year(fecha_blta)=" & agno & " AND colegio='" & colegio & "'  AND estado_blta='devo') as b LEFT JOIN fnza_dtll_mvto as dtmv ON b.folio_blta=dtmv.folio_blta) bl LEFT JOIN fnza_detalle_mensualidad as dt ON bl.folio_dtll=dt.folio_dtll GROUP BY folio_doc"
    QR = QR & " UNION "
    ' Devoluciones
    QR = QR & "SELECT fecha as fecha, bl.colegio, 'devo' as 'tipo_doc', folio_blta_fisico as 'folio_doc', 'blta' as 'tipo_afec', folio_blta_fisico as 'folio_afec', 0 as 'entrada', monto_blta*-1 as 'salida', (sum(monto_exen_hno + monto_exen_bca + monto_exen_desc + monto_exen_conv + monto_exen_tipo_pago) * -1) as 'beca' FROM (SELECT * FROM (SELECT b.*, dtmv.folio_dtll FROM (SELECT * FROM fnza_devoluciones WHERE month(fecha)=" & mes & " AND Year(fecha)=" & agno & " AND colegio='" & colegio & "') as b LEFT JOIN fnza_dtll_mvto as dtmv ON b.folio_blta=dtmv.folio_blta) as dev LEFT JOIN fnza_boletas as fb ON dev.folio_blta=fb.folio_blta) as bl LEFT JOIN fnza_detalle_mensualidad as dt ON bl.folio_dtll=dt.folio_dtll GROUP BY folio_doc"
    QR = QR & " UNION "
    ' Verifico boletas del 2004 para colegios que existian en el 2004.
    MyCol = RetornaCampo("CFG", "VALOR", "Param='CODBC'", conn)
    If (MyCol <> "PUD001") Then
        ' Boletas que pagan el 2004
        QR = QR & "SELECT gescol.fnza_boletas.fecha_blta as fecha, gescol.fnza_boletas.colegio, 'blta' as 'tipo_doc', gescol.fnza_boletas.folio_blta_fisico as 'folio_doc', '' as 'tipo_afec', '' as 'folio_afec', gescol.fnza_boletas.monto_blta as 'entrada', 0 as 'salida', sum(gescol2004.bol_apo_x_alu.monto_exencion+0) as 'beca' FROM gescol.fnza_boletas LEFT JOIN gescol2004.bol_apo_x_alu ON gescol2004.bol_apo_x_alu.folio+0=gescol.fnza_boletas.folio_blta_fisico WHERE month(gescol.fnza_boletas.fecha_blta)=" & mes & " AND Year(gescol.fnza_boletas.fecha_blta)=" & agno & " AND gescol.fnza_boletas.colegio='" & colegio & "'  AND gescol.fnza_boletas.estado_blta='2004' GROUP BY folio_doc"
        QR = QR & " UNION "
    End If
    ' Notas de  Credito
    QR = QR & "SELECT fecha_ntcr as fecha, colegio, 'ntcr' as 'tipo_doc', folio_fisico_ntcr as 'folio_doc', '' as 'tipo_afec', '' as 'folio_afec', 0 as 'entrada', monto_ntcr*-1 as 'salida', 0 as 'beca' FROM fnza_ntcr WHERE month(fecha_ntcr)=" & mes & " AND Year(fecha_ntcr)=" & agno & " AND colegio='" & colegio & "'  AND estado_ntcr='aprb' GROUP BY folio_doc"
    QR = QR & " UNION "
    ' Boletas Nulas
    QR = QR & "SELECT fecha_blta as fecha, bl.colegio, 'nula' as 'tipo_doc', folio_blta_fisico as 'folio_doc', '' as 'tipo_afec', '' as 'folio_afec', 0 as 'entrada', if((monto_blta is null),0,monto_blta) *-1 as 'salida', if((bl.folio_dtll is null),0,(sum(monto_exen_hno + monto_exen_bca + monto_exen_desc + monto_exen_conv + monto_exen_tipo_pago)) * -1) as 'beca' FROM (SELECT * FROM (SELECT * FROM fnza_boletas WHERE month(fecha_blta)=" & mes & " AND Year(fecha_blta)=" & agno & " AND colegio='" & colegio & "'  AND estado_blta='nula') as b LEFT JOIN fnza_dtll_mvto as dtmv ON b.folio_blta=dtmv.folio_blta) bl LEFT JOIN fnza_detalle_mensualidad as dt ON bl.folio_dtll=dt.folio_dtll GROUP BY folio_doc"
    QR = QR & " UNION "
    ' Boletas con anulaciones
    QR = QR & "SELECT fecha_blta as fecha, bl.colegio, 'blta' as 'tipo_doc', folio_blta_fisico as 'folio_doc', '' as 'tipo_afec', '' as 'folio_afec', if((monto_blta is null),0,monto_blta) as 'entrada', 0 as 'salida', if((bl.folio_dtll is null),0,sum(monto_exen_hno + monto_exen_bca + monto_exen_desc + monto_exen_conv + monto_exen_tipo_pago+0)) as 'beca' FROM (SELECT * FROM (SELECT * FROM fnza_boletas WHERE month(fecha_blta)=" & mes & " AND Year(fecha_blta)=" & agno & " AND colegio='" & colegio & "'  AND estado_blta='nula') as b LEFT JOIN fnza_dtll_mvto as dtmv ON b.folio_blta=dtmv.folio_blta) bl LEFT JOIN fnza_detalle_mensualidad as dt ON bl.folio_dtll=dt.folio_dtll WHERE monto_blta is not null GROUP BY folio_doc "
    ' fin de seleccion de registros
    QR = QR & ") as boletas LEFT JOIN (SELECT fc.nombre, fcf.folio_ini, fcf.folio_fin, fc.colegio as 'cole' FROM fnza_caja_folios as fcf, fnza_caja as fc WHERE fc.folio_caja=fcf.folio_caja) as cajas ON (boletas.folio_doc>=cajas.folio_ini AND boletas.folio_doc<=cajas.folio_fin) AND boletas.colegio=cajas.cole;"
    CMD_Libro.CommandText = QR
    CMD_Libro.Execute
    
    ' Primary KEY
    QR = "ALTER table fnza_libro_de_boletas ADD primary key(tipo_doc, folio_doc, fecha, colegio);"
    CMD_Libro.CommandText = QR
    CMD_Libro.Execute
    Libro_boletas = True
    
    Exit Function
Controlerror:
    Err.Raise Err.Number, Err.Source & vbCrLf & "Libro_boletas", Err.Description
End Function

Private Sub Load_Combos_Libro_boletas()
    Dim REC As ADODB.Recordset
    Dim QR As String
    
    ' Años
    If Year(Date) < 2005 Then
        MsgBox "Fecha de Sistema Errónea."
        Err.Raise vbObjectError + 1000, "Load_Combos_Libro_boletas", "Fecha de Sistema Errónea."
        Exit Sub
    End If
    For i = 2005 To Year(Date)
        IC1.ComboItems.Add (i - 2004), , i
    Next i
    Set IC1.SelectedItem = IC1.ComboItems.Item(Year(Date) - 2004)
    
    ' Meses
    IC2.ComboItems.Add 1, "ene", "Enero"
    IC2.ComboItems.Add 2, "feb", "Febrero"
    IC2.ComboItems.Add 3, "mar", "Marzo"
    IC2.ComboItems.Add 4, "abr", "Abril"
    IC2.ComboItems.Add 5, "may", "Mayo"
    IC2.ComboItems.Add 6, "jun", "Junio"
    IC2.ComboItems.Add 7, "jul", "Julio"
    IC2.ComboItems.Add 8, "ago", "Agosto"
    IC2.ComboItems.Add 9, "sep", "Septiembre"
    IC2.ComboItems.Add 10, "oct", "Octubre"
    IC2.ComboItems.Add 11, "nov", "Noviembre"
    IC2.ComboItems.Add 12, "dic", "Diciembre"
    Set IC2.SelectedItem = IC2.ComboItems.Item(Month(Date))
    
    'Colegios
    QR = "SELECT col.colegio, col.nombre from hist_cod_colegio as col, (SELECT hcc.colegio FROM establecimientos as e, hist_cod_colegio as hcc where e.rdb=hcc.cod_rbd) as aux WHERE Left(col.colegio, 6) = Left(aux.colegio, 6);"
    Set REC = New ADODB.Recordset
    REC.Open QR, conn
    If REC.RecordCount = 0 Then
        MsgBox "No se encontro la informacion del establecimiento."
        Err.Raise vbObjectError + 1001, "Load_Combos_Libro_boletas", "No se encontro la informacion del establecimiento en la Base de Datos."
        Exit Sub
    Else
        For i = 1 To REC.RecordCount
            IC3.ComboItems.Add i, REC!colegio, REC!nombre
            REC.MoveNext
        Next i
    End If
    Set IC3.SelectedItem = IC3.ComboItems.Item(1)
    REC.Close
    Set REC = Nothing
    
End Sub
Private Sub Load_Combos_Folios_Faltantes()
    Dim REC As ADODB.Recordset
    Dim QR As String
    
    'Colegios
    QR = "SELECT col.colegio, col.nombre from hist_cod_colegio as col, (SELECT hcc.colegio FROM establecimientos as e, hist_cod_colegio as hcc where e.rdb=hcc.cod_rbd) as aux WHERE Left(col.colegio, 6) = Left(aux.colegio, 6);"
    Set REC = New ADODB.Recordset
    REC.Open QR, conn
    If REC.RecordCount = 0 Then
        MsgBox "No se encontro la informacion del establecimiento."
        Err.Raise vbObjectError + 1001, "Load_Combos_Libro_boletas", "No se encontro la informacion del establecimiento en la Base de Datos."
        Exit Sub
    Else
        For i = 1 To REC.RecordCount
            IC4.ComboItems.Add i, REC!colegio, REC!nombre
            REC.MoveNext
        Next i
    End If
    Set IC4.SelectedItem = IC4.ComboItems.Item(1)
    REC.Close
    Set REC = Nothing
End Sub
Function Libro_boletas_reporte(ByVal mes As Integer, ByVal agno As Integer, ByVal colegio As String, ByRef CNX As ADODB.Connection, ByRef CRR As CrystalReport) As Boolean
On Error GoTo Controlerror:
    Dim Libro As String
    
    Libro_boletas_reporte = False
    Libro_boletas mes, agno, colegio, CNX
    ' Impresion del Anexo de Libro de Boletas
    CRR.ReportFileName = App.Path & "\rpt\fnza_lista_ntcr_bltanulas.rpt"
    CRR.WindowTitle = "Anexo a Libro de Boletas"
    LimpiaFormulas CRR, 20
    CRR.WindowState = crptMaximized
    CRR.Formulas(1) = "tit_mes_agno='" & UCase(IC2.SelectedItem.Text) & " de " & agno & "'"
    CRR.ReplaceSelectionFormula ("{fnza_libro_de_boletas.tipo_doc}<>'blta'")
    If Opt_Destino_LibroBol(0).Value Then
        CRR.Destination = crptToWindow
    Else
        CRR.Destination = crptToPrinter
    End If
    CRR.Action = 1
    ' Impresion del Libro de Boletas
    CRR.ReportFileName = App.Path & "\rpt\fnza_libro_de_boletas.rpt"
    CRR.WindowTitle = "Libro de Boletas"
    LimpiaFormulas CRR, 20
    CRR.WindowState = crptMaximized
    CRR.Formulas(1) = "tit_mes_agno='" & UCase(IC2.SelectedItem.Text) & " de " & agno & "'"
    CRR.ReplaceSelectionFormula ("")
    If Opt_Destino_LibroBol(0).Value Then
        CRR.Destination = crptToWindow
    Else
        CRR.Destination = crptToPrinter
    End If
    CRR.Action = 1
    ' Mensaje de impresion Lista
    If Opt_Destino_LibroBol(1).Value Then
        MsgBox "Impresion OK", vbOKOnly + vbInformation, "OK"
    End If
    
    Libro_boletas_reporte = True
    Exit Function
Controlerror:
    Err.Raise Err.Number, Err.Source & vbCrLf & "Libro_boletas_reporte", Err.Description
End Function

Private Sub LlenaCmbProcedencia(ByRef CNX As ADODB.Connection)
    Dim REC As ADODB.Recordset
    Dim QRY As String
    
    Set REC = New ADODB.Recordset
    QRY = "SELECT * FROM fnza_cod_proc_pago;"
    REC.Open QRY, CNX
    
    If REC.RecordCount > 0 Then
        For i = 1 To REC.RecordCount
            Cmb_Procedencia.ComboItems.Add i, REC!proc_pago, REC!descripcion
            REC.MoveNext
        Next i
        Cmb_Procedencia.ComboItems.Add i, "all", "Todas"
        Set Cmb_Procedencia.SelectedItem = Cmb_Procedencia.ComboItems.Item(i)
    Else
        Cmb_Procedencia.ComboItems.Add 1, "all", "Todas"
        Set Cmb_Procedencia.SelectedItem = Cmb_Procedencia.ComboItems.Item(1)
    End If
    REC.Close
    
End Sub

Private Sub LlenaCmbEstado(ByRef CNX As ADODB.Connection)
    Dim REC As ADODB.Recordset
    Dim QRY As String
    
    Set REC = New ADODB.Recordset
    QRY = "SELECT * FROM fnza_cod_estado_blta;"
    REC.Open QRY, CNX
    
    If REC.RecordCount > 0 Then
        REC.MoveFirst
        Cmb_Estado_Bol.ComboItems.Clear
        For i = 1 To REC.RecordCount
            Cmb_Estado_Bol.ComboItems.Add i, IIf(REC!estado_blta = "2004", "2oo4", REC!estado_blta), REC!descripcion
            REC.MoveNext
        Next i
        Cmb_Estado_Bol.ComboItems.Add i, "all", "Todos"
        Set Cmb_Estado_Bol.SelectedItem = Cmb_Estado_Bol.ComboItems.Item(i)
    Else
        Cmb_Estado_Bol.ComboItems.Add i, "all", "Todos"
        Set Cmb_Estado_Bol.SelectedItem = Cmb_Estado_Bol.ComboItems.Item(1)
    End If
    REC.Close
    
End Sub

Private Sub LlenaCmbColegios(ByRef ObjImgCombo As ImageCombo, ByVal Todos As Boolean, ByRef CNX As ADODB.Connection)
    Dim REC As ADODB.Recordset
    Dim QRY As String
    
    Set REC = New ADODB.Recordset
    'QRY = "SELECT hist.colegio, hist.nombre, hist.direccion FROM hist_cod_colegio as hist, (Select h.colegio from establecimientos as e, hist_cod_colegio as h WHERE e.rdb=h.cod_rbd) as resu WHERE LEFT(hist.colegio,6)=resu.colegio;"
    QRY = "SELECT hist.colegio, hist.nombre, hist.direccion FROM hist_cod_colegio AS hist, (SELECT h.colegio FROM establecimientos AS e, hist_cod_colegio AS h WHERE e.rdb=h.cod_rbd AND LENGTH(h.colegio) = 6) AS resu WHERE LEFT(hist.colegio,6)=resu.colegio AND LENGTH(hist.colegio) = 6;"
    REC.Open QRY, CNX
    
    If REC.RecordCount > 0 Then
        REC.MoveFirst
        ObjImgCombo.ComboItems.Clear
        
        For i = 1 To REC.RecordCount
            ObjImgCombo.ComboItems.Add i, REC!colegio, REC!nombre
            REC.MoveNext
        Next i
        'If Todos Then ObjImgCombo.ComboItems.Add i, "all", "Todos"
        
    Else
        If Todos Then
            ObjImgCombo.ComboItems.Add 1, "all", "Todos"
        Else
            ObjImgCombo.ComboItems.Add 1, "none", "No se encontraron Colegios"
        End If
    End If
    'Set ObjImgCombo.SelectedItem = ObjImgCombo.ComboItems.Item(1)
    Set ObjImgCombo.SelectedItem = ObjImgCombo.ComboItems.Item(ObjImgCombo.ComboItems.count)
    
    REC.Close
    
End Sub

Private Sub LlenaCmbAgno(ByVal StartYear As Integer, ByRef ObjImgCombo As ImageCombo)
        
    If StartYear >= 2005 Then
        ObjImgCombo.ComboItems.Clear
        For i = 1 To (Year(Date) - 2003)
            ObjImgCombo.ComboItems.Add i, , str(i + 2003)
        Next i
    Else
        Cmb_Estado_Bol.ComboItems.Add 1, , "2004"
        Cmb_Estado_Bol.ComboItems.Add 2, , "2005"
    End If
    Set ObjImgCombo.SelectedItem = ObjImgCombo.ComboItems.Item(2)
    
End Sub

Private Sub LlenaListaColumBoletas()
    ' Lista de las Columnas de la grilla a mostrar.
    Lst_Campos_Grilla.AddItem "Folio "
    Lst_Campos_Grilla.AddItem "Estado"
    Lst_Campos_Grilla.AddItem "Colegio"
    Lst_Campos_Grilla.AddItem "Apoderado"
    Lst_Campos_Grilla.AddItem "Alumno"
    Lst_Campos_Grilla.AddItem "Procedencia"
    Lst_Campos_Grilla.AddItem "Fecha Blta."
    Lst_Campos_Grilla.AddItem "Monto"
    'Lst_Campos_Grilla.AddItem "Exención"
    'Lst_Campos_Grilla.AddItem "Estado Mens."
    Lst_Campos_Grilla.AddItem "Venc. Inic."
    Lst_Campos_Grilla.AddItem "Venc. Final"
    Lst_Campos_Grilla.AddItem "Folio Interno"
    Lst_Campos_Grilla.AddItem "Tipo Pago"
    Lst_Campos_Grilla.AddItem "Usuario Ingreso"
    Lst_Campos_Grilla.AddItem "Fecha Ingreso"
    
    
    Lst_Campos_Grilla.Selected(0) = True
    Lst_Campos_Grilla.Selected(1) = True
    Lst_Campos_Grilla.Selected(2) = True
    Lst_Campos_Grilla.Selected(3) = True
    Lst_Campos_Grilla.Selected(4) = True
    Lst_Campos_Grilla.Selected(5) = True
    Lst_Campos_Grilla.Selected(6) = True
    Lst_Campos_Grilla.Selected(7) = True
    Lst_Campos_Grilla.Selected(8) = True
    Lst_Campos_Grilla.Selected(9) = True
    Lst_Campos_Grilla.Selected(10) = True
    Lst_Campos_Grilla.Selected(11) = True
    Lst_Campos_Grilla.Selected(12) = True
    Lst_Campos_Grilla.Selected(13) = True
    
    'Lst_Campos_Grilla.Selected(12) = False
    'Lst_Campos_Grilla.Selected(13) = False
End Sub

Private Sub MuestraColumnasBoletasSeleccionadas()
    Grd_Cons.ColWidth(0) = 500
    Grd_Cons.ColWidth(1) = IIf(Lst_Campos_Grilla.Selected(0), 1000, 0)
    Grd_Cons.ColWidth(2) = IIf(Lst_Campos_Grilla.Selected(1), 1000, 0)
    Grd_Cons.ColWidth(3) = IIf(Lst_Campos_Grilla.Selected(2), 1200, 0)
    Grd_Cons.ColWidth(4) = IIf(Lst_Campos_Grilla.Selected(3), 1000, 0)
    Grd_Cons.ColWidth(5) = IIf(Lst_Campos_Grilla.Selected(4), 1000, 0)
    Grd_Cons.ColWidth(6) = IIf(Lst_Campos_Grilla.Selected(5), 1300, 0)
    Grd_Cons.ColWidth(7) = IIf(Lst_Campos_Grilla.Selected(6), 1300, 0)
    Grd_Cons.ColWidth(8) = IIf(Lst_Campos_Grilla.Selected(7), 1000, 0)
    Grd_Cons.ColWidth(9) = IIf(Lst_Campos_Grilla.Selected(8), 1000, 0)
    Grd_Cons.ColWidth(10) = IIf(Lst_Campos_Grilla.Selected(9), 1300, 0)
    Grd_Cons.ColWidth(11) = IIf(Lst_Campos_Grilla.Selected(10), 1300, 0)
    Grd_Cons.ColWidth(12) = IIf(Lst_Campos_Grilla.Selected(11), 1000, 0)
    Grd_Cons.ColWidth(13) = IIf(Lst_Campos_Grilla.Selected(12), 2000, 0)
    Grd_Cons.ColWidth(14) = IIf(Lst_Campos_Grilla.Selected(13), 1300, 0)
    
    
   ' Grd_Cons.ColWidth(13) = IIf(Lst_Campos_Grilla.Selected(12), 1000, 0)
   ' Grd_Cons.ColWidth(14) = IIf(Lst_Campos_Grilla.Selected(13), 1000, 0)
    Grd_Cons.Refresh
End Sub

Function CursoBoleta(ByVal RunAlu As String, ByVal agno As Integer) As String
    Dim QRY As String
    Dim REC As ADODB.Recordset
    
    CursoBoleta = ""
    QRY = "SELECT if((m.cod_ens='996' OR m.cod_ens='010'),concat(c.cod_des,'º '),concat(m.num_gra,'º ',c.cod_des)) as curso FROM matriculas as m, codigos_ensenanza as c WHERE m.cod_ens=c.cod_ens AND m.ci_alu='" & RunAlu & "' AND anno_mat=" & agno & ";"
    Set REC = New ADODB.Recordset
    REC.Open QRY, conn
    If REC.RecordCount > 0 Then
        REC.MoveFirst
        CursoBoleta = REC!curso
    End If
    REC.Close
    
End Function

Function BoletaDH(ByVal RunAlu As String, ByVal Desde As Date, ByVal Hasta As Date) As String
    Dim mesCTc As Integer
    Dim Inicial As Integer
    Dim final As Integer
        
    BoletaDH = ""
    mesCTc = MesCuotaCero(RunAlu, Year(Desde), conn)
    If Month(Desde) = mesCTc Then
        BoletaDH = " 1/2"
        Inicial = Month(Desde) + 1
    ElseIf Month(Desde) = (mesCTc + 1) Then
        BoletaDH = " 2/2"
        Inicial = Month(Desde)
    Else
        BoletaDH = ""
        Inicial = Month(Desde)
    End If
    If Month(Desde) = Month(Hasta) Then
        BoletaDH = MesATexto(Inicial) & BoletaDH
    Else
        final = Month(Hasta)
        BoletaDH = MesATexto(Inicial) & BoletaDH & " a " & MesATexto(final)
    End If
    
End Function




Private Sub Txt_FolioINI_Cons_Change()
    Txt_FolioFIN_Cons.Text = Txt_FolioINI_Cons.Text
End Sub

Private Sub Txt_Monto_Ini_Change()
    Txt_Monto_Fin.Text = Txt_Monto_Ini.Text
End Sub
