VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Begin VB.Form Form_Cuponeras 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cuponeras"
   ClientHeight    =   9420
   ClientLeft      =   45
   ClientTop       =   615
   ClientWidth     =   11970
   Icon            =   "Form_Cuponeras.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   9420
   ScaleWidth      =   11970
   Begin VB.Frame Frame_Generacion_Cup 
      BorderStyle     =   0  'None
      Height          =   7455
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Visible         =   0   'False
      Width           =   10815
      Begin VB.Frame Frame_Bus 
         BorderStyle     =   0  'None
         Height          =   4815
         Index           =   2
         Left            =   5640
         TabIndex        =   63
         Top             =   1200
         Width           =   4935
         Begin VB.Frame Frame4 
            Caption         =   "Buscar por"
            ForeColor       =   &H00FF0000&
            Height          =   735
            Left            =   0
            TabIndex        =   64
            Top             =   0
            Width           =   3105
            Begin VB.OptionButton Opt_busqueda_caj 
               Caption         =   "Apoderado"
               Height          =   255
               Index           =   0
               Left            =   240
               TabIndex        =   66
               Top             =   300
               Value           =   -1  'True
               Width           =   1215
            End
            Begin VB.OptionButton Opt_busqueda_caj 
               Caption         =   "Alumno"
               Height          =   255
               Index           =   1
               Left            =   1680
               TabIndex        =   65
               Top             =   300
               Width           =   1215
            End
         End
         Begin VB.Frame Frame_datos_busqueda 
            Height          =   1335
            Left            =   0
            TabIndex        =   67
            Top             =   720
            Width           =   4095
            Begin VB.ListBox lst_busq_caja 
               Height          =   1425
               Index           =   0
               Left            =   120
               TabIndex        =   72
               Top             =   840
               Width           =   3855
            End
            Begin VB.ListBox lst_busq_caja 
               Height          =   1425
               Index           =   1
               Left            =   120
               TabIndex        =   75
               Top             =   840
               Width           =   1815
            End
            Begin VB.TextBox txt_crit_busqueda 
               Height          =   285
               Index           =   0
               Left            =   120
               TabIndex        =   71
               Top             =   600
               Width           =   3855
            End
            Begin VB.OptionButton opt_criterio 
               Caption         =   "R.u.t."
               Height          =   255
               Index           =   1
               Left            =   1680
               TabIndex        =   70
               Top             =   300
               Width           =   855
            End
            Begin VB.OptionButton opt_criterio 
               Caption         =   "Apellidos"
               Height          =   255
               Index           =   0
               Left            =   120
               TabIndex        =   69
               Top             =   300
               Value           =   -1  'True
               Width           =   975
            End
            Begin VB.CommandButton btn_can_busqueda 
               Caption         =   "Cancelar"
               Height          =   375
               Left            =   2760
               TabIndex        =   68
               Top             =   240
               Width           =   1215
            End
            Begin VB.TextBox txt_crit_busqueda 
               Height          =   285
               Index           =   1
               Left            =   120
               TabIndex        =   73
               Top             =   600
               Width           =   855
            End
            Begin VB.TextBox txt_dig_busqueda 
               Height          =   285
               Left            =   1200
               TabIndex        =   74
               Top             =   600
               Width           =   255
            End
            Begin VB.Label Label11 
               Alignment       =   2  'Center
               Caption         =   "-"
               Height          =   255
               Left            =   960
               TabIndex        =   76
               Top             =   600
               Width           =   255
            End
         End
         Begin VB.Frame Frame_DatosApod 
            Caption         =   "Datos Apoderado"
            ForeColor       =   &H00FF0000&
            Height          =   3015
            Left            =   0
            TabIndex        =   77
            Top             =   2040
            Width           =   4935
            Begin VB.TextBox Txt_RutApo 
               Height          =   285
               Left            =   1320
               TabIndex        =   85
               Top             =   240
               Width           =   1215
            End
            Begin VB.TextBox Txt_NomApo 
               Height          =   285
               Left            =   1320
               TabIndex        =   84
               Top             =   600
               Width           =   3495
            End
            Begin VB.TextBox Txt_ArancelTotal 
               Height          =   285
               Left            =   1320
               TabIndex        =   83
               Top             =   960
               Width           =   975
            End
            Begin VB.TextBox Txt_Beca 
               Height          =   285
               Left            =   1200
               TabIndex        =   82
               Top             =   1920
               Width           =   975
            End
            Begin VB.TextBox Txt_Hmnos 
               Height          =   285
               Left            =   1200
               TabIndex        =   81
               Top             =   2280
               Width           =   975
            End
            Begin VB.TextBox Txt_Conv 
               Height          =   285
               Left            =   3480
               TabIndex        =   80
               Top             =   1920
               Width           =   975
            End
            Begin VB.TextBox Txt_Otros 
               Height          =   285
               Left            =   3480
               TabIndex        =   79
               Top             =   2280
               Width           =   975
            End
            Begin VB.TextBox Txt_TotalCupon 
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   285
               Left            =   1200
               TabIndex        =   78
               Top             =   2640
               Width           =   975
            End
            Begin VB.Label Label12 
               Caption         =   "Rut"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   94
               Top             =   240
               Width           =   495
            End
            Begin VB.Label Label14 
               Caption         =   "Nombre"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   93
               Top             =   600
               Width           =   975
            End
            Begin VB.Label Label16 
               Caption         =   "Arancel Total"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   92
               Top             =   960
               Width           =   1215
            End
            Begin VB.Label Label17 
               Caption         =   "Beca"
               Height          =   255
               Left            =   120
               TabIndex        =   91
               Top             =   1920
               Width           =   495
            End
            Begin VB.Label Label18 
               Caption         =   "Hermanos"
               Height          =   255
               Left            =   120
               TabIndex        =   90
               Top             =   2280
               Width           =   855
            End
            Begin VB.Label Label19 
               Caption         =   "Convenio"
               Height          =   255
               Left            =   2520
               TabIndex        =   89
               Top             =   1920
               Width           =   855
            End
            Begin VB.Label Label20 
               Caption         =   "Otros"
               Height          =   255
               Left            =   2520
               TabIndex        =   88
               Top             =   2280
               Width           =   855
            End
            Begin VB.Label Label21 
               Caption         =   "A Pagar"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   87
               Top             =   2640
               Width           =   855
            End
            Begin VB.Label Label22 
               Caption         =   "Descuentos Totales"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   86
               Top             =   1560
               Width           =   2535
            End
            Begin VB.Line Line1 
               BorderColor     =   &H80000005&
               X1              =   30
               X2              =   4915
               Y1              =   1455
               Y2              =   1455
            End
            Begin VB.Line Line5 
               BorderColor     =   &H8000000C&
               X1              =   30
               X2              =   4915
               Y1              =   1440
               Y2              =   1440
            End
         End
      End
      Begin VB.Frame Frame1 
         Height          =   3735
         Left            =   0
         TabIndex        =   28
         Top             =   2760
         Width           =   5535
         Begin VB.Frame Frame_Importar_Ant 
            Caption         =   "Carga de Achivos Txt"
            ForeColor       =   &H00FF0000&
            Height          =   2655
            Left            =   120
            TabIndex        =   99
            Top             =   840
            Visible         =   0   'False
            Width           =   5295
            Begin VB.CommandButton Txt_Imp_EliCup 
               Caption         =   "Txt Eliminación"
               Height          =   375
               Left            =   840
               TabIndex        =   106
               Top             =   1200
               Width           =   1455
            End
            Begin VB.CommandButton btn_ruta_imp 
               Caption         =   "..."
               Height          =   255
               Left            =   4920
               TabIndex        =   105
               Top             =   855
               Width           =   255
            End
            Begin VB.TextBox Txt_RutaImp 
               Height          =   285
               Left            =   120
               Locked          =   -1  'True
               TabIndex        =   104
               Top             =   840
               Width           =   4695
            End
            Begin VB.CommandButton Btn_Imp_Cup 
               Caption         =   "Txt Generación "
               Height          =   375
               Left            =   2880
               TabIndex        =   100
               Top             =   1200
               Width           =   1455
            End
            Begin MSComCtl2.DTPicker DTP_Fecha_Cup 
               Height          =   375
               Left            =   1560
               TabIndex        =   101
               Top             =   360
               Width           =   1455
               _ExtentX        =   2566
               _ExtentY        =   661
               _Version        =   393216
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Format          =   47185921
               CurrentDate     =   38434
            End
            Begin ProgBarProzent.ProgBar ProgBar_Imp 
               Height          =   375
               Left            =   120
               TabIndex        =   103
               Top             =   2160
               Width           =   5055
               _ExtentX        =   8916
               _ExtentY        =   661
            End
            Begin VB.Label Label30 
               Caption         =   "Procesando Linea "
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   11.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   109
               Top             =   1800
               Width           =   2055
            End
            Begin VB.Label Label29 
               Alignment       =   2  'Center
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   11.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H000000FF&
               Height          =   255
               Left            =   2280
               TabIndex        =   108
               Top             =   1800
               Width           =   735
            End
            Begin VB.Label Label28 
               Caption         =   "Por favor espere..."
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   11.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   3000
               TabIndex        =   107
               Top             =   1800
               Width           =   2055
            End
            Begin VB.Label Label24 
               Caption         =   "Fecha Cuponera"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   102
               Top             =   360
               Width           =   1455
            End
         End
         Begin VB.TextBox txtNroBoleta 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1920
            Locked          =   -1  'True
            TabIndex        =   44
            Top             =   2400
            Width           =   1335
         End
         Begin VB.ComboBox cmbMoneda 
            Height          =   315
            Left            =   1920
            Style           =   2  'Dropdown List
            TabIndex        =   43
            Top             =   600
            Width           =   1335
         End
         Begin VB.TextBox txtRuta 
            Height          =   285
            Left            =   120
            Locked          =   -1  'True
            TabIndex        =   42
            Top             =   240
            Width           =   3615
         End
         Begin VB.CommandButton Command2 
            Caption         =   "..."
            Height          =   255
            Left            =   3840
            TabIndex        =   41
            Top             =   255
            Width           =   255
         End
         Begin VB.ComboBox Cmb_Mes1Cuota 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2A8B2
            Left            =   1920
            List            =   "Form_Cuponeras.frx":2A8DA
            Style           =   2  'Dropdown List
            TabIndex        =   40
            Top             =   960
            Width           =   735
         End
         Begin VB.ComboBox Cmb_Anho1Cuota 
            Height          =   315
            Left            =   2760
            Style           =   2  'Dropdown List
            TabIndex        =   39
            Top             =   960
            Width           =   975
         End
         Begin VB.CheckBox Chk_Imp 
            Caption         =   "Importación"
            Height          =   255
            Left            =   4200
            Style           =   1  'Graphical
            TabIndex        =   37
            Top             =   240
            Width           =   1215
         End
         Begin VB.TextBox txtNroBoleta_Final 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   4080
            Locked          =   -1  'True
            TabIndex        =   36
            Top             =   2400
            Width           =   1335
         End
         Begin VB.ComboBox Cmb_Vcto 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2A90E
            Left            =   1920
            List            =   "Form_Cuponeras.frx":2A95D
            Locked          =   -1  'True
            Style           =   1  'Simple Combo
            TabIndex        =   35
            Top             =   3120
            Width           =   735
         End
         Begin VB.TextBox txtEntreCuotas 
            Height          =   285
            Left            =   1920
            Locked          =   -1  'True
            TabIndex        =   34
            Text            =   "1"
            Top             =   2760
            Width           =   1335
         End
         Begin VB.ComboBox Cmb_Cuota_Mes 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2A9C5
            Left            =   3000
            List            =   "Form_Cuponeras.frx":2A9ED
            Locked          =   -1  'True
            Style           =   1  'Simple Combo
            TabIndex        =   33
            Top             =   1680
            Width           =   2415
         End
         Begin VB.ComboBox Cmb_Num_cuota 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2AA4F
            Left            =   1920
            List            =   "Form_Cuponeras.frx":2AA77
            Locked          =   -1  'True
            Style           =   1  'Simple Combo
            TabIndex        =   32
            Top             =   1680
            Width           =   975
         End
         Begin VB.ComboBox cmb_Cuotas 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2AAA7
            Left            =   1920
            List            =   "Form_Cuponeras.frx":2AACC
            Style           =   2  'Dropdown List
            TabIndex        =   31
            Top             =   1320
            Width           =   735
         End
         Begin VB.ComboBox Cmb_Num_cuota_Fin 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2AAF3
            Left            =   1920
            List            =   "Form_Cuponeras.frx":2AB1B
            Locked          =   -1  'True
            Style           =   1  'Simple Combo
            TabIndex        =   30
            Top             =   2040
            Width           =   975
         End
         Begin VB.ComboBox Cmb_Cuota_Mes_Fin 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2AB4B
            Left            =   3000
            List            =   "Form_Cuponeras.frx":2AB73
            Locked          =   -1  'True
            Style           =   1  'Simple Combo
            TabIndex        =   29
            Top             =   2040
            Width           =   2415
         End
         Begin MSComCtl2.DTPicker Dtp_Fecha_Gen 
            Height          =   375
            Left            =   4200
            TabIndex        =   38
            Top             =   3240
            Width           =   1215
            _ExtentX        =   2143
            _ExtentY        =   661
            _Version        =   393216
            Format          =   47185921
            CurrentDate     =   38385
         End
         Begin MSMask.MaskEdBox txtFecDec 
            Height          =   315
            Left            =   4440
            TabIndex        =   45
            Top             =   2760
            Width           =   1005
            _ExtentX        =   1773
            _ExtentY        =   556
            _Version        =   393216
            AutoTab         =   -1  'True
            MaxLength       =   10
            Format          =   "dd/mm/yyyy"
            Mask            =   "99/99/9999"
            PromptChar      =   "_"
         End
         Begin VB.Label Label8 
            AutoSize        =   -1  'True
            Caption         =   "Fecha Pago"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Index           =   1
            Left            =   3360
            TabIndex        =   56
            Top             =   2760
            Width           =   930
         End
         Begin VB.Label Label8 
            AutoSize        =   -1  'True
            Caption         =   "Nº Inicial de Boleta"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Index           =   0
            Left            =   120
            TabIndex        =   55
            Top             =   2400
            Width           =   1485
         End
         Begin VB.Label Label5 
            AutoSize        =   -1  'True
            Caption         =   "Mes/Año 1º Cuota"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Left            =   120
            TabIndex        =   54
            Top             =   960
            Width           =   1455
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            Caption         =   "Unidad Monetaria"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Left            =   120
            TabIndex        =   53
            Top             =   600
            Width           =   1425
         End
         Begin VB.Label Label8 
            AutoSize        =   -1  'True
            Caption         =   "Generación"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Index           =   2
            Left            =   3120
            TabIndex        =   52
            Top             =   3240
            Width           =   945
         End
         Begin VB.Label Label8 
            AutoSize        =   -1  'True
            Caption         =   "Hasta la"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Index           =   3
            Left            =   960
            TabIndex        =   51
            Top             =   2040
            Width           =   630
         End
         Begin VB.Label Label6 
            AutoSize        =   -1  'True
            Caption         =   "Meses entre Cuotas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Left            =   120
            TabIndex        =   50
            Top             =   2760
            Width           =   1695
         End
         Begin VB.Label Label7 
            AutoSize        =   -1  'True
            Caption         =   "Dia de Vcto."
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Left            =   120
            TabIndex        =   49
            Top             =   3120
            Width           =   960
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            Caption         =   "Numero de Cuota"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Left            =   120
            TabIndex        =   48
            Top             =   1680
            Width           =   1440
         End
         Begin VB.Label Label3 
            Caption         =   "Nº Est. Cuotas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   47
            Top             =   1320
            Width           =   1335
         End
         Begin VB.Label Label8 
            AutoSize        =   -1  'True
            Caption         =   "Hasta la"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Index           =   4
            Left            =   3360
            TabIndex        =   46
            Top             =   2400
            Width           =   630
         End
      End
      Begin VB.Frame Frame_Establecimiento 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   2655
         Left            =   0
         TabIndex        =   12
         Top             =   0
         Width           =   5535
         Begin VB.ComboBox Cmb_Colegio_Cup 
            Height          =   315
            Left            =   2160
            Style           =   2  'Dropdown List
            TabIndex        =   22
            Top             =   270
            Width           =   3255
         End
         Begin VB.ComboBox Cmb_Part_Cup 
            Height          =   315
            Left            =   2160
            Style           =   2  'Dropdown List
            TabIndex        =   21
            Top             =   750
            Width           =   3255
         End
         Begin VB.CheckBox Chk_Empresa 
            Caption         =   "Empresa oficial"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   0
            Left            =   120
            TabIndex        =   20
            TabStop         =   0   'False
            Top             =   240
            Width           =   2055
         End
         Begin VB.TextBox Txt_CodConvBci 
            Alignment       =   1  'Right Justify
            Height          =   285
            Left            =   2160
            Locked          =   -1  'True
            TabIndex        =   19
            Top             =   1200
            Width           =   975
         End
         Begin VB.CheckBox Chk_Empresa 
            Caption         =   "Empresa Alternativa"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Index           =   1
            Left            =   120
            TabIndex        =   18
            TabStop         =   0   'False
            Top             =   720
            Width           =   2055
         End
         Begin VB.ComboBox Cmb_Anho_Cup 
            Height          =   315
            ItemData        =   "Form_Cuponeras.frx":2ABD5
            Left            =   2160
            List            =   "Form_Cuponeras.frx":2ABD7
            Style           =   2  'Dropdown List
            TabIndex        =   17
            Top             =   1920
            Width           =   975
         End
         Begin VB.TextBox Txt_ArancelBase 
            Alignment       =   1  'Right Justify
            Height          =   285
            Left            =   4440
            Locked          =   -1  'True
            TabIndex        =   16
            Top             =   1200
            Width           =   975
         End
         Begin VB.TextBox Txt_CuentaCte 
            Alignment       =   1  'Right Justify
            Height          =   285
            Left            =   2160
            Locked          =   -1  'True
            TabIndex        =   15
            Top             =   1560
            Width           =   3255
         End
         Begin VB.ComboBox Cmb_Banco 
            Height          =   315
            Left            =   2160
            Style           =   2  'Dropdown List
            TabIndex        =   14
            Top             =   2280
            Width           =   3255
         End
         Begin VB.TextBox Txt_IdPart 
            Height          =   285
            Left            =   3360
            Locked          =   -1  'True
            TabIndex        =   13
            Top             =   1920
            Width           =   855
         End
         Begin VB.Label Label15 
            Caption         =   "Año Escolar"
            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        =   27
            Top             =   1920
            Width           =   1575
         End
         Begin VB.Label Label10 
            Caption         =   "Código Convenio"
            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        =   26
            Top             =   1200
            Width           =   1815
         End
         Begin VB.Label Label13 
            Caption         =   "Arancel Base"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   3240
            TabIndex        =   25
            Top             =   1200
            Width           =   1695
         End
         Begin VB.Label Label9 
            Caption         =   "Nº Cuenta Corriente"
            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        =   24
            Top             =   1560
            Width           =   1815
         End
         Begin VB.Label Label4 
            Caption         =   "Banco Destino"
            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        =   23
            Top             =   2280
            Width           =   1575
         End
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Generar Archivo"
         Height          =   375
         Left            =   6240
         TabIndex        =   10
         Top             =   6600
         Width           =   1575
      End
      Begin VB.CommandButton Btn_Can_Cup 
         Caption         =   "Cancelar"
         Height          =   375
         Left            =   8160
         TabIndex        =   9
         Top             =   6600
         Width           =   1575
      End
      Begin VB.Frame Frame_Aluxcur 
         Caption         =   "Situación de Alumnos a Considerar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000080&
         Height          =   615
         Left            =   5640
         TabIndex        =   1
         Top             =   0
         Width           =   4935
         Begin VB.OptionButton Opt_Aluxc 
            Caption         =   "Solo Matriculados"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   3
            Top             =   240
            Width           =   2415
         End
         Begin VB.OptionButton Opt_Aluxc 
            Caption         =   "Matriculados y en Curso"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   2280
            TabIndex        =   2
            Top             =   260
            Width           =   2415
         End
      End
      Begin MSComDlg.CommonDialog cd 
         Left            =   4680
         Top             =   1800
         _ExtentX        =   847
         _ExtentY        =   847
         _Version        =   393216
      End
      Begin ProgBarProzent.ProgBar ProgBar_Cuponeras 
         Height          =   375
         Left            =   5640
         TabIndex        =   11
         Top             =   6120
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   661
      End
      Begin VB.Frame Frame_Bus 
         BorderStyle     =   0  'None
         Height          =   4935
         Index           =   1
         Left            =   5640
         TabIndex        =   57
         Top             =   1200
         Width           =   4935
         Begin VB.Frame Frame_Cursos 
            Caption         =   "Cursos"
            ForeColor       =   &H00FF0000&
            Height          =   3255
            Left            =   0
            TabIndex        =   60
            Top             =   1560
            Width           =   3855
            Begin VB.CheckBox chk_todos_cursos 
               Caption         =   "Todos los cursos"
               Height          =   255
               Left            =   240
               TabIndex        =   62
               Top             =   2760
               Width           =   1575
            End
            Begin VB.ListBox lst_cursosinf 
               Height          =   2310
               Left            =   240
               Style           =   1  'Checkbox
               TabIndex        =   61
               Top             =   360
               Width           =   1335
            End
         End
         Begin VB.Frame Frame_TipEns 
            Caption         =   "Tipo de enseñanza"
            ForeColor       =   &H00FF0000&
            Height          =   855
            Left            =   0
            TabIndex        =   58
            Top             =   600
            Width           =   3855
            Begin VB.ComboBox cmb_modalidad 
               Height          =   315
               Left            =   120
               TabIndex        =   59
               Top             =   360
               Width           =   3375
            End
         End
      End
      Begin VB.Frame Frame_GrabaCrea 
         Height          =   495
         Left            =   0
         TabIndex        =   95
         Top             =   6480
         Width           =   5535
         Begin VB.OptionButton Opt_simula 
            Caption         =   "Crear Solo Archivo Txt"
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   97
            Top             =   160
            Width           =   2295
         End
         Begin VB.OptionButton Opt_simula 
            Caption         =   "Crear Archivo y grabar en Sistema"
            Height          =   255
            Index           =   1
            Left            =   2640
            TabIndex        =   96
            Top             =   160
            Width           =   2775
         End
      End
      Begin VB.Frame Frame_Tipo_Bus 
         Height          =   615
         Left            =   5640
         TabIndex        =   4
         Top             =   600
         Width           =   4935
         Begin VB.OptionButton Opt_Tipo_Bus 
            Caption         =   "Colegio"
            Height          =   375
            Index           =   0
            Left            =   240
            TabIndex        =   8
            Top             =   160
            Width           =   855
         End
         Begin VB.OptionButton Opt_Tipo_Bus 
            Caption         =   "Curso"
            Height          =   375
            Index           =   1
            Left            =   1320
            TabIndex        =   7
            Top             =   160
            Width           =   735
         End
         Begin VB.OptionButton Opt_Tipo_Bus 
            Caption         =   "Personalizado"
            Height          =   375
            Index           =   2
            Left            =   2280
            TabIndex        =   6
            Top             =   160
            Width           =   1335
         End
         Begin VB.OptionButton Opt_Tipo_Bus 
            Caption         =   "Pendientes"
            Height          =   375
            Index           =   3
            Left            =   3720
            TabIndex        =   5
            Top             =   160
            Visible         =   0   'False
            Width           =   1095
         End
      End
      Begin VB.Label lblRuta 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   3720
         TabIndex        =   98
         Top             =   2160
         Width           =   855
      End
   End
   Begin VB.Menu Mnu_Archivo 
      Caption         =   "Archivo"
      Begin VB.Menu Mnu_Archivo_1 
         Caption         =   "Generación de Archivo para el Banco"
      End
      Begin VB.Menu Mnu_Archivo_2 
         Caption         =   "Carga de Archivo Plano en Sistema"
         Enabled         =   0   'False
      End
      Begin VB.Menu Mnu_Archivo_3 
         Caption         =   "Salir"
      End
   End
