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    =   7080
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10755
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7080
   ScaleWidth      =   10755
   Begin VB.Frame Frame_Importar 
      Caption         =   "Datos de importacion"
      ForeColor       =   &H00FF0000&
      Height          =   3015
      Left            =   120
      TabIndex        =   80
      Top             =   6600
      Visible         =   0   'False
      Width           =   5295
      Begin VB.CommandButton Btn_Imp_txt_cup 
         Caption         =   "Importacion Txt Cuponeras"
         Height          =   375
         Left            =   2640
         TabIndex        =   84
         Top             =   840
         Width           =   2175
      End
      Begin VB.CommandButton Btn_Imp_Ok 
         Caption         =   "Importacion Pagos Contado"
         Height          =   375
         Left            =   360
         TabIndex        =   83
         Top             =   840
         Width           =   2175
      End
      Begin VB.CommandButton Btn_Ruta_Imp 
         Caption         =   "..."
         Height          =   315
         Left            =   4800
         TabIndex        =   82
         Top             =   360
         Width           =   255
      End
      Begin VB.TextBox Txt_RutaImp 
         Height          =   285
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   81
         Top             =   360
         Width           =   4455
      End
      Begin VB.Label lbl_Espere 
         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        =   87
         Top             =   1440
         Width           =   2055
      End
      Begin VB.Label Lbl_Linea 
         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            =   2160
         TabIndex        =   86
         Top             =   1440
         Width           =   735
      End
      Begin VB.Label Lbl_Procesando 
         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        =   85
         Top             =   1440
         Width           =   2055
      End
   End
   Begin VB.Frame Frame_Tipo_Bus 
      Height          =   735
      Left            =   5760
      TabIndex        =   18
      Top             =   120
      Width           =   4935
      Begin VB.OptionButton Opt_Tipo_Bus 
         Caption         =   "Pendientes"
         Height          =   375
         Index           =   3
         Left            =   3720
         TabIndex        =   93
         Top             =   240
         Width           =   1095
      End
      Begin VB.OptionButton Opt_Tipo_Bus 
         Caption         =   "Personalizado"
         Height          =   375
         Index           =   2
         Left            =   2280
         TabIndex        =   21
         Top             =   240
         Width           =   1335
      End
      Begin VB.OptionButton Opt_Tipo_Bus 
         Caption         =   "Curso"
         Height          =   375
         Index           =   1
         Left            =   1320
         TabIndex        =   20
         Top             =   240
         Width           =   735
      End
      Begin VB.OptionButton Opt_Tipo_Bus 
         Caption         =   "Colegio"
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   19
         Top             =   240
         Width           =   855
      End
   End
   Begin MSComDlg.CommonDialog cd 
      Left            =   5040
      Top             =   1920
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Btn_Can_Cup 
      Caption         =   "Cancelar"
      Height          =   375
      Left            =   8280
      TabIndex        =   8
      Top             =   6600
      Width           =   1575
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Generar Archivo"
      Height          =   375
      Left            =   6360
      TabIndex        =   7
      Top             =   6600
      Width           =   1575
   End
   Begin ProgBarProzent.ProgBar ProgBar_Cuponeras 
      Height          =   375
      Left            =   5760
      TabIndex        =   13
      Top             =   6120
      Width           =   4935
      _ExtentX        =   8705
      _ExtentY        =   661
   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            =   120
      TabIndex        =   11
      Top             =   120
      Width           =   5535
      Begin VB.ComboBox Cmb_Banco 
         Height          =   315
         Left            =   2160
         Style           =   2  'Dropdown List
         TabIndex        =   76
         Top             =   2280
         Width           =   3255
      End
      Begin VB.TextBox Txt_CuentaCte 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   2160
         Locked          =   -1  'True
         TabIndex        =   5
         Top             =   1560
         Width           =   3255
      End
      Begin VB.TextBox Txt_ArancelBase 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   4440
         Locked          =   -1  'True
         TabIndex        =   4
         Top             =   1200
         Width           =   975
      End
      Begin VB.ComboBox Cmb_Anho_Cup 
         Height          =   315
         ItemData        =   "Form_Cuponeras.frx":0000
         Left            =   2160
         List            =   "Form_Cuponeras.frx":0002
         Style           =   2  'Dropdown List
         TabIndex        =   6
         Top             =   1920
         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
         Style           =   1  'Graphical
         TabIndex        =   15
         TabStop         =   0   'False
         Top             =   720
         Width           =   1935
      End
      Begin VB.TextBox Txt_CodConvBci 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   2160
         Locked          =   -1  'True
         TabIndex        =   3
         Top             =   1200
         Width           =   975
      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
         Style           =   1  'Graphical
         TabIndex        =   9
         TabStop         =   0   'False
         Top             =   240
         Width           =   1935
      End
      Begin VB.ComboBox Cmb_Part_Cup 
         Height          =   315
         Left            =   2160
         Style           =   2  'Dropdown List
         TabIndex        =   2
         Top             =   750
         Width           =   3255
      End
      Begin VB.ComboBox Cmb_Colegio_Cup 
         Height          =   315
         Left            =   2160
         Style           =   2  'Dropdown List
         TabIndex        =   1
         Top             =   270
         Width           =   3255
      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        =   77
         Top             =   2280
         Width           =   1575
      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        =   17
         Top             =   1560
         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        =   16
         Top             =   1200
         Width           =   1695
      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        =   14
         Top             =   1200
         Width           =   1815
      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        =   12
         Top             =   1920
         Width           =   1575
      End
   End
   Begin VB.Frame Frame1 
      Height          =   3735
      Left            =   120
      TabIndex        =   10
      Top             =   2760
      Width           =   5535
      Begin VB.ComboBox Cmb_Cuota_Mes 
         Height          =   315
         ItemData        =   "Form_Cuponeras.frx":0004
         Left            =   3000
         List            =   "Form_Cuponeras.frx":002C
         Locked          =   -1  'True
         Style           =   1  'Simple Combo
         TabIndex        =   92
         Top             =   2400
         Width           =   2415
      End
      Begin VB.ComboBox Cmb_Vcto 
         Height          =   315
         ItemData        =   "Form_Cuponeras.frx":008E
         Left            =   1920
         List            =   "Form_Cuponeras.frx":00DD
         Locked          =   -1  'True
         Style           =   1  'Simple Combo
         TabIndex        =   91
         Top             =   2040
         Width           =   735
      End
      Begin VB.ComboBox Cmb_Num_cuota 
         Height          =   315
         ItemData        =   "Form_Cuponeras.frx":0145
         Left            =   1920
         List            =   "Form_Cuponeras.frx":016D
         Locked          =   -1  'True
         Style           =   1  'Simple Combo
         TabIndex        =   89
         Top             =   2400
         Width           =   975
      End
      Begin VB.CheckBox Chk_Imp 
         Caption         =   "Importación"
         Height          =   255
         Left            =   4200
         Style           =   1  'Graphical
         TabIndex        =   88
         Top             =   240
         Width           =   1215
      End
      Begin MSComCtl2.DTPicker Dtp_Fecha_Gen 
         Height          =   375
         Left            =   4200
         TabIndex        =   78
         Top             =   3240
         Width           =   1215
         _ExtentX        =   2143
         _ExtentY        =   661
         _Version        =   393216
         Format          =   70582273
         CurrentDate     =   38385
      End
      Begin VB.ComboBox Cmb_Anho1Cuota 
         Height          =   315
         Left            =   2760
         Style           =   2  'Dropdown List
         TabIndex        =   75
         Top             =   1320
         Width           =   975
      End
      Begin VB.ComboBox Cmb_Mes1Cuota 
         Height          =   315
         ItemData        =   "Form_Cuponeras.frx":019D
         Left            =   1920
         List            =   "Form_Cuponeras.frx":01C5
         Style           =   2  'Dropdown List
         TabIndex        =   74
         Top             =   1320
         Width           =   735
      End
      Begin VB.CommandButton Command2 
         Caption         =   "..."
         Height          =   255
         Left            =   3840
         TabIndex        =   65
         Top             =   255
         Width           =   255
      End
      Begin VB.TextBox txtRuta 
         Height          =   285
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   64
         Top             =   240
         Width           =   3615
      End
      Begin VB.ComboBox cmbMoneda 
         Height          =   315
         Left            =   1920
         Style           =   2  'Dropdown List
         TabIndex        =   63
         Top             =   600
         Width           =   1335
      End
      Begin VB.TextBox txtCuotas 
         Height          =   285
         Left            =   1920
         TabIndex        =   62
         Text            =   "10"
         Top             =   960
         Width           =   1335
      End
      Begin VB.TextBox txtEntreCuotas 
         Height          =   285
         Left            =   1920
         Locked          =   -1  'True
         TabIndex        =   61
         Text            =   "1"
         Top             =   1680
         Width           =   1335
      End
      Begin VB.TextBox txtNroBoleta 
         Height          =   285
         Left            =   1920
         Locked          =   -1  'True
         TabIndex        =   60
         Top             =   2760
         Width           =   1335
      End
      Begin MSMask.MaskEdBox txtFecDec 
         Height          =   315
         Left            =   1920
         TabIndex        =   66
         Top             =   3240
         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 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        =   90
         Top             =   2400
         Width           =   1440
      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        =   79
         Top             =   3240
         Width           =   945
      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        =   73
         Top             =   600
         Width           =   1425
      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        =   72
         Top             =   960
         Width           =   1335
      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        =   71
         Top             =   1320
         Width           =   1455
      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        =   70
         Top             =   1680
         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        =   69
         Top             =   2040
         Width           =   960
      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        =   68
         Top             =   2760
         Width           =   1485
      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            =   120
         TabIndex        =   67
         Top             =   3240
         Width           =   930
      End
   End
   Begin VB.Frame Frame_Bus 
      BorderStyle     =   0  'None
      Height          =   5055
      Index           =   1
      Left            =   5760
      TabIndex        =   36
      Top             =   840
      Width           =   4935
      Begin VB.Frame Frame_TipEns 
         Caption         =   "Tipo de enseñanza"
         ForeColor       =   &H00FF0000&
         Height          =   855
         Left            =   0
         TabIndex        =   40
         Top             =   1080
         Width           =   3855
         Begin VB.ComboBox cmb_modalidad 
            Height          =   315
            Left            =   120
            TabIndex        =   41
            Top             =   360
            Width           =   3375
         End
      End
      Begin VB.Frame Frame_Cursos 
         Caption         =   "Cursos"
         ForeColor       =   &H00FF0000&
         Height          =   3135
         Left            =   0
         TabIndex        =   37
         Top             =   1920
         Width           =   3855
         Begin VB.ListBox lst_cursosinf 
            Height          =   2085
            Left            =   240
            Style           =   1  'Checkbox
            TabIndex        =   39
            Top             =   360
            Width           =   1335
         End
         Begin VB.CheckBox chk_todos_cursos 
            Caption         =   "Todos los cursos"
            Height          =   255
            Left            =   240
            TabIndex        =   38
            Top             =   2640
            Width           =   1575
         End
      End
   End
   Begin VB.Frame Frame_Bus 
      BorderStyle     =   0  'None
      Height          =   5295
      Index           =   2
      Left            =   5760
      TabIndex        =   22
      Top             =   840
      Width           =   4935
      Begin VB.Frame Frame4 
         Caption         =   "Buscar por"
         ForeColor       =   &H00FF0000&
         Height          =   735
         Left            =   0
         TabIndex        =   33
         Top             =   120
         Width           =   3105
         Begin VB.OptionButton Opt_busqueda_caj 
            Caption         =   "Alumno"
            Height          =   255
            Index           =   1
            Left            =   1680
            TabIndex        =   35
            Top             =   300
            Width           =   1215
         End
         Begin VB.OptionButton Opt_busqueda_caj 
            Caption         =   "Apoderado"
            Height          =   255
            Index           =   0
            Left            =   240
            TabIndex        =   34
            Top             =   300
            Value           =   -1  'True
            Width           =   1215
         End
      End
      Begin VB.Frame Frame_datos_busqueda 
         Height          =   1095
         Left            =   0
         TabIndex        =   23
         Top             =   840
         Width           =   4095
         Begin VB.CommandButton btn_can_busqueda 
            Caption         =   "Cancelar"
            Height          =   375
            Left            =   2760
            TabIndex        =   28
            Top             =   240
            Width           =   1215
         End
         Begin VB.OptionButton opt_criterio 
            Caption         =   "Apellidos"
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   27
            Top             =   300
            Value           =   -1  'True
            Width           =   975
         End
         Begin VB.OptionButton opt_criterio 
            Caption         =   "R.u.t."
            Height          =   255
            Index           =   1
            Left            =   1680
            TabIndex        =   26
            Top             =   300
            Width           =   855
         End
         Begin VB.TextBox txt_crit_busqueda 
            Height          =   285
            Index           =   0
            Left            =   120
            TabIndex        =   25
            Top             =   600
            Width           =   3855
         End
         Begin VB.ListBox lst_busq_caja 
            Height          =   1425
            Index           =   0
            Left            =   120
            TabIndex        =   24
            Top             =   840
            Width           =   3855
         End
         Begin VB.TextBox txt_crit_busqueda 
            Height          =   285
            Index           =   1
            Left            =   120
            TabIndex        =   30
            Top             =   600
            Width           =   855
         End
         Begin VB.TextBox txt_dig_busqueda 
            Height          =   285
            Left            =   1200
            TabIndex        =   31
            Top             =   600
            Width           =   255
         End
         Begin VB.ListBox lst_busq_caja 
            Height          =   1425
            Index           =   1
            Left            =   120
            TabIndex        =   29
            Top             =   900
            Width           =   1815
         End
         Begin VB.Label Label11 
            Alignment       =   2  'Center
            Caption         =   "-"
            Height          =   255
            Left            =   960
            TabIndex        =   32
            Top             =   600
            Width           =   255
         End
      End
      Begin VB.Frame Frame_DatosApod 
         Caption         =   "Datos Apoderado"
         ForeColor       =   &H00FF0000&
         Height          =   3255
         Left            =   0
         TabIndex        =   42
         Top             =   1920
         Width           =   4935
         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        =   57
            Top             =   2640
            Width           =   975
         End
         Begin VB.TextBox Txt_Otros 
            Height          =   285
            Left            =   3480
            TabIndex        =   55
            Top             =   2280
            Width           =   975
         End
         Begin VB.TextBox Txt_Conv 
            Height          =   285
            Left            =   3480
            TabIndex        =   53
            Top             =   1920
            Width           =   975
         End
         Begin VB.TextBox Txt_Hmnos 
            Height          =   285
            Left            =   1200
            TabIndex        =   51
            Top             =   2280
            Width           =   975
         End
         Begin VB.TextBox Txt_Beca 
            Height          =   285
            Left            =   1200
            TabIndex        =   50
            Top             =   1920
            Width           =   975
         End
         Begin VB.TextBox Txt_ArancelTotal 
            Height          =   285
            Left            =   1320
            TabIndex        =   48
            Top             =   960
            Width           =   975
         End
         Begin VB.TextBox Txt_NomApo 
            Height          =   285
            Left            =   1320
            TabIndex        =   46
            Top             =   600
            Width           =   3495
         End
         Begin VB.TextBox Txt_RutApo 
            Height          =   285
            Left            =   1320
            TabIndex        =   44
            Top             =   240
            Width           =   1215
         End
         Begin VB.Line Line5 
            BorderColor     =   &H8000000C&
            X1              =   30
            X2              =   4915
            Y1              =   1440
            Y2              =   1440
         End
         Begin VB.Line Line1 
            BorderColor     =   &H80000005&
            X1              =   30
            X2              =   4915
            Y1              =   1455
            Y2              =   1455
         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        =   59
            Top             =   1560
            Width           =   2535
         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        =   58
            Top             =   2640
            Width           =   855
         End
         Begin VB.Label Label20 
            Caption         =   "Otros"
            Height          =   255
            Left            =   2520
            TabIndex        =   56
            Top             =   2280
            Width           =   855
         End
         Begin VB.Label Label19 
            Caption         =   "Convenio"
            Height          =   255
            Left            =   2520
            TabIndex        =   54
            Top             =   1920
            Width           =   855
         End
         Begin VB.Label Label18 
            Caption         =   "Hermanos"
            Height          =   255
            Left            =   120
            TabIndex        =   52
            Top             =   2280
            Width           =   855
         End
         Begin VB.Label Label17 
            Caption         =   "Beca"
            Height          =   255
            Left            =   120
            TabIndex        =   49
            Top             =   1920
            Width           =   495
         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        =   47
            Top             =   960
            Width           =   1215
         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        =   45
            Top             =   600
            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        =   43
            Top             =   240
            Width           =   495
         End
      End
   End
   Begin VB.Label lblRuta 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   3840
      TabIndex        =   0
      Top             =   2160
      Width           =   855
   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

