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"
Begin VB.Form Form_Cajas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Consulta e Ingresos de Pago año 2004"
   ClientHeight    =   8910
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   12750
   Icon            =   "Form_Cajas.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   8910
   ScaleWidth      =   12750
   Begin VB.CommandButton Btn_Cancelar 
      Caption         =   "Salir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   10440
      Picture         =   "Form_Cajas.frx":2A8B2
      Style           =   1  'Graphical
      TabIndex        =   59
      Top             =   4680
      Width           =   1335
   End
   Begin VB.Frame Frame_Principal 
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   9015
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   12975
      Begin VB.Frame Frame_datos_busqueda 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   2895
         Left            =   4200
         TabIndex        =   1
         Top             =   1800
         Width           =   4335
         Begin VB.ListBox lst_busq_caja 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   1320
            Index           =   0
            Left            =   240
            TabIndex        =   25
            Top             =   1200
            Width           =   3855
         End
         Begin VB.TextBox txt_crit_busqueda 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Index           =   0
            Left            =   240
            TabIndex        =   24
            Top             =   720
            Width           =   3855
         End
         Begin VB.OptionButton opt_criterio 
            Caption         =   "R.u.t."
            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            =   1680
            TabIndex        =   7
            Top             =   300
            Width           =   855
         End
         Begin VB.OptionButton opt_criterio 
            Caption         =   "Apellidos"
            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        =   6
            Top             =   300
            Width           =   975
         End
         Begin VB.CommandButton btn_can_busqueda 
            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            =   2880
            TabIndex        =   2
            Top             =   240
            Width           =   1215
         End
         Begin VB.ListBox lst_busq_caja 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   1110
            Index           =   1
            Left            =   240
            TabIndex        =   5
            Top             =   1200
            Width           =   1815
         End
         Begin VB.TextBox txt_crit_busqueda 
            Height          =   285
            Index           =   1
            Left            =   240
            TabIndex        =   3
            Top             =   720
            Width           =   855
         End
         Begin VB.TextBox txt_dig_busqueda 
            Height          =   285
            Left            =   1200
            TabIndex        =   4
            Top             =   720
            Width           =   255
         End
      End
      Begin VB.Frame Frame4 
         Caption         =   "Buscar por"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   735
         Left            =   0
         TabIndex        =   14
         Top             =   0
         Width           =   3105
         Begin VB.OptionButton Opt_busqueda_caj 
            Caption         =   "Apoderado"
            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        =   16
            Top             =   300
            Width           =   1215
         End
         Begin VB.OptionButton Opt_busqueda_caj 
            Caption         =   "Alumno"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   1680
            TabIndex        =   15
            Top             =   300
            Width           =   1215
         End
      End
      Begin VB.Frame Frame_Apo_Caja 
         Caption         =   "Datos del Apoderado"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   735
         Left            =   3240
         TabIndex        =   8
         Top             =   0
         Width           =   9255
         Begin VB.TextBox txt_nomapo_caja 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1080
            Locked          =   -1  'True
            TabIndex        =   11
            Top             =   300
            Width           =   5655
         End
         Begin VB.TextBox txt_rutapo_caja 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   7560
            Locked          =   -1  'True
            TabIndex        =   10
            Top             =   300
            Width           =   1095
         End
         Begin VB.TextBox txt_digapo_caja 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   8760
            Locked          =   -1  'True
            TabIndex        =   9
            Top             =   300
            Width           =   255
         End
         Begin VB.Label Label1 
            Caption         =   "Nombre"
            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        =   13
            Top             =   300
            Width           =   735
         End
         Begin VB.Label Label2 
            Caption         =   "R.u.t."
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   7080
            TabIndex        =   12
            Top             =   300
            Width           =   615
         End
      End
      Begin VB.Frame Frame_Alu_Caja 
         BorderStyle     =   0  'None
         ForeColor       =   &H00FF0000&
         Height          =   8295
         Left            =   0
         TabIndex        =   17
         Top             =   720
         Width           =   12855
         Begin VB.Frame Frame_Pagando 
            Caption         =   "Meses que Cancela"
            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            =   5280
            TabIndex        =   26
            Top             =   120
            Width           =   7185
            Begin VB.CommandButton Btn_Agregar 
               Caption         =   "Agregar al libro"
               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        =   60
               Top             =   4200
               Width           =   1455
            End
            Begin VB.TextBox Txt_MontoIdeal 
               Alignment       =   1  'Right Justify
               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            =   5640
               Locked          =   -1  'True
               MaxLength       =   6
               TabIndex        =   39
               Top             =   2040
               Width           =   1335
            End
            Begin VB.TextBox Txt_MontoPagado 
               Alignment       =   1  'Right Justify
               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            =   5640
               Locked          =   -1  'True
               MaxLength       =   6
               TabIndex        =   37
               Top             =   2400
               Width           =   1335
            End
            Begin VB.TextBox txt_Monto_Pago 
               Alignment       =   1  'Right Justify
               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            =   5640
               MaxLength       =   6
               TabIndex        =   30
               Top             =   2760
               Width           =   1335
            End
            Begin VB.TextBox txt_folio_disp 
               Alignment       =   1  'Right Justify
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H00800000&
               Height          =   285
               Left            =   5640
               MaxLength       =   8
               TabIndex        =   29
               Top             =   1560
               Width           =   1335
            End
            Begin VB.ComboBox Cmb_mes_pago 
               BackColor       =   &H00C0FFFF&
               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_Cajas.frx":2AED8
               Left            =   5040
               List            =   "Form_Cajas.frx":2AEFD
               Style           =   2  'Dropdown List
               TabIndex        =   28
               Top             =   240
               Width           =   1935
            End
            Begin VB.ComboBox Cmb_mes_pago2 
               BackColor       =   &H00C0FFFF&
               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_Cajas.frx":2AF56
               Left            =   5040
               List            =   "Form_Cajas.frx":2AF7B
               Style           =   2  'Dropdown List
               TabIndex        =   27
               Top             =   600
               Width           =   1935
            End
            Begin MSComCtl2.DTPicker Dtp_Fec_emision 
               Height          =   375
               Left            =   5640
               TabIndex        =   31
               Top             =   1080
               Width           =   1335
               _ExtentX        =   2355
               _ExtentY        =   661
               _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
               Format          =   103088129
               CurrentDate     =   38015
            End
            Begin MSFlexGridLib.MSFlexGrid Grd_Cuotas_Alu 
               Height          =   3495
               Left            =   240
               TabIndex        =   51
               Top             =   360
               Width           =   3495
               _ExtentX        =   6165
               _ExtentY        =   6165
               _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
            End
            Begin VB.Line Line6 
               BorderColor     =   &H8000000C&
               X1              =   3840
               X2              =   3840
               Y1              =   105
               Y2              =   4800
            End
            Begin VB.Label Label12 
               Caption         =   "Monto a Pagar"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   4080
               TabIndex        =   40
               Top             =   2760
               Width           =   1335
            End
            Begin VB.Label Label10 
               Caption         =   "Pagos realizados"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   4080
               TabIndex        =   38
               Top             =   2400
               Width           =   1335
            End
            Begin VB.Label Label5 
               Caption         =   "Fecha 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            =   4080
               TabIndex        =   36
               Top             =   1080
               Width           =   1335
            End
            Begin VB.Label Label7 
               Caption         =   "Monto Total"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   4080
               TabIndex        =   35
               Top             =   2040
               Width           =   1335
            End
            Begin VB.Label Label18 
               Caption         =   "Folio"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   4080
               TabIndex        =   34
               Top             =   1560
               Width           =   1335
            End
            Begin VB.Label Label19 
               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            =   4080
               TabIndex        =   33
               Top             =   240
               Width           =   1215
            End
            Begin VB.Label Label20 
               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            =   4080
               TabIndex        =   32
               Top             =   600
               Width           =   1215
            End
         End
         Begin VB.Frame Frame_BolEmitidas 
            Caption         =   "Detalle de Pagos efectuados"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00C00000&
            Height          =   2895
            Left            =   0
            TabIndex        =   41
            Top             =   5040
            Width           =   12495
            Begin VB.OptionButton Opt_Muestra_Pagos 
               Caption         =   "Apoderado"
               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            =   5400
               TabIndex        =   53
               Top             =   360
               Width           =   1695
            End
            Begin VB.OptionButton Opt_Muestra_Pagos 
               Caption         =   "Alumno"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Index           =   0
               Left            =   4200
               TabIndex        =   52
               Top             =   360
               Width           =   1095
            End
            Begin VB.ComboBox cmb_mes_consulta 
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   330
               Left            =   1320
               Style           =   2  'Dropdown List
               TabIndex        =   45
               Top             =   360
               Width           =   2295
            End
            Begin VB.CommandButton Btn_CargaPagos 
               Caption         =   "Carga Pagos"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   375
               Left            =   7320
               TabIndex        =   42
               Top             =   240
               Visible         =   0   'False
               Width           =   1215
            End
            Begin MSFlexGridLib.MSFlexGrid grd_tabla_pagos 
               Height          =   2055
               Left            =   120
               TabIndex        =   43
               Top             =   720
               Width           =   12240
               _ExtentX        =   21590
               _ExtentY        =   3625
               _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
            End
            Begin VB.Label Label11 
               Caption         =   "Mes Consulta"
               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        =   46
               Top             =   360
               Width           =   1575
            End
         End
         Begin VB.CheckBox Chk_VerPost 
            Caption         =   "Ver Alumnos Postulantes"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00C00000&
            Height          =   375
            Left            =   840
            Style           =   1  'Graphical
            TabIndex        =   54
            Top             =   2880
            Width           =   3255
         End
         Begin VB.Frame Frame_SeccionPagos 
            Caption         =   "Cancelación Mensualidad"
            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            =   0
            TabIndex        =   19
            Top             =   120
            Width           =   5115
            Begin VB.Frame Frame_Botones 
               Height          =   735
               Left            =   240
               TabIndex        =   44
               Top             =   1920
               Width           =   4695
               Begin VB.TextBox txt_situacion_actual 
                  Alignment       =   2  'Center
                  BeginProperty Font 
                     Name            =   "Arial"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00000000&
                  Height          =   285
                  Left            =   1560
                  TabIndex        =   49
                  Top             =   360
                  Width           =   3015
               End
               Begin VB.TextBox txt_arancel_col 
                  Alignment       =   2  'Center
                  BeginProperty Font 
                     Name            =   "Arial"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00000000&
                  Height          =   285
                  Left            =   120
                  TabIndex        =   47
                  Top             =   360
                  Width           =   1335
               End
               Begin VB.Label Label14 
                  Alignment       =   2  'Center
                  Caption         =   "Situación actual alumno"
                  BeginProperty Font 
                     Name            =   "Arial"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Height          =   255
                  Left            =   1560
                  TabIndex        =   50
                  Top             =   120
                  Width           =   3015
               End
               Begin VB.Label Label13 
                  Caption         =   "Arancel 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        =   48
                  Top             =   120
                  Width           =   1575
               End
            End
            Begin VB.Frame Frame_Ult_Folio 
               Caption         =   "Últimos Folios agregados"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H00C00000&
               Height          =   1095
               Left            =   240
               TabIndex        =   21
               Top             =   3480
               Width           =   4695
               Begin VB.Label Label8 
                  Caption         =   "Subvencionado"
                  BeginProperty Font 
                     Name            =   "Arial"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Height          =   255
                  Left            =   600
                  TabIndex        =   58
                  Top             =   360
                  Width           =   1815
               End
               Begin VB.Label Label9 
                  Caption         =   "Particular"
                  BeginProperty Font 
                     Name            =   "Arial"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Height          =   255
                  Left            =   600
                  TabIndex        =   57
                  Top             =   720
                  Width           =   1815
               End
               Begin VB.Label Lbl_Ult_FolaPart 
                  Alignment       =   2  'Center
                  BackColor       =   &H00FFFFFF&
                  BeginProperty Font 
                     Name            =   "Arial"
                     Size            =   11.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00C00000&
                  Height          =   255
                  Left            =   2640
                  TabIndex        =   56
                  Top             =   720
                  Width           =   1335
               End
               Begin VB.Label Lbl_Ult_Fola 
                  Alignment       =   2  'Center
                  BackColor       =   &H00FFFFFF&
                  BeginProperty Font 
                     Name            =   "Arial"
                     Size            =   11.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00C00000&
                  Height          =   255
                  Left            =   2640
                  TabIndex        =   55
                  Top             =   360
                  Width           =   1335
               End
            End
            Begin MSFlexGridLib.MSFlexGrid Grd_alumat_caja 
               Height          =   1455
               Left            =   240
               TabIndex        =   22
               Top             =   360
               Width           =   4695
               _ExtentX        =   8281
               _ExtentY        =   2566
               _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
            End
            Begin VB.CheckBox Chk_Nula 
               Caption         =   "Boleta Nula"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   195
               Left            =   240
               TabIndex        =   20
               Top             =   3240
               Visible         =   0   'False
               Width           =   1215
            End
         End
         Begin VB.Label lbl_Nmatriculados 
            Height          =   255
            Left            =   7080
            TabIndex        =   18
            Top             =   240
            Width           =   735
         End
      End
   End
   Begin VB.Label Label4 
      Caption         =   "Label4"
      Height          =   495
      Left            =   5280
      TabIndex        =   23
      Top             =   3480
      Width           =   1215
   End