End
Attribute VB_Name = "Form_Cuponeras"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim TipoGen As Integer ' Indica el tipo de generación, por colegio, curso, apoderado.
Dim AColegios(), APartic(), CodEmpresa As String, Abancos() As Variant, CodBanco As String
Dim IndAColegios As Long, IndAPartic As Integer
Dim Particular As Boolean, NomEmpresa As String
Dim ARutBus() As String, Busqueda As Integer, AnhoProx As Boolean
Dim Tipobus As Integer, RutApo As String
Dim Anuevocurso(), SelCursos As String, Criterio As String
Dim ACuota(11) As Variant, AMes(11) As Variant
Dim Aluxcur As Boolean, Simula As Boolean
Dim FilaPaquete1, FilaPaquete2
Dim Personalizado As Boolean


Private Sub Btn_Arch_Carpeta_Click()

'For t = 1 To FilaPaquete2 - 1
'    lin = Lineastxt(Me.Grd_Paquete_Bci(0).TextMatrix(t, 7))
'    Me.Grd_Paquete_Bci (0)
'Next t''

'For t = 1 To FilaPaquete1 - 1
'    lin = Lineastxt(Me.Grd_Paquete_Bci(1).TextMatrix(t, 7))
'Next t
'MsgBox lin









'Dim ArchivoBci As String, BciCuerpo, Cabecera, BciCab
'Dim CuentaEli, CuentaGen
'' Verificar que todos los archivos sean de un solo colegio
'' esto mediante la cta cte(existente en eliminación y generación)
'' o el cod bci existente.
'For t = 1 To FilaPaquete - 1
'    'Me.Grd_Paquete_Bci.TextMatrix(t, 7) = Me.Txt_RutaImp & "\" & Trim(Me.Grd_Paquete_Bci.TextMatrix(t, 2))
'    If UCase(Me.Grd_Paquete_Bci(0).TextMatrix(t, 1)) = "ELIMINACIÓN" Then
'        'Archivo de eliminacion
'        CuentaEli = Mid(TraeLinea(Me.Grd_Paquete_Bci(0).TextMatrix(t, 7), 1), 5, 8)
'        Me.Grd_Paquete_Bci(0).TextMatrix(t, 6) = CuentaEli
'    Else
'        'Archivo de GENERACIÓN
'        Cabecera = CabeceraBci(Me.Grd_Paquete_Bci(1).TextMatrix(t, 7))
'        CtaGen = Mid(Cabecera, 39, 8)
'        BciCab = Mid(Cabecera, 11, 3)
'        BciCuerpo = Mid(TraeLinea(Me.Grd_Paquete_Bci(1).TextMatrix(t, 7), 2), 50, 3)
'        If BciCuerpo <> "000" Then ' Es Prekinder
'            Colegio = devuelvecampo("hist_cod_colegio", "", "nombre", "cod_conv_bci ='" & BciCab & "'", conn)
'            Ubicacion = devuelvecampo("hist_cod_colegio", "", "nombre", "cod_conv_bci ='" & BciCuerpo & "'", conn)
'        Else ' Es Boston
'            Colegio = devuelvecampo("hist_cod_colegio", "", "nombre", "cod_conv_bci ='" & BciCab & "'", conn)
'            Ubicacion = Colegio
'        End If
'        Me.Grd_Paquete_Bci(1).TextMatrix(t, 6) = CtaGen
'
'    End If
'
'Next t
'If (ctaeli <> "" And CtaGen <> "") And ctaeli <> "" And CtaGen Then
'    MsgBox "Cuentas Corrientes de archivos seleccionado no concuerdan", vbCritical, "Alerta de Validación"
'    Exit Sub
'End If
'mostrar los colegios