Private Sub Btn_Can_Cup_Click()
Unload Me
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()
If Me.Txt_RutaImp <> "" Then
    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
    If Me.Cmb_Anho_Cup = Anno Then
        AnhoProx = False
    ElseIf Me.Cmb_Anho_Cup > Anno Then
        AnhoProx = True
    End If
    NLinea = 1
    Numeroarchivo = FreeFile
    'If Dir$(Archivo) <> "" Then
        Open Me.Txt_RutaImp For Input As #Numeroarchivo
            While Not EOF(Numeroarchivo)
                Line Input #Numeroarchivo, linea
                'Debug.Print linea & " " & Len(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
                        'Debug.Print linea & " " & Len(linea)
                    End If
                    Me.Lbl_Linea.Caption = NLinea ': Me.Lbl_Linea.Refresh
                    If NLinea = 1 Then
                        'BolInicial = Mid(linea, 70, 11)
                        TotCuotas = Val(Mid(linea, 47, 2))
                    Else
                        CuotaInicial = Val(Mid(linea, 57, 2))
                        RutApo = Mid(linea, 4, 8) & "-" & Mid(linea, 12, 1)
                        '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 & "'", 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(CDate("26-11-2004"), "R") & "' , 11 )" '" & TotCuotas & ")" 11 cuotas del cupon 1 cupon 00 a crear
                            FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & RutApo & "'", 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
                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