End
Attribute VB_Name = "Form_Cajas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Inigdeuda As Long, Fingdeuda As Long
Dim MesIniDeuda As Integer, MesFindeuda As Integer
Dim MarcaAlumno As Boolean, CuotaApoxMes As Long, PagoApoxMes As Long, DeudaApoxMes As Long
Dim ExencionApoxMes As Long, ArancelApoxMes As Long
Dim CodConvBci As String, CuotasPagadas As Long, CBci As String
Dim Tipobus As Integer ' Tipo de búsqueda 0 => Apoderado o 1 => Alumno
Dim NaluMat As Integer, NaluPos As Integer
'Dim PrimeraCarga As Boolean
Dim ARutBus() As String, fila As Long, FilaDeuda As Long, FilaAlu  As Long
Dim AMesesPago()
Dim RutApoCaja As String
Dim Busqueda As Integer, Rutalu As String
Dim Ncuotas As Integer
Dim PosibleAbono As Boolean, Conectant As Boolean
Dim CodEmpresa As String, CodEmpresaAlt As String
Sub CargaDeuda(Rutapod As String)
Me.cmb_mes_consulta.Clear
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
'               0            1
a = "select id_cuota, fecha_venc from gescol2004.anualidad_x_apo where rut_apo = '" & Rutapod & "' order by id_cuota ASC"
rs.Open a, conn
If rs.RecordCount > 0 Then
    ReDim AMesesPago(rs.RecordCount)
    Me.cmb_mes_consulta.AddItem "Todos los meses"
    AMesesPago(0) = ""
    For t = 1 To rs.RecordCount
        Me.cmb_mes_consulta.AddItem MesATexto(CInt(Month(rs!Fecha_Venc)))
        AMesesPago(t) = rs!id_cuota
        rs.MoveNext
    Next t
End If
rs.Close
Set rs = Nothing
Ncuotas = t
End Sub
Sub ActivabotonesBus(Activa As Boolean)
Me.btn_can_busqueda.Enabled = Activa
End Sub
Sub IniGrillaCuotasAlu()
Me.Grd_Cuotas_Alu.Clear
Me.Grd_Cuotas_Alu.Rows = 10
Me.Grd_Cuotas_Alu.Cols = 13
Me.Grd_Cuotas_Alu.FixedCols = 0
Me.Grd_Cuotas_Alu.FixedRows = 1
                            '     0    1       2         3        4        5        6        7        8        9           10        11