End Sub

Private Sub Btn_Can_Cup_Click()
Unload Me
End Sub

Private Sub Btn_Imp_Cup_Click()
If Me.Txt_CodConvBci <> "" And Me.Txt_CuentaCte <> "" And Me.Cmb_Banco <> "" Then
    If Me.Txt_RutaImp <> "" Then
        lin = Lineastxt(Me.Txt_RutaImp)
        Me.ProgBar_Imp.MaxValue = lin
        Me.ProgBar_Imp.ShowProgress 0
        Dim AbarraImp As Integer
        'Me.Lbl_Procesando.Visible = True
        'Me.lbl_linea.Visible = True
        'Me.lbl_Espere.Visible = True
        Dim Numeroarchivo As Integer, NLinea As Integer, TotCuotas As Integer
        Dim ValorCupon As Long, MesCupon As String
        Dim NumCupon As String, ICuota As Integer
        NLinea = 1
        Numeroarchivo = FreeFile
        AbarraImp = 0
        'If Dir$(Archivo) <> "" Then
            Open Me.Txt_RutaImp For Input As #Numeroarchivo
                While Not EOF(Numeroarchivo)
                    Line Input #Numeroarchivo, linea
                    If Trim(linea) <> "" Then
                        ' Si linea es mas larga de lo normal 80 debo recortar el nombre posicion 13 largo 20
                        ' ya que se alarga cuando el nombre tiene caracteres no validos
                        ' que son reemplazados.
                        If Len(linea) > 80 Then
                            dif = Len(linea) - 80
                            l = Mid(linea, 1, 12) & Mid(linea, 13, 20) & Mid(linea, 33 + dif, 80 - (32 + dif) + 1)
                            linea = l
                        End If
                        'Me.lbl_linea.Caption = NLinea ': Me.Lbl_Linea.Refresh
                        'Me.txt_cuponeras = linea
                    'If NLinea = 1 Then
                            'BolInicial = Mid(linea, 70, 11)
                            'TotCuotas = Val(Mid(Linea, 47, 2))
                     If NLinea > 1 Then
                            cuotainicial = Val(Mid(linea, 57, 2))
                            TotCuotas = (10 - cuotainicial) + 1
                            RutApo = Mid(linea, 4, 8) & "-" & Mid(linea, 12, 1)
                            If Left(RutApo, 1) = "0" Then
                                If Not ExistReg("apoderados", "rut_apo ='" & RutApo & "'", conn) Then
                                    RutApo = Mid(RutApo, 2, Len(RutApo) - 1)
                                End If
                            End If
                            'If RutApo = "15494585-7" Then MsgBox ("AQUI")
                            Colegio = AColegios(Me.Cmb_Colegio_Cup.ListIndex)
                            agno = Me.Cmb_Anho_Cup
                            fechavenc = Format(Mid(linea, 59, 2) & "-" & Mid(linea, 61, 2) & "-" & Mid(linea, 63, 2), "yyyy/mm/dd")
                            ValorCupon = Val(Mid(linea, 33, 9))
                            NumCupon = Mid(linea, 48, 11)
                            ICuota = ValorenArray(ACuota, Right(Trim(NumCupon), 2))
                            MesCupon = AMes(ICuota)
                            'Descomentar
                            FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & RutApo & "' and colegio ='" & CodEmpresa & "'", conn)
                            If FolioCuponera = "" Then ' No Existe cuponera
                                conn.Execute "insert into fnza_cuponeras (rut_apo, colegio, agno, mes_1, banco, fecha_gen, can_cupon) values('" & RutApo & "' , '" & CodEmpresa & "' ," & CInt(Me.Cmb_Anho_Cup) & " , " & CInt(MesCupon) & " , '" & CodBanco & "' , '" & InvierteFecha(Me.DTP_Fecha_Cup.Value, "R") & "' , 11 )" '" & TotCuotas & ")" 11 cuotas del cupon 1 cupon 00 a crear
                                FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & RutApo & "'and colegio ='" & CodEmpresa & "'", conn)
                                Call InsCupones(CLng(FolioCuponera), CInt(TotCuotas), CStr(NumCupon), CInt(MesCupon), InvierteFecha(CDate(fechavenc), "R"), ValorCupon)
                            Else
                                Call InsCupones(CLng(FolioCuponera), CInt(TotCuotas), CStr(NumCupon), CInt(MesCupon), InvierteFecha(CDate(fechavenc), "R"), ValorCupon)
                            End If
                            ' comentar linea para no alterar aux_men_apo_x_alu
                            'sValor = CuotaApo(RutApo, CodEmpresa, CInt(Me.Cmb_Anho_Cup), AnhoProx) ' GetValorCuota(sCodEns)
                        End If
                        NLinea = NLinea + 1
                    End If
                    AbarraImp = AbarraImp + 1
                    Me.ProgBar_Imp.ShowProgress AbarraImp
                   DoEvents
                Wend
            Close #Numeroarchivo
            'Me.Lbl_Procesando.Visible = True
            'Me.lbl_linea.Visible = True
            'Me.lbl_Espere.Visible = True
            MsgBox ("Fin del proceso")
    Else
        Call validatexto(Me.Txt_RutaImp, "Seleccione Archivo TXT Cuponeras de Importación")
    End If
Else
    MsgBox ("Faltan opciones por completar")
End If
End Sub

Private Sub Btn_Imp_Ok_Click()
If Me.Txt_RutaImp <> "" Then
    'Me.Lbl_Procesando.Visible = True
    'Me.lbl_linea.Visible = True
    'Me.lbl_Espere.Visible = True
    Dim Numeroarchivo As Integer
    Numeroarchivo = FreeFile
    NLinea = 1
    'If Dir$(Archivo) <> "" Then
        Open Me.Txt_RutaImp For Input As #Numeroarchivo
            While Not EOF(Numeroarchivo)
                Line Input #Numeroarchivo, linea1
                If Trim(linea) <> "" Then
                    'Me.lbl_linea.Caption = NLinea: Me.lbl_linea.Refresh
                    conn.Execute "replace into apo_pago_contado (rut_apo, agno) values ('" & linea1 & "' , " & Me.Cmb_Anho_Cup & ")"
                    NLinea = NLinea + 1
                End If
            Wend
        Close #Numeroarchivo
        MsgBox ("Fin del proceso")
        'Me.Lbl_Procesando.Visible = True
        'Me.lbl_linea.Visible = True
        'Me.lbl_Espere.Visible = True