End Sub

Private Sub Btn_Ruta_Imp_Click()
    cd.DialogTitle = "Grabar a..."
    cd.Filter = "Archivo txt (*.txt)|*.txt|"
    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_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.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(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_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(Me.Cmb_Anho_Cup & Me.Cmb_Num_cuota)
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()
If Me.Txt_CodConvBci <> "" And Me.Txt_CuentaCte <> "" And Me.txtCuotas <> "" 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
        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 & "' "
                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
            Call registro1
            Call Apoderados
        End If
Else
    MsgBox ("Faltan opciones por completar")
End If
End Sub
Private Sub Apoderados()
    Dim sql As String, sMatricula As String, sCte As String, ValorCupon As Long
    Dim ApoSinAnu As Integer, ApoConAnu As Integer, FolioCuponera
    Dim ValoresApo As Variant
    ' aqui se debe agregar las cadenas de curso y rut de apod.
    ' TRAE APODERADOS CON ALUMNOS ACTIVOS
    'If Me.Cmb_Anho_Cup = Anno Then
    '    AnhoProx = False
    'ElseIf Me.Cmb_Anho_Cup > Anno Then
    '    AnhoProx = True
    'End If
    ' Consulta cambiada para uso de tabla matriculas en reemplazo de alu_x_cur
    '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 ac.activo_alu = 'SI' " & Criterio & " order by a.rut_apo"
     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 ac.activo_alu = 'SI' " & Criterio & " order by a.rut_apo"
    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
    If rs.RecordCount > 0 Then
        For t = 1 To rs.RecordCount
            If Not IsNull(rs!rut_apo) Then
                'If rs!rut_apo = "08880376-0" Then MsgBox ("Aqui")
                If Not ExistReg("apo_pago_contado", "rut_apo ='" & rs!rut_apo & "'", conn) Then
                    ValoresApo = CuotaApo(rs!rut_apo, CodEmpresa, CInt(Me.Cmb_Anho_Cup), Val(Me.Cmb_Mes1Cuota))  ' GetValorCuota(sCodEns)
                    sValor = ValoresApo(6)
                    If sValor > 0 Then
                        ValorCupon = sValor
                        ApoConAnu = ApoConAnu + 1
                        sValor = Largo(Replace(addCeros(sValor, 3), ",", ""), 12)
                        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)
                        sNroBoleta = Largo(txtNroBoleta.Text, 11)
                        'sNroBoleta = largo(Format(Date, "yyyy") & largo(txtNroBoleta.Text, 2), 11)
                        sFechaPago = Format(txtFecDec.Text, "ddmmyy")
                        sFiller = "              "
                        Reg2 = "2" & sMatricula & sClte & sValor & Largo(txtCuotas.Text, 3) & sNroBoleta & sFechaPago & Largo(txtEntreCuotas, 2) & sFiller
                        Call CreateFile(Reg2, txtRuta.Text)
                        FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & rs!rut_apo & "'", 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('" & rs!rut_apo & "' , '" & CodEmpresa & "' ," & CInt(Me.Cmb_Anho_Cup) & " , " & CInt(Me.Cmb_Mes1Cuota) & " , '" & CodBanco & "' , '" & InvierteFecha(Me.Dtp_Fecha_Gen.Value, "R") & "' , " & Val(Me.txtCuotas) & ")"
                            FolioCuponera = devuelvecampo("fnza_cuponeras", "", "folio_cuponera", "rut_apo ='" & rs!rut_apo & "'", conn)
                            InsCupones CLng(FolioCuponera), CInt(Me.txtCuotas), CStr(sNroBoleta), CInt(Me.Cmb_Num_cuota.ItemData(Me.Cmb_Num_cuota.ListIndex)), InvierteFecha(CDate(txtFecDec.Text), "R"), ValorCupon
                        Else
                            Call InsCupones(CLng(FolioCuponera), CInt(Me.txtCuotas), CStr(sNroBoleta), CInt(Me.Cmb_Num_cuota.ItemData(Me.Cmb_Num_cuota.ListIndex)), InvierteFecha(CDate(txtFecDec.Text), "R"), ValorCupon)
                        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
                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 & " Total Apoderados -> " & rs.RecordCount & " : Cuponeras Generadas -> " & ApoConAnu
    Call CreateFile(info, Me.lblRuta.Caption & "LogCuponeras.txt")
    'Me.Label1.Caption = Label1.Caption & " / " & RutAlm
    Set rs = Nothing
    
    End Sub