Me.Grd_Cuotas_Alu.FormatString = "^ Nº|Mes   |Arancel |Exen. |Cuota   |Cuota Sis|Pagó  "
Me.Grd_Cuotas_Alu.ColWidth(0) = 300 ' Nº
Me.Grd_Cuotas_Alu.ColWidth(1) = 900 ' Mes
Me.Grd_Cuotas_Alu.ColWidth(2) = 0 ' Arancel
Me.Grd_Cuotas_Alu.ColWidth(3) = 700 'Exencion
Me.Grd_Cuotas_Alu.ColWidth(4) = 700 'Cuota
Me.Grd_Cuotas_Alu.ColWidth(5) = 0 ' Cuota sis
Me.Grd_Cuotas_Alu.ColWidth(6) = 700 ' Pagó
Me.Grd_Cuotas_Alu.ColWidth(7) = 0 ' Rut Alumno
Me.Grd_Cuotas_Alu.ColWidth(8) = 0 ' Activo
Me.Grd_Cuotas_Alu.ColWidth(9) = 0 ' Convenio
Me.Grd_Cuotas_Alu.ColWidth(10) = 0 ' Fecha Cambio
Me.Grd_Cuotas_Alu.ColWidth(11) = 0 ' Mes Cuota
Me.Grd_Cuotas_Alu.ColWidth(12) = 0 ' Cuota - Pagado
End Sub
Sub IniciaTablaPagos()
Me.grd_tabla_pagos.Clear
Me.grd_tabla_pagos.Rows = 12
Me.grd_tabla_pagos.Cols = 9
Me.grd_tabla_pagos.FixedCols = 0
Me.grd_tabla_pagos.FixedRows = 1
Me.grd_tabla_pagos.MergeCells = flexMergeRestrictColumns
Me.grd_tabla_pagos.MergeCol(0) = False
Me.grd_tabla_pagos.MergeCol(1) = True
Me.grd_tabla_pagos.MergeCol(2) = False
Me.grd_tabla_pagos.MergeCol(3) = False
Me.grd_tabla_pagos.MergeCol(4) = False
Me.grd_tabla_pagos.MergeCol(5) = False
Me.grd_tabla_pagos.MergeCol(6) = False
Me.grd_tabla_pagos.MergeCol(7) = False
Me.grd_tabla_pagos.FormatString = "^ Item  |^ Cuota Mes    |Fecha Pago  |Forma de Pago  |Pagado |Nº Boleta    |Fec.Emisión |Monto Boleta|Nombre del Alumno"
Me.grd_tabla_pagos.ColWidth(0) = 400
Me.grd_tabla_pagos.ColWidth(1) = 1100
Me.grd_tabla_pagos.ColWidth(2) = 1050
Me.grd_tabla_pagos.ColWidth(3) = 1200
Me.grd_tabla_pagos.ColWidth(4) = 1000
Me.grd_tabla_pagos.ColWidth(5) = 1000
Me.grd_tabla_pagos.ColWidth(6) = 1050
Me.grd_tabla_pagos.ColWidth(7) = 1100
Me.grd_tabla_pagos.ColWidth(8) = 3100
End Sub

Sub IniGrillaMat()
Me.lbl_Nmatriculados.Caption = "0"
Me.Grd_alumat_caja.Clear
Me.Grd_alumat_caja.Rows = 6
Me.Grd_alumat_caja.Cols = 11
Me.Grd_alumat_caja.FixedCols = 0
Me.Grd_alumat_caja.FixedRows = 1
Me.Grd_alumat_caja.FormatString = "^  Curso       |Nombre                     ||% Beca|||||||FecRetiro"
Me.Grd_alumat_caja.ColWidth(0) = 650
Me.Grd_alumat_caja.ColWidth(1) = 3650
Me.Grd_alumat_caja.ColWidth(2) = 2000  'situacion
Me.Grd_alumat_caja.ColWidth(3) = 800  ' % Beca
Me.Grd_alumat_caja.ColWidth(4) = 700  'arancel
Me.Grd_alumat_caja.ColWidth(5) = 1000 '800' exencion
Me.Grd_alumat_caja.ColWidth(6) = 1000 ' 700' a pagar
Me.Grd_alumat_caja.ColWidth(7) = 1000 'rut
Me.Grd_alumat_caja.ColWidth(8) = 500  '500 cod des1
Me.Grd_alumat_caja.ColWidth(9) = 1000  '
Me.Grd_alumat_caja.ColWidth(10) = 500 'Fecha Retiro
End Sub
Sub AluMatenGrilla(Rutapod As String)
Call IniGrillaMat
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
'               0            1         2        3            4               5              6         7            8           9        10         11         12           13
a = "select a.num_gra, a.let_cur, c.cod_des, p.nom_alu, p.ape_pat_alu, p.ape_mat_alu, m.reserva, m.activo_alu, fec_retiro, p.ci_alu, m.cuota1, ar.mensual, m.ind_beca, m.ind_mbeca  from gescol2004.postulantes p, gescol2004.apo_x_alu aa, gescol2004.matriculas m, gescol2004.alu_x_cur a, gescol2004.codigos_ensenanza c, gescol2004.arancel ar where aa.ci_alu=p.ci_alu and p.ci_alu = m.ci_alu and m.ci_alu=a.ci_alu and a.activo_alu=m.activo_alu and a.cod_ens=c.cod_ens and a.cod_ens=ar.cod_ens and a.fec_cam = '1111-11-11' and aa.rut_apo = '" & Rutapod & "' and m.anno_mat ='2004'"
rs.Open a, conn
' No pregunto por matriculado_alu porque puede estar retirado
NaluMat = IIf(rs.RecordCount > 0, rs.RecordCount, 0)
If rs.RecordCount > 0 Then
    Dim ColegioALU As String
    fila = 1
    While Not rs.EOF
        If UCase(rs!cod_des) = "K" Or UCase(rs!cod_des) = "PK" Then
            curso = UCase(rs!cod_des) & "º" & UCase(rs!Let_Cur)
        ElseIf UCase(rs!cod_des) = "EB" Or UCase(rs!cod_des) = "EM" Then
            curso = UCase(rs!Num_Gra) & "º" & UCase(rs!Let_Cur) & " " & UCase(rs!cod_des)
        End If
        Me.Grd_alumat_caja.TextMatrix(fila, 0) = curso
        Me.Grd_alumat_caja.TextMatrix(fila, 1) = rs!Nom_Alu & " " & rs!ape_pat_alu & " " & rs!ape_mat_alu
        If rs!Reserva = 1 Then
            Me.Grd_alumat_caja.TextMatrix(fila, 2) = "Matrícula con reserva"
        Else
            Me.Grd_alumat_caja.TextMatrix(fila, 2) = "Matrícula sin reserva"
        End If
        If UCase(rs!activo_alu) = "NO" Then
             Me.Grd_alumat_caja.TextMatrix(fila, 2) = "Retirado el " & rs(8)
        End If
        
        If rs!Ind_Beca = 1 Then
            porbeca = "100"
        ElseIf rs!Ind_MBeca = 1 Then
            porbeca = "50"
        ElseIf rs!Ind_Beca = 0 And rs!Ind_MBeca = 0 Then
            porbeca = "0"
        End If
        Me.Grd_alumat_caja.TextMatrix(fila, 3) = porbeca
        Me.Grd_alumat_caja.TextMatrix(fila, 4) = rs!Mensual
        Me.Grd_alumat_caja.TextMatrix(fila, 7) = rs!ci_alu
        Me.Grd_alumat_caja.TextMatrix(fila, 9) = IIf(Trim(UCase(rs!cod_des)) <> "PK", CodEmpresa, CodEmpresaAlt)
        Me.Grd_alumat_caja.TextMatrix(fila, 10) = rs!fec_retiro
        
        rs.MoveNext
        fila = fila + 1
        If fila > 5 Then
            Me.Grd_alumat_caja.Rows = Me.Grd_alumat_caja.Rows + 1
        End If
    Wend
    If fila > 5 Then Me.Grd_alumat_caja.Rows = Me.Grd_alumat_caja.Rows - 1
    Me.lbl_Nmatriculados.Caption = NaluMat
End If

rs.Close
Set rs = Nothing
'Call CalculaMensualidad
End Sub
Sub Creagrupo(Indice)
'Me.Frame_datos_busqueda.Visible = False
Me.Opt_busqueda_caj(Tipobus).Value = False
Me.Frame_Apo_Caja.Enabled = True
Me.Frame_Alu_Caja.Enabled = True
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
If Tipobus = 0 Then ' Busca por apoderado
    Me.txt_nomapo_caja = ARutBus(Indice, 0) & " " & ARutBus(Indice, 1) & " " & ARutBus(Indice, 2)
    Me.txt_rutapo_caja = separarut(ARutBus(Indice, 3))
    Me.txt_digapo_caja = separadigito(ARutBus(Indice, 3))
    'Rutapo = ARutBus(Indice, 3)
'    Me.Grd_alumat_caja.FixedCols = 0: Me.Grd_alumat_caja.FixedRows = 1
    Call AluMatenGrilla(ARutBus(Indice, 3)) 'Ordenar Por fecha de ingreso al curso