Else
    Call validatexto(Me.Txt_RutaImp, "Seleccione Archivo con rut correspondiente a pagos contado")
End If
End Sub

Private Sub Btn_Imp_txt_cup_Click()

End Sub

Private Sub btn_ruta_imp_Click()
    Dim file As String, objText As Control, i As Long, strMsg As String, posicion As Long
   
    cd.DialogTitle = "Grabar a..."
    cd.Filter = "Archivo BCI (*.bci)|*.bci|"
    cd.ShowSave
    
    file = cd.FileName
    If Len(file) > 0 Then
        Me.Txt_RutaImp.Text = file
        For i = 1 To Len(file)
            If Mid(file, i, 1) = "\" Then
                posicion = i
            End If
        Next
        Me.lblRuta.Caption = Mid(file, 1, posicion)
    End If
End Sub

Private Sub Chk_Empresa_Click(Index As Integer)
Select Case Index
    Case 0
        If Me.Chk_Empresa(Index).Value Then
            Me.Chk_Empresa(1).Value = 0
            Particular = False
        Else
            Me.Chk_Empresa(1).Value = 1
            Particular = True
        End If
        'Me.Chk_Empresa(1).Value = IIf(Me.Chk_Empresa(Index).Value = 0, 1, 0)
    
    Case 1
        If Me.Chk_Empresa(Index).Value Then
            Me.Chk_Empresa(0).Value = 0
            Particular = True
        Else
            Me.Chk_Empresa(0).Value = 1
            Particular = False
        End If
        'Me.Chk_Empresa(0).Value = IIf(Me.Chk_Empresa(Index).Value = 0, 1, 0)
End Select
'Particular = IIf(Index = 0, False, True)
Me.Txt_CodConvBci = IIf(Particular, devuelvecampo("hist_cod_colegio", "", "cod_conv_bci", "colegio ='" & APartic(IndAPartic) & "'", conn), devuelvecampo("hist_cod_colegio", "", "cod_conv_bci", "colegio ='" & AColegios(IndAColegios) & "'", conn))
Me.Txt_IdPart = IIf(Particular, devuelvecampo("hist_cod_colegio", "", "cod_conv_bci", "colegio ='" & AColegios(IndAColegios) & "'", conn), "")
Me.Txt_CuentaCte = IIf(Particular, devuelvecampo("fnza_cod_cta_cte", "", "cta_cte", "colegio ='" & APartic(IndAPartic) & "'", conn), devuelvecampo("fnza_cod_cta_cte", "", "cta_cte", "colegio ='" & AColegios(IndAColegios) & "'", conn))
NomEmpresa = IIf(Particular, Me.Cmb_Part_Cup, Me.Cmb_Colegio_Cup)
CodEmpresa = IIf(Particular, APartic(IndAPartic), AColegios(IndAColegios))
Me.Txt_ArancelBase = IIf(Particular, devuelvecampo("fnza_descuento", "", "arancel_base", "colegio='" & APartic(IndAPartic) & "'", conn), devuelvecampo("fnza_descuento", "", "arancel_base", "colegio='" & AColegios(IndAColegios) & "'", conn))
If Particular Then
    Me.Cmb_Colegio_Cup.BackColor = &H80000005
    Me.Cmb_Part_Cup.BackColor = &HC0FFFF
Else
    Me.Cmb_Colegio_Cup.BackColor = &HC0FFFF
    Me.Cmb_Part_Cup.BackColor = &H80000005
End If
End Sub

Private Sub Chk_Imp_Click()
Me.Frame_Importar_Ant.Visible = Me.Chk_Imp.Value
End Sub

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

Private Sub Cmb_Anho_Cup_Click()
If Trim(Me.Cmb_Num_cuota) <> "" And Trim(Me.Cmb_Anho_Cup) <> "" Then
    Me.txtNroBoleta = Trim(Txt_IdPart) & Trim(Me.Cmb_Anho_Cup & Me.Cmb_Num_cuota)
   
End If
End Sub

Private Sub Cmb_Anho1Cuota_Click()
If Trim(Me.Cmb_Vcto) <> "" And Trim(Me.Cmb_Mes1Cuota) <> "" And Trim(Me.Cmb_Anho1Cuota) <> "" Then
    Me.txtFecDec.Text = Me.Cmb_Vcto & "/" & Me.Cmb_Mes1Cuota & "/" & Me.Cmb_Anho1Cuota
End If
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.Chk_Empresa(0).Enabled = True
Else
    Me.Chk_Empresa(0).Enabled = False
End If

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

Private Sub cmb_Cuotas_Click()
If Me.cmb_Cuotas.ListIndex >= 0 Then
    If Me.Cmb_Num_cuota.ListIndex >= 0 Then
        If (Val(Me.Cmb_Num_cuota) + Val(Me.cmb_Cuotas) - 1) <= 10 Then
            Me.Cmb_Num_cuota_Fin.ListIndex = Val(Me.Cmb_Num_cuota) + Val(Me.cmb_Cuotas) - 1
            Me.txtNroBoleta_Final = Trim(Txt_IdPart) & Trim(Me.Cmb_Anho_Cup & FillconStr(str(Val(Me.Cmb_Num_cuota) + Val(Me.cmb_Cuotas) - 1), 2, "0", "izq"))
        Else
            MsgBox ("Nº Cuotas no válidas")
        End If
    End If
End If
End Sub

Private Sub Cmb_Mes1Cuota_Click()
If Trim(Me.Cmb_Vcto) <> "" And Trim(Me.Cmb_Mes1Cuota) <> "" And Trim(MeCmb_Anho1Cuota) <> "" Then
    Me.txtFecDec.Text = Me.Cmb_Vcto & "/" & Me.Cmb_Mes1Cuota & "/" & Me.Cmb_Anho1Cuota
End If
If Me.Cmb_Mes1Cuota.ListIndex >= 0 Then
    Me.Cmb_Num_cuota.ListIndex = Me.Cmb_Mes1Cuota.ListIndex - 1
End If
End Sub

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

Private Sub Cmb_Num_cuota_Click()
Me.Cmb_Cuota_Mes.ListIndex = Me.Cmb_Num_cuota.ListIndex
If Trim(Me.Cmb_Num_cuota) <> "" And Trim(Me.Cmb_Anho_Cup) <> "" Then
    
    Me.txtNroBoleta = Trim(Txt_IdPart) & Trim(Me.Cmb_Anho_Cup & Me.Cmb_Num_cuota)
End If

End Sub

Private Sub Cmb_Num_cuota_Fin_Click()
Me.Cmb_Cuota_Mes_Fin.ListIndex = Me.Cmb_Num_cuota_Fin.ListIndex
'If Me.Cmb_Anho_Cup <> "" And Me.cmb_Cuotas <> "" Then
'    Me.txtNroBoleta_Final = Trim(Me.Cmb_Anho_Cup & str(Val(Me.Cmb_Num_cuota) + Val(Me.cmb_Cuotas) - 1))
'End If
End Sub

Private Sub Cmb_Part_Cup_Click()
IndAPartic = Me.Cmb_Part_Cup.ListIndex
If IndAPartic >= 0 Then
    Me.Chk_Empresa(1).Enabled = True
Else
    Me.Chk_Empresa(1).Enabled = False
End If
End Sub

Private Sub Cmb_Vcto_Click()
If Trim(Me.Cmb_Vcto) <> "" And Trim(Me.Cmb_Mes1Cuota) <> "" And Trim(Me.Cmb_Anho1Cuota) <> "" Then
    Me.txtFecDec.Text = Me.Cmb_Vcto & "/" & Me.Cmb_Mes1Cuota & "/" & Me.Cmb_Anho1Cuota
End If
End Sub

Private Sub Command1_Click()
Dim Autoriz As String, CritPersonalizado As String
Personalizado = False
CritPersonalizado = ""
Autoriz = InputBox("Ingrese Codigo de autorizacion", "Ingrese Código de autorización")
If Autoriz = "admin.2005" Then
    Me.Frame_GrabaCrea.Enabled = False
    If Me.Txt_CodConvBci <> "" And Me.Txt_CuentaCte <> "" And Me.cmb_Cuotas <> "" And Me.txtEntreCuotas <> "" And Me.txtFecDec <> "" And Me.txtNroBoleta <> "" And Me.Cmb_Mes1Cuota <> "" And Me.Cmb_Anho1Cuota <> "" And Me.txtRuta <> "" And Me.Cmb_Vcto <> "" And Me.Cmb_Num_cuota <> "" And Me.Cmb_Banco <> "" Then
        If Me.Opt_Aluxc(0).Value Or Me.Opt_Aluxc(1).Value Then
            Aluxcur = IIf(Me.Opt_Aluxc(1).Value, True, False) ' Si está marcado matriculados y en curso
        Else
            MsgBox "Seleccione situación de Alumnos a considerar"
            Exit Sub
        End If
            Select Case TipoGen
                Case 0
                    Criterio = "" ' Trae todos los apoderados del colegio
                Case 1
                    If Me.lst_cursosinf.SelCount > 0 And Me.cmb_modalidad <> "" Then
                        Call ArmaCursos ' Arma cadenas de cursos a buscar para consulta sql.
                        Criterio = SelCursos ' asigna cadena a variable.
                    Else
                        MsgBox ("Seleccione curso(s).")
                        Exit Sub
                    End If
                Case 2
                    If Val(Me.Txt_TotalCupon) > 0 And Trim(Me.Txt_RutApo) <> "" Then
                        Criterio = " and a.rut_apo ='" & Me.Txt_RutApo & "' "
                        CritPersonalizado = " and rut_cli ='" & Me.Txt_RutApo & "' "
                        Personalizado = True
                    ElseIf Trim(Me.Txt_RutApo) = "" Then
                        MsgBox ("Seleccione Apoderado.")
                        Exit Sub
                    ElseIf Val(Me.Txt_TotalCupon) = 0 Then
                        MsgBox ("Imposible Generar Cupones con Valor 0.")
                        Exit Sub
                    End If
            End Select
            If MsgBox("¿ Desea Continuar ? ", vbYesNo + vbQuestion, "Generación de Cupones") = vbYes Then
                ' Llamar al sub de conexión
                If TablaTemp Then
                    If DatosExternos(CritPersonalizado) Then
                        Call registro1
                        Call Apoderados(Aluxcur)
                    Else
                        MsgBox ("No fue posible Rescatar los Datos de Cupones Pagados")
                        Exit Sub
                    End If
                Else
                    MsgBox ("No fue posible crear tabla temporal")
                    Exit Sub
                End If
            End If
    Else
        MsgBox ("Faltan opciones por completar")
    End If
Else
    MsgBox ("Código incorrecto. Consulte con el administrador del Sistema")
End If
Me.Frame_GrabaCrea.Enabled = True
End Sub

