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 = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_BoletasMasivo 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   8325
   ClientLeft      =   1605
   ClientTop       =   1965
   ClientWidth     =   12765
   Icon            =   "Form_BoletasMasivo.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   8325
   ScaleWidth      =   12765
   Begin VB.CommandButton Btn_Informe_pagos_banco 
      Caption         =   "Informe Pagos en Banco"
      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          =   735
      Left            =   11280
      TabIndex        =   67
      Top             =   840
      Width           =   1215
   End
   Begin VB.Frame Frame_Camb_Fecha 
      Caption         =   "Cambiar Fecha"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2055
      Left            =   2040
      TabIndex        =   63
      Top             =   3960
      Width           =   1935
      Begin VB.CommandButton btn_canc_camb_fecha 
         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            =   360
         TabIndex        =   66
         Top             =   1440
         Width           =   1215
      End
      Begin VB.CommandButton btn_camb_fecha 
         Caption         =   "Cambiar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   360
         TabIndex        =   65
         Top             =   960
         Width           =   1215
      End
      Begin MSComCtl2.DTPicker DT_Camb_Fecha 
         Height          =   315
         Left            =   240
         TabIndex        =   64
         Top             =   360
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         _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          =   51773441
         CurrentDate     =   38527
      End
   End
   Begin VB.CommandButton Btn_VerSucesos 
      Caption         =   "Ver Anomalías"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   11280
      TabIndex        =   57
      Top             =   1920
      Width           =   1215
   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          =   1935
      Left            =   120
      TabIndex        =   26
      Top             =   120
      Width           =   6375
      Begin VB.OptionButton Option2 
         Caption         =   "Empresa PreKinder"
         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            =   240
         TabIndex        =   69
         Top             =   600
         Width           =   2295
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Empresa Colegio"
         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            =   240
         TabIndex        =   68
         Top             =   360
         Width           =   1935
      End
      Begin VB.ComboBox Cmb_Banco 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   2880
         Style           =   2  'Dropdown List
         TabIndex        =   55
         Top             =   1200
         Width           =   3255
      End
      Begin VB.TextBox Txt_CodConvBci_Part 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   5400
         Locked          =   -1  'True
         TabIndex        =   52
         Top             =   720
         Width           =   735
      End
      Begin VB.TextBox Txt_Cod_Pac 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   5280
         Locked          =   -1  'True
         TabIndex        =   50
         Top             =   1200
         Width           =   735
      End
      Begin VB.TextBox Txt_CodConvBci 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   5400
         Locked          =   -1  'True
         TabIndex        =   29
         Top             =   360
         Width           =   735
      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            =   2640
         Style           =   2  'Dropdown List
         TabIndex        =   28
         Top             =   720
         Width           =   2535
      End
      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            =   2640
         Style           =   2  'Dropdown List
         TabIndex        =   27
         Top             =   360
         Width           =   2535
      End
      Begin VB.Frame Frm_Des_Pago 
         Caption         =   "Descargar pagos de"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   735
         Left            =   240
         TabIndex        =   70
         Top             =   960
         Width           =   1935
         Begin VB.OptionButton Option4 
            Caption         =   "IBR"
            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        =   72
            Top             =   480
            Width           =   1695
         End
         Begin VB.OptionButton Option3 
            Caption         =   "BCI"
            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        =   71
            Top             =   240
            Value           =   -1  'True
            Width           =   1335
         End
      End
      Begin VB.Label Label21 
         Caption         =   "Banco"
         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        =   56
         Top             =   1200
         Width           =   495
      End
      Begin VB.Label Label9 
         Caption         =   "Código P.A.C."
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3600
         TabIndex        =   51
         Top             =   1200
         Width           =   1215
      End
   End
   Begin VB.Frame Frame_Criterios 
      Caption         =   "Criterios de Descarga"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1335
      Left            =   120
      TabIndex        =   30
      Top             =   2040
      Width           =   6375
      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_BoletasMasivo.frx":2A8B2
         Left            =   5280
         List            =   "Form_BoletasMasivo.frx":2A8B4
         Style           =   2  'Dropdown List
         TabIndex        =   35
         Top             =   720
         Width           =   855
      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_BoletasMasivo.frx":2A8B6
         Left            =   4080
         List            =   "Form_BoletasMasivo.frx":2A91A
         Style           =   2  'Dropdown List
         TabIndex        =   34
         Top             =   720
         Width           =   975
      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_BoletasMasivo.frx":2A99A
         Left            =   4080
         List            =   "Form_BoletasMasivo.frx":2A9FE
         Style           =   2  'Dropdown List
         TabIndex        =   33
         Top             =   360
         Width           =   975
      End
      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_BoletasMasivo.frx":2AA7E
         Left            =   1440
         List            =   "Form_BoletasMasivo.frx":2AAA9
         Style           =   2  'Dropdown List
         TabIndex        =   32
         Top             =   360
         Width           =   2055
      End
      Begin VB.ComboBox Cmb_TipoPago 
         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_BoletasMasivo.frx":2AB12
         Left            =   1440
         List            =   "Form_BoletasMasivo.frx":2AB1C
         Style           =   2  'Dropdown List
         TabIndex        =   31
         Top             =   720
         Width           =   2055
      End
      Begin VB.Label Label6 
         Caption         =   "Tipo de Pago"
         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        =   40
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label Label14 
         Caption         =   "Mes de Pago"
         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        =   39
         Top             =   360
         Width           =   1335
      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            =   3720
         TabIndex        =   38
         Top             =   360
         Width           =   375
      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            =   3720
         TabIndex        =   37
         Top             =   720
         Width           =   375
      End
      Begin VB.Label Label19 
         Alignment       =   2  'Center
         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            =   5040
         TabIndex        =   36
         Top             =   480
         Width           =   855
      End
   End
   Begin VB.Frame Frame_Sucesos 
      Caption         =   "Sucesos"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   3255
      Left            =   6600
      TabIndex        =   41
      Top             =   120
      Width           =   4455
      Begin VB.CommandButton Btn_Consultar 
         Caption         =   "Descargar Pagos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2760
         TabIndex        =   49
         Top             =   2640
         Width           =   1455
      End
      Begin VB.TextBox Txt_Folio_Disp 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   1200
         TabIndex        =   47
         Top             =   2760
         Width           =   1335
      End
      Begin VB.ListBox lst_Tareas 
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   900
         Left            =   240
         TabIndex        =   44
         Top             =   1440
         Width           =   3975
      End
      Begin VB.PictureBox Picture1 
         Height          =   375
         Left            =   240
         ScaleHeight     =   315
         ScaleWidth      =   3915
         TabIndex        =   42
         Top             =   600
         Width           =   3975
         Begin VB.Label lbl_conexion_ext 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   0
            TabIndex        =   43
            Top             =   0
            Width           =   3855
         End
      End
      Begin VB.Label Label18 
         Caption         =   "Folio Inicial"
         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        =   48
         Top             =   2760
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "Tareas Realizadas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   46
         Top             =   1200
         Width           =   1695
      End
      Begin VB.Label Label1 
         Caption         =   "Estado Conexión"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   45
         Top             =   360
         Width           =   1695
      End
   End
   Begin VB.Frame Frame_Principal 
      Height          =   4815
      Left            =   120
      TabIndex        =   0
      Top             =   3360
      Width           =   12495
      Begin VB.Frame Frame_Dtll_Pago 
         Caption         =   "Detalle del Pago"
         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            =   7320
         TabIndex        =   60
         Top             =   360
         Visible         =   0   'False
         Width           =   4215
         Begin VB.CommandButton Btn_Cerrar_Dtll 
            Caption         =   "Salir"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   495
            Left            =   1440
            TabIndex        =   62
            Top             =   2160
            Width           =   1335
         End
         Begin MSFlexGridLib.MSFlexGrid Grd_Dtll_Pago 
            Height          =   1695
            Left            =   240
            TabIndex        =   61
            Top             =   360
            Width           =   3735
            _ExtentX        =   6588
            _ExtentY        =   2990
            _Version        =   393216
            FixedCols       =   0
            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.CommandButton Btn_Salir 
         Caption         =   "Salir"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   10800
         Picture         =   "Form_BoletasMasivo.frx":2AB32
         Style           =   1  'Graphical
         TabIndex        =   25
         Top             =   2760
         Width           =   1215
      End
      Begin ProgBarProzent.ProgBar ProgBar_Boletas 
         Height          =   375
         Left            =   120
         TabIndex        =   11
         Top             =   4320
         Width           =   12255
         _ExtentX        =   21616
         _ExtentY        =   661
      End
      Begin VB.Frame Frame_Totales 
         Caption         =   "Totales"
         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            =   120
         TabIndex        =   1
         Top             =   2640
         Width           =   3015
         Begin VB.TextBox Txt_Monto_Detalle 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1560
            Locked          =   -1  'True
            TabIndex        =   53
            Top             =   720
            Width           =   1215
         End
         Begin VB.TextBox txt_tot_boletas 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1560
            Locked          =   -1  'True
            TabIndex        =   3
            Top             =   360
            Width           =   1215
         End
         Begin VB.TextBox txt_tot_pesos 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1560
            Locked          =   -1  'True
            TabIndex        =   2
            Top             =   1080
            Width           =   1215
         End
         Begin VB.Label Label20 
            Caption         =   "Total Recaudado"
            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           =   1335
         End
         Begin VB.Label Label7 
            Caption         =   "Nº Boletas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   5
            Top             =   360
            Width           =   1335
         End
         Begin VB.Label Label8 
            Caption         =   "Total Detalles"
            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        =   4
            Top             =   720
            Width           =   1335
         End
      End
      Begin VB.Frame Frame_Imp_Agrega 
         ForeColor       =   &H00FF0000&
         Height          =   1575
         Left            =   3240
         TabIndex        =   10
         Top             =   2640
         Width           =   7215
         Begin VB.TextBox Txt_TextoLog 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   3480
            TabIndex        =   58
            Top             =   240
            Visible         =   0   'False
            Width           =   1575
         End
         Begin VB.Frame Frame1 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   975
            Left            =   5160
            TabIndex        =   23
            Top             =   480
            Width           =   1935
            Begin VB.Label Lbl_Ult_Fola 
               Alignment       =   2  'Center
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   12
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H00C00000&
               Height          =   375
               Left            =   120
               TabIndex        =   24
               Top             =   360
               Width           =   1695
            End
         End
         Begin VB.CommandButton Btn_Ver_Libro 
            Caption         =   "Ver 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            =   1800
            TabIndex        =   20
            Top             =   1080
            Visible         =   0   'False
            Width           =   1575
         End
         Begin VB.CommandButton Btn_Imprimir 
            Caption         =   "Imprimir"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   3480
            TabIndex        =   17
            Top             =   600
            Width           =   1575
         End
         Begin VB.TextBox Txt_Folio 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Index           =   1
            Left            =   240
            Locked          =   -1  'True
            TabIndex        =   14
            Top             =   1080
            Width           =   1215
         End
         Begin VB.TextBox Txt_Folio 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Index           =   0
            Left            =   240
            Locked          =   -1  'True
            TabIndex        =   13
            Top             =   480
            Width           =   1215
         End
         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            =   3480
            TabIndex        =   12
            Top             =   1080
            Width           =   1575
         End
         Begin MSComCtl2.DTPicker DTP_Fec_Emision 
            Height          =   405
            Left            =   1800
            TabIndex        =   18
            Top             =   600
            Width           =   1575
            _ExtentX        =   2778
            _ExtentY        =   714
            _Version        =   393216
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Format          =   51773441
            CurrentDate     =   38105
         End
         Begin VB.Label Label15 
            Alignment       =   2  'Center
            Caption         =   "Último Folio agregado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   5160
            TabIndex        =   22
            Top             =   240
            Width           =   1935
         End
         Begin VB.Label Label10 
            Alignment       =   2  'Center
            Caption         =   "Fecha de Emisión"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   1750
            TabIndex        =   19
            Top             =   240
            Width           =   1575
         End
         Begin VB.Label Label3 
            Caption         =   "Folio Inicial"
            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        =   16
            Top             =   240
            Width           =   1095
         End
         Begin VB.Label Label4 
            Caption         =   "Folio Final"
            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        =   15
            Top             =   840
            Width           =   975
         End
      End
      Begin VB.Frame Frame_Tipo_Folio 
         Caption         =   "Rango de 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          =   1815
         Left            =   4080
         TabIndex        =   6
         Top             =   360
         Width           =   3015
         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            =   960
            TabIndex        =   21
            Top             =   1200
            Width           =   1215
         End
         Begin VB.CommandButton Btn_Folio_Sel 
            Caption         =   "Folio Final"
            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            =   1560
            TabIndex        =   8
            Top             =   720
            Width           =   1215
         End
         Begin VB.CommandButton Btn_Folio_Sel 
            Caption         =   "Folio Inicial"
            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            =   240
            TabIndex        =   7
            Top             =   720
            Width           =   1215
         End
         Begin VB.Label lbl_boleta 
            Alignment       =   2  'Center
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   12
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   240
            TabIndex        =   9
            Top             =   240
            Width           =   2535
         End
      End
      Begin MSHierarchicalFlexGridLib.MSHFlexGrid Grd_pagos_bci 
         Height          =   2295
         Left            =   120
         TabIndex        =   59
         Top             =   240
         Width           =   12255
         _ExtentX        =   21616
         _ExtentY        =   4048
         _Version        =   393216
         BackColorSel    =   12640511
         ForeColorSel    =   16711680
         FocusRect       =   2
         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
   End