Else
    RutApoCaja = devuelvecampo("gescol2004.apo_x_alu", "", "rut_apo", "ci_alu ='" & ARutBus(Indice, 3) & "'", conn)
    If RutApoCaja <> "" Then
        rs.Open "select * from gescol2004.apoderados where rut_apo ='" & RutApoCaja & "'", conn
        If rs.RecordCount > 0 Then
            Me.txt_nomapo_caja.Text = rs("noms_apo") & " " & rs("ape1_apo") & " " & rs("ape2_apo")
            Me.txt_rutapo_caja.Text = separarut(rs("rut_apo"))
            Me.txt_digapo_caja.Text = separadigito(rs("rut_apo"))
            'Me.Grd_alumat_caja.FixedCols = 0: Me.Grd_alumat_caja.FixedRows = 1
            rs.Close
            Call AluMatenGrilla(RutApoCaja)
        Else
            MsgBox ("Alumno sin apoderado, complete la ficha")
            rs.Close
        End If
        
    End If
End If
Set rs = Nothing
' Preguntar si encontro alumnos postulantes y encender el botón check
Me.Chk_VerPost.Visible = IIf(NaluPos > 0, True, False)
RutApoCaja = Me.txt_rutapo_caja & "-" & Me.txt_digapo_caja
FonoApoCaja = devuelvecampo("gescol2004.apoderados", "", "fon_c_apo", "rut_apo ='" & RutApoCaja & "'", conn)
End Sub


Private Sub Btn_Agregar_Click()
On Error GoTo SinAnualidad:
If Len(Trim(Me.txt_Monto_Pago.Text)) = 0 Or Val(Trim(Me.txt_Monto_Pago.Text)) <= 0 Then Call validatexto(txt_Monto_Pago, "Ingrese Monto a Pagar"): Exit Sub
If PosibleAbono Then
    'If Val(Trim(Me.txt_Monto_Pago)) > Val(Trim(Me.Txt_MontoIdeal)) Then Call validatexto(txt_Monto_Pago, "Monto a pagar no puedo ser mayor al total"): Exit Sub
    If Val(Trim(Me.txt_Monto_Pago.Text)) > Val(Me.Grd_Cuotas_Alu.TextMatrix(Inigdeuda, 12)) Then Call validatexto(txt_Monto_Pago, "Monto no debe ser superior a saldo adeudado."): Exit Sub
End If
If Not MarcaAlumno Then
    MsgBox ("Seleccione un alumno de la grilla")
    Exit Sub
End If

If (Len(Trim(Me.Txt_Folio_Disp))) > 0 Then
    If MsgBox("Nombre Apoderado : " & Me.txt_nomapo_caja & Chr(13) & "Nombre Alumno       : " & Me.Grd_alumat_caja.TextMatrix(FilaAlu, 1) & Chr(13) & "Fecha de Boleta      : " & Me.DTP_Fec_Emision.Value & Chr(13) & "Nº de Boleta            : " & Me.Txt_Folio_Disp & Chr(13) & "Monto de la Boleta  : " & Me.txt_Monto_Pago & Chr(13) & Chr(13) & "                     ¿ AGREGAR AL LIBRO ?", vbYesNo + vbQuestion) = vbYes Then
        Dim MArancel As Long, MExencion As Long, MPagado As Long, MCuota As Long
        Dim MCPadres As Long, MAportes As Long, MOtros As Long
        Dim Folio As String, Prestado As String * 1
        Dim FEmision As String, FVencCuota As String, FPago As String, FNula As String
        Dim Cabecera As Long, NCup As Long, Convenio, CodBanco As String, Concheque As String * 1
        Dim Proc As String * 1, Nula As String * 1
        Dim CodColegio As String
        Procedencia = "1"
        Rutalucaja = Me.Grd_alumat_caja.TextMatrix(FilaAlu, 7)
        CodColegio = Me.Grd_alumat_caja.TextMatrix(FilaAlu, 9)
        Folio = FillconStr(Trim(Me.Txt_Folio_Disp), 8, "0", "IZQ")
        FEmision = InvierteFecha(Me.DTP_Fec_Emision.Value, "R")
        CodConvBci = Me.Grd_Cuotas_Alu.TextMatrix(1, 9)
        fechaven = devuelvecampo("gescol2004.anualidad_x_apo", "", "fecha_venc", "rut_apo ='" & RutApoCaja & "' and month(fecha_venc) = '" & Me.Grd_Cuotas_Alu.TextMatrix(Inigdeuda, 11) & "'", conn)
        FVencCuota = InvierteFecha(CDate(fechaven), "R")
        FPago = InvierteFecha(Me.DTP_Fec_Emision.Value, "R")
        MArancel = ArancelApoxMes ' CLng(Me.txt_Monto_Pago)
        MCuota = IIf(PosibleAbono, CLng(Me.txt_Monto_Pago), CuotaApoxMes)
        MExencion = ExencionApoxMes
        MCPadres = 0
        MAportes = 0
        MOtros = 0
        MTotal = (MCuota + MCPadres + MAportes + MOtros)
        Nula = 0
        If Nula = "1" Then
            FNula = FEmision
        Else
            FNula = "1111-11-11"
        End If
        If ExistReg("gescol2004.BOL_APO_X_ALU", "FOLIO ='" & Folio & "' and  cod_conv_bci ='" & CodConvBci & "'", conn) Then
            MsgBox ("FOLIO Nº " & Folio & " YA EXISTE NO SE AGREGARÁ ")
                Exit Sub
        Else
            Concheque = "0"
            conn.Execute "INSERT INTO gescol2004.bol_apo_x_alu(RUT_APO, CI_ALU, FOLIO, FEC_EMISION, FEC_VEN_CUOTA, FEC_PAGO, MONTO_ARANCEL, MONTO_EXENCION, MONTO_CPADRES, MONTO_APORTES, MONTO_OTROS, MONTO_TOTAL, NULA, FEC_NULA, PROCEDENCIA, COD_CONV_BCI, IND_CHEQUE) values('" & RutApoCaja & "', '" & Rutalucaja & "', '" & Folio & "', '" & FEmision & "', '" & FVencCuota & "', '" & FPago & "', '" & MArancel & "', '" & MExencion & "', 0, 0, 0, " & MTotal & ", '" & Nula & "', '" & FNula & "', '" & Procedencia & "', '" & CodConvBci & "','" & Concheque & "')"
            Call CrearBoleta2004(Val(Folio), CodColegio, "gescol", FPago, FEmision, Val(MTotal), RutApoCaja, Rutalu, conn)
            For t = Inigdeuda To Fingdeuda
                idcuota = CInt(devuelvecampo("gescol2004.anualidad_x_apo", "", "id_cuota", "rut_apo ='" & RutApoCaja & "' and month(fecha_venc) = " & Me.Grd_Cuotas_Alu.TextMatrix(t, 11), conn))
                MCuota = IIf(PosibleAbono, CLng(Me.txt_Monto_Pago), CLng(Me.Grd_Cuotas_Alu.TextMatrix(t, 12)))
                fechaven = devuelvecampo("gescol2004.anualidad_x_apo", "", "fecha_venc", "rut_apo ='" & RutApoCaja & "' and month(fecha_venc) = " & Me.Grd_Cuotas_Alu.TextMatrix(t, 11), conn)
                FVencCuota = InvierteFecha(CDate(fechaven), "R")
                conn.Execute "INSERT INTO gescol2004.pagos(RUT_APO, ID_CUOTA, COD_CONV_BCI, FOLIO, FEC_PAGO, CI_ALU, MONTO) values('" & RutApoCaja & "', " & idcuota & ", '" & CodConvBci & "', '" & Folio & "', '" & FEmision & "', '" & Rutalucaja & "', " & MCuota & ")"
                conn.Execute "update gescol2004.anualidad_x_apo set pagado = pagado + " & MCuota & " where rut_apo ='" & RutApoCaja & "' and id_cuota = " & idcuota
            Next t
            Call RefrescaFolios
            Call Grd_alumat_caja_Click
        End If
    End If
Else
    MsgBox ("Error en el Folio")
End If
Exit Sub
SinAnualidad:
If Err.Number = "13" Then
    MsgBox ("Apoderado no tiene creada la anualidad")
    'Unload Me
'    Menuinformes2 = "edideuda"
'    Load Form_Informes2
    'form_informes2.te
Else
    MsgBox ("Información de anomalía " & Err.Number & " " & Err.Description)
End If
End Sub

Private Sub btn_can_busqueda_Click()
Me.Frame_datos_busqueda.Visible = False
Me.Opt_busqueda_caj(Tipobus).Value = False
Me.Frame_Apo_Caja.Enabled = True
Me.Frame_Alu_Caja.Enabled = True
End Sub



Private Sub Btn_Cancelar_Click()
Unload Me
End Sub