Private Sub Apoderados(Aluxcur As Boolean)
    Dim sql As String, sMatricula As String, sCte As String, ValorCupon As Long
    Dim ApoSinAnu As Integer, ApoConAnu As Integer, FolioCuponera, CupoElim As Integer, CupoModi As Integer
    Dim ValoresApo As Variant, Cuponera As Variant
    Dim Rehacer As Boolean, sValor As Variant, ValorApo As Long
    
    Dim CuponInicial As Integer, Cu As Integer
    Dim BolInicial As String, MesInicial As Integer, MesFinal As Integer
    Dim NewNCupones As Integer, NewFecPago As String
    Dim NewCuotas As Integer
    
    ' Consulta cambiada para uso de tabla matriculas en reemplazo de alu_x_cur
    '
    If Aluxcur Then
        sql = "select distinct a.rut_apo, a.noms_apo, a.ape1_apo, a.ape2_apo from apoderados a, apo_x_alu ap, alu_x_cur ac where a.rut_apo = ap.rut_apo AND ap.ci_alu=ac.ci_alu AND ap.agno=ac.agno AND ap.agno=" & Cmb_Anho_Cup.Text & " AND ac.activo_alu = 'SI' " & Criterio & " order by a.rut_apo"
    Else
        sql = "select distinct a.rut_apo, a.noms_apo, a.ape1_apo, a.ape2_apo from apoderados a, apo_x_alu ap, matriculas ac where a.rut_apo = ap.rut_apo AND ap.ci_alu=ac.ci_alu  AND ap.agno=ac.anno_mat AND ap.agno=" & Cmb_Anho_Cup.Text & " AND ac.activo_alu = 'SI' " & Criterio & " order by a.rut_apo"
    End If
    Set Rs = New ADODB.Recordset
    Rs.CursorLocation = adUseClient
    Rs.Open sql, conn, adOpenDynamic, adLockOptimistic, adCmdText
    Me.ProgBar_Cuponeras.Zusatztext = "% Generado"
    Me.ProgBar_Cuponeras.ShowProgress 0
    Me.ProgBar_Cuponeras.MaxValue = Rs.RecordCount
    ApoSinAnu = 0: ApoConAnu = 0: CupoElim = 0: CupoModi = 0
    If Rs.RecordCount > 0 Then
        For t = 1 To Rs.RecordCount
            If Not IsNull(Rs!Rut_apo) Then
                'If Rs!rut_apo = "06697351-4" Then MsgBox (Rs!rut_apo)
                'Si no pagó al contado
                If Not ExistReg("apo_pago_contado", "rut_apo ='" & Rs!Rut_apo & "'", conn) Then
                    
                    'Aquí traigo el primer cupón pendiente de la cuponera
                    'y desde ese empiezo a trabajar
                    For Cu = Val(Me.Cmb_Num_cuota) To Val(Me.Cmb_Num_cuota_Fin)
                        If Not ExistReg("TMP_CUPONERAS", "rut_cli = '" & Rs!Rut_apo & "' and agno = " & Val(Me.Cmb_Anho_Cup) & " and num_cup = " & Cu, conn) Then
                            CuponInicial = Cu
                            Exit For
                         Else
                            infop = "Apoderado -> " & Rs!Rut_apo & " " & Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo & " -> Cupón Nº " & Cu & " Año " & Me.Cmb_Anho_Cup & " no se tocará ya que está Pagado."
                            Call CreateFile(infop, Me.lblRuta.Caption & "LogCupoPagados.txt")
                         End If
                    Next Cu
                    ' Si hay cupones pendientes a tratar
                    If CuponInicial <= Val(Me.Cmb_Num_cuota_Fin) Then
                        MesInicial = CuponInicial + 2
                        MesFinal = Val(Me.Cmb_Num_cuota_Fin) + 2
                        BolInicial = Me.Cmb_Anho_Cup & Me.Cmb_Num_cuota.List(CuponInicial)
                        NewNCupones = (Val(Me.Cmb_Num_cuota_Fin) - CuponInicial) + 1
                        NewFecPago = Format(CDate(Year(Me.txtFecDec.Text) & "-" & MesInicial & "-" & Day(Me.txtFecDec)), "dd-mm-yyyy")
                        sfechapago = Format(NewFecPago, "ddmmyy")
                        snroboleta = Largo(Me.Txt_IdPart & BolInicial, 11)
                        sClte = Tamaño(Mid(Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo, 1, 20), 20)
                        sMatricula = separarut(Rs!Rut_apo) & separadigito(Rs!Rut_apo)
                        sMatricula = Largo(sMatricula, 11)
                        sFiller = "              "
                        'Trae valores de fnza_mensualidad del mes del primer cupón no pagado
                        ValoresApo = CuotaApo(Rs!Rut_apo, CodEmpresa, CInt(Me.Cmb_Anho_Cup), MesInicial, Aluxcur) ' GetValorCuota(sCodEns)
                        ValorApo = ValoresApo(6)
                        If ValorApo > 0 Then
                            sValor = ValorApo
                            sValor = Largo(Replace(addCeros(sValor, 3), ",", ""), 12)
                            ValorCupon = sValor1
                            reg2 = "2" & sMatricula & sClte & sValor & Largo(Trim(str(NewNCupones)), 3) & snroboleta & sfechapago & Largo(txtEntreCuotas, 2) & sFiller
                            FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & Rs!Rut_apo & "' and colegio ='" & CodEmpresa & "'", conn)
                            'Pregunto si existe cuponera.
                            If FolioCuponera = "" Then 'Si no tiene cuponera
                                If Not Simula Then
                                    'Le genero una en la bdd y agrego al txt.
                                    'solo si elijo grabar datos en tablas
                                    conn.Execute "insert into fnza_cuponeras (rut_apo, colegio, agno, mes_1, banco, fecha_gen, can_cupon) values('" & Rs!Rut_apo & "' , '" & CodEmpresa & "' ," & CInt(Me.Cmb_Anho_Cup) & " , " & CInt(Me.Cmb_Mes1Cuota) & " , '" & CodBanco & "' , '" & InvierteFecha(Me.Dtp_Fecha_Gen.Value, "R") & "' , " & Val(Me.cmb_Cuotas) & ")"
                                    FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & Rs!Rut_apo & "' and colegio ='" & CodEmpresa & "'", conn)
                                    'Inserto los cupones
                                    'InsCupones CLng(FolioCuponera), CInt(Me.cmb_Cuotas), CStr(snroboleta), CInt(Me.Cmb_Num_cuota.ItemData(Me.Cmb_Num_cuota.ListIndex)), InvierteFecha(CDate(txtFecDec.Text), "R"), ValorCupon
                                    Call InsCupones(CLng(FolioCuponera), NewNCupones, Trim(BolInicial), MesInicial, InvierteFecha(CDate(NewFecPago), "R"), ValorApo)
                                End If
                                'Agrego movimiento al txt.
                                Call CreateFile(reg2, txtRuta.Text)
                                ApoConAnu = ApoConAnu + 1
                            Else 'Ya tiene cuponera
                                Cuponera = TraeCupon(Rs!Rut_apo, CodEmpresa, Val(Me.Cmb_Anho_Cup), MesInicial, CodBanco, conn)
                                ' traer nuevo valor
                                
                                
                                If Not IsNull(Cuponera(1)) And Cuponera(7) <> ValorApo And (ValorApo <> 0) Then
                                    'Si Montos son diferentes
                                    If Not Simula Then
                                        'Actualizo cupones en bdd, genero archivos de creación y de eliminación.
                                        'solo si elijo grabar datos en tablas
                                        Call EliminarCupon(Rs!Rut_apo, MesInicial, MesFinal)
                                        Call InsCupones(CLng(FolioCuponera), NewNCupones, Trim(BolInicial), MesInicial, InvierteFecha(CDate(NewFecPago), "R"), ValorApo)
                                    End If
                                    Call TxtElimin(Rs!Rut_apo, BolInicial, Me.txtNroBoleta_Final)
                                    Call CreateFile(reg2, txtRuta.Text)
                                    CupoModi = CupoModi + 1
                                    info = ApoSinAnu & ".- Apoderado -> " & Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo & " Cupones Modificados de " & Cuponera(7) & " a " & ValorApo
                                    Call CreateFile(info, Me.lblRuta.Caption & "LogCuponeras.txt")
                                    infob = CupoModi & ".- Normalizar.- Apoderado -> " & Rs!Rut_apo & " " & Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo & " Cupones " & CuponInicial & " al " & Me.Cmb_Num_cuota_Fin & " Modificados de " & Cuponera(7) & " a " & ValorApo
                                    Call CreateFile(infob, Me.lblRuta.Caption & "LogCupoModif.txt")
                                ElseIf IsNull(Cuponera(1)) Then ' Si no tiene cupon
                                    If Not Simula Then
                                        'No encontro ni pagado ni pendiente, los creo
                                        'solo si elijo grabar datos en tablas
                                        Call InsCupones(CLng(FolioCuponera), NewNCupones, Trim(BolInicial), MesInicial, InvierteFecha(CDate(NewFecPago), "R"), ValorApo)
                                    End If
                                    ' Genero archivos de creación
                                    Call CreateFile(reg2, txtRuta.Text)
                                    ApoConAnu = ApoConAnu + 1
                                Else
                                    'Entrar acá solo si se seleccionó la opción personalizado
                                    If Personalizado Then
                                        If MsgBox("Montos Iguales, Valor Cuponera       : " & Cuponera(7) & Chr(13) & _
                                                "                Valor Actual Sistema : " & ValorApo & Chr(13) & _
                                                "Situación de valores se encuentra OK." & Chr(13) & "Es posible que quiera generar el txt por otro motivo, ¿Desea generar el txt de todas formas?", vbYesNo, "Alerta de Validación") = vbYes Then
                                            Call CreateFile(reg2, txtRuta.Text)
                                            info = ApoSinAnu & ".- Apoderado -> " & Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo & " Se generó registro de generación sin tener diferencia en montos " & Cuponera(7) & ", el motivo puede ser error en los datos del apoderado."
                                            Call CreateFile(info, Me.lblRuta.Caption & "LogCuponerasForc.txt")
                                            ApoConAnu = ApoConAnu + 1
                                        End If
                                    End If
                                End If
                            End If
                        
                        Else
                            ' Preguntar si tiene cuponera y a pagar 0 -> Eliminar cupones
                            FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & Rs!Rut_apo & "' and colegio ='" & CodEmpresa & "'", conn)
                            If FolioCuponera <> "" Then 'Si tiene cuponera
                                Cuponera = TraeCupon(Rs!Rut_apo, CodEmpresa, Val(Me.Cmb_Anho_Cup), MesInicial, CodBanco, conn)
                                If Not IsNull(Cuponera(1)) And UCase(Cuponera(8)) = "PE" Then
                                    If Not Simula Then
                                        Call EliminarCupon(Rs!Rut_apo, MesInicial, MesFinal)
                                    End If
                                    Call TxtElimin(Rs!Rut_apo, BolInicial, Me.txtNroBoleta_Final)
                                    CupoElim = CupoElim + 1
                                    info = ApoSinAnu & ".- Apoderado -> " & Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo & " Cupones Eliminados"
                                    Call CreateFile(info, Me.lblRuta.Caption & "LogCuponeras.txt")
                                End If
                            Else
                                ApoSinAnu = ApoSinAnu + 1
                                info = ApoSinAnu & ".- Apoderado -> " & Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo & " Con anualidad 0 "
                                Call CreateFile(info, Me.lblRuta.Caption & "LogCuponeras.txt")
                            End If
                        End If
                    End If
                Else
                    ApoSinAnu = ApoSinAnu + 1
                    info = ApoSinAnu & ".- Apoderado -> " & Rs!ape1_apo & " " & Rs!ape2_apo & " " & Rs!Noms_Apo & " Pago al Contado"
                    Call CreateFile(info, Me.lblRuta.Caption & "LogCuponeras.txt")
                End If
            End If
            Rs.MoveNext
            Me.ProgBar_Cuponeras.ShowProgress t
            DoEvents
        Next t
    End If
    info = "Datos Generación:  Fecha -> " & Date & " Hora -> " & Time & " Cupones desde " & Me.Cmb_Cuota_Mes & " hasta " & Me.Cmb_Cuota_Mes_Fin
    Call CreateFile(info, Me.lblRuta.Caption & "LogCuponeras.txt")
    info = "Total Apoderados -> " & Rs.RecordCount & " : Cuponeras Nuevas Generadas -> " & ApoConAnu & " Cuponeras Eliminadas por anualidad 0 -> " & CupoElim & " Cuponeras Modificadas -> " & CupoModi
    Call CreateFile(info, Me.lblRuta.Caption & "LogCuponeras.txt")
    Set Rs = Nothing