End
Attribute VB_Name = "Form_BoletasMasivo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Anulacion As Boolean, AnhoCmb As String
Dim CodConvBci As String, Grupo() As String
Dim CodPart As String, TipoAlu As String
Dim HerBos As Integer, ArrayCol As Integer
Dim HerMM As Integer
Dim BolSel As String
Dim APagos_Bci() As String, Registros As Long
Dim Ultimofolio As String, Fila As Long, FilaBol As Long, Filaini As Long, Filafin As Long
Dim FilaDif As Long
Dim mes As String ' el numero de mes seleccionado
Dim Conectant  As Boolean
'***********************************************
Dim Particular As Boolean, ProcPago As String, AProcpago(2) As String, TipoPago As String
Dim AColegios(), APartic(), CodEmpresa As String
Public NomEmpresa As String
Dim IndAColegios As Long, IndAPartic As Integer
Dim Abancos() As Variant, CodBanco As String
Dim TotMonto3 As Long, TotMonto4 As Long, TotMonto5 As Long, TotMonto6 As Long
Dim Totdesglose As Long

Function CorrijeRut(Rutactual As String, Rutnuevo As String) As Boolean
Dim Corrija As Boolean
Corrija = True
If ExistReg("apoderados", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("apo_x_alu", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("cup_x_apo", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("bol_apo_x_alu", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("anualidad_x_apo", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("aux_let_emi", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("aux_men_apo_x_alu", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("cheques_x_apo", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("devoluciones", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("pagos", "rut_apo = '" & Rutnuevo & "'", conn) Or _
    ExistReg("cuotas_x_alu", "rut_apo = '" & Rutnuevo & "'", conn) Then
    Corrija = True

End If
If Corrija Then
    conn.Execute "update apoderados set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update apo_x_alu  set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update cup_x_apo set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update bol_apo_x_alu set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update anualidad_x_apo set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update aux_let_emi set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update aux_men_apo_x_alu set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update cheques_x_apo set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update devoluciones set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update pagos set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    conn.Execute "update cuotas_x_alu set rut_apo = '" & Rutnuevo & "' where rut_apo ='" & Rutactual & "'"
    
    CorrijeRut = True
Else
    CorrijeRut = False
End If
End Function
Sub IniciaGrilla()
Me.Grd_pagos_bci.Cols = 26
Me.Grd_pagos_bci.Rows = 2
Me.Grd_pagos_bci.FixedCols = 2
Me.Grd_pagos_bci.Clear
Me.Grd_pagos_bci.MergeCells = flexMergeRestrictColumns
Me.Grd_pagos_bci.MergeCol(0) = True
Me.Grd_pagos_bci.MergeCol(1) = True
Me.Grd_pagos_bci.MergeCol(2) = False
Me.Grd_pagos_bci.MergeCol(3) = False
Me.Grd_pagos_bci.MergeCol(4) = False
Me.Grd_pagos_bci.MergeCol(5) = False
Me.Grd_pagos_bci.MergeCol(6) = False
Me.Grd_pagos_bci.MergeCol(7) = False
Me.Grd_pagos_bci.MergeCol(8) = False
Me.Grd_pagos_bci.MergeCol(9) = False
Me.Grd_pagos_bci.MergeCol(10) = False
Me.Grd_pagos_bci.MergeCol(11) = False
Me.Grd_pagos_bci.MergeCol(12) = False
Me.Grd_pagos_bci.MergeCol(13) = False
Me.Grd_pagos_bci.MergeCol(14) = False
Me.Grd_pagos_bci.MergeCol(15) = False
Me.Grd_pagos_bci.MergeCol(16) = False
Me.Grd_pagos_bci.MergeCol(17) = False
Me.Grd_pagos_bci.MergeCol(18) = False
Me.Grd_pagos_bci.MergeCol(19) = False
Me.Grd_pagos_bci.MergeCol(20) = False
Me.Grd_pagos_bci.MergeCol(21) = False
Me.Grd_pagos_bci.MergeCol(22) = False
Me.Grd_pagos_bci.MergeCol(23) = False
Me.Grd_pagos_bci.MergeCol(24) = False '  0             1                  2           3           4                      5            6           7               8               9         10         11           12         13           14    15       16        17         18     19    20         21            22            23          24
Me.Grd_pagos_bci.MergeCol(25) = False
Me.Grd_pagos_bci.FormatString = " Rut apoderado |Nombre Apoderado  |Mensualidad |Excención   | Total x Alumno  | Total x Grupo  |^ Nº Boleta   |Pagado   |Nombre Alumnos        |Curso  |Fecha Venc.|Fecha Recaud.|Rut Alumno|AVANCEGRUPO     |NULA |CAB_BOL |NUM_CUP |CONVENIO|COLEGIO|CODENS|NIVEL|Folio Detalle|Folio Cuponera|Folio Cupon|Valor Cupon"
Me.Grd_pagos_bci.ColWidth(0) = 1000
Me.Grd_pagos_bci.ColWidth(1) = 3000
Me.Grd_pagos_bci.ColWidth(2) = 1000 ' estara oculta ya que no se tomará en cuenta aun
Me.Grd_pagos_bci.ColWidth(3) = 1000
Me.Grd_pagos_bci.ColWidth(4) = 1000
Me.Grd_pagos_bci.ColWidth(5) = 1000
Me.Grd_pagos_bci.ColWidth(6) = 1000
Me.Grd_pagos_bci.ColWidth(7) = 1000
Me.Grd_pagos_bci.ColWidth(8) = 3500
Me.Grd_pagos_bci.ColWidth(9) = 1000
Me.Grd_pagos_bci.ColWidth(10) = 1000
Me.Grd_pagos_bci.ColWidth(11) = 1000
Me.Grd_pagos_bci.ColWidth(12) = 1000
Me.Grd_pagos_bci.ColWidth(13) = 1000 '0 ' AVANCE DE GRUPO
Me.Grd_pagos_bci.ColWidth(14) = 1000 '0
Me.Grd_pagos_bci.ColWidth(15) = 1000 '0
Me.Grd_pagos_bci.ColWidth(16) = 1000 '0
Me.Grd_pagos_bci.ColWidth(17) = 1000 '0
Me.Grd_pagos_bci.ColWidth(18) = 1000 '0
Me.Grd_pagos_bci.ColWidth(19) = 1000 '0
Me.Grd_pagos_bci.ColWidth(20) = 1000 '0
Me.Grd_pagos_bci.ColWidth(21) = 1000
Me.Grd_pagos_bci.ColWidth(22) = 1000
Me.Grd_pagos_bci.ColWidth(23) = 1000
Me.Grd_pagos_bci.ColWidth(24) = 1000
Me.Grd_pagos_bci.ColWidth(25) = 1000
Me.lbl_conexion_ext.Caption = ""
Me.lst_Tareas.Clear
End Sub

Sub Desglosa()
Dim TotalPesos As Long, TotalPesosDif As Long, TotalDetalle As Long, NoExiste As Boolean
Dim AgnoEscol As Long, MesEscol As Long, ADetAlu As Variant, NConceptos As Integer
Dim TieneDetalle As Boolean, Cuponera As Variant, TieneDetalle2004 As Boolean
Dim ValorxGrupo As Long, ValorxGrupo2004 As Long, MesEscol2004 As Integer
Dim ImpriFolio As Boolean, BolaEmitir As Integer, ImpriFolio2004 As Boolean
Ultimofolio = val(Me.Txt_Folio_Disp)
Ultimofolio = InputBox("Confirmación de Folio", "Confirmación de Folio", Ultimofolio)
Abarra = 0
Me.ProgBar_Boletas.ShowProgress Abarra
Me.ProgBar_Boletas.MaxValue = Registros - 1
Me.ProgBar_Boletas.Zusatztext = "% Procesado"
'Me.Txt_Folio(0) = FillconStr(Val(UltimoFolio) + 1, 8, "0", "IZQ")
'Me.Txt_Folio(0).Refresh
Fila = 0: FilaDif = 0
TotalPesos = 0: TotalPesosDif = 0: TotalDetalle = 0: BolaEmitir = 0
TotMonto3 = 0: TotMonto4 = 0: TotMonto5 = 0: TotMonto6 = 0: Totdesglose = 0
If Registros > 0 Then
    Ultimofolio = val(Ultimofolio) - 1
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    Me.Grd_pagos_bci.Enabled = False
    For t = 0 To Registros - 1
        'If APagos_Bci(t, 0) = "08942158-6" Then MsgBox APagos_Bci(t, 0)
        ValorxGrupo = 0
        ' Traigo alumnos del apoderado según fnza_detalle_mensualidad
        If Len(APagos_Bci(t, 1)) > 4 Then
            'AgnoEscol = CLng(Right(APagos_Bci(t, 1), 4))
            AgnoEscol = CLng(Mid(APagos_Bci(t, 1), 1, 4))
        Else
            AgnoEscol = CLng(APagos_Bci(t, 1))
        End If
        'If AgnoEscol = 2008 Then MsgBox "STOP!!"
        'Si fecha vencimiento corresponde a diciembre, Mes es Febrero
        
        If (AgnoEscol >= 2005) Then
            If CDate(APagos_Bci(t, 4)) = CDate("2022-12-05") Then
                MesEscol = 2
            Else
                MesEscol = Month(CDate(APagos_Bci(t, 4)))
            End If
            Set RsAux = New ADODB.Recordset
            RsAux.CursorLocation = adUseClient
            'rsaux.Open "SELECT distinct fdm.run_alu, concat(a.noms_apo, ' ' , a.ape1_apo, ' ' , a.ape2_apo) as nomapo, concat(p.nom_alu, ' ' , p.ape_pat_alu, ' ' , p.ape_mat_alu) as nomalu FROM fnza_mensualidad fm, fnza_detalle_mensualidad fdm, apoderados a, postulantes p where fm.folio_mens=fdm.folio_mens and fm.colegio=fdm.colegio and fdm.run_alu=p.ci_alu and fm.run_apo=a.rut_apo and fm.run_apo='" & APagos_Bci(t, 0) & "' and fm.agno =" & AgnoEscol & " and fm.mes = " & MesEscol & " and fdm.colegio ='" & CodEmpresa & "'", conn
            '
             'If APagos_Bci(t, 0) = "10792983-5" Then MsgBox ("aqui")
             '
'            If APagos_Bci(t, 0) = "15344915-5" Then
'                 a = "15344915-5"
'            End If
            RsAux.Open "SELECT distinct fdm.run_alu, concat(a.noms_apo, ' ' , a.ape1_apo, ' ' , a.ape2_apo) as nomapo, concat(p.nom_alu, ' ' , p.ape_pat_alu, ' ' , p.ape_mat_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='" & APagos_Bci(t, 0) & "' and fm.agno =" & AgnoEscol & " and ac.agno=(fm.agno - " & IIf((MesEscol = 2), 1, 0) & " ) and fm.mes = " & MesEscol & " and fdm.colegio ='" & APagos_Bci(t, 8) & "'", conn
            
            If RsAux.RecordCount > 0 Then
                RsAux.MoveFirst
                TieneDetalle = True
                For te = 0 To RsAux.RecordCount - 1
                    TieneDetalle = False
                    ADetAlu = DtllMesAlu(RsAux!run_alu, APagos_Bci(t, 8), CInt(MesEscol), CInt(AgnoEscol), conn)
                    If Not IsNull(ADetAlu(1, 1)) Then
                        NConceptos = UBound(ADetAlu, 2) ' Esto indica cantidad de conceptos
                        For I = 1 To NConceptos
                        ' Si detalle está impago agregar a grilla
                            If dtll_impago(ADetAlu(1, I), conn) Then
                                Ultimofolio = val(Ultimofolio) + 1
                                BolaEmitir = BolaEmitir + 1
                                ImpriFolio = True
                            Else
                                ImpriFolio = False
                            End If
                                Me.Grd_pagos_bci.AddItem ""
                                Fila = Fila + 1
                                Me.Grd_pagos_bci.TextMatrix(Fila, 0) = APagos_Bci(t, 0) ' rut apo
                                Me.Grd_pagos_bci.TextMatrix(Fila, 1) = RsAux!NomApo ' "Nombre del apoderado" 'Rs!noms_apo & " " & Rs!ape1_apo & " " & Rs!ape2_apo ' nombre apo
                                Me.Grd_pagos_bci.TextMatrix(Fila, 2) = ADetAlu(4, I) ' Total Concepto
                                Me.Grd_pagos_bci.TextMatrix(Fila, 3) = ADetAlu(5, I) + ADetAlu(6, I) + ADetAlu(7, 1) + ADetAlu(8, I) ' Total Excención
                                Me.Grd_pagos_bci.TextMatrix(Fila, 25) = ADetAlu(6, I)
                                Me.Grd_pagos_bci.TextMatrix(Fila, 4) = ADetAlu(9, I)
                                ValorxGrupo = ValorxGrupo + CLng(Me.Grd_pagos_bci.TextMatrix(Fila, 4))
                                If Not ImpriFolio Then
                                    Me.Grd_pagos_bci.Col = 6: Me.Grd_pagos_bci.Row = Fila
                                    Me.Grd_pagos_bci.CellBackColor = &HC0FFC0
                                Else
                                    Me.Grd_pagos_bci.Col = 6: Me.Grd_pagos_bci.Row = Fila
                                    Me.Grd_pagos_bci.CellBackColor = &HFFFFFF
                                End If
                                Me.Grd_pagos_bci.TextMatrix(Fila, 6) = IIf(ImpriFolio, FillconStr(val(Ultimofolio), 8, "0", "IZQ"), "Cancelada")
                                Me.Grd_pagos_bci.TextMatrix(Fila, 8) = RsAux!NomAlu '"Nombre del alumno"
                                '************************************************************************
                                'Esto pasar a una función que traiga el curso separado por
                                'cod_ens, num_gra, let_cur, cod_des
                                'si no existe curso traer el nivel y cod_des donde está matriculado.
                                Set rsConCurso = New ADODB.Recordset
                                rsConCurso.CursorLocation = adUseClient
                                rsConCurso.Open "select a.num_gra, a.let_cur, a.cod_ens, c.cod_des from alu_x_cur a, codigos_ensenanza c where a.cod_ens=c.cod_ens and a.fec_cam = '1111-11-11' and a.ci_alu='" & RsAux!run_alu & "' order by c.ord_ens DESC limit 1", conn
                                If rsConCurso.RecordCount > 0 Then
                                    If UCase(rsConCurso!cod_des) = "K" Or UCase(rsConCurso!cod_des) = "PK" Then
                                        curso = "K" & "º" & UCase(rsConCurso!Let_Cur)
                                    ElseIf UCase(rsConCurso!cod_des) = "EB" Or UCase(rsConCurso!cod_des) = "EM" Then
                                        curso = UCase(rsConCurso!Num_Gra) & "º" & UCase(rsConCurso!Let_Cur) & " " & UCase(rsConCurso!cod_des)
                                    End If
                                Else
                                    curso = ""
                                End If
                                rsConCurso.Close: Set rsConCurso = Nothing
                                '**************************************************************************
                                Me.Grd_pagos_bci.TextMatrix(Fila, 9) = curso ' curso
                                Me.Grd_pagos_bci.TextMatrix(Fila, 10) = ADetAlu(3, I) ' Fecha Vencimiento del detalle
                                Me.Grd_pagos_bci.TextMatrix(Fila, 11) = APagos_Bci(t, 3) ' Fecha del pago
                                Me.Grd_pagos_bci.TextMatrix(Fila, 12) = RsAux!run_alu
                                'Me.Grd_Pagos_BCI.TextMatrix(Fila, 13) => AVANCE DE GRUPO
                                Me.Grd_pagos_bci.TextMatrix(Fila, 14) = "0"
                                Me.Grd_pagos_bci.TextMatrix(Fila, 15) = AgnoEscol ' CABECERA y AÑO DE PROCESO
                                Me.Grd_pagos_bci.TextMatrix(Fila, 16) = APagos_Bci(t, 2) ' Nº CUPÓN
                                Me.Grd_pagos_bci.TextMatrix(Fila, 17) = APagos_Bci(t, 7) ' CONVENIO
                                Me.Grd_pagos_bci.TextMatrix(Fila, 18) = APagos_Bci(t, 8)
                                Me.Grd_pagos_bci.TextMatrix(Fila, 19) = "" 'vendrá de la función curso
                                Me.Grd_pagos_bci.TextMatrix(Fila, 20) = "" 'vendrá de la función curso
                                Me.Grd_pagos_bci.TextMatrix(Fila, 21) = ADetAlu(1, I)
                                Me.Grd_pagos_bci.Refresh
                                TieneDetalle = True
                            'Else
                            '    info = "Detalle con el folio interno " & Me.Grd_Pagos_BCI.TextMatrix(Fila, 21) & " Rut Apoderado" & APagos_Bci(t, 0) & " Rut Alumno " & rsaux!run_alu & " Se encuentra cancelado"
                            '    Call Log_AddAnotacion(info, True)
                           
                        Next I
                    End If
                    RsAux.MoveNext
                Next te
                If TieneDetalle Then
                    Me.Grd_pagos_bci.TextMatrix(Fila, 5) = ValorxGrupo
                    Me.Grd_pagos_bci.TextMatrix(Fila, 7) = APagos_Bci(t, 5)
                    If val(Me.Grd_pagos_bci.TextMatrix(Fila, 5)) <> val(Me.Grd_pagos_bci.TextMatrix(Fila, 7)) Then
                        Me.Grd_pagos_bci.Col = 5: Me.Grd_pagos_bci.Row = Fila: Me.Grd_pagos_bci.CellBackColor = &HC0C0FF
                        Me.Grd_pagos_bci.Col = 6: Me.Grd_pagos_bci.Row = Fila: Me.Grd_pagos_bci.CellBackColor = &HC0C0FF
                        Me.Grd_pagos_bci.Col = 7: Me.Grd_pagos_bci.Row = Fila: Me.Grd_pagos_bci.CellBackColor = &HC0C0FF
                        info = "Rut Apoderado " & APagos_Bci(t, 0) & " Diferencias en la Mensualidad Suma detalles " & Me.Grd_pagos_bci.TextMatrix(Fila, 5) & " Año " & AgnoEscol & " Mes " & MesEscol & " Monto Cupón " & Me.Grd_pagos_bci.TextMatrix(Fila, 16) & " Banco " & Me.Grd_pagos_bci.TextMatrix(Fila, 7)
                        Me.Txt_TextoLog.Text = Me.Txt_TextoLog.Text & vbCrLf & info
                        Call Log_AddAnotacion(info, True)
                    End If
                    Cuponera = TraeCupon(APagos_Bci(t, 0), APagos_Bci(t, 8), AgnoEscol, MesEscol, CodBanco, conn)
                    If Not IsNull(Cuponera(1)) Then
                        Me.Grd_pagos_bci.TextMatrix(Fila, 22) = Cuponera(1)
                        Me.Grd_pagos_bci.TextMatrix(Fila, 23) = Cuponera(3)
                        Me.Grd_pagos_bci.TextMatrix(Fila, 24) = Cuponera(7)
                        If val(Me.Grd_pagos_bci.TextMatrix(Fila, 7)) <> val(Me.Grd_pagos_bci.TextMatrix(Fila, 24)) Then
                            info = "Rut Apoderado: " & APagos_Bci(t, 0) & " Diferencias en Valor Cupón " & AgnoEscol & " Mes " & MesEscol & " Valor Sistema " & Me.Grd_pagos_bci.TextMatrix(Fila, 24) & " Valor Banco " & Me.Grd_pagos_bci.TextMatrix(Fila, 7)
                            Me.Txt_TextoLog.Text = Me.Txt_TextoLog.Text & vbCrLf & info
                            Call Log_AddAnotacion(info, True)
                        End If
                    Else
                        If MesEscol <> 2 Then
                            info = "Rut apoderado : " & APagos_Bci(t, 0) & " No se encuentra Cupon en Sistema Año " & AgnoEscol & " Mes " & MesEscol
                            Me.Txt_TextoLog.Text = Me.Txt_TextoLog.Text & vbCrLf & info
                            Call Log_AddAnotacion(info, True)
                        End If
                    End If
                End If
                TotalPesos = TotalPesos + val(Me.Grd_pagos_bci.TextMatrix(Fila, 7))
                TotalDetalle = TotalDetalle + val(Me.Grd_pagos_bci.TextMatrix(Fila, 5))
                Me.txt_tot_boletas = BolaEmitir
                Me.Txt_Monto_Detalle = TotalDetalle
                Me.txt_tot_pesos = TotalPesos
            Else
                If Not ExistReg("apoderados", "rut_apo='" & APagos_Bci(t, 0) & "'", conn) Then
                    info = "Rut Apoderado " & APagos_Bci(t, 0) & " : No se encontró para el mes " & MesEscol & " en año " & AgnoEscol
                Else
                    info = "Rut Apoderado " & APagos_Bci(t, 0) & " No se encontró Detalle de la Mensualidad para el mes " & MesEscol & " año " & AgnoEscol
                End If
                Me.Txt_TextoLog.Text = Me.Txt_TextoLog.Text & vbCrLf & info
                Call Log_AddAnotacion(info, True)
            End If
            RsAux.Close: Set RsAux = Nothing
        ElseIf AgnoEscol = 2004 Then
            ' Si mensualidad que paga corresponde al 2004
            MesEscol2004 = Month(CDate(APagos_Bci(t, 4)))
            Grupo = TraeMenAgrup(CodConvBci, APagos_Bci(t, 0), Month(CDate(APagos_Bci(t, 4))), TipoAlu, False)
            Hijos = val(Grupo(0, 0))
            If Hijos > 0 Then
                ValorxGrupo2004 = 0
                For te = 0 To Hijos - 1
                    TieneDetalle2004 = False
                    ' Preguntar si cuota Impaga
                    If Cuotaimpaga(Grupo(te, 2), Month((CDate(APagos_Bci(t, 4)))), val(Grupo(te, 3)), conn) Then
                        Ultimofolio = val(Ultimofolio) + 1
                        BolaEmitir = BolaEmitir + 1
                        ImpriFolio2004 = True
                    Else
                        ImpriFolio2004 = False
                    End If
                        
                        Me.Grd_pagos_bci.AddItem ""
                        Fila = Fila + 1
                        'HijosSinBol = HijosSinBol + 1
                        Me.Grd_pagos_bci.TextMatrix(Fila, 0) = Grupo(te, 6) ' rut apo
                        Me.Grd_pagos_bci.TextMatrix(Fila, 1) = Grupo(te, 7) ' nombre apo
                        Me.Grd_pagos_bci.TextMatrix(Fila, 2) = Grupo(te, 10) ' mensualidad
                        Me.Grd_pagos_bci.TextMatrix(Fila, 3) = Grupo(te, 4) ' excencion
                        Me.Grd_pagos_bci.TextMatrix(Fila, 4) = Grupo(te, 3) ' a pagar alumno
                        ValorxGrupo2004 = ValorxGrupo2004 + CLng(Me.Grd_pagos_bci.TextMatrix(Fila, 4))
                        If Not ImpriFolio2004 Then
                            Me.Grd_pagos_bci.Col = 6: Me.Grd_pagos_bci.Row = Fila
                            Me.Grd_pagos_bci.CellBackColor = &HC0FFC0
                        Else
                            Me.Grd_pagos_bci.Col = 6: Me.Grd_pagos_bci.Row = Fila
                            Me.Grd_pagos_bci.CellBackColor = &HFFFFFF
                        End If
                        Me.Grd_pagos_bci.TextMatrix(Fila, 6) = IIf(ImpriFolio2004, FillconStr(val(Ultimofolio), 8, "0", "IZQ"), "Cancelada")
                        Me.Grd_pagos_bci.TextMatrix(Fila, 8) = Grupo(te, 8) ' nombre alu
                        Me.Grd_pagos_bci.TextMatrix(Fila, 9) = Grupo(te, 9) ' curso
                        Me.Grd_pagos_bci.TextMatrix(Fila, 10) = APagos_Bci(t, 4)
                        Me.Grd_pagos_bci.TextMatrix(Fila, 11) = APagos_Bci(t, 3)
                        Me.Grd_pagos_bci.TextMatrix(Fila, 12) = Grupo(te, 2)
                        'Me.Grd_Pagos_BCI.TextMatrix(Fila, 13) => AVANCE DE GRUPO
                        Me.Grd_pagos_bci.TextMatrix(Fila, 14) = "0"
                        Me.Grd_pagos_bci.TextMatrix(Fila, 15) = Year(APagos_Bci(t, 4)) ' CABECERA
                        Me.Grd_pagos_bci.TextMatrix(Fila, 16) = APagos_Bci(t, 2) ' Nº CUPÓN
                        Me.Grd_pagos_bci.TextMatrix(Fila, 17) = APagos_Bci(t, 7) ' CONVENIO
                        Me.Grd_pagos_bci.Refresh
                        TieneDetalle2004 = True
                    'Else
                    '    NoExiste = False
                    'End If
                Next te
            Else
                'If Not valorenlista(Lst_Rut_Erroneos, APagos_Bci(t, 0)) Then
                '    Me.Frame_Rut_Erroneos.Visible = True
                '    Me.Lst_Rut_Erroneos.AddItem APagos_Bci(t, 0)
                'End If
            End If
                If TieneDetalle2004 Then
                    Me.Grd_pagos_bci.TextMatrix(Fila, 5) = ValorxGrupo2004
                    Me.Grd_pagos_bci.TextMatrix(Fila, 7) = APagos_Bci(t, 5)
                    If val(Me.Grd_pagos_bci.TextMatrix(Fila, 5)) <> val(Me.Grd_pagos_bci.TextMatrix(Fila, 7)) Then
                        Me.Grd_pagos_bci.Col = 5: Me.Grd_pagos_bci.Row = Fila: Me.Grd_pagos_bci.CellBackColor = &HC0C0FF
                        Me.Grd_pagos_bci.Col = 6: Me.Grd_pagos_bci.Row = Fila: Me.Grd_pagos_bci.CellBackColor = &HC0C0FF
                        Me.Grd_pagos_bci.Col = 7: Me.Grd_pagos_bci.Row = Fila: Me.Grd_pagos_bci.CellBackColor = &HC0C0FF
                        info = "Rut Apoderado " & APagos_Bci(t, 0) & " Diferencias en la Mensualidad Suma detalles 2004 " & Me.Grd_pagos_bci.TextMatrix(Fila, 5) & " Año " & AgnoEscol & " Mes " & MesEscol
                        Me.Txt_TextoLog.Text = Me.Txt_TextoLog.Text & vbCrLf & info
                        Call Log_AddAnotacion(info, True)
                    End If
                    Else
                End If
                TotalPesos = TotalPesos + val(Me.Grd_pagos_bci.TextMatrix(Fila, 7))
                TotalDetalle = TotalDetalle + val(Me.Grd_pagos_bci.TextMatrix(Fila, 5))
                Me.txt_tot_boletas = BolaEmitir
                Me.Txt_Monto_Detalle = TotalDetalle
                Me.txt_tot_pesos = TotalPesos
        End If
        Me.ProgBar_Boletas.ShowProgress t
        DoEvents
    Next t
    Me.Grd_pagos_bci.Enabled = True
    If Trim(Me.Txt_TextoLog.Text) <> "" Then
        Form_BoletasMasivo_Dialog.Txt_Sucesos = Me.Txt_TextoLog
    End If
End If

'If FilaDif > 0 Then
'MsgBox ("Se han encontrado Diferencias en las mensualidades")
'End If
Set rs = Nothing
End Sub
Sub TraeInfo()
Dim fechas As String
'Dim aggno As Integer
Dim mess As Integer
Dim colegio As String
Dim cole As String
Dim EstadoCupon As String
Dim var_sql As String
Dim rs As ADODB.Recordset
'Dim R As ADODB.Recordset

'Dim FechaAl As Date, FechaDel As Date
    Set rs = New ADODB.Recordset
    'Set objRS = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    Me.lst_Tareas.AddItem "Transfiriendo Información de Pagos"
    Me.lst_Tareas.Refresh
    FechaDel = InvierteFecha(CDate(AnhoCmb & "/" & mes & "/" & Me.Cmb_del_dia.Text), "R")
    FechaAl = InvierteFecha(CDate(AnhoCmb & "/" & mes & "/" & Me.Cmb_al_dia.Text), "R")
    'Tabla para guardar envios a cobranza desfazados.
    conn.Execute "CREATE TABLE IF NOT EXISTS fnza_elimina_cobranza (rut_apo varchar(10) NOT NULL default '', cab_bol varchar(100) NOT NULL default '', num_cup varchar(100) NOT NULL default '', fech_ven date NOT NULL default '0000-00-00', monto bigint(20) NOT NULL default '0', estado varchar(100) NOT NULL default '', PRIMARY KEY  (rut_apo,cab_bol,num_cup,fech_ven)) ENGINE=MyISAM;"
    
    Select Case Me.Cmb_TipoPago.ListIndex
        Case 0
            'Procedencia = "2"
            'AQUI SE DEBE HACER LA MAGIA PARA DISTINGUIR ENTRE BCI Y RECAUDA.
            Orden = "fech_rec,rut_cli,fech_ven;"
            'corrección de valores pagos miss marta por error de banco.
            ConnExt.Execute "UPDATE pagos_bci SET cab_bol='" & Trim(RetornaCampo("CFG", "valor", "param='CodConvBCIBC'", conn)) & "2007' where cab_bol='" & Trim(RetornaCampo("CFG", "valor", "param='CodConvBCIBC'", conn)) & "200';"
            If Not Particular Then
            '                        0     1        2        3         4         5       6          7       8
                rs.Open "select rut_cli, cab_bol, num_cup, fech_rec, fech_ven, monto, monto_tot, convenio, origen from pagos_bci where fech_rec >= '" & FechaDel & "' and fech_rec <= '" & FechaAl & "' and convenio = " & CLng(Me.Txt_CodConvBci) & " order by " & Orden, ConnExt
            Else
                rs.Open "select rut_cli, cab_bol, num_cup, fech_rec, fech_ven, monto, monto_tot, convenio, origen from pagos_bci where fech_rec >= '" & FechaDel & "' and fech_rec <= '" & FechaAl & "' and convenio = '" & CLng(Me.Txt_CodConvBci_Part) & "' and left(cab_bol,3) = '" & RetornaCampo("CFG", "valor", "param='CodConvBCIBC'", conn) & "' order by " & Orden, ConnExt
            End If
            
        Case 1 ' si seleccionó pac
            'Procedencia = "3"
                Orden = "fech_rec,rut_cli,fech_ven"
            If CodPart = "" Then
            '                       0         1        2        3     4          5
                rs.Open "select rut_cli, fech_rec, convenio, monto, estado, mes_abonado from pagos_pac where fech_rec >= '" & FechaDel & "' and fech_rec <= '" & FechaAl & "' and convenio = '" & CLng(Me.Txt_Cod_Pac) & "' and estado = '021' order by " & Orden, ConnExt
            'Else
            '    rs.Open "select rut_cli, cab_bol, num_cup, fech_rec, fech_ven, monto, monto_tot, convenio from pagos_bci where month(fech_rec)= '" & Mes & "' and convenio = '" & CLng(CodPart) & "' and left(cab_bol,3) = '" & CodConvenio & "' order by " & Orden, ConnExt
            End If
    End Select
    
    Registros = 0
    If rs.RecordCount > 0 Then
        Registros = rs.RecordCount
        ' ****************************
        ' creación reporte de descarga
        Dim QRY As String
        Dim CMD As ADODB.Command
        Set CMD = New ADODB.Command
        CMD.ActiveConnection = conn
        CMD.CommandType = adCmdText
        QRY = "DROP TABLE IF EXISTS fnza_pagos_banco_temp;"
        CMD.CommandText = QRY
        CMD.Execute
        QRY = "CREATE TABLE IF NOT EXISTS fnza_pagos_banco_temp " & _
                "(" & _
                "rut_cli varchar(10) NOT NULL default '', " & _
                "cab_bol bigint(20) NOT NULL default '0', " & _
                "num_cup varchar(100) NOT NULL default '', " & _
                "fech_rec date NOT NULL default '0000-00-00', " & _
                "fech_ven date NOT NULL default '0000-00-00', " & _
                "monto varchar(100) NOT NULL default '', " & _
                "monto_tot varchar(100) NOT NULL default '', " & _
                "convenio varchar(100) NOT NULL default '', " & _
                "colegio varchar(100) NOT NULL default '', " & _
                "PRIMARY KEY  (rut_cli,cab_bol,num_cup,fech_ven,convenio), " & _
                "UNIQUE KEY unique_index_fnza_temp_pagos_banco (rut_cli,cab_bol,num_cup,fech_ven,convenio) " & _
                ") ENGINE=MyISAM COLLATE latin1_spanish_ci;"
        CMD.CommandText = QRY
        CMD.Execute
        ' fin creación reporte descarga
        ' *****************************
        Abarra = 0
        Me.ProgBar_Boletas.ShowProgress Abarra
        Me.ProgBar_Boletas.MaxValue = Registros - 1
        Me.ProgBar_Boletas.Zusatztext = "% Transferido"
        ReDim APagos_Bci(Registros, 8) ' paso a una matriz toda la informacion
        For t = 0 To Registros - 1
            ' *************************************
            ' Insertar registro en tabla de reporte
            
'            If rs("rut_cli") = "15344915-5" Then
'                a = "15344915-5"
'            End If
            
            If Particular = True Then
                cole = CODPK
            Else
                cole = CODBC
            End If
                        
'            objRS.Open var_sql, conn
            'If rs!cab_bol = 2008 Then MsgBox "OK, STOP"
            QRY = "REPLACE fnza_pagos_banco_temp(rut_cli,cab_bol,num_cup,fech_rec,fech_ven,monto,monto_tot,convenio,colegio) VALUES ('" & rs("rut_cli") & "','" & rs("cab_bol") & "','" & rs("num_cup") & "','" & Format(rs("fech_rec"), "yyyy-mm-dd") & "','" & Format(rs("fech_ven"), "yyyy-mm-dd") & "','" & rs("monto") & "','" & rs("monto_tot") & "','" & rs("convenio") & "','" & cole & "');"
            CMD.CommandText = QRY
            CMD.Execute
            
'            objRS.Close
            
            fechas = Format(rs("fech_ven"), "YYYY-mm-dd")
            If fechas = "2023-03-05" Then fechas = "2023-02-10"
'            aggno = Format(rs("fech_ven"), "YYYY")
'            mess = Format(rs("fech_ven"), "m")
            
'            var_sql = "SELECT *" _
'                    & " From fnza_mensualidad" _
'                    & " WHERE fech_venc = '" _
'                    & fecha & "' and run_apo = '" & rs("rut_cli") & "'"
'
'            var_sql = "SELECT *" _
'                    & " From fnza_mensualidad" _
'                    & " WHERE run_apo = '" & rs("rut_cli") & "' and agno = " _
'                    & aggno & " and mes = " & mess
            
'            var_sql = "SELECT *" _
'                    & " From fnza_mensualidad" _
'                    & " WHERE run_apo = '" & rs("rut_cli") _
'                    & "' and agno = " _
'                    & aggno
'
'            Set R = New ADODB.Recordset
'            R.Open var_sql, conn, adOpenDynamic, adLockOptimistic
'            If Not R.EOF Then
'            For i = 1 To 11
'                If R("monto_mens") = rs("monto") And R("fech_venc") = rs("fech_ven") Then
'                    colegio = R("colegio")
'                End If
'                R.MoveNext
'            Next i
'            End If
'            R.Close
            colegio = devuelve_colegio(rs("rut_cli"), fechas, rs("monto"))
                        
            ' Fin insertar registro en tabla reporte
            ' **************************************
            If Me.Cmb_TipoPago.ListIndex = 0 Then
                'cuponeras
                APagos_Bci(t, 0) = rs("rut_cli")
                APagos_Bci(t, 1) = rs("cab_bol")
                APagos_Bci(t, 2) = rs("num_cup")
                APagos_Bci(t, 3) = rs("fech_rec")
                APagos_Bci(t, 4) = rs("fech_ven")
                APagos_Bci(t, 5) = rs("monto")
                APagos_Bci(t, 6) = rs("monto_tot")
                APagos_Bci(t, 7) = rs("convenio")
                APagos_Bci(t, 8) = colegio
            Else
                ' pac
                APagos_Bci(t, 0) = rs("rut_cli")
                APagos_Bci(t, 1) = ""
                APagos_Bci(t, 2) = ""
                APagos_Bci(t, 3) = rs("fech_rec")
                APagos_Bci(t, 4) = rs("mes_abonado")
                APagos_Bci(t, 5) = rs("monto")
                APagos_Bci(t, 6) = ""
                APagos_Bci(t, 7) = rs("convenio")
                APagos_Bci(t, 8) = colegio
            End If
            'PROCESO QUE DISCRIMINA PAGOS EN BANCO ENVIADOS A COBRANZA.
            EstadoCupon = RetornaCampo("fnza_cuponeras as c, fnza_deta_cupones as d", "d.estado", "c.folio_cuponera=d.folio_cuponera and c.esta_fin='PE' and c.rut_apo='" & rs("rut_cli") & "' and d.vcto='" & Format(rs("fech_ven"), "yyyy-mm") & "-10' and numero='" & rs("cab_bol") & Format(rs("num_cup"), "00") & "'", conn)
            If EstadoCupon = "GC" And rs("origen") = "BCI" Then
                conn.Execute "INSERT INTO fnza_elimina_cobranza(rut_apo,cab_bol,num_cup,fech_ven,monto,estado) VALUES ('" & rs("rut_cli") & "', '" & rs("cab_bol") & Format(rs("num_cup"), "00") & "', '" & rs("num_cup") & "', '" & Format(rs("fech_ven"), "yyyy-mm-dd") & "', " & rs("monto") & ", 'eliminar') ON DUPLICATE KEY UPDATE rut_apo=rut_apo;"
            End If
            '----------------------------------------------------------
            rs.MoveNext
            Me.ProgBar_Boletas.ShowProgress t + 0
            DoEvents
        Next t
    End If
    rs.Close
    ConnExt.Close
    Me.lst_Tareas.AddItem Registros & " Pagos informados"
    Me.lst_Tareas.Refresh
    Me.lbl_conexion_ext.Caption = "Conexión con Servidor Remoto Cerrada"
    Me.lbl_conexion_ext.Refresh
    If Registros > 0 Then
        Call Desglosa
        Btn_Informe_pagos_banco.Enabled = True
    End If
End Sub

Private Sub Btn_Agregar_Click()
Dim accion_detalle As String
On Error GoTo Controlerror
If Option4.Value = True Then
    TipoPago = "cobr"
Else
    TipoPago = "depo"
End If
If (Len(Trim(Me.txt_folio(0))) > 0 And Len(Trim(Me.txt_folio(1))) > 0) And (val(Me.txt_folio(1)) >= val(Me.txt_folio(0))) Then
    If MsgBox("Las Boletas que agregará al Libro" & vbCrLf & vbCrLf & "¿Se encuentran impresas?", vbYesNo, "Verificación") = vbNo Then
        If MsgBox("¿Desea agregar estas boletas al libro de todas formas?", vbExclamation + vbYesNo, "Verificación") = vbYes Then
            Dim CMD As ADODB.Command
            Dim QRT As String
            Set CMD = New ADODB.Command
            CMD.CommandType = adCmdText
            CMD.ActiveConnection = conn
            QRT = "CREATE TABLE IF NOT EXISTS `fnza_log_boletas_no_impresas` (`FOLIO` bigint(20) unsigned NOT NULL auto_increment,`USUARIO_LOGIN` varchar(100) NOT NULL default '',`USUARIO_NOMBRE` varchar(100) NOT NULL default '', `FOLIO_INICIAL` bigint(20) NOT NULL default '0', `FOLIO_FINAL` bigint(20) NOT NULL default '0', `FECHA` datetime NOT NULL default '0000-00-00 00:00:00', `IMPRESO` varchar(2) NOT NULL default 'NO', PRIMARY KEY  (`FOLIO`) ) ENGINE=MyISAM;"
            CMD.CommandText = QRT
            CMD.Execute
            
            QRT = "INSERT fnza_log_boletas_no_impresas(usuario_login,usuario_nombre,folio_inicial,folio_final,fecha) VALUES('" & Nom_usu_ses & "','" & Nom_com_usu_ses & "'," & val(Me.txt_folio(0)) & "," & val(Me.txt_folio(1)) & ",concat(current_date,' ',current_time))"
            CMD.CommandText = QRT
            CMD.Execute
        Else
            Exit Sub
        End If
    End If
    Dim ADetBol(2, 1) As Long ' Columna , Fila
    Abarra = 0
    Me.ProgBar_Boletas.ShowProgress 0
    Me.ProgBar_Boletas.MaxValue = Filafin - Filaini
    'Me.ProgBar_Boletas.MaxValue = Filafin
    Me.ProgBar_Boletas.Zusatztext = "% Agregado"
    
    For p = val(Filaini) To val(Filafin)
        If UCase(Me.Grd_pagos_bci.TextMatrix(p, 6)) <> "CANCELADA" Then
            RutApo = Me.Grd_pagos_bci.TextMatrix(p, 0)
            Rutalu = Me.Grd_pagos_bci.TextMatrix(p, 12)
            Folio = val(Me.Grd_pagos_bci.TextMatrix(p, 6))
            
            FEmision = Format(Me.Dtp_Fec_emision.Value, "yyyy-mm-dd")
            FPago = Format(Me.Grd_pagos_bci.TextMatrix(p, 11), "yyyy-mm-dd")
            agno = CLng(Me.Grd_pagos_bci.TextMatrix(p, 15))
            If agno <> "2004" Then 'o preguntar por el colegio vacio
                ADetBol(1, 1) = Me.Grd_pagos_bci.TextMatrix(p, 21): ADetBol(2, 1) = Me.Grd_pagos_bci.TextMatrix(p, 4)
                 If crear_boleta(Folio, Mid(CodEmpresa, 1, 6), RutApo, Rutalu, FEmision, FPago, ADetBol(2, 1), ProcPago, TipoPago, ADetBol(), "", "", 0, 0, conn) Then
                    info = "Boleta creada con el folio detalle " & ADetBol(1, 1) & " para el alumno " & Rutalu & " , apoderado " & RutApo & " por $" & ADetBol(2, 1)
                    Call Log_AddAnotacion(info, True)
                    Me.Lbl_Ult_Fola = Folio
                    If val(Me.Grd_pagos_bci.TextMatrix(Fila, 4)) >= val(Me.Grd_pagos_bci.TextMatrix(Fila, 24)) Then
                        conn.Execute "update fnza_deta_cupones set estado='PA' where folio_cupon = " & val(Me.Grd_pagos_bci.TextMatrix(Fila, 23))
                        Call RegistrarOpeCupon("PAG", val(Me.Grd_pagos_bci.TextMatrix(t, 22)), val(Me.Grd_pagos_bci.TextMatrix(p, 23)), conn)
                        Call Act_Estado_Cuponera(val(Me.Grd_pagos_bci.TextMatrix(p, 22)), conn)
                    End If
                'Log fnza_historico_log
                accion_detalle = "Se a generado la boleta con folio " & Folio _
                               & " con monto " & Grd_pagos_bci.TextMatrix(p, 5) _
                               & " para el año " & agno
                Call Inserta_Vitacora_Finanza(CStr(Rutalu), CStr(RutApo), "Boletas masivo", accion_detalle, 0, 0)
                'fin de log
21:
                Else
                    info = "Error: No fue posible crear boleta con el folio detalle " & ADetBol(1, 1) & " para el alumno " & Rutalu & " , apoderado " & RutApo & " por $" & ADetBol(2, 1)
                    Call Log_AddAnotacion(info, True)
                End If
            Else ' Si es cuota del 2004
                If ExistReg("gescol2004.BOL_APO_X_ALU", "FOLIO =" & Folio & " and cod_conv_bci ='" & CodConvBci & "'", conn) Then
                    If MsgBox("FOLIO Nº " & Folio & " YA EXISTE NO SE AGREGARÁ " & Chr(13) & "¿ Desea seguir ?", vbYesNo) = vbNo Then
                        Exit Sub
                    End If
                Else
                    'conn.Execute "INSERT INTO bol_apo_x_alu(RUT_APO, CI_ALU, FOLIO, FEC_EMISION, MONTO_ARANCEL, MONTO_EXENCION, MONTO_CPADRES, MONTO_APORTES, MONTO_OTROS, MONTO_TOTAL, NULA, FEC_NULA, PROCEDENCIA, COD_CONV_BCI, IND_CHEQUE) values('" & RutApo & "', '" & Rutalu & "', '" & Folio & "', '" & FEmision & "','" & MArancel & "', '" & MExencion & "', 0, 0, 0, " & MTotal & ", '" & Nula & "', '" & FNula & "', '" & Procedencia & "', '" & CodConvBci & "','0')"
                    FVencCuota = InvierteFecha(Me.Grd_pagos_bci.TextMatrix(p, 10), "R")
                    MArancel = val(Me.Grd_pagos_bci.TextMatrix(p, 2))
                    MExencion = val(Me.Grd_pagos_bci.TextMatrix(p, 3))
                    MCPadres = 0
                    MAportes = 0
                    MOtros = 0
                    MTotal = (MArancel - MExencion) + MCPadres + MAportes + MOtros
                    Dim Folio2004 As String
                    Folio2004 = FillconStr(Trim(Folio), 8, "0", "IZQ")
                    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('" & RutApo & "', '" & Rutalu & "', '" & Folio2004 & "', '" & FEmision & "', '" & FVencCuota & "', '" & FPago & "', '" & MArancel & "', '" & MExencion & "', 0, 0, 0, " & MTotal & ", '0', '1111-11-11', '2', '" & CodConvBci & "','0')"
                    'If Nula <> "1" Then
                        idcuota = DevuelveCampo("gescol2004.anualidad_x_apo", "", "id_cuota", "rut_apo ='" & RutApo & "' and month(fecha_venc)='" & Month(FVencCuota) & "'", conn)
                        If Not ExistReg("gescol2004.pagos", "rut_apo='" & RutApo & "' and id_cuota='" & idcuota & "' and cod_conv_bci ='" & CodConvBci & "' and ci_alu='" & Rutalu & "'", conn) Then
                            conn.Execute "INSERT INTO gescol2004.pagos(RUT_APO, ID_CUOTA, COD_CONV_BCI, FOLIO, FEC_PAGO, CI_ALU, MONTO) values('" & RutApo & "', '" & idcuota & "', '" & CodConvBci & "', '" & Folio2004 & "', '" & FPago & "', '" & Rutalu & "', " & MTotal & ")"
                            conn.Execute "update gescol2004.anualidad_x_apo set pagado = pagado + " & MTotal & " where rut_apo ='" & RutApo & "' and id_cuota ='" & idcuota & "'"
                            Call CrearBoleta2004(val(Folio), CodEmpresa, "gescol", FPago, FEmision, val(MTotal), RutApo, Rutalu, conn)
                        End If
                        
                    'Log fnza_historico_log
                        accion_detalle = "Se a generado la boleta con folio " & Folio _
                                   & " con monto " & val(MTotal) _
                                   & " para el año " & agno
                        Call Inserta_Vitacora_Finanza(CStr(Rutalu), CStr(RutApo), "Boletas masivo", accion_detalle, 0, 0)
                    'fin de log
                        
                    'End If
                    ' Separar los últimos folios agregados
                    'Me.Lbl_Ult_Fola.Caption = Folio
                    'Me.Lbl_Ult_Fola.Refresh
                End If
            End If
        End If
        
        Abarra = Abarra + 1
        Me.ProgBar_Boletas.ShowProgress (Abarra + 0)
        DoEvents
    Next p
    Me.ProgBar_Boletas.ShowProgress 0
Else
    MsgBox ("Error en los Folios Seleccionados")
End If
Exit Sub
Controlerror:
    If Err.Number = (vbObjectError + 521) Then
        Dim descri As String
        Dim Source As String
        descri = Err.Description
        Source = Err.Source
        MsgBox descri & vbCrLf & Source, vbExclamation, "ALERTA DE VALIDACIÓN"
        Log_AddAnotacion vbCrLf & "   (Error)" & (vbObjectError + 521) & " : " & descri & " : " & Source & vbCrLf, True
        Resume 21
    End If
    MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source, vbCritical, "ALERTA DE ANOMALÍA"
End Sub



Private Sub btn_camb_fecha_Click()
    Me.Grd_pagos_bci.TextMatrix(Me.Grd_pagos_bci.Row, Me.Grd_pagos_bci.Col) = Me.DT_Camb_Fecha.Value
    Me.Frame_Camb_Fecha.Visible = False
End Sub

Private Sub btn_canc_camb_fecha_Click()
    Me.Frame_Camb_Fecha.Visible = False
End Sub

Private Sub btn_Cancelar_Click()
Me.Frame_Tipo_Folio.Visible = False
Me.Grd_pagos_bci.Enabled = True
Me.Grd_pagos_bci.SetFocus
End Sub

Private Sub Btn_Cerrar_Dtll_Click()
Me.Frame_Dtll_Pago.Visible = False
End Sub

Private Sub Btn_Consultar_Click()
If CodEmpresa <> "" And NomEmpresa <> "" And Me.Cmb_Mes <> "" And Me.Cmb_TipoPago <> "" Then
    mes = Me.Cmb_Mes.ItemData(Me.Cmb_Mes.ListIndex)
    AnhoCmb = Trim(Me.Cmb_anho)
    If IsDate(AnhoCmb & "/" & mes & "/" & Me.Cmb_del_dia.Text) And IsDate(AnhoCmb & "/" & mes & "/" & Me.Cmb_al_dia.Text) Then
        Me.Frame_Criterios.Enabled = False
        Me.Frame_Imp_Agrega.Enabled = False
        Me.Btn_Salir.Enabled = False
        Ultimofolio = Ult_Folio_Fisico(CodEmpresa, conn)
        Me.Txt_Folio_Disp.Text = Ultimofolio + 1
        If Len(Trim(Me.Cmb_Mes)) > 0 And Len(Trim(Me.Cmb_TipoPago)) > 0 And Len(Trim(Me.Cmb_al_dia)) > 0 And Len(Trim(Me.Cmb_del_dia)) > 0 Then
            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
        Call IniciaGrilla
        'Me.Grd_Pagos_BCI.Clear
        Me.Lbl_Ult_Fola.Caption = ""
        Me.lbl_conexion_ext.Caption = "Estableciendo Conexión con Servidor Remoto"
        Me.lbl_conexion_ext.Refresh
        If ConectarBD(ConnExt, "192.168.7.91", BaseDatosExt, "groot", "kripplefight", False) Then
            'MsgBox ("conexión extablecida")
            Me.lbl_conexion_ext.Caption = "Conexión con Servidor Remoto establecida "
            Me.lbl_conexion_ext.Refresh
            Me.txt_folio(0).Text = "": Me.txt_folio(1).Text = ""
            Me.Txt_TextoLog = ""
            Me.Btn_VerSucesos.Visible = False
            Unload Form_BoletasMasivo_Dialog
            Call TraeInfo
        Else
            Me.lbl_conexion_ext.Caption = "Conexión fallida"
        End If
    Else
        MsgBox ("Faltan opciones por seleccionar")
    End If
    Me.Frame_Criterios.Enabled = True
    Me.Frame_Imp_Agrega.Enabled = True
    Me.Btn_Salir.Enabled = True
    Else
        MsgBox ("Fecha(s) no válida(s)")
    End If
Else
    MsgBox ("Faltan parámetros por seleccionar Revise Empresa, Mes y Tipo de Pago")
End If
End Sub

Private Sub Btn_Folio_Sel_Click(Index As Integer)
Select Case Index
    Case 0
        Filaini = FilaBol
    Case 1
        Filafin = FilaBol
End Select
Me.Grd_pagos_bci.Col = 6
Me.Grd_pagos_bci.Enabled = True
Me.txt_folio(Index) = BolSel
Me.Frame_Tipo_Folio.Visible = False
Me.Grd_pagos_bci.SetFocus
End Sub

Private Sub Btn_Imprimir_Click()
If (Len(Trim(Me.txt_folio(0))) > 0 And Len(Trim(Me.txt_folio(1))) > 0) And (val(Me.txt_folio(1)) >= val(Me.txt_folio(0))) Then
    If MsgBox("¿Fecha de emisión es correcta ? " & Me.Dtp_Fec_emision.Value, vbYesNo + vbQuestion) = vbYes Then
        Dim MArancel As Long, MExencion As Long, MPagado As Long, MTotal As Long
        Dim MCPadres As String, MAportes As String, MOtros As String, MParcial As Long
        Dim FEmision As String, NomApo As String, RutApo As String, NomAlu As String, curso As String
        Dim suma As String, Mensual As String
        Dim iniPrinter As String
        Dim ResetPrinter As String
        Dim FormFeed As String
        Dim CuotaCero As Integer
        Dim f_ini As Integer, f_fin As Integer
        
        Set cNum2Let = New clsNum2Let
        'las secuencias para enviar una boleta a la impresora de matriz son
        'iniPrinter = Chr(27) + Chr(67) + Chr(51) + Chr(13) + Chr(27) + Chr(74) + Chr(120)
        '027 067 051 013 027 074 120 (pagina de 8 pulgadas o 51 lineas)
        'esta es la secuencia de reposicion, cuando termina el proceso es una especie de reset
        'iniPrinter = Chr(27) + "@" + Chr(27) + "C" + Chr(24) + Chr(13) '+ Chr(12) '+ Chr(0) + Chr(4)
        
        iniPrinter = Chr(27) + Chr(67) + Chr(51) + Chr(13) + Chr(27) + Chr(74) + Chr(120)
        ResetPrinter = Chr(27) + "@"
        FormFeed = Chr(12)
        'Open "C:\text1.txt" For Output As 1
        Open "LPT1:" For Output As 1
        Folios = ""
        For t = val(Filaini) To val(Filafin)
            If UCase(Me.Grd_pagos_bci.TextMatrix(t, 6)) <> "CANCELADA" Then
                RutApo = Me.Grd_pagos_bci.TextMatrix(t, 0)
                Rutalu = Me.Grd_pagos_bci.TextMatrix(p, 12)
                If RutApo = "08942158-6" Then
                    MsgBox "stop mario", vbCritical + vbExclamation + vbInformation + vbOKOnly, "Critical Stop for Debug Information!"
                End If
                NomApo = Left(Me.Grd_pagos_bci.TextMatrix(t, 1), 31)
                Mensualidad = Me.Grd_pagos_bci.TextMatrix(t, 2)
                Folio = Me.Grd_pagos_bci.TextMatrix(t, 6)
                Folios = Folios & "-" & Folio
                Pagado = Me.Grd_pagos_bci.TextMatrix(t, 4)
                NomAlu = Me.Grd_pagos_bci.TextMatrix(t, 8)
                curso = Me.Grd_pagos_bci.TextMatrix(t, 9)
                
                'IF (funcion que determine si es una primera cuota) then
                '
                CuotaCero = MesCuotaCero(Me.Grd_pagos_bci.TextMatrix(t, 10), val(Trim(Me.Grd_pagos_bci.TextMatrix(t, 15))), conn)
                
                If (Month(CDate(Me.Grd_pagos_bci.TextMatrix(t, 10))) = CuotaCero) And (val(Trim(Me.Grd_pagos_bci.TextMatrix(t, 15))) > 2004) Then
                    mes = Me.Cmb_Mes.List(Month(CDate(Me.Grd_pagos_bci.TextMatrix(t, 10)))) & " 1 de 2."
                ElseIf (Month(CDate(Me.Grd_pagos_bci.TextMatrix(t, 10))) = (CuotaCero + 1)) And (val(Trim(Me.Grd_pagos_bci.TextMatrix(t, 15))) > 2004) Then
                    mes = Me.Cmb_Mes.List(Month(CDate(Me.Grd_pagos_bci.TextMatrix(t, 10))) - 1) & " 2 de 2."
                Else
                    mes = Me.Cmb_Mes.List(Month(CDate(Me.Grd_pagos_bci.TextMatrix(t, 10))) - 1)
                End If
                
                '
                'FIN del IF.
                FEmision = Me.Dtp_Fec_emision.Value
                MArancel = CLng(Me.Grd_pagos_bci.TextMatrix(t, 2))
                If CLng(Me.Grd_pagos_bci.TextMatrix(t, 25)) = 0 Then
                    OtrasExencion = CLng(Me.Grd_pagos_bci.TextMatrix(t, 3))
                    MExencion = CLng(Me.Grd_pagos_bci.TextMatrix(t, 25))
                    'MParcial = (MArancel - MExencion)
'                    If MExencion = 0 Then
'                        MParcial = 0
'                    Else
'                        MParcial = (MArancel - MExencion)
'                    End If
                    
                    If (MExencion = 0) Or (MArancel > MExencion) Then
                        MParcial = 0
                    Else
                        MParcial = (MArancel - MExencion)
                    End If
                                        
                    MParcial1 = (MArancel - OtrasExencion)
                    MTotal = MParcial1
                Else
                    OtrasExencion = 0
                    MExencion = CLng(Me.Grd_pagos_bci.TextMatrix(t, 25))
                    If (MArancel = MExencion) Then
                        MParcial = (MArancel - MExencion)
                    Else
                        MParcial = 0
                    End If
                    MParcial1 = (MArancel - MExencion)
                    MTotal = MParcial1
                End If
                
                If OtrasExencion = 0 Then
                    Xc1 = 4
                Else
                    Xc1 = 0
                End If
                
                If MExencion = 0 Then
                    Xc = 4
                Else
                    Xc = 0
                End If
                
                 ' vbCrLf + vbCrLf + Space(23) + Mes + " " + Me.Grd_pagos_bci.TextMatrix(t, 15) + Space(34) + curso &
                
                MAportes = ""
                MCPadres = ""
                MOtros = ""
                'MTotal = MParcial '+ MCPadres + MAportes + MOtros
                cNum2Let.Numero = MTotal
                EnPalabras = cNum2Let.ALetra
                letra = 1: TOTAL_LETRAS = 10: agno_v = 5
                Print #1, Chr(15) & _
                vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf & _
                vbCrLf + Space(23) + NomApo + Space(11) + RutApo & _
                vbCrLf + vbCrLf + Space(23) + NomAlu & _
                vbCrLf + vbCrLf + Space(23) + IIf(mes = "Febrero", "1 de 11", mes) + " " + IIf(mes = "Febrero", "", Me.Grd_pagos_bci.TextMatrix(t, 15)) + IIf(mes = "Febrero", Space(40), Space(34)) + curso & _
                vbCrLf; vbCrLf + Space(25) + Pagado + Space(15) + EnPalabras & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + Space(51) + CStr(MArancel) & _
                vbCrLf + vbCrLf + Space(51) + Space(Xc) + CStr(MExencion) + Space(20) + CStr(MParcial) & _
                vbCrLf + vbCrLf + Space(51) + Space(Xc1) + CStr(OtrasExencion) + Space(20) + CStr(MParcial1) & _
                vbCrLf + vbCrLf + Space(72) + CStr(MAportes) & _
                vbCrLf + vbCrLf + Space(72) + CStr(MCPadres) & _
                vbCrLf + vbCrLf + Space(72) + CStr(MOtros) & _
                vbCrLf + vbCrLf + Space(76) + CStr(MTotal) & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + Space(20) + FEmision & _
                vbCrLf + vbCrLf
            Else
             MsgBox "STOP"
            End If
            
            
        Next t
    Print #1, ResetPrinter
    Close 1
     'Log fnza_historico_log
                accion_detalle = "Se han impreso las boletas con folios: " & Folios _
                               & " para el año " & agno
                Call Inserta_Vitacora_Finanza(CStr("MASIVOS"), CStr("MASIVOS"), "Boletas masivo", CStr(accion_detalle), 0, 0)
     'fin de log
        If MsgBox("¿Desea Agregar al libro ? ", vbYesNo + vbQuestion) = vbYes Then
            Call Btn_Agregar_Click
        Else
            'Log fnza_historico_log
                    accion_detalle = "El usuario NOOOOO AGREGO las boletas al libro con folios: " & Folios _
                                   & " para el año " & agno
                    Call Inserta_Vitacora_Finanza(CStr("MASIVOS"), CStr("MASIVOS"), "Boletas masivo", CStr(accion_detalle), 0, 0)
             'fin de log
        End If
    Else
          
        Me.Dtp_Fec_emision.SetFocus
    End If

Else
    MsgBox ("Error en los Folios Seleccionados")
End If
End Sub

Private Sub Btn_Salir_Click()
Unload Me
End Sub

Private Sub Btn_Ver_Libro_Click()
Call CreaBD(DirAplicacion & "\GesTemp.mdb")
Set rep = DBEngine.Workspaces(0).OpenDatabase(DirAplicacion & "\GesTemp.mdb")
Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Detalles", "11,10")

    'horiz = Left(horiz, Len(horiz) - 2): horiz = "(" & horiz & ")"
'    a = "insert into Detalles " & ins & " values " & detal
'    Rep.Execute a
    'b = "insert into Detalles " & ins & " values " & horiz
    'If R >= 1 Then
    '    Rep.Execute b
    'End If

sumatotal = 0
sumadia = val(Me.Grd_pagos_bci.TextMatrix(1, 7))
FechaRec = Me.Grd_pagos_bci.TextMatrix(1, 11)
For t = 2 To Me.Grd_pagos_bci.Rows - 1
    If FechaRec = Me.Grd_pagos_bci.TextMatrix(t, 11) Then
        sumadia = sumadia + val(Me.Grd_pagos_bci.TextMatrix(t, 7))
    ElseIf FechaRec <> Me.Grd_pagos_bci.TextMatrix(t, 11) And Len(Trim(Me.Grd_pagos_bci.TextMatrix(t, 11))) > 0 Then
        a = "insert into Detalles (C1, C2) values ('" & FechaRec & "','" & sumadia & "')"
        sumatotal = sumatotal + val(sumadia)
        rep.Execute a
        FechaRec = Me.Grd_pagos_bci.TextMatrix(t, 11)
        sumadia = val(Me.Grd_pagos_bci.TextMatrix(t, 7))
    End If
Next t
a = "insert into Detalles (C1, C2) values ('" & FechaRec & "','" & sumadia & "')"
sumatotal = sumatotal + val(sumadia)
rep.Execute a
a = "insert into Detalles (C1, C2) values ('TOTAL DEL MES','" & sumatotal & "')"
rep.Execute a
rep.Close
titulo = "LIBRO DE BOLETAS MES DE " & UCase(Me.Cmb_Mes)
Nombrecol = DevuelveCampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
Direccol = DevuelveCampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
ComunaCol = DevuelveCampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
Form_main.CrystalReport.WindowTitle = titulo
Form_main.CrystalReport.Formulas(0) = "nomcol = '" & Nombrecol & "'"
Form_main.CrystalReport.Formulas(1) = "dircol = '" & Direccol & "'"
Form_main.CrystalReport.Formulas(2) = "comunacol = '" & ComunaCol & "'"
Form_main.CrystalReport.Formulas(3) = "titulo= '" & titulo & "'"
Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\libropre.rpt"
Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
Form_main.CrystalReport.WindowState = crptMaximized
Form_main.CrystalReport.ReplaceSelectionFormula ("")
Form_main.CrystalReport.Action = 1
Form_main.CrystalReport.ReplaceSelectionFormula ("")
'    Kill (DirAplicacion + "GesTemp.mdb")

End Sub

Private Sub Btn_VerSucesos_Click()
Form_BoletasMasivo_Dialog.Txt_Sucesos = ""
Form_BoletasMasivo_Dialog.Txt_Sucesos = Me.Txt_TextoLog
End Sub

Private Sub Cmb_Banco_Click()
CodBanco = Abancos(Me.Cmb_Banco.ListIndex)
End Sub

Private Sub Cmb_Colegio_Cup_Click()
IndAColegios = Me.Cmb_Colegio_Cup.ListIndex
If IndAColegios >= 0 Then
    Me.Option1.Enabled = True
    Me.Option2.Enabled = True
Else
    Me.Option1.Enabled = True
    Me.Option2.Enabled = True
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_del_dia_Click()
If Me.Cmb_del_dia.ListIndex >= 0 Then
    diaini = Me.Cmb_del_dia.Text
    Me.Cmb_al_dia.Clear
    For t = val(diaini) To 31
        Me.Cmb_al_dia.AddItem Trim(FillconStr(CStr(t), 2, "0", "IZQ"))
    Next t
    Me.Cmb_al_dia.ListIndex = 0
End If
End Sub

Private Sub Cmb_Mes_Click()
'MsgBox Me.Cmb_Mes.ItemData(Me.Cmb_Mes.ListIndex)
End Sub


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

Private Sub Cmb_TipoPago_Click()
ProcPago = AProcpago(Me.Cmb_TipoPago.ListIndex)
End Sub

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

Private Sub Btn_Informe_pagos_banco_Click()
        ' ****************************
        ' Muestra reporte de pagos BCI
        Call LimpiaFormulas(Form_main.CrystalReport, 30)
        Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\fnza_informe_rec_bci.rpt"
        Form_main.CrystalReport.WindowState = crptMaximized
        Form_main.CrystalReport.WindowTitle = "Informe de Pagos Informados por Banco"
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        Form_main.CrystalReport.Destination = crptToWindow
        Form_main.CrystalReport.Action = 1
        ' Fin muestra reporte pagos BCI
        ' *****************************
End Sub

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

Private Sub Form_Load()
Me.Frame_Camb_Fecha.Visible = False
'Set rs = New ADODB.Recordset
'Form_main.Mae.Enabled = False
'Form_main.con.Enabled = False
'Form_main.fin.Enabled = False
'Form_main.Her.Enabled = False
'Form_main.Inf.Enabled = False
'Form_main.Mov.Enabled = False
AProcpago(0) = "icup"
AProcpago(1) = "ipac"
TipoPago = "depo"
Me.Btn_VerSucesos.Visible = False
Me.Caption = "IMPRESIÓN DE BOLETAS AÑO ESCOLAR " & Anno
Call llenacomboconarreglo(Cmb_Colegio_Cup, "hist_cod_colegio where length(colegio)=6 ", "nombre", "colegio", AColegios, conn)
Call llenacomboconarreglo(Me.Cmb_Banco, "fnza_cod_banco", "descripcion", "banco", Abancos, conn)
    Indbci = ValorenArray(Abancos, "16")
    If Indbci >= 0 Then
        Me.Cmb_Banco.ListIndex = Indbci
    End If

For I = 2005 To (Anno + 1)
    Me.Cmb_anho.AddItem I
Next I

Me.Cmb_TipoPago.ListIndex = 0: Me.Cmb_TipoPago.Enabled = True
Me.Width = 12800
Me.Height = 8700
Me.Frame_Tipo_Folio.Visible = False
Me.Dtp_Fec_emision.Value = Date
Call IniciaGrilla
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unload Form_BoletasMasivo_Dialog
'Form_main.Mae.Enabled = True
'Form_main.con.Enabled = True
'Form_main.fin.Enabled = True
'Form_main.Her.Enabled = True
'Form_main.Inf.Enabled = True
'Form_main.Mov.Enabled = True
End Sub

Private Sub Grd_Pagos_BCI_DblClick()
''MsgBox (Me.Grd_Pagos_BCI.Col & " " & Me.Grd_Pagos_BCI.Row)
Fila = Me.Grd_pagos_bci.Row

If Me.Grd_pagos_bci.Col = 10 Then
    If Not (Me.Grd_pagos_bci.TextMatrix(Fila, Me.Grd_pagos_bci.Col) = "") Then
        Me.DT_Camb_Fecha.Value = CDate(Me.Grd_pagos_bci.TextMatrix(Fila, Me.Grd_pagos_bci.Col))
        Me.Frame_Camb_Fecha.Visible = True
    End If
Else
    If UCase(Me.Grd_pagos_bci.TextMatrix(Fila, 6)) <> "CANCELADA" And Me.Grd_pagos_bci.TextMatrix(Fila, 6) <> "" Then
        FilaBol = Me.Grd_pagos_bci.Row
        BolSel = Me.Grd_pagos_bci.TextMatrix(FilaBol, 6)
        Me.Grd_pagos_bci.Enabled = False
        Me.lbl_boleta.Caption = BolSel
        Me.Frame_Tipo_Folio.Visible = True
        Me.Btn_Folio_Sel(0).SetFocus
    Else
        If UCase(Me.Grd_pagos_bci.TextMatrix(Fila, 6)) = "CANCELADA" And Me.Grd_pagos_bci.TextMatrix(Fila, 21) <> "" Then
            ' Mostrar detalle del pago
            Me.Frame_Dtll_Pago.Visible = True
            Call LlenaGrilla(Me.Grd_Dtll_Pago, "Folio          , Emisión         , Pago           , Estado            ", "fnza_dtll_mvto fm, fnza_boletas fb, fnza_movimientos_mensualidad fmm, fnza_cod_estado_blta feb", "fb.folio_blta_fisico; fb.fecha_blta; fmm.fech_pago; feb.estado_blta", "fb.folio_blta=fm.folio_blta and fm.folio_mvto=fmm.folio_mvto and fb.estado_blta=feb.estado_blta and fb.tipo_doc = 'blta' and fm.folio_dtll =" & val(Me.Grd_pagos_bci.TextMatrix(Fila, 21)), conn)
        ElseIf UCase(Me.Grd_pagos_bci.TextMatrix(Fila, 6)) = "CANCELADA" And Me.Grd_pagos_bci.TextMatrix(Fila, 21) = "" Then
            MsgBox "Pago año anterior"
        End If
    End If
End If
End Sub

Private Sub Grd_Pagos_BCI_KeyDown(KeyCode As Integer, Shift As Integer)
'Dim rango As String, Desde As Long, Hasta As Long
'Col = Me.Grd_Pagos_BCI.Col: Fila = Me.Grd_Pagos_BCI.Row
'If (Col = 3 Or Col = 4) And (Me.Grd_Pagos_BCI.TextMatrix(Fila, 13) <> "") Then
'    rango = Me.Grd_Pagos_BCI.TextMatrix(Fila, 13)
'    ndesde = InStr(1, rango, "D")
'    nhasta = InStr(1, rango, "A")
'    Desde = CLng((Mid(rango, ndesde + 1, (nhasta - ndesde) - 1)))
'    Hasta = CLng(Val(Mid(rango, nhasta + 1, Len(rango) - nhasta)))
'    If KeyCode = 46 And Grd_Pagos_BCI.Text <> "" Then
'        Grd_Pagos_BCI.Text = ""
'    ElseIf KeyCode = 8 And Len(Grd_Pagos_BCI.Text) <> 0 Then
'        Grd_Pagos_BCI.Text = Mid(Grd_Pagos_BCI.Text, 1, Len(Grd_Pagos_BCI.Text) - 1)
'    End If
'    For t = Desde To Hasta
'        pporgrupo = pporgrupo + Val(Me.Grd_Pagos_BCI.TextMatrix(t, 4))
'    Next t
'    Me.Grd_Pagos_BCI.TextMatrix(Hasta, 5) = pporgrupo
 ''   If Me.Grd_Pagos_BCI.TextMatrix(Hasta, 5) = Me.Grd_Pagos_BCI.TextMatrix(Hasta, 7) Then
 ''       For t = Desde To Hasta
 ''           For tu = 0 To Me.Grd_Pagos_BCI.Cols - 1
 ''               Me.Grd_Pagos_BCI.Col = tu: Me.Grd_Pagos_BCI.Row = t
 ''               Me.Grd_Pagos_BCI.CellBackColor = &HFFFFFF
 ''           Next tu
 ''       Next t
 ''       Me.Grd_Pagos_BCI.Row = Hasta: Me.Grd_Pagos_BCI.Col = 5: Me.Grd_Pagos_BCI.CellBackColor = &HFFFFC0  ' celeste
 ''       Me.Grd_Pagos_BCI.Row = Hasta: Me.Grd_Pagos_BCI.Col = 7: Me.Grd_Pagos_BCI.CellBackColor = &HFFFFC0
 ''   Else
 ''       For t = Desde To Hasta '
 ''           For tu = 0 To Me.Grd_Pagos_BCI.Cols - 1
 ''               Me.Grd_Pagos_BCI.Col = tu: Me.Grd_Pagos_BCI.Row = t
 ''               Me.Grd_Pagos_BCI.CellBackColor = &HC0C0FF    ' rojo
 ''           Next tu
 ''       Next t
 ' '  End If
'ElseIf Col = 6 Then
'    If KeyCode = 46 And Grd_Pagos_BCI.Text <> "" Then
'        Grd_Pagos_BCI.Text = ""
'    ElseIf KeyCode = 8 And Len(Grd_Pagos_BCI.Text) <> 0 Then
'        Grd_Pagos_BCI.Text = Mid(Grd_Pagos_BCI.Text, 1, Len(Grd_Pagos_BCI.Text) - 1)
'    End If
'End If
End Sub

Private Sub Grd_Pagos_BCI_KeyPress(KeyAscii As Integer)
' rango
'Dim rango As String, Desde As Long, Hasta As Long
'Col = Me.Grd_Pagos_BCI.Col: Fila = Me.Grd_Pagos_BCI.Row
'If Col = 3 Or Col = 4 Then
'    rango = Me.Grd_Pagos_BCI.TextMatrix(Fila, 13)
'    ndesde = InStr(1, rango, "D")
'    nhasta = InStr(1, rango, "A")
'    Desde = CLng((Mid(rango, ndesde + 1, (nhasta - ndesde) - 1)))
'    Hasta = CLng(Val(Mid(rango, nhasta + 1, Len(rango) - nhasta)))
'    If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
'        Grd_Pagos_BCI.Text = Grd_Pagos_BCI.Text & Chr(KeyAscii)
'        Grd_Pagos_BCI.CellAlignment = 8
'        Select Case Col
'            Case 3
'                Me.Grd_Pagos_BCI.TextMatrix(Fila, 4) = Val(Me.Grd_Pagos_BCI.TextMatrix(Fila, 2)) - Val(Me.Grd_Pagos_BCI.TextMatrix(Fila, 3))
'            Case 4
'                Me.Grd_Pagos_BCI.TextMatrix(Fila, 3) = Val(Me.Grd_Pagos_BCI.TextMatrix(Fila, 2)) - Val(Me.Grd_Pagos_BCI.TextMatrix(Fila, 4))
'        End Select
'
'        'Me.Grd_Dif_Mens.TextMatrix (Fila + Val(Me.Grd_Dif_Mens.TextMatrix(Fila, 13), 3))=
'    End If
'    For t = Desde To Hasta
'        pporgrupo = pporgrupo + Val(Me.Grd_Pagos_BCI.TextMatrix(t, 4))
'    Next t
'    Me.Grd_Pagos_BCI.TextMatrix(Hasta, 5) = pporgrupo
'
 '   'If Me.Grd_Pagos_BCI.TextMatrix(Hasta, 5) = Me.Grd_Pagos_BCI.TextMatrix(Hasta, 7) Then
 '   '    For t = Desde To Hasta
 '   '        For tu = 0 To Me.Grd_Pagos_BCI.Cols - 1
 '   '            Me.Grd_Pagos_BCI.Col = tu: Me.Grd_Pagos_BCI.Row = t
 '   '            Me.Grd_Pagos_BCI.CellBackColor = &HFFFFFF
 '   '        Next tu
 '   '    Next t
 '   '    Me.Grd_Pagos_BCI.Row = Hasta: Me.Grd_Pagos_BCI.Col = 5: Me.Grd_Pagos_BCI.CellBackColor = &HFFFFC0  ' celeste
 '   '    Me.Grd_Pagos_BCI.Row = Hasta: Me.Grd_Pagos_BCI.Col = 7: Me.Grd_Pagos_BCI.CellBackColor = &HFFFFC0
 '   'Else
 '   '    For t = Desde To Hasta '
 '   '        For tu = 0 To Me.Grd_Pagos_BCI.Cols - 1
 '   '            Me.Grd_Pagos_BCI.Col = tu: Me.Grd_Pagos_BCI.Row = t
 '   '            Me.Grd_Pagos_BCI.CellBackColor = &HC0C0FF    ' rojo
 '   '        Next tu
 '  '     Next t
 '  ' End If
'ElseIf Col = 6 Then
'    If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
'        Grd_Pagos_BCI.Text = Grd_Pagos_BCI.Text & Chr(KeyAscii)
'        Grd_Pagos_BCI.CellAlignment = 8
'    End If
'End If
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) 'Exencion
                            MatrizHer(m - 1, 4) = cuotasexe(0, 0) 'Cuota
                        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

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 PorcentExe2004(rutalumno As String, MesCuota As String) As Single
Dim porc As Single
cuotasexe = TraeCuotaalu2004(rutalumno, MesCuota)
porc = 100 - ((100 * cuotasexe(0, 0)) / cuotasexe(0, 1))
PorcentExe2004 = porc
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
Function Cuotaimpaga(Rutalu As String, MesCuota As String, DebieraPagar As Long, CNX As ADODB.Connection) As Boolean
    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", CNX)
    Pagadon = IIf(Pagado <> "", Pagado, "0")
    Cuotaimpaga = IIf(Pagadon >= DebieraPagar, False, True)
End Function
        
Private Sub Option1_Click()
    Particular = False
    Me.Frm_Des_Pago.Enabled = True
    If Option3.Value Then
        Me.Txt_CodConvBci = RetornaCampo("CFG", "valor", "param='CodConvBCIBC'", conn)
        Me.Txt_CodConvBci_Part = RetornaCampo("CFG", "valor", "param='CodConvBCIPK'", 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))
    Else
        Me.Txt_CodConvBci.Text = RetornaCampo("CFG", "valor", "param='CCBC'", conn)
        Me.Txt_CodConvBci_Part.Text = RetornaCampo("CFG", "valor", "param='CCPK'", conn)
        Me.Txt_Cod_Pac.Text = IIf(Particular, DevuelveCampo("hist_cod_colegio", "", "cod_pac", "colegio ='" & APartic(IndAPartic) & "'", conn), DevuelveCampo("hist_cod_colegio", "", "cod_pac", "colegio ='" & AColegios(IndAColegios) & "'", conn))
    End If
    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.Txt_CodConvBci.BackColor = &H80000005
        Me.Cmb_Part_Cup.BackColor = &HC0FFFF
        Me.Txt_CodConvBci_Part.BackColor = &HC0FFFF
        TipoAlu = "PK": CodConvBci = Me.Txt_CodConvBci_Part
    Else
        Me.Cmb_Colegio_Cup.BackColor = &HC0FFFF
        Me.Txt_CodConvBci.BackColor = &HC0FFFF
        Me.Cmb_Part_Cup.BackColor = &H80000005
        Me.Txt_CodConvBci_Part.BackColor = &H80000005
        TipoAlu = "BOS": CodConvBci = Me.Txt_CodConvBci
    End If
End Sub

Private Sub Option2_Click()
    Particular = True
    Me.Frm_Des_Pago.Enabled = True
    If Option3.Value Then
        Me.Txt_CodConvBci = RetornaCampo("CFG", "valor", "param='CodConvBCIBC'", conn)
        Me.Txt_CodConvBci_Part = RetornaCampo("CFG", "valor", "param='CodConvBCIPK'", 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))
    Else
        Me.Txt_CodConvBci.Text = RetornaCampo("CFG", "valor", "param='CCBC'", conn)
        Me.Txt_CodConvBci_Part.Text = RetornaCampo("CFG", "valor", "param='CCPK'", conn)
        Me.Txt_Cod_Pac.Text = IIf(Particular, DevuelveCampo("hist_cod_colegio", "", "cod_pac", "colegio ='" & APartic(IndAPartic) & "'", conn), DevuelveCampo("hist_cod_colegio", "", "cod_pac", "colegio ='" & AColegios(IndAColegios) & "'", conn))
    End If
    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.Txt_CodConvBci.BackColor = &H80000005
        Me.Cmb_Part_Cup.BackColor = &HC0FFFF
        Me.Txt_CodConvBci_Part.BackColor = &HC0FFFF
        TipoAlu = "PK": CodConvBci = Me.Txt_CodConvBci_Part
    Else
        Me.Cmb_Colegio_Cup.BackColor = &HC0FFFF
        Me.Txt_CodConvBci.BackColor = &HC0FFFF
        Me.Cmb_Part_Cup.BackColor = &H80000005
        Me.Txt_CodConvBci_Part.BackColor = &H80000005
        TipoAlu = "BOS": CodConvBci = Me.Txt_CodConvBci
    End If
End Sub

Private Sub Option3_Click()
    If Me.Option1.Value Then
        Call Option1_Click
    Else
        Call Option2_Click
    End If
End Sub

Private Sub Option4_Click()
    If Me.Option1.Value Then
        Call Option1_Click
    Else
        Call Option2_Click
    End If
End Sub

Private Function devuelve_colegio(rut As String, Fecha As String, monto As Long) As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    
    var_sql = "SELECT colegio,monto_mens" _
            & " From fnza_mensualidad" _
            & " WHERE run_apo = '" & rut _
            & "' and fech_venc = '" & Fecha & "'"
            
   
    objRS.Open var_sql, conn
    If Not objRS.EOF Then
        For I = 1 To objRS.RecordCount
            If objRS("monto_mens") = monto Then
                colegio = objRS("colegio")
            End If
            objRS.MoveNext
        Next I
    End If
    objRS.Close
    devuelve_colegio = colegio
End Function