Private Sub Btn_CargaPagos_Click()
Call IniciaTablaPagos
Dim MesConsulta As Integer
'RutMatri = Me.Grd_alumat_caja.TextMatrix(Fila, 7)
MesConsulta = Me.cmb_mes_consulta.ListIndex
If MesConsulta >= 0 Then
    id = IIf(MesConsulta > 0, "and a.id_cuota = " & AMesesPago(MesConsulta), "")
    CritCialu = IIf(Me.Opt_Muestra_Pagos(0).Value, "and p.ci_alu ='" & Rutalu & "'", "")
    'rsaux.Open "select a.fecha_venc, p.fec_pago, p.monto, b.monto_total, b.folio, b.fec_emision, b.procedencia, pos.nom_alu, pos.ape_pat_alu, pos.ape_mat_alu from anualidad_x_apo a, pagos p, bol_apo_x_alu b, postulantes pos where a.rut_apo=p.rut_apo and p.id_cuota=a.id_cuota and b.folio=p.folio and a.rut_apo= '" & RutApoCaja & "' and b.ci_alu=pos.ci_alu " & Id & " " & CritCialu & " order by p.fec_pago, a.fecha_venc, p.folio", conn
    'Call llenagrilla(Me.grd_tabla_pagos, "Vencimiento, Boleta     , Fecha Emisión, Monto Pagado", "bol_apo_x_alu", "fec_ven_cuota; folio; fec_emision; monto_total", "rut_apo ='" & Rutapo & "' and ci_alu='" & RutMatri & "'order by fec_ven_cuota", conn)
    Set RsAux = New ADODB.Recordset
    RsAux.CursorLocation = adUseClient
    'rsaux.Open "select d.fecha_venc, p.fec_pago, p.monto, p.folio, b.fec_emision, b.procedencia from pagos p, bol_apo_x_alu b, anualidad_x_apo d where p.rut_apo=b.rut_apo and p.cod_conv_bci=b.cod_conv_bci and p.folio=b.folio and p.id_cuota=d.id_cuota and d.rut_apo ='" & Rutapo & "'" & id & " order by p.fec_pago, d.fecha_venc", conn
    RsAux.Open "select a.fecha_venc, p.fec_pago, p.monto, b.monto_total, b.folio, b.fec_emision, b.procedencia, pos.nom_alu, pos.ape_pat_alu, pos.ape_mat_alu from gescol2004.anualidad_x_apo a, gescol2004.pagos p, gescol2004.bol_apo_x_alu b, gescol2004.postulantes pos where a.rut_apo=p.rut_apo and p.id_cuota=a.id_cuota and b.folio=p.folio and a.rut_apo= '" & RutApoCaja & "' and b.ci_alu=pos.ci_alu " & id & " " & CritCialu & " order by p.fec_pago, a.fecha_venc, p.folio", conn
    'rsaux.Open "select  from pagos p, bol_apo_x_alu b where rut_apo ='" & Rutapo & "' and ci_alu='" & RutMatri & "' and nula='0' order by fec_ven_cuota", conn
    t = 0
    CuotasPagadas = IIf(RsAux.RecordCount > 0, RsAux.RecordCount, 0)
    If RsAux.RecordCount > 0 Then
        While Not RsAux.EOF
            Me.grd_tabla_pagos.AddItem ""
            t = t + 1
            Me.grd_tabla_pagos.TextMatrix(t, 0) = t
            Me.grd_tabla_pagos.TextMatrix(t, 1) = UCase(MesATexto(CInt(Month(RsAux!Fecha_Venc))))
            Me.grd_tabla_pagos.TextMatrix(t, 2) = RsAux!fec_pago
            Select Case RsAux!Procedencia
                Case "1"
                    NomProced = "Directo Caja"
                Case "2"
                    NomProced = "Cuponera"
                Case "3"
                    NomProced = "P.A.C."
            End Select
            Me.grd_tabla_pagos.TextMatrix(t, 3) = NomProced
            Me.grd_tabla_pagos.TextMatrix(t, 4) = RsAux!Monto
            Me.grd_tabla_pagos.TextMatrix(t, 5) = RsAux!Folio
            Me.grd_tabla_pagos.TextMatrix(t, 6) = RsAux!fec_emision
            Me.grd_tabla_pagos.TextMatrix(t, 7) = RsAux!Monto_Total
            Me.grd_tabla_pagos.TextMatrix(t, 8) = RsAux!Nom_Alu & " " & RsAux!ape_pat_alu & " " & RsAux!ape_mat_alu
            RsAux.MoveNext
        Wend
    Else
        Call IniciaTablaPagos
        'MsgBox ("No hay pagos registrados en mes de " & Me.Grd_Deuda.TextMatrix(FilaDeuda, 1))
    End If
    RsAux.Close
    Set RsAux = Nothing
    If CuotasPagadas > 0 Then
        'Me.btn_imp_pagos.Enabled = True
    Else
        'Me.btn_imp_pagos.Enabled = False
    End If
End If
End Sub

'Private Sub Chk_PagosProx_Click()
'Select Case Me.Chk_PagosProx.Value
'    Case 1
'        Call llenagrilla(Me.Grd_PagosProx, "Nº Cuota, Nº Boleta, Fecha Pago, Rut Apoderado, Nombre Apoderado, Apellido Paterno    , Apellido Materno    , Rut Alumno, Nombre Alumno, Apellido Paterno, Apellido Materno , Excención, Pagado, Forma Pago", "boletas_auxiliar b, aux_men_apo_x_alu am, aux_pagos pag, apoderados a, apo_x_alu ap, postulantes p", "am.cuota; b.folio_boleta; b.fecha_pago; b.rut_apo_deuda; a.noms_apo; a.ape1_apo; a.ape2_apo; b.ci_alu; p.nom_alu; p.ape_pat_alu; p.ape_mat_alu; b.monto_excencion; b.monto_pagado; b.forma_pago", "b.colegio=pag.colegio and b.folio_interno=pag.folio_interno and pag.ci_alu=am.ci_alu and pag.cuota=am.cuota and pag.agno=am.agno and a.rut_apo=ap.rut_apo and ap.ci_alu=p.ci_alu and b.rut_apo_deuda=a.rut_apo and b.ci_alu=p.ci_alu and b.rut_apo_deuda ='" & RutApoCaja & "' and b.ci_alu='" & Rutalu & "'order by am.cuota asc", conn)
'        Me.Frame_PagosProx.Visible = True
'    Case 0
'        Me.Frame_PagosProx.Visible = False
'End Select
'End Sub

Private Sub Chk_VerPost_Click()
If Me.Chk_VerPost.Value = 1 Then
    Me.Enabled = False
    'FilaCheque = 0
    'Call Form_Aux2.IniGrillaPos
    Form_Aux2.Show
Else
    Form_Aux2.Hide
End If
End Sub

Private Sub cmb_forma_pago_Change()

End Sub

Private Sub cmb_mes_consulta_Click()
Call Btn_CargaPagos_Click
End Sub

Private Sub Cmb_mes_pago_Click()
p = Me.Cmb_mes_pago.ListIndex
D = 0
Me.Cmb_mes_pago2.Clear
If p >= 0 Then
    For t = p To Me.Cmb_mes_pago.ListCount - 1
        Me.Cmb_mes_pago2.AddItem Me.Cmb_mes_pago.List(t)
        Me.Cmb_mes_pago2.ItemData(D) = Me.Cmb_mes_pago.ItemData(t)
        D = D + 1
    Next t
    Me.Cmb_mes_pago2.ListIndex = Me.Cmb_mes_pago.ListIndex - p
End If
End Sub