End Sub

Private Sub registro1()
    Dim Reg1 As String, CabActual As String
    'Dim sql As String
    'sql = "SELECT NOM_EST FROM establecimientos "
    'Set rs = New ADODB.Recordset
    'rs.CursorLocation = adUseClient
    'rs.Open sql, oCon, adOpenDynamic, adLockOptimistic, adCmdText
    'If Not rs.EOF Then
    'If Not IsNull(rs!NOM_EST) Then
    'End If
    'Set rs = Nothing
    'Si tiene cabecera, no le debe crear otra
    CabActual = CabeceraBci(Me.txtRuta.Text)
    sempresa = Tamaño("CONV BCI " & Trim(Me.Txt_CodConvBci) & " " & Mid(UCase(NomEmpresa), 1, 37), 37)
    sCtaCte = Me.Txt_CuentaCte 'Cuenta Corriente
    sNroCuotas = Largo(cmb_Cuotas.Text, 2)
    sValor = Me.Txt_ArancelBase
    sValor = Largo(Replace(addCeros(sValor, 3), ",", ""), 12)
    sEntreCuotas = Largo(txtEntreCuotas.Text, 2)
    sDiaVcto = Largo(Me.Cmb_Vcto.Text, 2)
    snroboleta = Largo(txtNroBoleta.Text, 11)
    
    Reg1 = "1" & sempresa & sCtaCte & sNroCuotas & cmbMoneda.ListIndex _
            & sValor & Me.Cmb_Mes1Cuota & Format(Me.Cmb_Anho1Cuota, "yy") & sEntreCuotas & sDiaVcto & snroboleta
    ' Si los primeros 38 caracteres de la cabecera del archivo actual son iguales
    ' a los 38 caracteres de la cabecera generada para esta emisión. No se crea cabecera.
    ' de lo contrario si, lo que nos alertaría de un error
    
    If CabActual = "" Then
        Call CreateFile(Reg1, txtRuta.Text)
    Else
        If (Mid(CabActual, 1, 38) <> Mid(Reg1, 1, 38)) Then
            MsgBox ("Cabecera de archivo seleccionado no corresponde al Colegio en proceso." & Chr(13) & _
                "Cab. Archivo Seleccionado : " & Mid(Reg1, 1, 38) & Chr(13) & _
                "Cab. Generada por Proceso : " & Mid(CabActual, 1, 38) & Chr(13) & _
                "Sírvase a revisar")
            Call CreateFile(Reg1, txtRuta.Text)
        End If
    End If
End Sub
Private Function GetValorCuota(ByVal cod As String) As Double
    Dim sql As String, Rs As ADODB.Recordset
    
    sql = "SELECT mensual FROM `arancel` WHERE COD_ENS = '" & cod & "' "
    Set Rs = New ADODB.Recordset
    Rs.CursorLocation = adUseClient
    Rs.Open sql, conn, adOpenDynamic, adLockOptimistic, adCmdText
    If Not Rs.EOF Then
        If Not IsNull(Rs!Mensual) Then GetValorCuota = Rs!Mensual
    End If
    Rs.Close
    Set Rs = Nothing
End Function
Private Sub Command2_Click()
    Dim file As String, objText As Control, i As Long, strMsg As String, posicion As Long
   
    cd.DialogTitle = "Grabar a..."
    cd.Filter = "Archivo BCI (*.bci)|*.bci|"
    cd.ShowSave
    
    file = cd.FileName
    If Len(file) > 0 Then
        txtRuta.Text = file
        For i = 1 To Len(file)
            If Mid(file, i, 1) = "\" Then
                posicion = i
            End If
        Next
        Me.lblRuta.Caption = Mid(file, 1, posicion)
    End If
    
    
End Sub



Private Sub Dir_Arch_cup_Change()
'Me.Txt_RutaImp = Me.Dir_Arch_cup.Path
   Dim fs, f, f1, fc, s, TProceso
    Call IniciaGrillaPaquete
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(Me.Dir_Arch_cup.Path)
    Set fc = f.Files
    FilaPaquete1 = 1: FilaPaquete2 = 1
    For Each f1 In fc
        If UCase(Right(f1.Name, 4)) = ".BCI" Then
            If Trim(UCase(Left(f1.Name, 7))) = "ELIMINA" Then
                TProceso = "ELIMINACIÓN"
                Me.Grd_Paquete_Bci(0).AddItem ""
                Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 0) = FilaPaquete1
                Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 1) = TProceso
                Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 2) = f1.Name
                Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 3) = f1.Size
                Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 4) = f1.DateLastModified
                Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 5) = ""
                Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 7) = Me.Dir_Arch_cup.Path & "\" & Me.Grd_Paquete_Bci(0).TextMatrix(FilaPaquete1, 2)
                FilaPaquete1 = FilaPaquete1 + 1
            Else
                TProceso = "GENERACIÓN"
                Me.Grd_Paquete_Bci(1).AddItem ""
                Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 0) = FilaPaquete2
                Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 1) = TProceso
                Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 2) = f1.Name
                Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 3) = f1.Size
                Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 4) = f1.DateLastModified
                Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 5) = ""
                Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 7) = Me.Dir_Arch_cup.Path & "\" & Me.Grd_Paquete_Bci(1).TextMatrix(FilaPaquete2, 2)
                FilaPaquete2 = FilaPaquete2 + 1
            End If
        End If
    Next
    Set fs = Nothing: Set f = Nothing: Set fc = Nothing
End Sub

Private Sub Drive_arch_cup_Change()
On Error GoTo DriveNodisp
Me.Dir_Arch_cup.Path = Me.Drive_arch_cup.Drive
Exit Sub
DriveNodisp:
MsgBox "Dispositivo No está Listo", vbCritical, "Alerta de Validación"
Me.Drive_arch_cup.Drive = "c:"
End Sub


Private Sub Form_Load()
Dim Indbci As Integer
 ACuota(1) = "00":  AMes(1) = "02" ' Febrero
 ACuota(2) = "01":  AMes(2) = "03" ' Marzo
 ACuota(3) = "02":  AMes(3) = "04" ' Abril
 ACuota(4) = "03":  AMes(4) = "05" ' Mayo
 ACuota(5) = "04":  AMes(5) = "06" ' Junio
 ACuota(6) = "05":  AMes(6) = "07" ' Julio
 ACuota(7) = "06":  AMes(7) = "08" ' Agosto
 ACuota(8) = "07":  AMes(8) = "09" ' Septiembre
 ACuota(9) = "08":  AMes(9) = "10" ' Octubre
ACuota(10) = "09": AMes(10) = "11" ' Noviembre
ACuota(11) = "10": AMes(11) = "12" ' Diciembre
Me.Width = 11940
Me.Height = 7950
    With cmbMoneda
        .AddItem "Pesos M/N", 0
        .AddItem "Dólar", 1
        .AddItem "U.F.", 2
    End With
    cmbMoneda.ListIndex = 0
Particular = False
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
Me.Cmb_Anho_Cup.AddItem Val(Anno)
Me.Cmb_Anho_Cup.AddItem Val(Anno) + 1
Me.Cmb_Anho1Cuota.AddItem Val(Anno) - 1: Me.Cmb_Anho1Cuota.AddItem Val(Anno): Me.Cmb_Anho1Cuota.AddItem Val(Anno) + 1
Me.Cmb_Vcto = "10"
Me.Dtp_Fecha_Gen.MaxDate = Date
Me.Dtp_Fecha_Gen.Value = Date
Me.Chk_Empresa(0).Enabled = False: Me.Chk_Empresa(1).Enabled = False
Me.Opt_Tipo_Bus(0).Value = True
Me.lst_busq_caja(0).Visible = False
Me.lst_busq_caja(1).Visible = False
Me.opt_criterio(0).Value = True
Me.Opt_simula(0).Value = True
Busqueda = 1
Call Mnu_Archivo_1_Click
End Sub



Private Sub lst_busq_caja_DblClick(Index As Integer)
' Debe tener seleccionado el colegio y el año
If Me.Cmb_Anho_Cup <> "" And CodEmpresa <> "" Then
    Dim Ind As Integer
    Ind = Me.lst_busq_caja(Index).ListIndex
    Me.lst_busq_caja(Index).Visible = False
    Me.Frame_datos_busqueda.Visible = False
    Me.Opt_busqueda_caj(Tipobus).Value = False
    Ind = Me.lst_busq_caja(Index).ListIndex
    Call Creagrupo(Ind)
Else
    MsgBox ("Debe Seleccionar Empresa y Año Escolar")
End If
End Sub

Private Sub Mnu_Archivo_1_Click()
Me.Caption = Mnu_Archivo_1.Caption
Call HideFramesCup
Me.Frame_Generacion_Cup.Left = 0
Me.Frame_Generacion_Cup.Top = 0
Me.Frame_Generacion_Cup.Visible = True
End Sub

Private Sub Mnu_Archivo_2_Click()
Me.Caption = Mnu_Archivo_2.Caption
Call HideFramesCup
Me.Frame_CargaTxt_Cup.Left = 0
Me.Frame_CargaTxt_Cup.Top = 0
Me.Frame_CargaTxt_Cup.Visible = True
Call IniciaGrillaPaquete
End Sub

Private Sub Mnu_Archivo_3_Click()
Unload Me
End Sub

Private Sub Opt_Aluxc_Click(Index As Integer)
Aluxcur = IIf(Me.Opt_Aluxc(1).Value, True, False) ' Si está marcado matriculados y en curso
End Sub

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

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

Private Sub Opt_simula_Click(Index As Integer)
Simula = IIf(Index = 0, True, False)
End Sub

Private Sub Opt_Tipo_Bus_Click(Index As Integer)
Call OcultaFramesBus
If Index <> 0 Then
    Me.Frame_Bus(Index).Visible = True