Private Sub registro1()
    Dim Reg1 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
    sempresa = Tamaño("CONV BCI " & Trim(Me.Txt_CodConvBci) & " " & Mid(UCase(NomEmpresa), 1, 37), 37)
    sCtaCte = Me.Txt_CuentaCte 'Cuenta Corriente
    sNroCuotas = Largo(txtCuotas.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
    
    Call CreateFile(Reg1, txtRuta.Text)
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
    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 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.Height = 7455: Me.Width = 10845
    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
busqueda = 1
End Sub

Private Sub Frame2_DragDrop(Source As Control, X As Single, Y As Single)

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 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_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 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) As Variant()
Dim CuotaAlu As Variant
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
'RsFuncion3.Open "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 ac.cod_ens=c.cod_ens and ac.activo_alu = 'SI' " & CodDes, conn
RsFuncion.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 ac.cod_ens=c.cod_ens and ac.activo_alu = 'SI' " & CodDes, 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) & "'", 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
ValoresApo = CuotaApo(RutApo, CodEmpresa, CInt(Me.Cmb_Anho_Cup), Val(Me.Cmb_Mes1Cuota))  ' 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
' Cambio de consulta tabla alu_x_cur por matrículas.
'RsFuncion3.Open "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 ac.cod_ens=c.cod_ens and ac.activo_alu = 'SI' " & CodDes, conn
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 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