Private Sub Cmb_mes_pago2_Click()
If MarcaAlumno Then
    If Me.Cmb_mes_pago.ListIndex > -1 Then
        Inigdeuda = CLng(Me.Cmb_mes_pago.ItemData(Me.Cmb_mes_pago.ListIndex))
        Fingdeuda = CLng(Me.Cmb_mes_pago2.ItemData(Me.Cmb_mes_pago2.ListIndex))
        MesIniDeuda = Me.Grd_Cuotas_Alu.TextMatrix(Inigdeuda, 11) ' Month(Me.Grd_Deuda.TextMatrix(Inigdeuda, 4))
        MesFindeuda = Me.Grd_Cuotas_Alu.TextMatrix(Inigdeuda, 11)
        Tdeuda = 0: DeudaApoxMes = 0: CuotaApoxMes = 0
        'Chequear el monto a pagar, la cuota del alumno, ya que debe
        'calcular bien la cuota segun cuotas_x_alu
        For te = 1 To Me.Grd_Cuotas_Alu.Rows - 2
            For t = 0 To Me.Grd_Cuotas_Alu.Cols - 1
                Me.Grd_Cuotas_Alu.Row = te: Me.Grd_Cuotas_Alu.Col = t
                Me.Grd_Cuotas_Alu.CellBackColor = &HFFFFFF
            Next t
        Next te
        For te = Inigdeuda To Fingdeuda
            For t = 0 To Me.Grd_alumat_caja.Cols - 1
                Me.Grd_Cuotas_Alu.Row = te: Me.Grd_Cuotas_Alu.Col = t
                Me.Grd_Cuotas_Alu.CellBackColor = &HC0FFFF
            Next t
        Next te
        Tdeuda = 0: CuotaApoxMes = 0: PagoApoxMes = 0: ExencionApoxMes = 0
        ArancelApoxMes = 0
        For t = Inigdeuda To Fingdeuda
            CuotaAlu = Val(Me.Grd_Cuotas_Alu.TextMatrix(t, 4))
            Tdeuda = Tdeuda + CLng(CuotaAlu)
            CuotaApoxMes = CuotaApoxMes + Val(Me.Grd_Cuotas_Alu.TextMatrix(t, 12))
            ArancelApoxMes = ArancelApoxMes + Val(Me.Grd_Cuotas_Alu.TextMatrix(t, 2))
            ExencionApoxMes = ExencionApoxMes + Val(Me.Grd_Cuotas_Alu.TextMatrix(t, 3))
            pagoxmes = pagoxmes + Val(Me.Grd_Cuotas_Alu.TextMatrix(t, 6))
        Next t
        DeudaApoxMes = CuotaApoxMes - PagoApoxMes
        Me.Txt_MontoIdeal = Tdeuda
        'Pagado = devuelvecampo("bol_apo_x_alu", "", "sum(monto_total)", "rut_apo='" & RutApoCaja & "' and month(fec_ven_cuota) >= " & MesIniDeuda & " and month(fec_ven_cuota) <=" & MesFindeuda & " and ci_alu ='" & Me.Grd_alumat_caja.TextMatrix(Fila, 7) & "'")
        Pagado = devuelvecampo("gescol2004.anualidad_x_apo a, gescol2004.pagos p ", "", "sum(p.monto)", "a.id_cuota=p.id_cuota and p.rut_apo=a.rut_apo and p.rut_apo='" & RutApoCaja & "' and month(a.fecha_venc) >= " & MesIniDeuda & " and month(a.fecha_venc) <=" & MesFindeuda & " and p.ci_alu ='" & Me.Grd_alumat_caja.TextMatrix(FilaAlu, 7) & "'", conn)
        Me.Txt_MontoPagado = IIf(IsNull(Pagado) Or Len(Trim(Pagado)) = 0, 0, Pagado)
        Me.txt_Monto_Pago = Val(Me.Txt_MontoIdeal) - Val(Me.Txt_MontoPagado)
        If (Inigdeuda - Fingdeuda) = 0 Then
            Me.txt_Monto_Pago.Enabled = True
            PosibleAbono = True
        Else
            Me.txt_Monto_Pago.Enabled = False
            PosibleAbono = False
        End If
    Else
        Me.Txt_MontoIdeal = 0
        Me.Txt_MontoPagado = 0
        Me.txt_Monto_Pago = 0
    End If
Else
        'MsgBox ("Debe seleccionar un alumno")
End If
'MsgBox (Me.Cmb_mes_pago2.ItemData(Me.Cmb_mes_pago2.ListIndex))
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Form_Load()
CBci = devuelvecampo("gescol2004.establecimientos", "", "cod_conv_bci", "cod_conv_bci=cod_conv_bci", conn)
CodEmpresa = devuelvecampo("hist_cod_colegio", "", "colegio", "cod_conv_bci='" & CBci & "'", conn)
CodEmpresaAlt = devuelvecampo("hist_cod_colegio", "", "colegio", "mid(colegio,1,6)='" & CodEmpresa & "' and length(colegio)>6", conn)

Me.Height = 7950
Me.Width = 11865
CentrarForma Me
Me.Frame_Apo_Caja.Enabled = False
Me.Frame_Alu_Caja.Enabled = False
'Me.Frame_Prox_pagos.Visible = False
Me.lst_busq_caja(0).Visible = False
Me.lst_busq_caja(1).Visible = False
Me.DTP_Fec_Emision.Value = Date
Me.Chk_VerPost.Visible = False
Call IniGrillaMat: 'Call IniGrillaPos
Call IniciaTablaPagos
Call IniGrillaCuotasAlu
Busqueda = 1
Me.Show
Me.opt_criterio(0).Value = True
Me.Opt_busqueda_caj(0).Value = True
Me.Opt_Muestra_Pagos(1).Value = True
MarcaAlumno = False
Call RefrescaFolios
End Sub

Private Sub Grd_alumat_caja_Click()
FilaAlu = Me.Grd_alumat_caja.Row
If Me.Grd_alumat_caja.Row <= NaluMat Then
    Me.txt_arancel_col = Me.Grd_alumat_caja.TextMatrix(FilaAlu, 4)
    Me.txt_situacion_actual = Me.Grd_alumat_caja.TextMatrix(FilaAlu, 2)
    If Val(Me.Grd_alumat_caja.TextMatrix(Me.Grd_alumat_caja.Row, 3)) <> "100" Then
        MarcaAlumno = True
        Me.Frame_Pagando.Enabled = True
        Rutalu = Me.Grd_alumat_caja.TextMatrix(FilaAlu, 7)
        For te = 1 To NaluMat
            For t = 0 To Me.Grd_alumat_caja.Cols - 1
                Me.Grd_alumat_caja.Row = te: Me.Grd_alumat_caja.Col = t
                Me.Grd_alumat_caja.CellBackColor = &HFFFFFF
            Next t
        Next te
        For t = 0 To Me.Grd_alumat_caja.Cols - 1
            Me.Grd_alumat_caja.Row = FilaAlu: Me.Grd_alumat_caja.Col = t
            Me.Grd_alumat_caja.CellBackColor = &HC0E0FF
        Next t
        'Me.txt_Monto_Pago = Me.Grd_alumat_caja.TextMatrix(Fila, 4)
        ' preguntar si tiene anualidad creada
        Call IniGrillaCuotasAlu
        cuotasalu = TraecuotasGrilla(Grd_Cuotas_Alu, Rutalu)
        If cuotasalu = 0 Then
            MsgBox ("Alumno sin anualidad creada")
            Exit Sub
        End If
        CodConvBci = Me.Grd_Cuotas_Alu.TextMatrix(1, 9)
        Call MesesdePago
        Call Cmb_mes_pago2_Click
        Call CargaDeuda(RutApoCaja)
        Call Opt_Muestra_Pagos_Click(0)
        'Me.Opt_Muestra_Pagos(0).Enabled = True
        
        If UCase(Trim(Me.Grd_alumat_caja.TextMatrix(FilaAlu, 8))) = "PK" Then
            MsgBox ("Hacer boleta de Pre-Kinder a mano." & Chr(13) & "Y no olvide presionar boton Agregar al Libro")
        Else
        End If
    Else
        MsgBox ("ALUMNO BECADO IMPOSIBLE EMITIR BOLETA")
    End If
End If
End Sub

Private Sub Lbl_Ult_FolaPart_Click()
'&H8000000F&
End Sub

Private Sub lst_busq_caja_DblClick(Index As Integer)
Filacheque = 0
Dim Ind As Integer
    Ind = Me.lst_busq_caja(Index).ListIndex
    Me.lst_busq_caja(Index).Visible = False
    ActivabotonesBus (True)
    Me.Frame_datos_busqueda.Visible = False
    Me.Cmb_mes_pago.ListIndex = -1
    'Me.Frame_Pagando.Enabled = False
    Call IniGrillaCuotasAlu
    Call IniciaTablaPagos
    Call Creagrupo(Ind)
    'Call CargaDeuda(RutApoCaja)
    If Me.cmb_mes_consulta.ListCount > 0 Then
        Me.cmb_mes_consulta.ListIndex = 0
    End If
    Me.txt_arancel_col = ""
    Me.txt_situacion_actual = ""
    Me.Txt_MontoIdeal = ""
    Me.Txt_MontoPagado = ""
    Me.txt_Monto_Pago = ""
    fila = 0
    MarcaAlumno = False
End Sub