End If
TipoGen = Index ' Asigno a tipogen el index de selección.....
Select Case TipoGen
    Case 1
        Me.cmb_modalidad.Clear
        Call llenacombo(cmb_modalidad, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
        Me.lst_cursosinf.Clear
        Me.chk_todos_cursos.Value = 0
    Case 2
        Me.Txt_RutApo = ""
        Me.Txt_NomApo = ""
        Me.Txt_ArancelTotal = ""
        Me.Txt_Beca = ""
        Me.Txt_Conv = ""
        Me.Txt_TotalCupon = ""
        Me.Txt_Hmnos = ""
        Me.Txt_Otros = ""
    
End Select
End Sub


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

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

Private Sub Txt_Imp_EliCup_Click()
If Me.Txt_CodConvBci <> "" And Me.Txt_CuentaCte <> "" And Me.Cmb_Banco <> "" Then
    If Me.Txt_RutaImp <> "" Then
        lin = Lineastxt(Me.Txt_RutaImp)
        Me.ProgBar_Imp.MaxValue = lin
        Me.ProgBar_Imp.ShowProgress 0
        Dim AbarraImp As Integer
        'Me.Lbl_Procesando.Visible = True
        'Me.lbl_linea.Visible = True
        'Me.lbl_Espere.Visible = True
        Dim Numeroarchivo As Integer, NLinea As Integer
        Dim MesINI As Integer, MesFin As Integer, AgnoCupo As Integer
        NLinea = 1
        Numeroarchivo = FreeFile
        AbarraImp = 0
        'If Dir$(Archivo) <> "" Then
            Open Me.Txt_RutaImp For Input As #Numeroarchivo
                While Not EOF(Numeroarchivo)
                    Line Input #Numeroarchivo, linea
                    If Trim(linea) <> "" Then
                        RutApo = Mid(linea, 16, 8) & "-" & Mid(linea, 25, 1)
                        If Left(RutApo, 1) = "0" Then
                            'Si el rut empieza con cero se cerciora que exista su equivalente
                            'por ej. 09123456-7 puede que en la bdd sea 9123456-7
                            If Not ExistReg("APODERADOS", "rut_apo ='" & RutApo & "'", conn) Then
                                RutApo = Mid(RutApo, 2, Len(RutApo) - 1)
                            End If
                        End If
                        MesINI = Val(Mid(linea, 35, 2)) + 2
                        MesFin = Val(Mid(linea, 46, 2)) + 2
                        Call EliminarCupon(RutApo, MesINI, MesFin)
                        NLinea = NLinea + 1
                    End If
                    AbarraImp = AbarraImp + 1
                    Me.ProgBar_Imp.ShowProgress AbarraImp
                    DoEvents
                Wend
            Close #Numeroarchivo
            'Me.Lbl_Procesando.Visible = True
            'Me.lbl_linea.Visible = True
            'Me.lbl_Espere.Visible = True
            MsgBox ("Fin del proceso")
    Else
        Call validatexto(Me.Txt_RutaImp, "Seleccione Archivo TXT Cuponeras de Eliminacion")
    End If
Else
    MsgBox ("Faltan opciones por completar")
End If
End Sub

Private Sub txtFecDec_Validate(Cancel As Boolean)
    Dim sFecha As String
    sFecha = Me.txtFecDec.Text
    sFecha = Replace(sFecha, "_", "")
    If Len(sFecha) > 2 Then
        If IsDate(sFecha) Then
            sFecha = Fecha(sFecha)
            If Len(sFecha) = 0 Then
                MsgBox "La fecha ingresada no es valida o no corresponde" _
                    , vbExclamation, "Validación de fecha"
                Me.txtFecDec.SelStart = 0
                Me.txtFecDec.SelLength = Len(txtFecDec.Text)
                Me.txtFecDec.SetFocus
                Cancel = True
                Exit Sub
            Else
                Me.txtFecDec.Text = sFecha
            End If
        Else
            MsgBox "La fecha ingresada es incorrecta", vbExclamation _
                    , "Validación de fecha"
            Me.txtFecDec.SelStart = 0
            Me.txtFecDec.SelLength = Len(txtFecDec.Text)
            Me.txtFecDec.SetFocus
            Cancel = True
            Exit Sub
        End If
    End If
End Sub
Function CuotaApo(RutApo As String, CodEmpresa As String, Anho As Integer, Mes As Integer, Aluxcur As Boolean) As Variant()
Dim CuotaAlu As Variant, strsql As String
Dim Arancel As Long, Hermano As Long, Beca As Long
Dim Descuento As Long, Convenio As Long
Dim Total_aPagar As Long, Total_Abonado As Long
Set RsFuncion = New ADODB.Recordset
RsFuncion.CursorLocation = adUseClient
Dim Resp(1 To 7) As Variant
Arancel = 0: Hermano = 0: Beca = 0: Descuento = 0: Convenio = 0
Total_aPagar = 0: Total_Abonado = 0
' Reemplazada para usar matriculas en vez de alu_x_cur
If Aluxcur Then
    strsql = "select ac.ci_alu, a.rut_apo from apoderados a, apo_x_alu ap, alu_x_cur ac, codigos_ensenanza c where a.rut_apo = ap.rut_apo and a.rut_apo='" & RutApo & "' and ap.ci_alu=ac.ci_alu AND ap.agno=ac.agno AND ap.agno='" & Anho & "' and ac.cod_ens=c.cod_ens and ac.activo_alu = 'SI' " & CodDes
Else
    strsql = "select ac.ci_alu, a.rut_apo from apoderados a, apo_x_alu ap, matriculas ac, codigos_ensenanza c where a.rut_apo = ap.rut_apo and a.rut_apo='" & RutApo & "' and ap.ci_alu=ac.ci_alu AND ap.agno=ac.anno_mat AND ap.agno='" & Anho & "' and ac.cod_ens=c.cod_ens and ac.activo_alu = 'SI' " & CodDes
End If
RsFuncion.Open strsql, conn
TotalApo = 0
If RsFuncion.RecordCount > 0 Then
    For te = 0 To RsFuncion.RecordCount - 1
        CuotaAlu = TotalMesAlu(RsFuncion!Ci_alu, CodEmpresa, Mes, Anho, conn)
        Arancel = Arancel + IIf(IsNull(CuotaAlu(1)), 0, CuotaAlu(1))
        Hermano = Hermano + IIf(IsNull(CuotaAlu(2)), 0, CuotaAlu(2))
        Beca = Beca + IIf(IsNull(CuotaAlu(3)), 0, CuotaAlu(3))
        Descuento = Descuento + IIf(IsNull(CuotaAlu(4)), 0, CuotaAlu(4))
        Convenio = Convenio + IIf(IsNull(CuotaAlu(5)), 0, CuotaAlu(5))
        Total_aPagar = Total_aPagar + IIf(IsNull(CuotaAlu(6)), 0, CuotaAlu(6))
        Total_Abonado = Total_Abonado + IIf(IsNull(CuotaAlu(7)), 0, CuotaAlu(7))
        RsFuncion.MoveNext
    Next te
End If
RsFuncion.Close
Resp(1) = Arancel
Resp(2) = Hermano
Resp(3) = Beca
Resp(4) = Descuento
Resp(5) = Convenio
Resp(6) = Total_aPagar
Resp(7) = Total_Abonado
CuotaApo = Resp
Set RsFuncion = Nothing
End Function
Sub OcultaFramesBus()
Me.Frame_Bus(1).Visible = False
Me.Frame_Bus(2).Visible = False
End Sub
Sub ArmaCursos()
Dim Ngrado As String, Letra As String, modalidad As String, Con As Integer
Con = 0
SelCursos = ""
If Me.lst_cursosinf.SelCount > 0 And Me.cmb_modalidad.Text <> "" Then
    modalidad = devuelvecampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_modalidad.Text & "'", conn)
    For t = 0 To Me.lst_cursosinf.ListCount - 1
        If Me.lst_cursosinf.Selected(t) Then
            Con = t
        End If
    Next t
    For t = 0 To Me.lst_cursosinf.ListCount - 1
        If Me.lst_cursosinf.Selected(t) Then
            Ngrado = Anuevocurso(t, 1)
            Letra = Anuevocurso(t, 2)
            If t = Con Then
                SelCursos = SelCursos & "(ac.num_gra  = '" & Ngrado & "' and ac.let_cur = '" & Letra & "' and ac.cod_ens ='" & modalidad & "')"
            Else
                SelCursos = SelCursos & "(ac.num_gra  = '" & Ngrado & "' and ac.let_cur = '" & Letra & "' and ac.cod_ens ='" & modalidad & "')" & " or "
            End If
        End If
    Next
    SelCursos = "and (" & SelCursos & ")"
End If
End Sub
Sub Creagrupo(Indice)
Dim APValores() As Long
Me.Opt_busqueda_caj(Tipobus).Value = False
Set Rs = New ADODB.Recordset
If Tipobus = 0 Then ' Busca por apoderado
    
    Me.Txt_NomApo = ARutBus(Indice, 0) & " " & ARutBus(Indice, 1) & " " & ARutBus(Indice, 2)
    Me.Txt_RutApo = ARutBus(Indice, 3)
        
    'Call AluMatenGrilla(ARutBus(Indice, 3)) 'Ordenar Por fecha de ingreso al curso
Else
    RutApo = devuelvecampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & ARutBus(Indice, 3) & "' AND agno='" & Cmb_Anho_Cup.Text & "';", conn)
    If RutApo <> "" Then
        Rs.CursorLocation = adUseClient
        Rs.Open "select * from apoderados where rut_apo ='" & RutApo & "'", conn
        If Rs.RecordCount > 0 Then
            Me.Txt_NomApo.Text = Rs("noms_apo") & " " & Rs("ape1_apo") & " " & Rs("ape2_apo")
            Me.Txt_RutApo.Text = Rs("rut_apo")
            'Me.grd_alumat_edim.FixedCols = 0: Me.grd_alumat_edim.FixedRows = 1
            Rs.Close
            
            'Call AluMatenGrilla(RutApo)
        Else
            MsgBox ("Alumno sin apoderado, complete la ficha")
            Rs.Close
        End If
    End If
End If
RutApo = Me.Txt_RutApo
' Lleno los textbox con los valores totales que debe pagar el apoderado
'If Me.Cmb_Anho_Cup = Anno Then
'        AnhoProx = False
'ElseIf Me.Cmb_Anho_Cup > Anno Then
'        AnhoProx = True
'End If
Aluxcur = IIf(Me.Opt_Aluxc(1).Value, True, False) ' Si está marcado matriculados y en curso
ValoresApo = CuotaApo(RutApo, CodEmpresa, CInt(Me.Cmb_Anho_Cup), Val(Me.Cmb_Mes1Cuota), Aluxcur) ' GetValorCuota(sCodEns)
If ValoresApo(1) > 0 Then
    Me.Txt_ArancelTotal = ValoresApo(1)
    Me.Txt_Hmnos = ValoresApo(2)
    Me.Txt_Beca = ValoresApo(3)
    Me.Txt_Otros = ValoresApo(4)
    Me.Txt_Conv = ValoresApo(5)
    Me.Txt_TotalCupon = ValoresApo(6)
    Me.Command1.Enabled = IIf(Me.Txt_TotalCupon > 0, True, False)
Else ' si la suma de los aranceles base es 0
    MsgBox ("Apoderado no tiene alumnos para este año")
    Me.Txt_TotalCupon = "": Me.Txt_Otros = ""
    Me.Txt_Conv = "": Me.Txt_Beca = "": Me.Txt_Hmnos = ""
End If
End Sub
Function CalculaCuotaApo(RutApo As String, CodEmpresa As String, Anho As Integer, EsAnhoProximo As Boolean) As Long()
Dim CodDes As String, TotalApo As Long, CuotaCalcu() As Long
Dim Monto_Total As Long, Monto_Exen_Beca As Long, Monto_Exen_Hmno As Long, Monto_Exen_Conv As Long
Dim Monto_Exen_Descto As Long, Monto_Tot_Cuota As Long, Monto_Base As Long
Dim Venci As String, MatrizVal(0, 5) As Long
Monto_Base = 0: Monto_Exen_Beca = 0: Monto_Exen_Hmno = 0: Monto_Exen_Conv = 0
Monto_Exen_Descto = 0: Monto_Tot_Cuota = 0
If EsAnhoProximo Then
    CodDes = "" ' no calcula los prekinder ya que no se encontraría ninguno