Private Sub Opt_busqueda_caj_Click(Index As Integer)
    Tipobus = Index
    Me.Frame_datos_busqueda.Height = 1095
    Me.Frame_datos_busqueda.Visible = True
    Me.Frame_Apo_Caja.Enabled = False
    Me.Frame_Alu_Caja.Enabled = False
    If Me.opt_criterio(0).Value Then
        Call opt_criterio_Click(0)
    Else
        Call opt_criterio_Click(1)
    End If
End Sub

Private Sub opt_criterio_Click(Index As Integer)
Dim Otroindice As Integer
Otroindice = (Index - 1) * -1
Me.txt_crit_busqueda(Otroindice).Visible = False
Me.lst_busq_caja(Otroindice).Visible = False
Me.txt_crit_busqueda(Index).Visible = True
Me.txt_crit_busqueda(Index).Visible = True
'If Me.Frame_datos_busqueda.Visible Then
    Me.txt_crit_busqueda(Index) = ""
    Me.lst_busq_caja(Index) = ""
    Me.txt_dig_busqueda = ""
    Me.txt_crit_busqueda(Index).SetFocus
'End If
End Sub

Private Sub Opt_Muestra_Pagos_Click(Index As Integer)
'Call CargaDeuda(RutApoCaja)
Call Btn_CargaPagos_Click
End Sub


Private Sub txt_crit_busqueda_Change(Index As Integer)
Dim Tablas As String, campos As String, CampoComp As String, Orden As String
If Tipobus = 0 And Index = 0 Then ' Apoderado por apellido
    campos = "noms_apo, ape1_apo, ape2_apo, rut_apo": Tablas = "gescol2004.apoderados": CampoComp = "ape1_apo": Orden = "ape1_apo, ape2_apo, noms_apo"
ElseIf Tipobus = 0 And Index = 1 Then ' Apoderado por Rut
    campos = "noms_apo, ape1_apo, ape2_apo, rut_apo": Tablas = "gescol2004.apoderados": CampoComp = "rut_apo": Orden = "rut_apo"
ElseIf Tipobus = 1 And Index = 0 Then 'Alumno por apellido
    campos = "nom_alu, ape_pat_alu, ape_mat_alu, ci_alu": Tablas = "gescol2004.postulantes": CampoComp = "ape_pat_alu": Orden = "ape_pat_alu, ape_mat_alu, nom_alu"
ElseIf Tipobus = 1 And Index = 1 Then 'Alumno por rut
    campos = "nom_alu, ape_pat_alu, ape_mat_alu, ci_alu": Tablas = "gescol2004.postulantes": CampoComp = "ci_alu": Orden = "ci_alu"
End If

If Busqueda = 1 Then
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    lst_busq_caja(Index).Clear
    If Not ((Chr(KeyAscii) >= "A" And Chr(KeyAscii) <= "Z") Or (Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z")) Then
        KeyAscii = 0
        If Me.txt_crit_busqueda(Index).Text <> "" Then
            Criterio = "'" + Me.txt_crit_busqueda(Index).Text + Consulta + "%'"
            rs.CursorLocation = adUseClient
            rs.Open "SELECT " & campos & " FROM " & Tablas & " where " & CampoComp & " like " & Criterio & " order by " & Orden, conn
            
            Me.lst_busq_caja(Index).Visible = False
            Me.Frame_datos_busqueda.Height = 1095
            If rs.RecordCount > 0 Then
                
                Me.Frame_datos_busqueda.Height = 2535
                Me.Frame_datos_busqueda.Refresh
                ReDim ARutBus(rs.RecordCount, 4)
                'Indi = 0
                X = 0
                Me.lst_busq_caja(Index).Visible = True
                While Not rs.EOF
                    If Index = 0 Then
                        Me.lst_busq_caja(Index).AddItem rs(1) & " " & rs(2) & " " & rs(0)
                    Else
                        Me.lst_busq_caja(Index).AddItem rs(3)
                    End If
                    ARutBus(X, 0) = IIf(IsNull(rs(0)), "", rs(0))
                    ARutBus(X, 1) = IIf(IsNull(rs(1)), "", rs(1))
                    ARutBus(X, 2) = IIf(IsNull(rs(2)), "", rs(2))
                    ARutBus(X, 3) = IIf(IsNull(rs(3)), "", rs(3))
                    rs.MoveNext
                    X = X + 1
                Wend
            Else
                Me.Frame_datos_busqueda.Height = 1095
                'Indi = 0
            End If
            rs.Close
        Else
            Me.lst_busq_caja(Index).Visible = False
            Me.Frame_datos_busqueda.Height = 1095
        End If
    End If
    Set rs = Nothing
End If
End Sub

Private Sub txt_crit_busqueda_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
    Call btn_can_busqueda_Click
End If
End Sub

Sub MesesdePago()
Me.Cmb_mes_pago.Clear: Me.Cmb_mes_pago2.Clear
Indice = 0
For t = 1 To Me.Grd_Cuotas_Alu.Rows - 1
    If Len(Trim(Me.Grd_Cuotas_Alu.TextMatrix(t, 0))) > 0 And Val(Trim(Me.Grd_Cuotas_Alu.TextMatrix(t, 6))) < Val(Trim(Me.Grd_Cuotas_Alu.TextMatrix(t, 4))) Then
        Me.Cmb_mes_pago.AddItem Me.Grd_Cuotas_Alu.TextMatrix(t, 1)
        Me.Cmb_mes_pago.ItemData(Indice) = Me.Grd_Cuotas_Alu.TextMatrix(t, 0)
        Indice = Indice + 1
    End If
Next t
If Me.Cmb_mes_pago.ListCount > 0 Then
    Me.Cmb_mes_pago.ListIndex = 0
    'Me.Cmb_mes_pago.Enabled = False
End If
End Sub

Private Sub txt_crit_busqueda_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 1 Then
    If (Chr(KeyAscii) >= "0" And Chr(KeyAscii) <= "9") Then
        Exit Sub
    ElseIf KeyAscii = 8 Then Exit Sub
    ElseIf KeyAscii = 32 Then Exit Sub
    End If
    KeyAscii = 0
End If
End Sub

Private Sub txt_folio_disp_KeyPress(KeyAscii As Integer)
If (Chr(KeyAscii) >= "0" And Chr(KeyAscii) <= "9") Then
    Exit Sub
ElseIf KeyAscii = 8 Then Exit Sub
ElseIf KeyAscii = 32 Then Exit Sub
End If
KeyAscii = 0
End Sub

Private Sub txt_Monto_Pago_KeyPress(KeyAscii As Integer)
If (Chr(KeyAscii) >= "0" And Chr(KeyAscii) <= "9") Then
    Exit Sub
ElseIf KeyAscii = 8 Then Exit Sub
ElseIf KeyAscii = 32 Then Exit Sub
End If
KeyAscii = 0
End Sub

Function TraecuotasGrilla(grilla As MSFlexGrid, Rutalu As String) As Integer
    Dim ValorMes As Long, cialu As String, Activoalu As String, Codbci As String
    Dim FecMov As String, ExeAlu As Long, Cuotasis As Long, FilaCuota As Long
    Dim Totarancel As Long, TotExencion  As Long, TotCuota As Long, TotPagado As Long
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open "select * from gescol2004.cuotas_x_alu where ci_alu ='" & Rutalu & "' order by mes_cuota ASC limit 1", conn
    FilaCuota = 0
    Me.Grd_Cuotas_Alu.Rows = 1
    If rs.RecordCount > 0 Then
        cialu = rs!ci_alu
        MesCuota = rs!mes_cuota
        Activoalu = rs!activo_alu
        Codbci = rs!cod_bci
        FecMov = IIf(Year(rs!fec_mov) = "1111" And Month(rs!fec_mov) = "11" And Day(rs!fec_mov) = "11", "----------", rs!fec_mov)
        ValorMes = IIf(IsNull(rs!cuota_alu), rs!cuota_sis, rs!cuota_alu)
        ExeAlu = rs!exe_alu
        Cuotasis = rs!cuota_sis
        FilaCuota = FilaCuota + 1
        grilla.AddItem ""
        grilla.TextMatrix(FilaCuota, 0) = FilaCuota
        grilla.TextMatrix(FilaCuota, 1) = MesATexto(CInt(rs!mes_cuota))
        grilla.TextMatrix(FilaCuota, 2) = Me.Grd_alumat_caja.TextMatrix(FilaAlu, 4)
        grilla.TextMatrix(FilaCuota, 3) = ExeAlu
        grilla.TextMatrix(FilaCuota, 4) = ValorMes
        grilla.TextMatrix(FilaCuota, 5) = Cuotasis
        grilla.TextMatrix(FilaCuota, 7) = cialu
        grilla.TextMatrix(FilaCuota, 8) = Activoalu
        grilla.TextMatrix(FilaCuota, 9) = Codbci
        grilla.TextMatrix(FilaCuota, 10) = FecMov
        grilla.TextMatrix(FilaCuota, 11) = MesCuota
        'Pagado = devuelvecampo("anualidad_x_apo a, pagos p ", "", "sum(monto_total)", "a.id_cuota=p.id_cuota and p.rut_apo='" & RutApoCaja & "' and month(a.fecha_venc) >= " & MesIniDeuda & " and month(a.fecha_venc) <=" & MesFindeuda & " and p.ci_alu ='" & Me.Grd_alumat_caja.TextMatrix(FilaAlu, 7) & "'")
        Pagado = devuelvecampo("gescol2004.anualidad_x_apo a ,gescol2004.pagos p", "", "Sum(p.monto)", " a.rut_apo=p.rut_apo and a.id_cuota=p.id_cuota and month(a.fecha_venc)='" & MesCuota & "' and p.ci_alu ='" & Rutalu & "' order by p.id_cuota", conn)
        Pagadon = IIf(Pagado <> "", Pagado, "0")
        grilla.TextMatrix(FilaCuota, 6) = Pagadon
        grilla.TextMatrix(FilaCuota, 12) = Val(grilla.TextMatrix(FilaCuota, 4)) - Val(grilla.TextMatrix(FilaCuota, 6))
        
        Totarancel = Totarancel + Val(grilla.TextMatrix(FilaCuota, 2))
        TotExencion = TotExencion + Val(grilla.TextMatrix(FilaCuota, 3))
        TotCuota = TotCuota + Val(grilla.TextMatrix(FilaCuota, 4))
        TotPagado = TotPagado + Val(grilla.TextMatrix(FilaCuota, 6))
        MesRetiro = MesRetiroContable(CDate(Me.Grd_alumat_caja.TextMatrix(FilaAlu, 10)))
        For t = Val(MesCuota) + 1 To MesRetiro
        'For t = Val(MesCuota) + 1 To 12
            RsAux.CursorLocation = adUseClient
            RsAux.Open "select * from gescol2004.cuotas_x_alu where ci_alu='" & Rutalu & "' and mes_cuota ='" & FillconStr(Trim(CStr(t)), 2, "0", "IZQ") & "' order by mes_cuota ASC limit 1", conn
            FilaCuota = FilaCuota + 1
            grilla.AddItem ""
            grilla.TextMatrix(FilaCuota, 0) = FilaCuota
            grilla.TextMatrix(FilaCuota, 1) = MesATexto(CInt(t))
            grilla.TextMatrix(FilaCuota, 2) = Me.Grd_alumat_caja.TextMatrix(FilaAlu, 4)
            If RsAux.RecordCount > 0 Then
                'Grilla.TextMatrix(filacuota, 2) = IIf(IsNull(rsaux!cuota_alu), rsaux!Cuota_Sis, rsaux!cuota_alu)
                ValorMes = IIf(IsNull(RsAux!cuota_alu), RsAux!cuota_sis, RsAux!cuota_alu)
                cialu = RsAux!ci_alu
                MesCuota = RsAux!mes_cuota
                Activoalu = RsAux!activo_alu
                Codbci = RsAux!cod_bci
                FecMov = IIf(Year(RsAux!fec_mov) = "1111" And Month(RsAux!fec_mov) = "11" And Day(RsAux!fec_mov) = "11", "----------", RsAux!fec_mov)
                ValorMes = IIf(IsNull(RsAux!cuota_alu), RsAux!cuota_sis, RsAux!cuota_alu)
                ExeAlu = RsAux!exe_alu
                Cuotasis = RsAux!cuota_sis
                grilla.TextMatrix(FilaCuota, 3) = ExeAlu
                grilla.TextMatrix(FilaCuota, 4) = ValorMes
                grilla.TextMatrix(FilaCuota, 5) = Cuotasis
                grilla.TextMatrix(FilaCuota, 7) = cialu
                grilla.TextMatrix(FilaCuota, 8) = Activoalu
                grilla.TextMatrix(FilaCuota, 9) = Codbci
                grilla.TextMatrix(FilaCuota, 10) = FecMov
            Else
                grilla.TextMatrix(FilaCuota, 3) = ExeAlu
                grilla.TextMatrix(FilaCuota, 4) = ValorMes
                grilla.TextMatrix(FilaCuota, 5) = Cuotasis
                grilla.TextMatrix(FilaCuota, 7) = cialu
                grilla.TextMatrix(FilaCuota, 8) = Activoalu
                grilla.TextMatrix(FilaCuota, 9) = Codbci
                grilla.TextMatrix(FilaCuota, 10) = FecMov
            End If
            Pagado = devuelvecampo("gescol2004.anualidad_x_apo a ,gescol2004.pagos p", "", "Sum(p.monto)", " a.rut_apo=p.rut_apo and a.id_cuota=p.id_cuota and month(a.fecha_venc)= '" & t & "' and p.ci_alu ='" & Rutalu & "' order by p.id_cuota", conn)
            Pagadon = IIf(Pagado <> "", Pagado, "0")
            grilla.TextMatrix(FilaCuota, 6) = Pagadon
            grilla.TextMatrix(FilaCuota, 11) = FillconStr(Trim(CStr(t)), 2, "0", "IZQ")
            grilla.TextMatrix(FilaCuota, 12) = Val(grilla.TextMatrix(FilaCuota, 4)) - Val(grilla.TextMatrix(FilaCuota, 6))
            Totarancel = Totarancel + Val(grilla.TextMatrix(FilaCuota, 2))
            TotExencion = TotExencion + Val(grilla.TextMatrix(FilaCuota, 3))
            TotCuota = TotCuota + Val(grilla.TextMatrix(FilaCuota, 4))
            TotPagado = TotPagado + Val(grilla.TextMatrix(FilaCuota, 6))
            RsAux.Close
        Next t
        FilaCuota = FilaCuota + 1
        grilla.AddItem ""
        For t = 0 To grilla.Cols - 1
            grilla.Row = FilaCuota: grilla.Col = t
            grilla.CellBackColor = &HC0FFC0
        Next t
        grilla.TextMatrix(FilaCuota, 1) = "Totales"
        grilla.TextMatrix(FilaCuota, 2) = Totarancel
        grilla.TextMatrix(FilaCuota, 3) = TotExencion
        grilla.TextMatrix(FilaCuota, 4) = TotCuota
        grilla.TextMatrix(FilaCuota, 6) = TotPagado
    End If
    rs.Close
    Set rs = Nothing: Set RsAux = Nothing
    TraecuotasGrilla = FilaCuota
End Function

Sub RefrescaFolios()
Me.Lbl_Ult_Fola.Caption = devuelvecampo("gescol2004.bol_apo_x_alu", "", "folio", "cod_conv_bci ='" & CBci & "' order by folio DESC limit 1", conn)
Me.Lbl_Ult_FolaPart = devuelvecampo("gescol2004.bol_apo_x_alu", "", "folio", "cod_conv_bci <>'" & CBci & "' and cod_conv_bci <> '' order by folio DESC limit 1", conn)
End Sub
Public Function MesRetiroContable(FechaRetiro As Date) As Integer ' hasta que mes debe pagar
If Year(FechaRetiro) = "1111" And Month(FechaRetiro) = "11" And Day(FechaRetiro) = "11" Then
    MesRetiroContable = 12
Else
    If Month(FechaRetiro) >= 3 Then
        If Day(FechaRetiro) <= 15 Then
            MesRetiroContable = Val(Month(FechaRetiro)) - 1
        Else
            MesRetiroContable = Val(Month(FechaRetiro))
        End If
    End If
End If
End Function
Public Function MesIngresoContable(FechaMatricula As Date) As Integer ' Desde que mes debe pagar
'If Year(FechaRetiro) = "1111" And Month(FechaRetiro) = "11" And Day(FechaRetiro) = "11" Then
'    MesRetiroContable = 12
'Else
    If Month(FechaMatricula) >= 2 Then
        If Day(FechaMatricula) <= 15 Then
            MesIngresoContable = Val(Month(FechaMatricula))
        Else
            MesIngresoContable = Val(Month(FechaMatricula)) + 1
        End If
    End If
'End If
End Function