Else
    CodDes = IIf(Len(CodEmpresa) > 6, " and c.cod_des = 'PK'", " and c.cod_des <> 'PK'")
End If
Set rsfuncion3 = New ADODB.Recordset
rsfuncion3.CursorLocation = adUseClient

rsfuncion3.Open "select ac.ci_alu, a.rut_apo from apoderados a, apo_x_alu ap, matriculas ac, codigos_ensenanza c where a.rut_apo = ap.rut_apo and a.rut_apo='" & RutApo & "' AND ap.ci_alu=ac.ci_alu AND ap.agno=ac.anno_mat AND ap.agno=" & Anho & " AND ac.cod_ens=c.cod_ens and ac.activo_alu = 'SI' " & CodDes, conn

TotalApo = 0
If rsfuncion3.RecordCount > 0 Then
    For te = 0 To rsfuncion3.RecordCount - 1
        CuotaCalcu = CalculaCuotaalu(rsfuncion3!Ci_alu, CodEmpresa, Anho, EsAnhoProximo)
        Monto_Total = CuotaCalcu(0, 0)
        'Si la función devuelve -1, quiere decir que salio del colegio y no
        'tiene mensualidades para el próximo año.
        If Monto_Total > -1 Then
            Monto_Base = Monto_Base + CuotaCalcu(0, 0)
            Monto_Exen_Beca = Monto_Exen_Beca + CuotaCalcu(0, 1)
            Monto_Exen_Hmno = Monto_Exen_Hmno + CuotaCalcu(0, 2)
            Monto_Exen_Conv = Monto_Exen_Conv + CuotaCalcu(0, 3)
            Monto_Exen_Descto = Monto_Exen_Descto + CuotaCalcu(0, 4)
            Monto_Tot_Cuota = Monto_Tot_Cuota + CuotaCalcu(0, 5)
        End If
        rsfuncion3.MoveNext
    Next te
Else
    Monto_Base = -1 ' Consulta no trajo alumnos, posiblemente no estén activos.
End If
MatrizVal(0, 0) = Monto_Base
MatrizVal(0, 1) = Monto_Exen_Beca
MatrizVal(0, 2) = Monto_Exen_Hmno
MatrizVal(0, 3) = Monto_Exen_Conv
MatrizVal(0, 4) = Monto_Exen_Descto
MatrizVal(0, 5) = Monto_Tot_Cuota
CalculaCuotaApo = MatrizVal
End Function
Sub TxtElimin(ByVal Rutapod As String, BolIni As String, BolFin As String)
Dim CtaCte As String, NumeroCliente As String, IniBol As String, FinBol As String
Dim linea As String
CtaCte = Tamaño(Largo("9" & Me.Txt_CuentaCte, 12), 13)
NumeroCliente = Tamaño(Largo(Mid(Rutapod, 1, Len(Rutapod) - 2), 10), 11) & Tamaño(Right(Rutapod, 1), 2)
IniBol = Tamaño(Largo(BolIni, 10), 11)
FinBol = Tamaño(Largo(BolFin, 10), 42)
linea = CtaCte & NumeroCliente & IniBol & FinBol
Call CreateFile(linea, Me.lblRuta & "elimina_cupones_" & Format(Date, "yyyymmdd") & ".bci")
End Sub
Sub EliminarCupon(ByVal Rutapod As String, ByVal MesINI As Integer, ByVal MesFin As Integer)
Dim FolCupon As Variant, TMes As Integer
'For TMes = Val(Me.Cmb_Cuota_Mes.ItemData(Me.Cmb_Cuota_Mes.ListIndex)) To Val(Me.Cmb_Cuota_Mes_Fin.ItemData(Me.Cmb_Cuota_Mes_Fin.ListIndex))
For TMes = MesINI To MesFin
    FolCupon = TraeCupon(Rutapod, CodEmpresa, Val(Me.Cmb_Anho_Cup), TMes, CodBanco, conn)
    If Not IsNull(FolCupon(1)) Then
        conn.Execute "update fnza_deta_cupones set estado='EL' where folio_cupon =" & FolCupon(3)
        Call RegistrarOpeCupon("ELI", CLng(FolCupon(1)), CLng(FolCupon(3)), conn)
    End If
Next TMes
End Sub
'Conecta y Trae Informacion
Function DatosExternos(CritApoderado As String) As Boolean
    DatosExternos = False
    Dim ServidorExt As String, UsuarioExt As String, PasswordExt As String, BaseDatosExt As String
    
    ServidorExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "HOST", ""))
    If Len(Trim(ServidorExt)) = 0 Then
        ServidorExt = InputBox("Ingrese dieccion del Servidor externo", "Dirección Servidor")
        IniWrite "GESCOL.INI", "EXTERNO", "HOST", Form_main.EnCrypt_Main.EnCrypt(ServidorExt)
    End If
    UsuarioExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "USUARIO", ""))
    If Len(Trim(UsuarioExt)) = 0 Then
        UsuarioExt = InputBox("Ingrese Nombre de usuario", "Nombre de usuario de conexión")
        IniWrite "GESCOL.INI", "EXTERNO", "USUARIO", Form_main.EnCrypt_Main.EnCrypt(UsuarioExt)
    End If
    
    PasswordExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "PASSWORD", ""))
    If Len(Trim(PasswordExt)) = 0 Then
        PasswordExt = InputBox("Ingrese Password", "Password de conexión")
        IniWrite "GESCOL.INI", "EXTERNO", "PASSWORD", Form_main.EnCrypt_Main.EnCrypt(PasswordExt)
    End If
        
    BaseDatosExt = Form_main.EnCrypt_Main.DeCrypt(IniGet("GESCOL.INI", "EXTERNO", "BASEDATOS", ""))
    If Len(Trim(BaseDatosExt)) = 0 Then
        BaseDatosExt = InputBox("Ingrese Base de datos", "Base de datos Remota")
        IniWrite "GESCOL.INI", "EXTERNO", "BASEDATOS", Form_main.EnCrypt_Main.EnCrypt(BaseDatosExt)
    End If
    If ConectarBD(ConnExt, ServidorExt, BaseDatosExt, UsuarioExt, PasswordExt, False) Then
        'Si es de un apoderado traer solo sus pagos, para evitar demora.
        RutCli = ""
        Dim SqlExt As String
        Set RsFuncion = New ADODB.Recordset
        RsFuncion.CursorLocation = adUseClient
        If Not Particular Then
        '                       0               1                    2        3         4         5       6
            SqlExt = "select rut_cli, right(cab_bol,4) as 'agno', num_cup, fech_rec, fech_ven, monto, monto_tot, convenio from pagos_bci where convenio = " & CLng(Me.Txt_CodConvBci) & " and right(cab_bol,4) ='" & Me.Cmb_Anho_Cup & "' and num_cup >= " & Val(Me.Cmb_Num_cuota) & " and num_cup <= " & Val(Me.Cmb_Num_cuota_Fin) & CritApoderado & " order by rut_cli, num_cup"
        Else
            SqlExt = "select rut_cli, right(cab_bol,4) as 'agno', num_cup, fech_rec, fech_ven, monto, monto_tot, convenio from pagos_bci where convenio = '" & CLng(Me.Txt_CodConvBci) & "' and left(cab_bol,3) = '" & Me.Txt_IdPart & "' and right(cab_bol,4) ='" & Me.Cmb_Anho_Cup & "' and num_cup >= " & Val(Me.Cmb_Num_cuota) & " and num_cup <= " & Val(Me.Cmb_Num_cuota_Fin) & CritApoderado & " order by rut_cli, num_cup"
        End If
        RsFuncion.Open SqlExt, ConnExt
        If RsFuncion.RecordCount > 0 Then
            Form_Progress.Label1.Caption = "Transfiriendo Información Bancaria"
            Form_Progress.Show
            Form_Progress.ProgBar1.MaxValue = RsFuncion.RecordCount - 1
            Form_Progress.ProgBar1.ShowProgress 0
            For h = 0 To RsFuncion.RecordCount - 1
                conn.Execute "replace into TMP_CUPONERAS values('" & RsFuncion!rut_cli & "', " & Val(RsFuncion!agno) & " , " & RsFuncion!num_cup & ", '" & RsFuncion!Convenio & "', " & RsFuncion!Monto & ")"
                RsFuncion.MoveNext
                Form_Progress.ProgBar1.ShowProgress h + 0
                Form_Progress.SetFocus
                DoEvents
            Next h
            DatosExternos = True
            Form_Progress.ProgBar1.ShowProgress 0
            Unload Form_Progress
        ElseIf RsFuncion.RecordCount = 0 Then
            DatosExternos = True
        End If
        RsFuncion.Close
        Set RsFuncion = Nothing
    End If
End Function
Function TablaTemp() As Boolean
On Error GoTo controlerr
conn.Execute "DROP TABLE IF EXISTS `TMP_CUPONERAS`"
conn.Execute "CREATE TABLE TMP_CUPONERAS" & _
"(" & _
    "RUT_CLI         VARCHAR(10)   not null," & _
    "AGNO            NUMERIC(4)    not null," & _
    "NUM_CUP         NUMERIC(2)    not null," & _
    "CONV_BCI        VARCHAR(3)    not null," & _
    "MONTO           BIGINT(6)     not null," & _
    "primary key (RUT_CLI, AGNO, NUM_CUP));"
    Set RsFuncion = New ADODB.Recordset
    RsFuncion.CursorLocation = adUseClient
    RsFuncion.Open "select * from TMP_CUPONERAS", conn
    TablaTemp = True
    RsFuncion.Close
    Set RsFuncion = Nothing
Exit Function
controlerr:
Set RsFuncion = Nothing
TablaTemp = False
End Function
Sub HideFramesCup()
Me.Frame_Generacion_Cup.Visible = False
'Me.Frame_CargaTxt_Cup.Visible = False
End Sub

Sub IniciaGrillaPaquete()
For t = 0 To 1
    Me.Grd_Paquete_Bci(t).Cols = 8
    Me.Grd_Paquete_Bci(t).Rows = 2
    Me.Grd_Paquete_Bci(t).FixedCols = 0
    Me.Grd_Paquete_Bci(t).Clear             '0       1         2        3         4         5          6         7
    Me.Grd_Paquete_Bci(t).FormatString = "^Item |Operación |Archivo  |Tamaño |Modificado|Empresa  |Cuenta Cte. |Ruta "
    Me.Grd_Paquete_Bci(t).ColWidth(0) = 400
    Me.Grd_Paquete_Bci(t).ColWidth(1) = 1200
    Me.Grd_Paquete_Bci(t).ColWidth(2) = 2000
    Me.Grd_Paquete_Bci(t).ColWidth(3) = 700
    Me.Grd_Paquete_Bci(t).ColWidth(4) = 1700
    Me.Grd_Paquete_Bci(t).ColWidth(5) = 0
    Me.Grd_Paquete_Bci(t).ColWidth(6) = 1700
    Me.Grd_Paquete_Bci(t).ColWidth(7) = 0
Next t
End Sub
Function Lineastxt(Archivo) As Integer
Dim Numeroarchivo As Integer, linea As Integer
Numeroarchivo = FreeFile: linea = 0
 If Dir$(Archivo) <> "" Then
    Open Archivo For Input As #Numeroarchivo
        While Not EOF(Numeroarchivo)
            Line Input #Numeroarchivo, linea1
            linea = linea + 1
        Wend
    Close Numeroarchivo
 End If
Lineastxt = linea
End Function
