VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "MSCOMCTL.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_Matr_Alu_Act_Prox_Agno_hue 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Matricula de Alumnos Activos para el proximo año"
   ClientHeight    =   9075
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   11790
   Icon            =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   605
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   786
   Begin VB.Frame frm_Descuentos 
      Caption         =   "Descuentos"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1695
      Left            =   8640
      TabIndex        =   55
      Top             =   5760
      Width           =   2895
      Begin VB.ListBox lst_descuentos_conflicto 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   900
         Left            =   120
         TabIndex        =   56
         Top             =   240
         Visible         =   0   'False
         Width           =   2655
      End
      Begin VB.ListBox lst_descuentos_nombre 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   780
         ItemData        =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":2A8B2
         Left            =   120
         List            =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":2A8B9
         Style           =   1  'Checkbox
         TabIndex        =   57
         Top             =   240
         Width           =   2655
      End
      Begin VB.Label Label15 
         Caption         =   "Presionar CTRL para seleccionar multiples descuentos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   435
         Left            =   120
         TabIndex        =   58
         Top             =   1200
         Width           =   2655
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Seccionar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1215
      Left            =   120
      TabIndex        =   8
      Top             =   120
      Width           =   1815
      Begin VB.OptionButton Option1 
         Caption         =   "Por Apoderado"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   120
         TabIndex        =   14
         Top             =   600
         Width           =   1455
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Por Curso"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   13
         Top             =   840
         Width           =   1455
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Por Alumno"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Index           =   2
         Left            =   120
         TabIndex        =   15
         Top             =   360
         Value           =   -1  'True
         Width           =   1335
      End
   End
   Begin VB.ListBox List2 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1950
      Left            =   7560
      TabIndex        =   27
      Top             =   840
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.ListBox List1 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1950
      Left            =   2880
      TabIndex        =   26
      Top             =   840
      Visible         =   0   'False
      Width           =   4215
   End
   Begin VB.Frame Frame7 
      Height          =   735
      Left            =   120
      TabIndex        =   34
      Top             =   8160
      Width           =   8295
      Begin MSComctlLib.ProgressBar PBar 
         Height          =   375
         Left            =   120
         TabIndex        =   35
         Top             =   240
         Width           =   8055
         _ExtentX        =   14208
         _ExtentY        =   661
         _Version        =   393216
         BorderStyle     =   1
         Appearance      =   0
         Max             =   1
         Scrolling       =   1
      End
   End
   Begin VB.Frame Frame6 
      Height          =   735
      Left            =   8520
      TabIndex        =   30
      Top             =   8160
      Width           =   3135
      Begin VB.CommandButton Command2 
         Caption         =   "Limpiar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   32
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton Command3 
         Caption         =   "Salir"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1680
         TabIndex        =   31
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Generar Reporte"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1680
         TabIndex        =   33
         Top             =   240
         Width           =   1335
      End
   End
   Begin VB.ListBox List4 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1950
      Left            =   7560
      TabIndex        =   29
      Top             =   840
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.ListBox List3 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1950
      Left            =   2880
      TabIndex        =   28
      Top             =   840
      Visible         =   0   'False
      Width           =   4215
   End
   Begin VB.Frame Frame5 
      Caption         =   "Seleccion por Apoderado"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1215
      Left            =   2040
      TabIndex        =   12
      Top             =   120
      Width           =   9615
      Begin VB.ComboBox Combo1 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   7320
         TabIndex        =   44
         Text            =   "Combo1"
         Top             =   480
         Width           =   975
      End
      Begin VB.CommandButton Btn_Ver_Apoderado 
         Caption         =   "Ver"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   8640
         Picture         =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":2A8D4
         Style           =   1  'Graphical
         TabIndex        =   25
         Top             =   360
         Width           =   735
      End
      Begin VB.TextBox Text4 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   5520
         TabIndex        =   22
         Text            =   "Text4"
         Top             =   480
         Width           =   1335
      End
      Begin VB.TextBox Text3 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   840
         TabIndex        =   21
         Text            =   "Text3"
         Top             =   480
         Width           =   4215
      End
      Begin VB.Label Label9 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   6960
         TabIndex        =   45
         Top             =   480
         Width           =   375
      End
      Begin VB.Label Label8 
         Caption         =   "Run"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5160
         TabIndex        =   24
         Top             =   480
         Width           =   495
      End
      Begin VB.Label Label7 
         Caption         =   "Nombre"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   23
         Top             =   480
         Width           =   615
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Selección por Curso"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1215
      Left            =   2040
      TabIndex        =   0
      Top             =   120
      Width           =   9615
      Begin VB.CommandButton Btn_Ver_Lista 
         Caption         =   "Ver"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   8640
         Picture         =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":2AE4B
         Style           =   1  'Graphical
         TabIndex        =   11
         Top             =   360
         Width           =   735
      End
      Begin VB.CheckBox Check_Letra 
         Caption         =   "Letra"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   195
         Left            =   5880
         TabIndex        =   10
         Top             =   360
         Width           =   1095
      End
      Begin MSComctlLib.ImageCombo IC_Ensenanza 
         Height          =   345
         Left            =   1440
         TabIndex        =   1
         Top             =   600
         Width           =   3135
         _ExtentX        =   5530
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "IC_Ensenanza"
      End
      Begin MSComctlLib.ImageCombo IC_Nivel 
         Height          =   345
         Left            =   4680
         TabIndex        =   2
         Top             =   600
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "IC_Nivel"
      End
      Begin MSComctlLib.ImageCombo IC_Letra 
         Height          =   345
         Left            =   5880
         TabIndex        =   3
         Top             =   600
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "IC_Letra"
      End
      Begin MSComctlLib.ImageCombo IC_Agno 
         Height          =   345
         Left            =   240
         TabIndex        =   4
         Top             =   600
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Text            =   "IC_Agno"
      End
      Begin MSComctlLib.ImageCombo IC_Filtro 
         Height          =   345
         Left            =   7080
         TabIndex        =   49
         Top             =   600
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "IC_Filtro"
      End
      Begin VB.Label Label4 
         Caption         =   "Filtro"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   7080
         TabIndex        =   50
         Top             =   360
         Width           =   1335
      End
      Begin VB.Label Label3 
         Caption         =   "Nivel"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   4680
         TabIndex        =   7
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   1440
         TabIndex        =   6
         Top             =   360
         Width           =   3135
      End
      Begin VB.Label Label1 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   240
         TabIndex        =   5
         Top             =   360
         Width           =   1095
      End
   End
   Begin VB.Frame Frame8 
      Caption         =   "Alumno:"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   6615
      Left            =   8520
      TabIndex        =   36
      Top             =   1440
      Width           =   3135
      Begin VB.Frame Frame9 
         Caption         =   "Valor matricula"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   735
         Left            =   120
         TabIndex        =   62
         Top             =   3480
         Width           =   2895
         Begin VB.ComboBox cb_valor_matricula 
            Height          =   315
            Left            =   120
            TabIndex        =   63
            Top             =   240
            Width           =   2655
         End
      End
      Begin VB.Frame Frame12 
         Caption         =   "Tipo de Pago Mensualidades"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   735
         Left            =   120
         TabIndex        =   60
         Top             =   2640
         Width           =   2895
         Begin VB.ComboBox cmb_tp_mensualidad 
            Height          =   315
            Left            =   120
            TabIndex        =   61
            Top             =   240
            Width           =   2655
         End
      End
      Begin VB.Frame Frame11 
         Caption         =   "Matricular"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1095
         Left            =   120
         TabIndex        =   41
         Top             =   600
         Width           =   2895
         Begin MSComCtl2.DTPicker DTP_Fec_Mat 
            Height          =   300
            Left            =   1440
            TabIndex        =   53
            Top             =   600
            Width           =   1335
            _ExtentX        =   2355
            _ExtentY        =   529
            _Version        =   393216
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Format          =   53805057
            CurrentDate     =   40624
         End
         Begin VB.CheckBox Chk_Repite 
            Caption         =   "Repitente"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   1440
            TabIndex        =   51
            Top             =   360
            Width           =   1095
         End
         Begin VB.CheckBox Check_Mat 
            Caption         =   "Considerar Para Matricula"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   120
            TabIndex        =   42
            Top             =   600
            Visible         =   0   'False
            Width           =   2175
         End
         Begin VB.CheckBox Check_confirma 
            Caption         =   "Matricular"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   120
            TabIndex        =   52
            Top             =   360
            Width           =   1455
         End
         Begin VB.Label Label11 
            Caption         =   "Fecha Mat."
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   54
            Top             =   600
            Width           =   855
         End
      End
      Begin VB.TextBox Text5 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000F&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   120
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         TabIndex        =   43
         Top             =   240
         Width           =   2895
      End
      Begin VB.CommandButton Btn_Guardar_Cambios 
         Caption         =   "Guardar"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   960
         TabIndex        =   38
         Top             =   6120
         Width           =   1095
      End
      Begin VB.Frame Frame10 
         Caption         =   "Tipo de Pago Matricula"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   735
         Left            =   120
         TabIndex        =   37
         Top             =   1800
         Width           =   2895
         Begin VB.ComboBox cbx_forma_pago 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            ItemData        =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":2B3C2
            Left            =   120
            List            =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":2B3D8
            TabIndex        =   59
            Top             =   240
            Width           =   2655
         End
      End
      Begin VB.TextBox Text6 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000F&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   48
         Top             =   720
         Width           =   2895
      End
   End
   Begin VB.Frame Frame3 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   6615
      Left            =   120
      TabIndex        =   39
      Top             =   1440
      Width           =   8295
      Begin MSHierarchicalFlexGridLib.MSHFlexGrid Grid1 
         Height          =   6255
         Left            =   120
         TabIndex        =   40
         Top             =   240
         Width           =   8055
         _ExtentX        =   14208
         _ExtentY        =   11033
         _Version        =   393216
         FocusRect       =   0
         SelectionMode   =   1
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         _NumberOfBands  =   1
         _Band(0).Cols   =   2
      End
   End
   Begin VB.Frame Frame4 
      Caption         =   "Selección por Alumno"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1215
      Left            =   2040
      TabIndex        =   9
      Top             =   120
      Width           =   9615
      Begin VB.ComboBox Combo2 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   7320
         TabIndex        =   46
         Text            =   "Combo1"
         Top             =   480
         Width           =   975
      End
      Begin VB.CommandButton Btn_Ver_Alumno 
         Caption         =   "Ver"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   8640
         Picture         =   "Form_Matr_Alu_Act_Prox_Agno_hue.frx":2B419
         Style           =   1  'Graphical
         TabIndex        =   20
         Top             =   360
         Width           =   735
      End
      Begin VB.TextBox Text2 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   5520
         TabIndex        =   17
         Text            =   "Text2"
         Top             =   480
         Width           =   1335
      End
      Begin VB.TextBox Text1 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   840
         TabIndex        =   16
         Text            =   "Text1"
         Top             =   480
         Width           =   4215
      End
      Begin VB.Label Label10 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   6960
         TabIndex        =   47
         Top             =   480
         Width           =   495
      End
      Begin VB.Label Label6 
         Caption         =   "Run"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5160
         TabIndex        =   19
         Top             =   480
         Width           =   495
      End
      Begin VB.Label Label5 
         Caption         =   "Nombre"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   18
         Top             =   480
         Width           =   615
      End
   End
End
Attribute VB_Name = "Form_Matr_Alu_Act_Prox_Agno_hue"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Variables Globales del Formulario.
    Dim ErrorStatus As Boolean
    Dim Flag_sub As Boolean

Private Sub Btn_Guardar_Cambios_Click()
'On Error GoTo Controlerror:
    ' Validar y Guardar Cambios
    Dim conecta As Boolean
    Dim Ind_Beca As Integer 'Indica si tiene beca
    Dim Ind_MBeca As Integer 'Indica si tiene media beca
    Dim Ind_Cupo As Integer 'Indica si paga con cuponera
    Dim Ind_Cont As Integer 'Indica si paga al contado
    Dim Ind_Cheq As Integer 'Indica si paga con cheque
    Dim Ind_Matr As Integer 'Indica si debe quedar matriculado en el proximo año
    Dim Ind_Exis As Integer 'Indica si ya esta matriculado para el proximo año
    Dim Ind_Curso As Integer 'Indica si ya tiene curso para el proximo año
    Dim FECMAT As Date
    Dim MyRow As Long
    Dim QRY As String
    Dim CMD As ADODB.Command
    Dim Affected As Long
    Dim Affect As Long
    Dim Codens As String
    Dim NumGra As String
    Dim PSWD As String
    Dim accion_realizada As String
    Dim log As Boolean
    Dim deuda As Boolean
    Dim agno_mat As Integer
    Dim rec As ADODB.Recordset
    Set rec = New ADODB.Recordset
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim b_rut_apo As String
    Dim accion_detalle As String
    Dim sw_cheques As Boolean
    Dim log_mensaje As String
'    Dim curso_alu As String
'    Dim valor_mat As String
        
    MyRow = Me.Grid1.Row
    Affected = 0
    ' Validación matricula
    If cbx_forma_pago.Text = "" Then
        MsgBox "Debe ingresar forma de pago para la Matricula", vbInformation
        Exit Sub
    End If
     ' Validación ingreso de forma de pago de mensualidades
    If cmb_tp_mensualidad.Text = "" Then
        MsgBox "Debe ingresar forma de pago para las Mensualidades", vbInformation
        Exit Sub
    End If
  
    ' Bloqueo alumno 4° Medio
    If Chk_Repite.Value = 0 And Grid1.TextMatrix(Grid1.Row, 5) = "310" And Grid1.TextMatrix(Grid1.Row, 6) = 4 Then
        MsgBox "Alumno de 4° Medio NO puede ser matriculado si no es repitente."
        Exit Sub
    End If
    
    ' Validad valor matricula que sea seelccionado
    If cb_valor_matricula.Text = "" And Combo1.Text >= 2022 Then
        MsgBox "Debe seleccionar el valor de la matricula", vbInformation
        Exit Sub
    End If
            
    '''''''''
If Check_confirma.Value = 1 Then
    Check_Mat.Value = 1
    
    mat_con_deuda = DevuelveCampo("usuarios", "", "matricular_con_deuda", "AUT_NOMBRE_USUARIO ='" & Nom_usu_ses & "'", conn)
    
    var_sql = "SELECT IF(LENGTH(condicional) > 1,'condicional',if(length(caducidad) > 1,'caducidad','repitencia')) as situacion FROM fnza_bloqueados_condicionales WHERE rut = '" & Grid1.TextMatrix(Grid1.Row, 2) & "'"
    'Situacion = devuelvecampo("fnza_bloqueados_condicionales", "", "IF(LENGTH(condicional) > 1,'condicional','caducidad') as situacion", "rut ='" & Grid1.TextMatrix(Grid1.Row, 2) & "'", conn)
    rec.Open var_sql, conn
    If rec.RecordCount > 0 Then
        Situacion = rec("situacion")
    End If
    rec.Close
    
    If Situacion <> "" Then
        If Situacion = "condicional" Then
            MsgBox "El alumno no puede ser matriculado porque se encuentra CONDICIONAL", vbInformation
            Exit Sub
        Else
            If Situacion = "caducidad" Then
                MsgBox "El alumno no puede ser matriculado porque tiene CADUCIDAD de matricula", vbInformation
                Exit Sub
            Else
                MsgBox "El alumno no puede ser matriculado porque esta en estado de Repitencia", vbInformation
                Exit Sub
            End If
        End If
    End If
    
    
    
    
        
        cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
        
        colegio = IIf(cole = "FAR001", "Farfana_2005", IIf(cole = "LON001", "Maipu_2005", IIf(cole = "SNB001", "Sanbernardo_2005", IIf(cole = "PUD001", "Pudahuel_2005", "otro"))))
                
            'If verifica_deuda(Grid1.TextMatrix(Grid1.Row, 2)) = True Or deuda_exage(Grid1.TextMatrix(Grid1.Row, 2), colegio) = True Then
            If verifica_deuda_particulares(Grid1.TextMatrix(Grid1.Row, 2), college) = True Then
                If mat_con_deuda = 0 Then
                    'MsgBox "Alumno No puede ser matriculado porque tiene deuda, si desea matricularlo debe comunicarse con el Departamento de Operaciones." & vbCrLf & vbCrLf & "Telefono: 6319515", vbCritical
                    If arr_deuda(4) = "cheques protestados" Then
                        If arr_deuda(3) = "titular" Then
                            MsgBox "Alumno No puede ser matriculado porque el Titular tiene cheques protestados, en " & arr_deuda(2), vbCritical
                        Else
                            MsgBox "Alumno No puede ser matriculado porque el apoderado tiene cheques protestados, en " & arr_deuda(2), vbCritical
                        End If
                        
                    Else
                        MsgBox "Alumno No puede ser matriculado porque el " & arr_deuda(3) & " tiene deuda, en " & arr_deuda(2), vbCritical
                    End If
'                   Form_Matr_Alu_Act_Prox_Agno.Enabled = False
'                   Form_main.Enabled = False
                    Check_confirma.Value = 0
                    Exit Sub
                Else
                If MsgBox("Alumno con deuda, ¿El alumno realizó repactación?", vbYesNo, "Atención") = vbNo Then
                    Check_confirma.Value = 0
                   ' MsgBox arr_deuda(2)
                    Exit Sub
                End If
                End If
            End If
            
                      
            'Aqui revisamos chueque protestados
                
    Else
        Check_Mat.Value = 0
        DTP_Fec_Mat.Enabled = True
    End If
    '''''''''
    
    
    'Verifica cheques y PAT
    conecta = ConectarBDSiempre(connLN, "192.168.7.91", "comunes_gescol", "groot", "kripplefight", True)

    'Busco Run Apoderado
    If Option1(2).Value = True Then
        var_sql = "SELECT rut_apo FROM apo_x_alu WHERE agno = " & (val(Grid1.TextMatrix(MyRow, 8))) & " and ci_alu = '" & Grid1.TextMatrix(Grid1.Row, 2) & "'"
        rec.Open var_sql, conn
        b_rut_apo = rec("rut_apo")
        rec.Close
    Else
        b_rut_apo = Text4.Text
    End If
    
            ' Validación de correo e email
    var_sql = "SELECT cel_apo,email FROM apoderados WHERE rut_apo = '" & b_rut_apo & "'"
    rec.Open var_sql, conn
        celular = rec("cel_apo")
        email = rec("email")
    rec.Close
    celular = val(celular)
    If Len(celular) < 8 Then
        MsgBox "Alumno no puede ser matriculado si no se ha ingresado el celular"
        Exit Sub
    End If
    
    If Len(email) < 8 Or InStr(email, "@") = 0 Or InStr(email, ".") = 0 Then
        MsgBox "Alumno no puede ser matriculado si no se ha ingresado el email"
        Exit Sub
    End If
    
    
    var_sql = "SELECT * FROM fnza_enmendados WHERE rut = '" & b_rut_apo & "'"
    'Situacion = devuelvecampo("fnza_bloqueados_condicionales", "", "IF(LENGTH(condicional) > 1,'condicional','caducidad') as situacion", "rut ='" & Grid1.TextMatrix(Grid1.Row, 2) & "'", conn)
    rec.Open var_sql, conn
    If rec.RecordCount > 0 Then
        MsgBox "No es posible realizar la matricula, Apoderado con cheques enmendados", vbInformation
        rec.Close
        Exit Sub
    End If
    rec.Close
    
    var_sql = "SELECT * FROM fnza_cheques_rescatados WHERE rut_apo = '" & b_rut_apo & "'"
    'Situacion = devuelvecampo("fnza_bloqueados_condicionales", "", "IF(LENGTH(condicional) > 1,'condicional','caducidad') as situacion", "rut ='" & Grid1.TextMatrix(Grid1.Row, 2) & "'", conn)
    rec.Open var_sql, conn
    If rec.RecordCount > 0 Then
        MsgBox "No es posible realizar la matricula, Apoderado con cheques rescatados", vbInformation
        rec.Close
        Exit Sub
    End If
    rec.Close
    
'''''''    ''''''''''' Bloqueo los que seleccionan la forma de pagos cheque y tienen protestos.
'''''''    If cbx_forma_pago.Text = "Cheque" Then
'''''''        var_sql = "SELECT motivo,nombre FROM `fnza_lista_negra_apoderados` f,colegios c where f.colegio = c.colegio and ci_apo = '" & b_rut_apo & "' and bloqueado = 1"
'''''''        'Situacion = devuelvecampo("fnza_bloqueados_condicionales", "", "IF(LENGTH(condicional) > 1,'condicional','caducidad') as situacion", "rut ='" & Grid1.TextMatrix(Grid1.Row, 2) & "'", conn)
'''''''        rec.Open var_sql, conn
'''''''        If rec.RecordCount > 0 Then
'''''''            MsgBox "No es posible realizar la matricula con forma de pagos CHEQUE, porque apoderado tiene cheques protestados", vbInformation
'''''''            rec.Close
'''''''            Exit Sub
'''''''        End If
'''''''        rec.Close
'''''''    End If
    
    
     
    ''''' Bloqueo hermanos protestos
    var_sql = "SELECT ci_apo,ci_alu FROM fnza_lista_negra_apoderados n,apo_x_alu axa" _
            & " WHERE bloqueado = 1 and n.ci_apo = axa.rut_apo AND ci_apo = '" & b_rut_apo & "' GROUP BY n.ci_apo,axa.ci_alu"
    rec.Open var_sql, conn
    While Not rec.EOF
        var_sql = "SELECT * FROM fnza_lista_negra_apoderados n,apo_x_alu axa" _
                & " WHERE bloqueado = 1 and n.ci_apo = axa.rut_apo AND ci_alu = '" & rec("ci_alu") & "' GROUP BY n.ci_apo,axa.ci_alu"
        objRS.Open var_sql, conn
        If objRS.RecordCount > 0 Then
            MsgBox "Apoderado o Alumnos con cheques protestados", vbInformation
            objRS.Close
            rec.Close
            Exit Sub
        End If
        objRS.Close
        rec.MoveNext
    Wend
    rec.Close
    
    
     ''''' Bloqueo codigo DICOM
    var_sql = "SELECT IF(LENGTH(dicom) IS NULL,0,LENGTH(dicom)) AS dicom FROM fnza_cheques_recibidos WHERE run_apo = '" & b_rut_apo & "' AND agno = 2020"
    rec.Open var_sql, conn
    If rec.RecordCount > 0 Then
            If rec("dicom") = 3 Or rec("dicom") = 0 Then
                MsgBox "No es posible matricular apoderado con DICOM, o no fue ingresado codigo de verificación", vbInformation
                rec.Close
                Exit Sub
            End If
    End If
    rec.Close
        

    'Bloquea por rut apo
    var_sql = "SELECT motivo,nombre FROM `fnza_lista_negra_apoderados` f,colegios c where f.colegio = c.colegio and ci_apo = '" & b_rut_apo & "' and bloqueado = 1"
    rec.Open var_sql, connLN
    If rec.RecordCount > 0 Then
        If rec("motivo") = "Apoderado con cheque(s) protestado(s) sin regularizar" Or rec("motivo") = "Apoderado con cheque(s) en cartera vencido(s) y sin regularizar" Then

            MsgBox "El apoderado no puede matricular por " & rec("motivo") & " en " & rec("nombre") _
            & ", si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbInformation

        Else
            MsgBox "El apoderado no puede matricular por " & rec("motivo") & " en " & rec("nombre") _
            & ", si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbInformation
        End If
        Exit Sub
    End If
    rec.Close


    'Bloquea por rut tit
    var_sql = "SELECT motivo,nombre FROM `fnza_lista_negra_apoderados` f,colegios c where f.colegio = c.colegio and ci_tit = '" & b_rut_apo & "' and bloqueado = 1"
    rec.Open var_sql, connLN
    If rec.RecordCount > 0 Then
        If rec("motivo") = "Apoderado con cheque(s) protestado(s) sin regularizar" Or rec("motivo") = "Apoderado con cheque(s) en cartera vencido(s) y sin regularizar" Then

            MsgBox "El apoderado no puede matricular por " & rec("motivo") & " en " & rec("nombre") _
            & ", si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbInformation

        Else
            MsgBox "El apoderado no puede matricular por " & rec("motivo") & " en " & rec("nombre") _
            & ", si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbInformation
        End If
        Exit Sub
    End If
    rec.Close


    'Bloquea por alumno
    var_sql = "SELECT motivo,nombre FROM `fnza_lista_negra_alumnos` f,colegios c where f.colegio = c.colegio and ci_alu = '" & Grid1.TextMatrix(Grid1.Row, 2) & "' and bloqueado = 1"
    rec.Open var_sql, connLN
    If rec.RecordCount > 0 Then
        If rec("motivo") = "Apoderado con cheque(s) protestado(s) sin regularizar" Or rec("motivo") = "Apoderado con cheque(s) en cartera vencido(s) y sin regularizar" Then
            MsgBox "El alumno no puede ser matriculado porque el " & rec("motivo") & " en " & rec("nombre") _
                & ", si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbInformation
        Else
            MsgBox "El alumno no puede ser matriculado porque el " & rec("motivo") & " en " & rec("nombre") _
                & ", si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbInformation
        End If
        Exit Sub
    End If
    rec.Close
    connLN.Close
    
    
    ''''''''Verifica cheques protestados y PAT de lista.
    'cheques
    var_sql = "SELECT * FROM temp_protestados WHERE rut = '" & b_rut_apo & "'"
    rec.Open var_sql, conn
    If rec.RecordCount > 0 Then
        sw_pro = True
    End If
    rec.Close
    
    'PAT
    var_sql = "SELECT * FROM temp_pat WHERE rut = '" & b_rut_apo & "'"
    rec.Open var_sql, conn
    If rec.RecordCount > 0 Then
        sw_pat = True
    End If
    rec.Close
    
    
    
    
            If sw_pro = True Or sw_pat = True Then
                If mat_con_deuda = 0 Then
                    'MsgBox "Alumno No puede ser matriculado porque tiene deuda, si desea matricularlo debe comunicarse con el Departamento de Operaciones." & vbCrLf & vbCrLf & "Telefono: 6319515", vbCritical
                    If sw_pro = True Then
                        MsgBox "Alumno No puede ser matriculado porque el Titular tiene cheques protestados, si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbCritical
                    Else
                        MsgBox "Alumno No puede ser matriculado porque el Apoderado tiene PAT, si desea matricular necesita autorizacion de Katherine Cortes, comunicarse al fono 26319510", vbCritical
                    End If
'                   Form_Matr_Alu_Act_Prox_Agno.Enabled = False
'                   Form_main.Enabled = False
                    Check_confirma.Value = 0
                    Exit Sub
                Else
                If MsgBox("Alumno con deuda, ¿El alumno realizó repactación?", vbYesNo, "Atención") = vbNo Then
                    Check_confirma.Value = 0
                   ' MsgBox arr_deuda(2)
                    Exit Sub
                End If
                End If
            End If
        
    ''''''Verifico que cheques esten ingresados para poder realizar matricula.
    var_sql = "SELECT SUM(monto_chq) as mc FROM fnza_cheques_recibidos WHERE run_apo = '" & b_rut_apo & "' AND agno = " & val(Grid1.TextMatrix(MyRow, 8)) + 1
    rec.Open var_sql, conn
    If rec.RecordCount > 0 And Not IsNull(rec("mc")) Then
        monto_cheques = rec("mc")
    Else
        monto_cheques = 0
    End If
    rec.Close
    var_sql = "SELECT SUM(monto_mens) as mm FROM fnza_mensualidad WHERE run_apo = '" & b_rut_apo & "' AND agno = " & val(Grid1.TextMatrix(MyRow, 8)) + 1
    rec.Open var_sql, conn
    If rec.RecordCount > 0 And Not IsNull(rec("mm")) Then
        monto_mensualidad = rec("mm")
    Else
        monto_mensualidad = 0
    End If
    rec.Close
    
    sw_cheques = True
    If monto_cheques < 89900 And cbx_forma_pago.Text = "Cheques" Then
        MsgBox "La matricula NO se puede realizar, los cheques deben ser ingresados al sistema", vbInformation
        sw_cheques = False
        'Load Form_Ingreso_Cheques
        'Form_Ingreso_Cheques.cmb_agno.Text = 2020
        'Exit Sub
    End If
    
    If sw_cheques = True And monto_cheques < 899000 And cmb_tp_mensualidad.Text = "Cheques" Then
        MsgBox "La matricula NO se puede realizar, los cheques deben ser ingresados al sistema", vbInformation
        sw_cheques = False
        'Load Form_Ingreso_Cheques
        'Form_Ingreso_Cheques.cmb_agno.Text = 2020
        'Exit Sub
    End If
         
    If sw_cheques = False Then
        Load Form_Ingreso_Cheques
        Form_Ingreso_Cheques.Flag_Sub_True
        Form_Ingreso_Cheques.Text1.Text = Grid1.TextMatrix(Grid1.Row, 1)
        Form_Ingreso_Cheques.text2.Text = Grid1.TextMatrix(Grid1.Row, 2)
        Form_Ingreso_Cheques.Flag_Sub_False
        Form_Ingreso_Cheques.Text1.Locked = True
        Form_Ingreso_Cheques.text2.Locked = True
        Form_Ingreso_Cheques.Text11 = Grid1.TextMatrix(Grid1.Row, 10)
        Form_Ingreso_Cheques.Text12 = Grid1.TextMatrix(Grid1.Row, 11)
        Form_Ingreso_Cheques.Show
        Exit Sub
    End If
         
         
         
    
    'Verifico que el apoderado no haya tenido ningun protesto
  '  If Option3(3).Value = True Then
'    deuda = valida_protestos(Grid1.TextMatrix(Grid1.Row, 2))
'        If deuda Then
'            MsgBox "El apoderado no puede tener tipo de pago cheques, porque ha tenido cheques protestados", vbExclamation, "Matricula de Alumnos Activos para el proximo año"
'            Exit Sub
'        End If
'    End If

    Dim REC1 As ADODB.Recordset
    Dim QRY1 As String
    
    Set REC1 = New ADODB.Recordset
    
    QRY1 = "SELECT * FROM matriculas WHERE anno_mat = '" & Combo2.Text & "' AND cod_sit = 'R' AND ci_alu = '" & Trim(Grid1.TextMatrix(MyRow, 2)) & "'"
    'Set REC1 = New ADODB.Recordset
    REC1.Open QRY1, conn
    
    If Not REC1.EOF Then
        rep = 1
    Else
        rep = 0
    End If
    
    If Chk_Repite.Value = 1 Then
    
        If rep = 0 Then
        
        If MsgBox("El alumno NO está registrado como REPITENTE el año " & Combo2.Text & ", ¿Desea matricularlo como repitente de todas maneras?", vbQuestion + vbYesNo, "El Alumno no es Repitente") = vbYes Then
            PSWD = InputBox("Ingrese Código de Autorización para Repitencia", "Código para declarar repitencia")
            If Not (PSWD = RetornaCampo("CFG", "valor", "Param='CodRepitencia'", conn)) Then
            MsgBox "Código de autorización incorrecto." & vbCrLf & vbCrLf & "Información no guardada.", vbExclamation, "No Autorizado."
            Exit Sub
            End If
        Else
            Chk_Repite.Value = 0
        End If
        
        Else
            PSWD = InputBox("Ingrese Código de Autorización para Repitencia", "Código para declarar repitencia")
            If Not (PSWD = RetornaCampo("CFG", "valor", "Param='CodRepitencia'", conn)) Then
            MsgBox "Código de autorización incorrecto." & vbCrLf & vbCrLf & "Información no guardada.", vbExclamation, "No Autorizado."
            Exit Sub
            End If
        End If
        
    Else
    'pregunta si es repitente
    
        If rep = 1 Then
            If MsgBox("El alumno está registrado como REPITENTE el año " & Combo2.Text & ", ¿Desea modificar la información de matrícula?", vbCritical + vbYesNo, "El Alumno es Repitente") = vbYes Then
                Exit Sub
            End If
        End If
        
    End If
    
    If RetornaCampo("apo_x_alu", "rut_apo", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND agno='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "'", conn) = "" Then
        'Aquí le asigno el apoderado al alumno para el año siguiente            '
        QRY = "SELECT * FROM apo_x_alu" _
        & " where agno = " & (val(Grid1.TextMatrix(MyRow, 8))) _
        & " and ci_alu = '" & Trim(Grid1.TextMatrix(MyRow, 2)) & "'"
        rec.Open QRY, conn
        QRY = "replace into apo_x_alu(rut_apo,ci_alu,parent_apo,agno)" _
        & "values('" & rec("rut_apo") & "','" & rec("ci_alu") & "','" _
        & rec("parent_apo") & "'," & (rec("agno") + 1) & ")"
        conn.Execute QRY
        rec.Close
        'MsgBox "El alumno no tiene definido apoderado para el año " & (Val(Grid1.TextMatrix(MyRow, 8)) + 1) & ".", vbExclamation, "INCONSISTENCIA"
        'Exit Sub
    End If
     
'    If Not ((Option2(0).Value Or Option2(1).Value Or Option2(2).Value) And (Option3(0).Value Or Option3(1).Value Or Option3(2).Value Or Option3(3).Value)) Then
'        MsgBox "Faltan datos que completar", vbExclamation, "VALIDACION"
'        Exit Sub
'    End If
    Set CMD = New ADODB.Command
    CMD.ActiveConnection = conn
    CMD.CommandType = adCmdText
    
    Ind_Exis = val(RetornaCampo("matriculas", "count(ci_alu) as existe", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn))
    Ind_Matr = IIf((Check_Mat.Value = 1 Or Check_Mat.Value = 2), 1, 0)
    FECMAT = IIf(Ind_Exis = 0, DTP_Fec_Mat.Value, RetornaCampo("matriculas", "fec_mat", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn))
    If Ind_Exis > 0 Then
        Ind_Curso = val(RetornaCampo("alu_x_cur", "count(ci_alu) as existe", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND agno='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn))
        If Ind_Curso = 1 Then
            MsgBox "El alumno tiene curso asignado, no se pueden realizar movimientos mientras este sea el caso"
            Exit Sub
        End If
        If Not (Ind_Matr = 1) Then
            If MsgBox("Esta operación eliminará la matrícula del alumno para el próximo año." & vbCrLf & vbCrLf & "Presione CANCELAR para detener la operación, de lo contrario presione ACEPTAR para eliminar la matrícula.", vbExclamation + vbOKCancel, "Desmatricular Alumno") = vbCancel Then
                Grid1_SelChange
                Exit Sub
            End If
            QRY = "DELETE FROM matriculas WHERE ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI' AND fec_mat='" & Format(FECMAT, "yyyy-mm-dd") & "';"
            CMD.CommandText = QRY
            CMD.Execute Affected
            '########################
            'Borrar de Tablas de Fnza
            RecalculaCuota_Alu_Retiro Trim(Grid1.TextMatrix(MyRow, 2)), FECMAT, conn, (val(Grid1.TextMatrix(MyRow, 8)) + 1)
            '########################
            If Affected > 0 Then
                ' Insertar Log de eliminacion de matricula.
                QRY = "CREATE TABLE IF NOT EXISTS `fnza_log_edicion_maaa_matricula` (`FOLIO_REGEDIT` bigint(20) NOT NULL auto_increment,`LOGIN_USUARIO` varchar(100) NOT NULL default '',`NOMBRE_USUARIO` varchar(100) NOT NULL default '',`RUN_ALU` varchar(10) NOT NULL default '',`FEC_MAT` date NOT NULL default '0000-00-00',`ANNO_MAT` int(11) NOT NULL default '0',`FECHA_MODIFICACION` datetime NOT NULL default '0000-00-00 00:00:00', `ACCION` varchar(50) NOT NULL default '',PRIMARY KEY  (`FOLIO_REGEDIT`),UNIQUE KEY `fnza_log_maaa_matricula_sec_key` (`FECHA_MODIFICACION`,`LOGIN_USUARIO`),KEY `fnza_log_maaa_matricula_index_one` (`RUN_ALU`,`FEC_MAT`,`ANNO_MAT`)) ENGINE=MyISAM;"
                CMD.CommandText = QRY
                CMD.Execute Affect
                QRY = "INSERT INTO FNZA_LOG_EDICION_MAAA_MATRICULA(LOGIN_USUARIO,NOMBRE_USUARIO,RUN_ALU,FEC_MAT,ANNO_MAT,FECHA_MODIFICACION,ACCION) VALUES ('" & Nom_usu_ses & "','" & Nom_com_usu_ses & "','" & Grid1.TextMatrix(MyRow, 2) & "','" & Format(FECMAT, "yyyy-mm-dd") & "','" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "',concat(current_date,' ',current_time),'Matricula Eliminada');"
                CMD.CommandText = QRY
                CMD.Execute Affect
                ' Fin Log.
            End If
            'RecalculaCuota_Alu Trim(Grid1.TextMatrix(MyRow, 2)), (Val(Grid1.TextMatrix(MyRow, 8)) + 1), conn
            RecalculaCuota_Alu_Retiro Trim(Grid1.TextMatrix(MyRow, 2)), FECMAT, conn
            MsgBox "Matricula del alumno eliminada", vbInformation, "GesCol"
            
                ' Log Desmatricula
                
                accion_realizada = "El alumno fue DESMATRICULADO" _
                                & " para el período " & (val(Grid1.TextMatrix(MyRow, 8)) + 1)
                log = Inserta_Vitacora_Alumno(Grid1.TextMatrix(Grid1.Row, 2), accion_realizada)
                ' Fin Log.
            
            Exit Sub
            '# FIN
        Else
            Codens = Grid1.TextMatrix(MyRow, 5)
            NumGra = Grid1.TextMatrix(MyRow, 6)
            If Not (Chk_Repite.Value = 1) Then
                Select Case Codens
                    Case "111"
                        Codens = "996"
                        NumGra = 1
                    Case "996"
                        Codens = "010"
                        NumGra = 1
                    Case "010"
                        Codens = "110"
                        NumGra = 1
                    Case "110"
                        If NumGra = "8" Then
                            Codens = "310"
                            NumGra = 1
                        Else
                            NumGra = NumGra + 1
                        End If
                    Case "310"
                        If NumGra = "4" Then
                            NumGra = 4
                        Else
                            NumGra = NumGra + 1
                        End If
                    Case Else
                        Err.Raise vbObjectError + 1100, "Form_Matr_Alu_Act_Prox_Agno.Btn_Guardar_Cambios", "Tipo de enseñanza no valido o incorrecto para el alumno " & Trim(Grid1.TextMatrix(MyRow, 2))
                End Select
            End If
            'Si el alumno tiene cheques protestados devuelve verdadero
'    If verifica_cheques_protestados(Trim(Grid1.TextMatrix(Grid1.Row, 2)), (Val(Grid1.TextMatrix(MyRow, 8)) + 1)) Then
'        MsgBox "El alumno tiene cheques protestados.", vbCritical, "Alumno no puede ser matriculado"
'        'conn.Execute "DELETE FROM apo_x_alu WHERE ci_alu='" & Rut_ALu & "' and agno=" & Trim(cmb_AnhoPos.Text) & ";"
'        Exit Sub
'    End If
'    If verifica_alumno_protestados(Trim(Grid1.TextMatrix(Grid1.Row, 2))) Then
'        MsgBox "El alumno tiene cheques protestados.", vbCritical, "Alumno no puede ser matriculado"
'        'conn.Execute "DELETE FROM apo_x_alu WHERE ci_alu='" & Rut_ALu & "' and agno=" & Trim(cmb_AnhoPos.Text) & ";"
'        Exit Sub
'    End If
    
            'If Format(DTP_Fec_Mat, "mm-dd") = "12-31" Then
                fecha_real = DevuelveCampo("establecimientos", "", "DATE_FORMAT(NOW(),'%Y-%m-%d')", "1=1", conn)
            'Else
            '    fecha_real = Format(DTP_Fec_Mat, "yyyy-mm-dd")
            'End If
    
            'SI
            QRY = "REPLACE matriculas(fec_mat_r,ci_alu,activo_alu,fec_mat,anno_mat,num_mat,fec_retiro,reserva,cod_ens,num_gra,cod_jor,confirmado) VALUES ('" & fecha_real & "','" & Trim(Grid1.TextMatrix(MyRow, 2)) & "','SI','" & Format(DTP_Fec_Mat.Value, "yyyy-mm-dd") & "','" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "','00000','1111-11-11','0','" & Codens & "','" & NumGra & "','" & val(Grid1.TextMatrix(MyRow, 9)) & "','" & IIf((Check_confirma.Value = 1 Or Check_confirma.Value = 2), "SI", "NO") & "');"
            CMD.CommandText = QRY
            CMD.Execute Affected
            RecalculaCuota_Alu_Retiro Trim(Grid1.TextMatrix(MyRow, 2)), (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "/02/02", conn
            If Not (Affected > 0) Then
                Err.Raise vbObjectError + 2000, Btn_Guardar_Cambios, "No se pudo actualizar la matricula en la B.D."
            Else
                ' Insertar Log de insercion de matricula.
                QRY = "CREATE TABLE IF NOT EXISTS `fnza_log_edicion_maaa_matricula` (`FOLIO_REGEDIT` bigint(20) NOT NULL auto_increment,`LOGIN_USUARIO` varchar(100) NOT NULL default '',`NOMBRE_USUARIO` varchar(100) NOT NULL default '',`RUN_ALU` varchar(10) NOT NULL default '',`FEC_MAT` date NOT NULL default '0000-00-00',`ANNO_MAT` int(11) NOT NULL default '0',`FECHA_MODIFICACION` datetime NOT NULL default '0000-00-00 00:00:00', `ACCION` varchar(50) NOT NULL default '',PRIMARY KEY  (`FOLIO_REGEDIT`),UNIQUE KEY `fnza_log_maaa_matricula_sec_key` (`FECHA_MODIFICACION`,`LOGIN_USUARIO`),KEY `fnza_log_maaa_matricula_index_one` (`RUN_ALU`,`FEC_MAT`,`ANNO_MAT`)) ENGINE=MyISAM;"
                CMD.CommandText = QRY
                CMD.Execute Affect
                QRY = "INSERT INTO FNZA_LOG_EDICION_MAAA_MATRICULA(LOGIN_USUARIO,NOMBRE_USUARIO,RUN_ALU,FEC_MAT,ANNO_MAT,FECHA_MODIFICACION,ACCION) VALUES ('" & Nom_usu_ses & "','" & Nom_com_usu_ses & "','" & Grid1.TextMatrix(MyRow, 2) & "','" & Format(FECMAT, "yyyy-mm-dd") & "','" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "',concat(current_date,' ',current_time),'Matricula Actualizada - Accion:" & Affected & " - Confirnada:" & IIf((Check_confirma.Value = 1 Or Check_confirma.Value = 2), "SI", "NO") & "');"
                CMD.CommandText = QRY
                CMD.Execute Affect
                ' Fin Log.
                
                Select Case Codens
                    Case "111"
                        grado = "PG"
                    Case "996"
                        grado = "PK"
                    Case "010"
                        grado = "K"
                    Case "110"
                        grado = "EB"
                    Case "310"
                        grado = "EM"
                End Select
                curso = CStr(NumGra) & "º " & grado
                accion_realizada = "El alumno fue matriculado en " & curso _
                                & ", para el período " & (val(Grid1.TextMatrix(MyRow, 8)) + 1)
                log = Inserta_Vitacora_Alumno(Grid1.TextMatrix(Grid1.Row, 2), accion_realizada)
                ' Fin Log.
                
            End If
        End If
    Else
        If Not (Ind_Matr = 1) Then
            Exit Sub
        Else
            Codens = Grid1.TextMatrix(MyRow, 5)
            NumGra = Grid1.TextMatrix(MyRow, 6)
            If Not (Chk_Repite.Value = 1) Then
                Select Case Codens
                    Case "111"
                        Codens = "996"
                        NumGra = 1
                    Case "996"
                        Codens = "010"
                        NumGra = 1
                    Case "010"
                        Codens = "110"
                        NumGra = 1
                    Case "110"
                        If NumGra = "8" Then
                            Codens = "310"
                            NumGra = 1
                        Else
                            NumGra = NumGra + 1
                        End If
                    Case "310"
                        If NumGra = "4" Then
                            NumGra = 4
                        Else
                            NumGra = NumGra + 1
                        End If
                    Case Else
                        Err.Raise vbObjectError + 1100, "Form_Matr_Alu_Act_Prox_Agno.Btn_Guardar_Cambios", "Tipo de enseñanza no valido o incorrecto para el alumno " & Trim(Grid1.TextMatrix(MyRow, 2))
                End Select
            End If
            If verifica_cheques_protestados(Trim(Grid1.TextMatrix(Grid1.Row, 2)), (val(Grid1.TextMatrix(MyRow, 8)) + 1)) Then
                MsgBox "El alumno tiene cheques protestados.", vbCritical, "Alumno no puede ser matriculado"
                'conn.Execute "DELETE FROM apo_x_alu WHERE ci_alu='" & Rut_ALu & "' and agno=" & Trim(cmb_AnhoPos.Text) & ";"
                Exit Sub
            End If
            If verifica_alumno_protestados(Trim(Grid1.TextMatrix(Grid1.Row, 2))) Then
                MsgBox "El alumno tiene cheques protestados.", vbCritical, "Alumno no puede ser matriculado"
                'conn.Execute "DELETE FROM apo_x_alu WHERE ci_alu='" & Rut_ALu & "' and agno=" & Trim(cmb_AnhoPos.Text) & ";"
                Exit Sub
            End If
            
            'SI
            
            'If Format(DTP_Fec_Mat, "mm-dd") = "12-31" Then
                fecha_real = DevuelveCampo("establecimientos", "", "DATE_FORMAT(NOW(),'%Y-%m-%d')", "1=1", conn)
            'Else
             '   fecha_real = Format(DTP_Fec_Mat, "yyyy-mm-dd")
            'End If
            
            QRY = "INSERT matriculas(fec_mat_r,ci_alu,activo_alu,fec_mat,anno_mat,num_mat,fec_retiro,reserva,cod_ens,num_gra,cod_jor,confirmado) VALUES ('" & fecha_real & "','" & Trim(Grid1.TextMatrix(MyRow, 2)) & "','SI','" & Format(FECMAT, "yyyy-mm-dd") & "','" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "','00000','1111-11-11','0','" & Codens & "','" & NumGra & "','" & val(Grid1.TextMatrix(MyRow, 9)) & "','" & IIf((Check_confirma.Value = 1 Or Check_confirma.Value = 2), "SI", "NO") & "');"
            CMD.CommandText = QRY
            CMD.Execute Affected
            If Not (Affected > 0) Then
                Err.Raise vbObjectError + 2000, Btn_Guardar_Cambios, "No se pudo crear la matricula en la B.D."
            Else
                ' Insertar Log de insercion de matricula.
                QRY = "CREATE TABLE IF NOT EXISTS `fnza_log_edicion_maaa_matricula` (`FOLIO_REGEDIT` bigint(20) NOT NULL auto_increment,`LOGIN_USUARIO` varchar(100) NOT NULL default '',`NOMBRE_USUARIO` varchar(100) NOT NULL default '',`RUN_ALU` varchar(10) NOT NULL default '',`FEC_MAT` date NOT NULL default '0000-00-00',`ANNO_MAT` int(11) NOT NULL default '0',`FECHA_MODIFICACION` datetime NOT NULL default '0000-00-00 00:00:00', `ACCION` varchar(50) NOT NULL default '',PRIMARY KEY  (`FOLIO_REGEDIT`),UNIQUE KEY `fnza_log_maaa_matricula_sec_key` (`FECHA_MODIFICACION`,`LOGIN_USUARIO`),KEY `fnza_log_maaa_matricula_index_one` (`RUN_ALU`,`FEC_MAT`,`ANNO_MAT`)) ENGINE=MyISAM;"
                CMD.CommandText = QRY
                CMD.Execute Affect
                QRY = "INSERT INTO FNZA_LOG_EDICION_MAAA_MATRICULA(LOGIN_USUARIO,NOMBRE_USUARIO,RUN_ALU,FEC_MAT,ANNO_MAT,FECHA_MODIFICACION,ACCION) VALUES ('" & Nom_usu_ses & "','" & Nom_com_usu_ses & "','" & Grid1.TextMatrix(MyRow, 2) & "','" & Format(FECMAT, "yyyy-mm-dd") & "','" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "',concat(current_date,' ',current_time),'Matricula Creada - Accion:" & Affected & " - Confirmada:" & IIf((Check_confirma.Value = 1 Or Check_confirma.Value = 2), "SI", "NO") & "');"
                CMD.CommandText = QRY
                CMD.Execute Affect
                ' Fin Log.
                
                ' Insertar Log de insercion de matricula.
                Select Case Codens
                    Case "111"
                        grado = "PG"
                    Case "996"
                        grado = "PK"
                    Case "010"
                        grado = "K"
                    Case "110"
                        grado = "EB"
                    Case "310"
                        grado = "EM"
                End Select
                curso = CStr(NumGra) & "º " & grado
                accion_realizada = "El alumno fue matriculado en " & curso _
                                & ", para el período " & (val(Grid1.TextMatrix(MyRow, 8)) + 1)
                log = Inserta_Vitacora_Alumno(Grid1.TextMatrix(Grid1.Row, 2), accion_realizada)
                ' Fin Log.
                
                ' Log finanza
                accion_detalle = "El usuario selecciono para el año " & (val(Grid1.TextMatrix(MyRow, 8)) + 1) _
                               & " para matricula: " & cbx_forma_pago.Text _
                               & ", mensualidad: " & cmb_tp_mensualidad.Text
                Call Inserta_Vitacora_Finanza(Grid1.TextMatrix(Grid1.Row, 2), b_rut_apo, "Forma de Pago", accion_detalle, 0, 0)
                ' Fin Log
                
            End If
        End If
    End If
    
'    Ind_Cont = IIf(Me.cbx_forma_pago.Text = "Contado", 1, 0)
'    Ind_Cheq = IIf(Me.cbx_forma_pago.Text = "Cheque", 1, 0)
'    ind_pac = IIf(Me.cbx_forma_pago.Text = "PAC", 1, 0)
    
    'Huechuraba
    Ind_Cont = 0
    Ind_Cheq = 0
    ind_pac = 0
    
    ' aqui guardar la forma de pago cheques
    QRY = "UPDATE matriculas SET " & _
            "ind_beca=0, " & _
            "forma_pago = '" & cbx_forma_pago.Text & "', " & _
            "fp_matricula = '" & cbx_forma_pago.Text & "', " & _
            "fp_mensualidad = '" & cmb_tp_mensualidad.Text & "', " & _
            "usuario_ingreso = '" & Nom_com_usu_ses & "', " & _
            "ind_mbeca=0, " & _
            "ind_cup=0, " & _
            "ind_cont=" & Ind_Cont & ", " & _
            "ind_cheq=" & Ind_Cheq & ", " & _
            "ind_pac=" & ind_pac & " WHERE " & _
            "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND " & _
            "fec_mat='" & Format(FECMAT, "yyyy-mm-dd") & "' AND " & _
            "anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' LIMIT 1;"
    CMD.CommandText = QRY
    CMD.Execute Affected
    
    If Affected > 0 Then
        ' Insertar Log de modificación de tipo de pago de Alumno.
        QRY = "CREATE TABLE IF NOT EXISTS `fnza_log_edicion_maaa_tpagos` (`FOLIO_REGEDIT` bigint(20) NOT NULL auto_increment,`LOGIN_USUARIO` varchar(100) NOT NULL default '',`NOMBRE_USUARIO` varchar(100) NOT NULL default '',`RUN_ALU` varchar(10) NOT NULL default '',`FEC_MAT` date NOT NULL default '0000-00-00',`ANNO_MAT` int(11) NOT NULL default '0',`IND_BECA` decimal(10,0) NOT NULL default '0',`IND_MBECA` decimal(10,0) NOT NULL default '0',`IND_CUP` decimal(10,0) NOT NULL default '0',`IND_CONT` decimal(10,0) NOT NULL default '0',`IND_CHEQ` decimal(10,0) NOT NULL default '0',`FECHA_MODIFICACION` datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY  (`FOLIO_REGEDIT`),UNIQUE KEY `fnza_log_maaa_tpagos_sec_key` (`FECHA_MODIFICACION`,`LOGIN_USUARIO`),KEY `fnza_log_maaa_tpagos_index_one` (`RUN_ALU`,`FEC_MAT`,`ANNO_MAT`)) ENGINE=MyISAM;"
        CMD.CommandText = QRY
        CMD.Execute
        QRY = "INSERT INTO FNZA_LOG_EDICION_MAAA_TPAGOS(LOGIN_USUARIO,NOMBRE_USUARIO,RUN_ALU,FEC_MAT,ANNO_MAT,IND_BECA,IND_MBECA,IND_CUP,IND_CONT,IND_CHEQ,FECHA_MODIFICACION) VALUES ('" & Nom_usu_ses & "','" & Nom_com_usu_ses & "','" & Grid1.TextMatrix(MyRow, 2) & "','" & Format(FECMAT, "yyyy-mm-dd") & "','" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "','" & Ind_Beca & "','" & Ind_MBeca & "','" & Ind_Cupo & "','" & Ind_Cont & "','" & Ind_Cheq & "',concat(current_date,' ',current_time));"
        CMD.CommandText = QRY
        CMD.Execute Affect
        ' Fin Log de cambio modificación de tipo de pago de Alumno.
    End If
    
    ' Recalculamos las Mensualidades
    RecalculaCuota_Alu Trim(Grid1.TextMatrix(MyRow, 2)), (val(Grid1.TextMatrix(MyRow, 8)) + 1), conn
    
    
    
'INICIO ACTUALIZACION HUECHURABA
'--------------------------------------------------------------------------------------------------
           
    Rut_ALu = Trim(Grid1.TextMatrix(MyRow, 2))
    AnhoPos = val(Grid1.TextMatrix(MyRow, 8)) + 1
    
    ' Borro mensualidad repetida
    var_sql = "SELECT mes FROM fnza_detalle_mensualidad WHERE agno = " & AnhoPos & " AND run_alu = '" & Rut_ALu & "' AND concepto = 'ct00'"
    rec.Open var_sql, conn
    If rec.RecordCount > 0 Then
        var_sql = "DELETE FROM fnza_detalle_mensualidad WHERE estado_dtll = 'impg' and concepto = 'esco' and agno = " & AnhoPos & " AND run_alu = '" & Rut_ALu & "' AND mes = " & rec("mes")
        conn.Execute var_sql
    End If
    rec.Close
    
    ' traemos el rut del apoderado
    StrSql = "select rut_apo from apo_x_alu where ci_alu = '" & Rut_ALu & "' limit 1"
    Set Rst = conn.Execute(StrSql)
    Do While Not Rst.EOF
        rut_apo = Rst("rut_apo")
        Rst.MoveNext
    Loop
    
    ' trae el valor de la cuota de incorporacion
    StrSql = "select concat(cod_ens,num_gra) from matriculas where ci_alu='" & Rut_ALu & "' order by anno_mat desc limit 1"
    StrSql = "select * from fnza_descuento where agno=" & AnhoPos & " and curso = (" & StrSql & ")"
    Set Rst = conn.Execute(StrSql)
    Do While Not Rst.EOF
        cuota_inco = Rst("cuota_incorporacion")
        Rst.MoveNext
    Loop
    
    'Log forma de pago
''        accion = "Forma pago"
''        accion_detalle = "El usuario eligio la forma de pago " & Me.cbx_forma_pago.Text & " para la matricula del alumno para el año " & AnhoPos
''        Call Inserta_Vitacora_Finanza(Form_Pagar_Mensualidad_hue.Grilla.TextMatrix(Form_Pagar_Mensualidad_hue.Grilla.Row, 0), _
''        Form_Pagar_Mensualidad_hue.text2.Text, CStr(accion), CStr(accion_detalle), 0, 0)
    'Fin de log
    
    
    ' Inserta la cuota de incoporacion si esta especificado en el combobox
    If "NO" = "SI" Then
        StrSql = "insert into fnza_detalle_mensualidad (" & _
                    "FOLIO_MENS,RUN_ALU, COLEGIO, CONCEPTO," & _
                    "FECH_VENC, MONTO_TOTAL, MONTO_EXEN_HNO, MONTO_EXEN_BCA," & _
                    "MONTO_EXEN_DESC, MONTO_EXEN_CONV, MONTO_EXEN_TIPO_PAGO, MONTO_TOT_CUOTA," & _
                    "MONTO_ABONO, FECH_PAGO, ESTADO_DTLL, COD_CONVENIO," & _
                    "Mes , agno, Tercio )" & _
                 "Select" & _
                    "'0' as FOLIO_MENS,RUN_ALU, COLEGIO, 'inco' as CONCEPTO, concat(year(FECH_VENC),'01',day(FECH_VENC)) as FECH_VENC, '" & cuota_inco & "' as MONTO_TOTAL, MONTO_EXEN_HNO, MONTO_EXEN_BCA, MONTO_EXEN_DESC, MONTO_EXEN_CONV, MONTO_EXEN_TIPO_PAGO, '" & cuota_inco & "' as MONTO_TOT_CUOTA, MONTO_ABONO, FECH_PAGO, ESTADO_DTLL, COD_CONVENIO, '1' as MES, AGNO, TERCIO " & _
                    "from fnza_detalle_mensualidad where agno='" & AnhoPos & "' and run_alu = '" & Rut_ALu & "' and mes = '3' "
        conn.Execute (StrSql)
        
        'Comprobar si existe fnza_mensualidad
        StrSql = "select count(*) as cuantos from fnza_mensualidad where run_apo = '" & rut_apo & "' and mes = 1"
        Set Rst = conn.Execute(StrSql)
        If Rst("cuantos") > 0 Then
            'strsql = "update fnza_mensualidad set " & _
            strsql = strsql & " update fnza_mensualidad set    monto_mens = monto_mens+" & cuota_inco
            StrSql = " update fnza_mensualidad set    monto_mens = monto_mens+" & cuota_inco & " where run_apo = '" & rut_apo & "' and agno=" & AnhoPos & " and mes = 1"
            conn.Execute (StrSql)
        Else
            'si no existe
            StrSql = "insert into fnza_mensualidad (" & _
                "    colegio , run_apo, FECH_VENC, " & _
                "    MONTO_MENS , ABONO_MENS, FECH_PAGO, ESTADO_MENS, " & _
                "    MES,AGNO )" & _
                "select" & _
                "    COLEGIO,RUN_APO,concat('" & AnhoPos & "'-01-10') as FECH_VENC," & _
                "    (select monto_total from fnza_detalle_mensualidad where run_alu  ='" & Rut_ALu & "' and concepto= 'inco') as MONTO_MENS," & _
                "    ABONO_MENS , FECH_PAGO, ESTADO_MENS, " & _
                "    '1' as MES,AGNO " & _
                " from fnza_mensualidad where agno=" & Combo2.Text & " and run_apo = '" & rut_apo & "' and mes = 3"
            conn.Execute (StrSql)
        End If
            StrSql = "select folio_mens from fnza_mensualidad where run_apo = '" & rut_apo & "' and agno=" & AnhoPos & " and mes =1"
            StrSql = "update fnza_detalle_mensualidad set folio_mens = (" & StrSql & ") where agno =" & AnhoPos & " and run_alu='" & Rut_ALu & "' and concepto='inco'"
            conn.Execute (StrSql)
    End If ' Si cbx_cuota_incorporacion = "SI"
    
'    '' Valor matricula codens numgra
'   ' Modifico el valor de la matricula al año anterior
'    curso_alu = Codens & NumGra
'    valor_mat = DevuelveCampo("fnza_descuento", "", "matricula", "agno = " & AnhoPos & " AND curso = '" & curso_alu & "'", conn)
'    strsql = "Update fnza_detalle_mensualidad" _
'           & " SET monto_total = " & valor_mat & ",monto_tot_cuota = " & valor_mat & ",monto_tot_cuota_d = " & valor_mat _
'           & " WHERE agno = " & AnhoPos & " AND run_alu = '" & Rut_ALu & "' AND concepto = 'ct00'"
'    conn.Execute strsql
        
    ' Obtengo valor UF mensualidades
    If AnhoPos > 2021 Then
        var_sql = "SELECT arancel_base_UF FROM fnza_descuento WHERE agno = " & AnhoPos _
                & " AND curso = (SELECT CONCAT(cod_ens,num_gra) FROM matriculas WHERE anno_mat = " & AnhoPos & " AND ci_alu = '" & Rut_ALu & "')"
        rec.Open var_sql, conn
        If rec.RecordCount > 0 Then monto_total_uf = rec("arancel_base_UF")
        rec.Close
        StrSql = "update fnza_detalle_mensualidad set " & _
                            " monto_total_UF = " & Replace(monto_total_uf, ",", ".") & _
                            ",monto_tot_cuota_UF = " & Replace(monto_total_uf, ",", ".") & _
                            ",MONTO_EXEN_UF = 0 where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='esco'"
        conn.Execute (StrSql)
    End If
    
    If AnhoPos >= 2023 Then
    
        ''' Modifico valor matricula al seleccionado por cordinador
        StrSql = "UPDATE fnza_detalle_mensualidad SET monto_total = " & cb_valor_matricula.Text & ",monto_tot_cuota = " & cb_valor_matricula.Text _
               & " WHERE agno = " & AnhoPos & " AND run_alu = '" & Rut_ALu & "' AND concepto = 'ct00'"
        conn.Execute (StrSql)
    
         ''' Modifico valor matricula al seleccionado por cordinador
        StrSql = "replace into fnza_valor_matricula(ci_alu,agno,valor,usuario) VALUES('" & Rut_ALu & "'," & AnhoPos & "," & cb_valor_matricula.Text & ",'" & Nom_com_usu_ses & "')"
        conn.Execute (StrSql)
    
    End If
    
    'Calculo los descuentos para actualizar las tablas
    StrSql = "select * from descuentos "
    log_mensaje = ""
    
    For I = 0 To Me.lst_descuentos_nombre.ListCount - 1
        If Me.lst_descuentos_nombre.Selected(I) = True Then
            StrSql = "select * from descuentos where id_descuento='" & Me.lst_descuentos_nombre.ItemData(I) & "'"
            Set Rst = conn.Execute(StrSql)
            If Not Rst.EOF Then
                x100_matricula = Rst("porciento_matricula")
                x100_mensualidad = Rst("porciento_mensualidad")
                If log_mensaje = "" Then
                    log_mensaje = Rst("descuento")
                Else
                    log_mensaje = log_mensaje & ", " & Rst("descuento")
                End If
                
                ' matricula
                If x100_matricula > 0 Then
'                    strsql = "update fnza_detalle_mensualidad set " & _
'                            " MONTO_EXEN_DESC = MONTO_EXEN_DESC + (MONTO_TOT_CUOTA*(" & x100_matricula & "/100))," & _
'                            " MONTO_TOT_CUOTA = MONTO_TOTAL - ( MONTO_EXEN_DESC + ((MONTO_TOT_CUOTA*" & x100_matricula & "/100)) )" & _
'                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='ct00'"
                    StrSql = "update fnza_detalle_mensualidad set " & _
                            " MONTO_EXEN_DESC = MONTO_EXEN_DESC + (MONTO_TOT_CUOTA*(" & x100_matricula & "/100))," & _
                            " MONTO_TOT_CUOTA = MONTO_TOTAL - ( MONTO_EXEN_DESC )" & _
                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='ct00'"
                    conn.Execute (StrSql)
                End If
                ' mensualidad
                If x100_mensualidad > 0 Then
                    'monto_total_UF
'                   strsql = "update fnza_detalle_mensualidad set " & _
'                            " MONTO_EXEN_DESC = MONTO_EXEN_DESC + ((MONTO_TOT_CUOTA*" & x100_mensualidad & "/100))," & _
'                            " MONTO_TOT_CUOTA = MONTO_TOTAL - ( MONTO_EXEN_DESC + ((MONTO_TOT_CUOTA*" & x100_mensualidad & "/100)) )" & _
'                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='esco'"
                    
                    If AnhoPos > 2021 Then
                    StrSql = "update fnza_detalle_mensualidad set " & _
                            " MONTO_EXEN_UF = MONTO_EXEN_UF + ((MONTO_TOT_CUOTA_UF*" & x100_mensualidad & "/100))," & _
                            " MONTO_TOT_CUOTA_UF = MONTO_TOTAL_UF - ( MONTO_EXEN_UF )" & _
                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='esco'"
                    conn.Execute (StrSql)
                    End If

                    StrSql = "update fnza_detalle_mensualidad set " & _
                            " MONTO_EXEN_DESC = MONTO_EXEN_DESC + ((MONTO_TOT_CUOTA*" & x100_mensualidad & "/100))," & _
                            " MONTO_TOT_CUOTA = MONTO_TOTAL - ( MONTO_EXEN_DESC )" & _
                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='esco'"
                    conn.Execute (StrSql)
                End If
                'incorporacion
            End If
        End If
    Next I
    
    StrSql = "update "
    StrSql = StrSql & "    fnza_mensualidad as U,"
    StrSql = StrSql & "    (select D.mes,sum(D.monto_tot_cuota) as suma from fnza_mensualidad M"
    StrSql = StrSql & "    inner join fnza_detalle_mensualidad D"
    StrSql = StrSql & "    on M.folio_mens = D.folio_mens"
    StrSql = StrSql & "    where M.agno= " & AnhoPos & " and M.run_apo = '" & rut_apo & "'"
    StrSql = StrSql & "    group by D.mes) as T"
    StrSql = StrSql & " set"
    StrSql = StrSql & "    U.monto_mens = t.suma"
    StrSql = StrSql & " Where"
    StrSql = StrSql & "    U.agno = " & AnhoPos & " and"
    StrSql = StrSql & "    U.run_apo = '" & rut_apo & "' and"
    StrSql = StrSql & "    U.mes = T.mes"
    conn.Execute (StrSql)
    
    ' Log finanza
          accion_detalle = "El usuario selecciono para el año " & AnhoPos & " los siguientes descuentos: "
          accion_detalle = accion_detalle & log_mensaje
          Call Inserta_Vitacora_Finanza(CStr(Rut_ALu), b_rut_apo, "Descuentos", accion_detalle, 0, 0)
   ' Fin Log
     
        
'FIN ACTUALIZACION HUECHURABA
'--------------------------------------------------------------------------------------------------
  
 '''' Duplicamos registro de apo_x_alu matriculas y fnza_detalle_mensualidad opara Contabilidad
 If AnhoPos >= 2023 Then
    var_sql = "replace INTO apo_x_alu_contabilidad" _
             & " SELECT * FROM apo_x_alu WHERE agno = " & AnhoPos & " AND ci_alu = '" & Rut_ALu & "'"
    conn.Execute var_sql
         
    var_sql = "replace INTO matriculas_contabilidad" _
             & " SELECT * FROM matriculas WHERE anno_mat = " & AnhoPos & " AND ci_alu = '" & Rut_ALu & "'"
    conn.Execute var_sql
 
    var_sql = "replace INTO fnza_detalle_mensualidad_contabilidad" _
             & " SELECT * FROM fnza_detalle_mensualidad WHERE agno = " & AnhoPos & " AND run_alu = '" & Rut_ALu & "'"
    conn.Execute var_sql
 End If
 '''' Fin duplicación
    
    
    
    ' cerramos y listo
    MsgBox "El alumno ha sido matriculado exitosamente", vbInformation, "LISTO"
    Exit Sub
Controlerror:
    MsgBox Err.Description & vbCrLf & vbCrLf & Err.Source, vbCritical, "ANOMALIA " & Err.Number

    Resume
End Sub

Private Sub Btn_Ver_Alumno_Click()
    Dim InfoAlu As Variant
    Dim agno As Integer
    Dim Item As Integer
    Dim curso As String
    
    Frame8.Enabled = False
    Frame11.Enabled = False
    'Frame10.Enabled = False
    frm_Descuentos.Enabled = False
    Btn_Guardar_Cambios.Enabled = False
    
    VaciarInfoCuadroAlumno
    Frame6.Enabled = False
    ' Seteo de barra de progreso
    PBar.Min = 0
    PBar.Value = 0
    PBar.Max = 1
    ' fin seteo barra progreso
    agno = val(Combo2.Text)
    Item = 0
    SeteaVistaAlumno
    'Frame3.Caption = Text1.Text & " " & Text2.Text
    'Frame3.Caption = "SELECCIONE UN ALUMNO PARA CONTINUAR"
        InfoAlu = InfoPagoAlu(text2.Text, agno, conn, True)
        If Not (InfoAlu(2, 1) = "") Then  'Run distinto de vacio
            PBar.Max = PBar.Value + UBound(InfoAlu, 2)
            Flag_sub = True
            For I = 1 To UBound(InfoAlu, 2)
                    curso = RetornaCampo("codigos_ensenanza", "cod_des", " cod_ens='" & InfoAlu(8, I) & "' ", conn)
                    If Not (curso = "PK" Or curso = "K") Then
                        curso = InfoAlu(9, I) & "º " & curso
                    End If
                    curso = curso & " " & DevuelveCampo("alu_x_cur", "", "let_cur", " ci_alu='" & InfoAlu(2, I) & "' AND fec_mat='" & Format(InfoAlu(5, I), "yyyy-mm-dd") & "' AND activo_alu='SI' AND cod_ens='" & InfoAlu(8, I) & "' ", conn)
                    Item = Item + 1
                    Grid1.AddItem Item & Chr(9) & InfoAlu(1, I) & Chr(9) & InfoAlu(2, I) & Chr(9) & InfoAlu(5, I) & Chr(9) & InfoAlu(11, I) & Chr(9) & InfoAlu(8, I) & Chr(9) & InfoAlu(9, I) & Chr(9) & curso & Chr(9) & InfoAlu(10, I) & Chr(9) & InfoAlu(12, I) & Chr(9) & InfoAlu(6, I) & Chr(9) & InfoAlu(7, I), Item
                    Grid1.Row = Item
                    Grid1.Col = 4
                    Grid1.CellBackColor = &HC0FFFF
            Next I
            Flag_sub = False
        End If
   Frame6.Enabled = True
End Sub

Private Sub Btn_Ver_Apoderado_Click()
    Dim InfoAlu As Variant
    Dim agno As Integer
    Dim Item As Integer
    Dim rec As ADODB.Recordset
    Dim QRY As String
    Dim curso As String
    cmb_tp_mensualidad.Text = ""
    cbx_forma_pago.Text = ""
    Btn_Guardar_Cambios.Enabled = False
        
    VaciarInfoCuadroAlumno
    Frame6.Enabled = False
    ' Seteo de barra de progreso
    PBar.Min = 0
    PBar.Value = 0
    PBar.Max = 1
    ' fin seteo barra progreso
    agno = val(Combo1.Text)
    Item = 0
    SeteaVistaApoderado
    Frame3.Caption = "APODERADO: " & Text3.Text & " " & Text4.Text
    Set rec = New ADODB.Recordset
        QRY = "SELECT DISTINCT axa.ci_alu, m.anno_mat FROM apo_x_alu as axa, matriculas as m, codigos_ensenanza as ce WHERE rut_apo='" & Text4.Text & "' AND anno_mat='" & agno & "' AND axa.ci_alu=m.ci_alu AND ce.cod_ens=m.cod_ens ORDER BY ce.ord_ens DESC, m.num_gra DESC, axa.ci_alu;"
        rec.Open QRY, conn
        If rec.RecordCount > 0 Then
            PBar.Max = PBar.Value + rec.RecordCount
            rec.MoveFirst
            For alu = 1 To rec.RecordCount
                InfoAlu = InfoPagoAlu(rec!ci_alu, agno, conn, True)
                PBar.Max = PBar.Max + UBound(InfoAlu, 2) - 1
                If Not (InfoAlu(2, 1) = "") Then  'Run distinto de vacio
                    Flag_sub = True
                    For I = 1 To UBound(InfoAlu, 2)
                        curso = DevuelveCampo("codigos_ensenanza", "", "cod_des", " cod_ens='" & InfoAlu(8, I) & "' ", conn)
                    If Not (curso = "PK" Or curso = "K") Then
                        curso = InfoAlu(9, I) & "º " & curso
                    End If
                    curso = curso & " " & DevuelveCampo("alu_x_cur", "", "let_cur", " ci_alu='" & InfoAlu(2, I) & "' AND fec_mat='" & Format(InfoAlu(5, I), "yyyy-mm-dd") & "' AND activo_alu='SI' AND cod_ens='" & InfoAlu(8, I) & "' ", conn)
                    Item = Item + 1
                    Grid1.AddItem Item & Chr(9) & InfoAlu(1, I) & Chr(9) & InfoAlu(2, I) & Chr(9) & InfoAlu(5, I) & Chr(9) & InfoAlu(11, I) & Chr(9) & InfoAlu(8, I) & Chr(9) & InfoAlu(9, I) & Chr(9) & curso & Chr(9) & InfoAlu(10, I) & Chr(9) & InfoAlu(12, I) & Chr(9) & InfoAlu(6, I) & Chr(9) & InfoAlu(7, I), Item
                    Grid1.Row = Item
                    Grid1.Col = 4
                    Grid1.CellBackColor = &HC0FFFF
                    Next I
                    Flag_sub = False
                End If
                rec.MoveNext
                PBar.Value = Item
            Next alu
        End If
        rec.Close
   Frame6.Enabled = True
End Sub

Private Sub Btn_Ver_Lista_Click()
    Dim rec As ADODB.Recordset
    Dim QRY As String
    Dim InfoAlu As Variant
    Dim Item As Integer
    Dim curso As String
    
    Btn_Guardar_Cambios.Enabled = False
        
    VaciarInfoCuadroAlumno
    ' Seteo de barra de progreso
    PBar.Min = 0
    PBar.Value = 0
    PBar.Max = 1
    ' fin seteo barra progreso
    Frame6.Enabled = False
    ' Seteo de la grilla
    SeteaVistaCurso
    
    Set rec = New ADODB.Recordset
    Item = 0
    
    ' Seleccionar por curso o por nivel.
    If Check_Letra.Value = 1 Then
        Select Case IC_Filtro.SelectedItem.Key
            Case "mat"
                QRY = "SELECT axc.ci_alu, p.* FROM alu_x_cur as axc, postulantes as p, (SELECT m.ci_alu FROM matriculas as m LEFT JOIN (SELECT ci_alu FROM `matriculas` WHERE anno_mat=" & (val(IC_Agno.SelectedItem.Text) + 1) & " AND activo_alu='SI') as mpa ON m.ci_alu=mpa.ci_alu WHERE m.anno_mat=" & Trim(IC_Agno.SelectedItem.Text) & " AND m.activo_alu='SI' AND mpa.ci_alu is not null) as sel WHERE axc.ci_alu=p.ci_alu AND axc.ci_alu=sel.ci_alu AND axc.activo_alu='SI' AND axc.agno=" & Trim(IC_Agno.SelectedItem.Text) & " AND axc.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND axc.num_gra=" & Trim(IC_Nivel.SelectedItem.Text) & " AND axc.let_cur='" & Trim(IC_Letra.SelectedItem.Text) & "' ORDER BY p.ape_pat_alu, p.ape_mat_alu, p.nom_alu;"
            Case "sin"
                QRY = "SELECT axc.ci_alu, p.* FROM alu_x_cur as axc, postulantes as p, (SELECT m.ci_alu FROM matriculas as m LEFT JOIN (SELECT ci_alu FROM `matriculas` WHERE anno_mat=" & (val(IC_Agno.SelectedItem.Text) + 1) & " AND activo_alu='SI') as mpa ON m.ci_alu=mpa.ci_alu WHERE m.anno_mat=" & Trim(IC_Agno.SelectedItem.Text) & " AND m.activo_alu='SI' AND mpa.ci_alu is null) as sel WHERE axc.ci_alu=p.ci_alu AND axc.ci_alu=sel.ci_alu AND axc.activo_alu='SI' AND axc.agno=" & Trim(IC_Agno.SelectedItem.Text) & " AND axc.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND axc.num_gra=" & Trim(IC_Nivel.SelectedItem.Text) & " AND axc.let_cur='" & Trim(IC_Letra.SelectedItem.Text) & "' ORDER BY p.ape_pat_alu, p.ape_mat_alu, p.nom_alu;"
            Case Else
                QRY = "SELECT axc.ci_alu FROM alu_x_cur as axc, postulantes as p WHERE axc.agno='" & Trim(IC_Agno.SelectedItem.Text) & "' AND axc.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND axc.num_gra=" & Trim(IC_Nivel.SelectedItem.Text) & " AND axc.let_cur='" & Trim(IC_Letra.SelectedItem.Text) & "' AND axc.activo_alu='SI' AND axc.ci_alu=p.ci_alu ORDER BY p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, axc.ci_alu;"
        End Select
        Frame3.Caption = "AÑO " & IC_Agno.SelectedItem.Text & ", " & IC_Ensenanza.SelectedItem.Text & " Nivel:" & IC_Nivel.SelectedItem.Text & " LETRA: " & IC_Letra.SelectedItem.Text
    Else
        Select Case IC_Filtro.SelectedItem.Key
            Case "mat"
                QRY = "SELECT axc.ci_alu, p.* FROM alu_x_cur as axc, postulantes as p, (SELECT m.ci_alu FROM matriculas as m LEFT JOIN (SELECT ci_alu FROM `matriculas` WHERE anno_mat=" & (val(IC_Agno.SelectedItem.Text) + 1) & " AND activo_alu='SI') as mpa ON m.ci_alu=mpa.ci_alu WHERE m.anno_mat=" & Trim(IC_Agno.SelectedItem.Text) & " AND m.activo_alu='SI' AND mpa.ci_alu is not null) as sel WHERE axc.ci_alu=p.ci_alu AND axc.ci_alu=sel.ci_alu AND axc.activo_alu='SI' AND axc.agno=" & Trim(IC_Agno.SelectedItem.Text) & " AND axc.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND axc.num_gra=" & Trim(IC_Nivel.SelectedItem.Text) & " ORDER BY p.ape_pat_alu, p.ape_mat_alu, p.nom_alu;"
            Case "sin"
                QRY = "SELECT axc.ci_alu, p.* FROM alu_x_cur as axc, postulantes as p, (SELECT m.ci_alu FROM matriculas as m LEFT JOIN (SELECT ci_alu FROM `matriculas` WHERE anno_mat=" & (val(IC_Agno.SelectedItem.Text) + 1) & " AND activo_alu='SI') as mpa ON m.ci_alu=mpa.ci_alu WHERE m.anno_mat=" & Trim(IC_Agno.SelectedItem.Text) & " AND m.activo_alu='SI' AND mpa.ci_alu is null) as sel WHERE axc.ci_alu=p.ci_alu AND axc.ci_alu=sel.ci_alu AND axc.activo_alu='SI' AND axc.agno=" & Trim(IC_Agno.SelectedItem.Text) & " AND axc.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND axc.num_gra=" & Trim(IC_Nivel.SelectedItem.Text) & " ORDER BY p.ape_pat_alu, p.ape_mat_alu, p.nom_alu;"
            Case Else
                QRY = "SELECT  m.ci_alu FROM alu_x_cur as m, postulantes as p WHERE m.agno='" & Trim(IC_Agno.SelectedItem.Text) & "' AND m.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND m.num_gra=" & Trim(IC_Nivel.SelectedItem.Text) & " AND m.activo_alu='SI' AND m.ci_alu=p.ci_alu ORDER BY p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, m.ci_alu;"
        End Select
        Frame3.Caption = "AÑO " & IC_Agno.SelectedItem.Text & ", " & IC_Ensenanza.SelectedItem.Text & " Nivel:" & IC_Nivel.SelectedItem.Text
    End If
    
    rec.Open QRY, conn
    If rec.RecordCount > 0 Then
        PBar.Max = rec.RecordCount
        rec.MoveFirst
        For al = 1 To rec.RecordCount
            ' Sacar y mostrar info de alumnos
            InfoAlu = InfoPagoAlu(rec!ci_alu, val(Trim(IC_Agno.SelectedItem.Text)), conn, True)
            If Not (InfoAlu(2, 1) = "") Then  'Run distinto de vacio
                Flag_sub = True
                For I = 1 To UBound(InfoAlu, 2)
                    curso = DevuelveCampo("codigos_ensenanza", "", "cod_des", " cod_ens='" & InfoAlu(8, I) & "' ", conn)
                    If Not (curso = "PK" Or curso = "K") Then
                        curso = InfoAlu(9, I) & "º " & curso
                    End If
                    curso = curso & " " & DevuelveCampo("alu_x_cur", "", "let_cur", " ci_alu='" & InfoAlu(2, I) & "' AND fec_mat='" & Format(InfoAlu(5, I), "yyyy-mm-dd") & "' AND activo_alu='SI' AND cod_ens='" & InfoAlu(8, I) & "' ", conn)
                    Item = Item + 1
                    Grid1.AddItem Item & Chr(9) & InfoAlu(1, I) & Chr(9) & InfoAlu(2, I) & Chr(9) & InfoAlu(5, I) & Chr(9) & InfoAlu(11, I) & Chr(9) & InfoAlu(8, I) & Chr(9) & InfoAlu(9, I) & Chr(9) & curso & Chr(9) & InfoAlu(10, I) & Chr(9) & InfoAlu(12, I) & Chr(9) & InfoAlu(6, I) & Chr(9) & InfoAlu(7, I), Item
                    Grid1.Row = Item
                    Grid1.Col = 4
                    Grid1.CellBackColor = &HC0FFFF
                Next I
                Flag_sub = False
            End If
            rec.MoveNext
            PBar.Value = al
        Next al
    End If
    rec.Close
    Frame6.Enabled = True
End Sub

Private Sub Check_confirma_Click()
    If Check_confirma.Value = 1 Then
        Check_Mat.Value = 1
    Else
        DTP_Fec_Mat.Enabled = True
        Check_Mat.Value = 0
    End If
End Sub

Private Sub Check_Letra_Click()
    If Check_Letra.Value = 0 Then
        IC_Letra.Enabled = False
    ElseIf Check_Letra.Value = 1 And Not (ErrorStatus) And IC_Ensenanza.Enabled And IC_Nivel.Enabled Then
        IC_Letra.Enabled = True
        Call Set_IC_Letra
    Else
        Check_Letra.Value = 0
        IC_Letra.Enabled = False
    End If
End Sub

Private Sub Check_Mat_Click()

    
    ''''''''''''
    If Check_Mat.Value = 1 Then
        'DTP_Fec_Mat.Enabled = True
        'DTP_Fec_Mat.MinDate = CDate(Format(Date, "dd-mm-")) & Val(Grid1.TextMatrix(Grid1.Row, 8))
        
       ' DTP_Fec_Mat.MinDate = CDate(Format(Date, "dd-mm-") & Val(Grid1.TextMatrix(Grid1.Row, 8)))
        
        DTP_Fec_Mat.MinDate = CDate(RetornaCampo("CFG", "valor", "param='PerEscIni' and agno='" & (val(Grid1.TextMatrix(Grid1.Row, 8))) & "'", conn))
        
        
        DTP_Fec_Mat.MaxDate = CDate(RetornaCampo("CFG", "valor", "param='PerEscFin' and agno='" & (val(Grid1.TextMatrix(Grid1.Row, 8)) + 1) & "'", conn))
        'DTP_Fec_Mat.MaxDate = Date
        If RetornaCampo("matriculas", "fec_mat", "anno_mat='" & (val(Grid1.TextMatrix(Grid1.Row, 8)) + 1) & "' AND activo_alu='SI' AND ci_alu='" & Trim(Grid1.TextMatrix(Grid1.Row, 2)) & "'", conn) = "" Then
            DTP_Fec_Mat.Value = Date
        Else
            DTP_Fec_Mat.MinDate = RetornaCampo("matriculas", "fec_mat", "anno_mat='" & (val(Grid1.TextMatrix(Grid1.Row, 8)) + 1) & "' AND activo_alu='SI' AND ci_alu='" & Trim(Grid1.TextMatrix(Grid1.Row, 2)) & "'", conn)
            DTP_Fec_Mat.Value = RetornaCampo("matriculas", "fec_mat", "anno_mat='" & (val(Grid1.TextMatrix(Grid1.Row, 8)) + 1) & "' AND activo_alu='SI' AND ci_alu='" & Trim(Grid1.TextMatrix(Grid1.Row, 2)) & "'", conn)
        End If
        Check_confirma.Value = 1
    Else
        Check_confirma.Value = 0
    End If
    '
    ''''''''''''
    
End Sub



Private Sub Combo1_Click()
    If Text3.Text <> "" And Text4.Text <> "" Then
        Btn_Ver_Apoderado_Click
    End If
End Sub

Private Sub Combo2_Click()
    If Text1.Text <> "" And text2.Text <> "" Then
        Btn_Ver_Alumno_Click
    End If
End Sub

Private Sub Command2_Click()
    VaciarInfoCuadroAlumno
    Text1.Text = ""
    text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    List1.Visible = False
    List2.Visible = False
    List3.Visible = False
    List4.Visible = False
    If Option1(0).Value Then
        MuestraFrame ("curso")
    ElseIf Option1(1).Value Then
        MuestraFrame ("apoderado")
    ElseIf Option1(2).Value Then
        MuestraFrame ("alumno")
    End If
End Sub

Private Sub Command3_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    ' Setear el combo años.
    Me.Top = 0
    Me.Left = 0
    Set_IC_Filtro
    IC_Letra.Text = ""
    IC_Letra.ComboItems.Clear
    Call Set_IC_Agno
    LlenaCombosAgno
    ' Limpiar textos
    Text1.Text = ""
    text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    'Mostrar opcion de curso al iniciar
    Option1(2).Value = True
    MuestraFrame ("alumno")
    ErrorStatus = False
    
'   Cargar descuentos
    Dim Rst As ADODB.Recordset
    
    Set Rst = New ADODB.Recordset
    Query = "select * from descuentos"
    Rst.Open Query, conn
    
    Me.lst_descuentos_nombre.Clear
    Do While Not Rst.EOF
        Me.lst_descuentos_nombre.AddItem Rst("descuento")
        Me.lst_descuentos_nombre.ItemData(Me.lst_descuentos_nombre.ListCount - 1) = Rst("id_descuento")
        Me.lst_descuentos_conflicto.AddItem Rst("conflicto")
        Rst.MoveNext
    Loop
    Rst.Close
    Set Rst = Nothing
'   Fin carga descuentos

    cmb_tp_mensualidad.AddItem "Cuponera"
    cmb_tp_mensualidad.AddItem "Cheques"
    cmb_tp_mensualidad.AddItem "Debito"
    cmb_tp_mensualidad.AddItem "Credito"
    cmb_tp_mensualidad.AddItem "Transferencia"
    cmb_tp_mensualidad.AddItem "Efectivo"
    ''''''cmb_tp_mensualidad.AddItem "PAT"
    ''''''cmb_tp_mensualidad.AddItem "Pagare"

End Sub

Private Sub lst_descuentos_nombre_ItemCheck(Item As Integer)
    sw = False
    For I = 0 To lst_descuentos_nombre.ListCount - 1
        If I <> lst_descuentos_nombre.ListIndex Then
            If lst_descuentos_nombre.Selected(I) = True And _
                lst_descuentos_conflicto.List(I) = lst_descuentos_conflicto.List(lst_descuentos_nombre.ListIndex) Then
                    sw = True
                    Exit For
            End If
        End If
    Next I
    If sw Then
        MsgBox "Existe descompatibilidad entre los descuentos seleccionador. Vuelva a intentar", vbExclamation, ""
        lst_descuentos_nombre.Selected(lst_descuentos_nombre.ListIndex) = False
    End If
    Set sw = Nothing
End Sub

Private Sub Set_IC_Agno()
    Dim agno As Integer
    
    agno = Anno
    IC_Agno.ComboItems.Clear
    For I = 2005 To Anno
        IC_Agno.ComboItems.Add I - 2004, , str(I)
    Next I
    Set IC_Agno.SelectedItem = IC_Agno.ComboItems.Item(Anno - 2004)
    ErrorStatus = False
    ' Llenar combo enseñanza
    IC_Ensenanza.Enabled = True
    IC_Nivel.Enabled = False
    IC_Letra.Enabled = False
    Call Set_IC_Ensenanza
    
End Sub

Private Sub Set_IC_Filtro()
    IC_Filtro.ComboItems.Clear
    '######################
    ' Opciones de Filtrado
    '######################
    IC_Filtro.ComboItems.Add 1, "all", "Todos"
    IC_Filtro.ComboItems.Add 2, "mat", "Matriculados"
    IC_Filtro.ComboItems.Add 3, "sin", "Sin Matricula"
    Set IC_Filtro.SelectedItem = IC_Filtro.ComboItems.Item(1)
End Sub
Private Sub Set_IC_Ensenanza()
    Dim rec As ADODB.Recordset
    Dim QRY As String
    
    QRY = "SELECT DISTINCT m.cod_ens, ce.des_ens FROM matriculas as m, codigos_ensenanza as ce WHERE m.cod_ens=ce.cod_ens AND m.anno_mat=" & IC_Agno.SelectedItem.Text & " ORDER BY ce.ord_ens;"
    Set rec = New ADODB.Recordset
    rec.Open QRY, conn
    
    IC_Ensenanza.ComboItems.Clear
    If rec.RecordCount > 0 Then
        rec.MoveFirst
        For I = 1 To rec.RecordCount
            IC_Ensenanza.ComboItems.Add I, "K" & Format(rec!Cod_Ens, "000"), rec!des_ens
            rec.MoveNext
        Next I
        Set IC_Ensenanza.SelectedItem = IC_Ensenanza.ComboItems.Item(1)
        ErrorStatus = False
        ' Llenar Siguiente Combo.
        IC_Nivel.Enabled = True
        IC_Letra.Enabled = False
        Call Set_IC_Nivel
    Else
        ErrorStatus = True
        IC_Ensenanza.Enabled = False
        IC_Nivel.Enabled = False
        IC_Letra.Enabled = False
    End If
    rec.Close
End Sub

Private Sub Set_IC_Nivel()
    Dim rec As ADODB.Recordset
    Dim QRY As String

    QRY = "SELECT DISTINCT m.num_gra FROM matriculas as m WHERE m.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND m.anno_mat=" & IC_Agno.SelectedItem.Text & " ORDER BY m.num_gra;"
    Set rec = New ADODB.Recordset
    rec.Open QRY, conn
    
    IC_Nivel.ComboItems.Clear
    If rec.RecordCount > 0 Then
        rec.MoveFirst
        For I = 1 To rec.RecordCount
            IC_Nivel.ComboItems.Add I, , str(rec!Num_Gra)
            rec.MoveNext
        Next I
        Set IC_Nivel.SelectedItem = IC_Nivel.ComboItems.Item(1)
        ErrorStatus = False
        ' Llenar Siguiente Combo.
        If Check_Letra.Value = 1 Then
            IC_Letra.Enabled = True
            Call Set_IC_Letra
        End If
    Else
        ErrorStatus = True
        IC_Nivel.Enabled = False
        IC_Letra.Enabled = False
    End If
    rec.Close
End Sub

Private Sub Set_IC_Letra()
    Dim rec As ADODB.Recordset
    Dim QRY As String
    
    If Check_Letra.Value = 1 Then
        IC_Letra.ComboItems.Clear
        IC_Letra.Text = ""
        QRY = "SELECT DISTINCT m.let_cur FROM alu_x_cur as m WHERE m.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND m.agno=" & Trim(IC_Agno.SelectedItem.Text) & " AND m.num_gra='" & Trim(IC_Nivel.SelectedItem.Text) & "' ORDER BY m.num_gra;"
        Set rec = New ADODB.Recordset
        rec.Open QRY, conn
        If rec.RecordCount > 0 Then
            rec.MoveFirst
            For I = 1 To rec.RecordCount
                IC_Letra.ComboItems.Add I, , rec!Let_Cur
                rec.MoveNext
            Next I
            Set IC_Letra.SelectedItem = IC_Letra.ComboItems.Item(1)
            ErrorStatus = False
            ' Llenar Siguiente Combo.
        Else
            ErrorStatus = True
            Check_Letra.Value = 0
            IC_Letra.Enabled = False
        End If
        rec.Close
    Else
        ErrorStatus = False
        IC_Letra.Enabled = False
    End If
End Sub

Private Sub Grid1_SelChange()
Dim MyRow As Integer
Dim Beca As Integer
Dim FormaPag As String
Dim Repite As Integer
If Not Flag_sub Then

    
    VaciarInfoCuadroAlumno
    ' solo autorizados pueden modificar informacion
    If Not (CodPerfil = "#ADM#" Or CodPerfil = "#BCA#" Or CodPerfil = "#BEC#" Or CorPerfil = "#SBD#") Then Exit Sub
    
    MyRow = Grid1.Row
    If Grid1.TextMatrix(MyRow, 0) = "" Then
        Frame8.Enabled = False
        Frame11.Enabled = False
        'Frame10.Enabled = False
        frm_Descuentos.Enabled = False
        Btn_Guardar_Cambios.Enabled = False
        Exit Sub
    End If
    
    If (Option1(0).Value) Or (Option1(1).Value) Or (Option1(2).Value) Then
         ' Dejar sólo modificar año actual o proximo
         'If Val(Grid1.TextMatrix(MyRow, 8) + 1) < Year(Date) Then Exit Sub
         ' #########################################
         Text5.Text = Grid1.TextMatrix(MyRow, 1)
         
        Frame8.Enabled = True
        Frame11.Enabled = True
        Frame10.Enabled = True
        frm_Descuentos.Enabled = True
        Btn_Guardar_Cambios.Enabled = True
        
         Text6.Text = Grid1.TextMatrix(MyRow, 2)
         ' Preguntar si existe la matricula
         If val(RetornaCampo("matriculas", "count(ci_alu) as count_ci", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & Trim(val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn)) > 0 Then
            Beca = val(RetornaCampo("matriculas", "if(ind_beca=1,100,if(ind_mbeca=1,50,0)) as beca_porc", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn))
            FormaPag = RetornaCampo("matriculas", "if(ind_cup=1,'cuponera',if(ind_cont=1,'contado',if(ind_cheq=1,'cheque','ninguna'))) as forma_pago_alu", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn)
            Check_Mat.Value = 1
            If RetornaCampo("matriculas", "confirmado", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn) = "SI" Then
                Check_confirma.Value = 1
            Else
                Check_confirma.Value = 0
            End If
            If (DevuelveCampo("establecimientos", "", "RDB", "1=1", conn) <> "9782-9") Then
                If DevuelveCampo("fnza_detalle_mensualidad", "", "estado_dtll", "agno=" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & " AND concepto='ct00' AND run_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "'", conn) <> "impg" Then
                    'Check_Mat.Enabled = False
                Else
                    Check_Mat.Enabled = True
                End If
            End If
            
            If Check_confirma.Value = 1 Then
                'Check_confirma.Enabled = False
            Else
                Check_confirma.Enabled = True
            End If
            
            Frame11.Enabled = False
            ' cod_ens y num_gra filas 5 y 6 de la grid1
            
    
            If val(RetornaCampo("matriculas", "count(ci_alu) as count_ci", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND cod_ens='" & Trim(Grid1.TextMatrix(MyRow, 5)) & "' AND num_gra='" & val(Grid1.TextMatrix(MyRow, 6)) & "' AND activo_alu='SI'", conn)) > 0 Then
                Chk_Repite.Value = 1
            Else
                Chk_Repite.Value = 0
            End If
            
            
          Else
            Beca = 0
            FormaPag = ""
            Check_Mat.Value = 0
            Check_confirma.Value = 0
            Check_Mat.Enabled = True
            Check_confirma.Enabled = True
            Frame11.Enabled = True
         End If
         
         'Solo autorizados pueden modificar becas asignadas o desmatricular
         If (CodPerfil = "#ADM#" Or CodPerfil = "#BEC#" Or CorPerfil = "#SBD#") Then
            Frame11.Enabled = True
         End If
         
            If RetornaCampo("matriculas", "confirmado", "ci_alu='" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' AND anno_mat='" & (val(Grid1.TextMatrix(MyRow, 8)) + 1) & "' AND activo_alu='SI'", conn) = "SI" Then
                '################################################################
                ' Pongo en falso los tipos de pago para que no pueda modificarlos
                'Frame10.Enabled = False
            End If
            
         'Cargo valor de matricula
            ' Valor matricula
        'StrSql = "SELECT CONCAT(cod_ens,num_gra) AS curso FROM matriculas WHERE anno_mat = 2022 AND ci_alu = '" & Rut_ALu & "'"
        cb_valor_matricula.Clear
''        curso_mat_act = DevuelveCampo("matriculas", "", "CONCAT(cod_ens,num_gra) AS curso", "ci_alu = '" & Trim(Grid1.TextMatrix(MyRow, 2)) & "' and activo_alu = 'SI' and anno_mat = " & val(Grid1.TextMatrix(MyRow, 8)), conn)
''        curso_mat = DevuelveCampo("curso_siguiente", "", "CONCAT(cod_ens_sig,num_gra_sig)", "CONCAT(cod_ens,num_gra) = '" & curso_mat_act & "' ", conn)
''        valor_mat_nue = DevuelveCampo("fnza_descuento", "", "matricula_nuevos", "curso = '" & curso_mat & "' and agno = " & (val(Grid1.TextMatrix(MyRow, 8)) + 1), conn)
''        valor_mat_ant = DevuelveCampo("fnza_descuento", "", "matricula", "curso = '" & curso_mat & "' and agno = " & (val(Grid1.TextMatrix(MyRow, 8)) + 1), conn)
        If (val(Grid1.TextMatrix(MyRow, 8)) + 1) = 2025 Then
            cb_valor_matricula.AddItem 298000
        Else
            cb_valor_matricula.AddItem 298000
            cb_valor_matricula.AddItem 249400
        End If
        cb_valor_matricula.Text = ""  'valor_mat_nue
        ' fin
    End If
End If
End Sub

Private Sub IC_Agno_Click()
    IC_Ensenanza.Enabled = True
    Set_IC_Ensenanza
End Sub

Private Sub IC_Ensenanza_Click()
    IC_Nivel.Enabled = True
    Call Set_IC_Nivel
End Sub

Private Sub IC_Nivel_Click()
    If Check_Letra.Value = 1 Then
        IC_Letra.Enabled = True
        Call Set_IC_Letra
    End If
End Sub

Private Sub MuestraFrame(ByVal frm As String)
    ' Muestra seleccion por curso
    If frm = "curso" Then
        Frame1.Visible = True
        SeteaVistaCurso
    Else
        Frame1.Visible = False
    End If
    ' Muestra seleccion por apoderado
    If frm = "apoderado" Then
        Frame5.Visible = True
        SeteaVistaApoderado
        Btn_Ver_Alumno.Enabled = False
    Else
        Frame5.Visible = False
    End If
    ' Muestra seleccion por alumno
    If frm = "alumno" Then
        Frame4.Visible = True
        Btn_Ver_Apoderado.Enabled = False
        SeteaVistaAlumno
    Else
        Frame4.Visible = False
    End If
End Sub


Private Sub Label14_Click()

End Sub

Private Sub List1_DblClick()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    
    Text1.Text = List1.Text
    List1.Visible = False
    List2.Visible = False
    RC.Open "SELECT ci_alu FROM postulantes WHERE left(CONCAT(ape_Pat_alu,' ',ape_Mat_alu,' ',nom_alu)," & Len(Text1.Text) & ")='" & Text1.Text & "' ORDER BY ape_pat_alu, ape_mat_alu, nom_alu;", conn
    RC.MoveFirst
    Flag_sub = True
    text2.Text = RC("ci_alu")
    RC.Close
    Flag_sub = False
    Btn_Ver_Alumno.Enabled = True
End Sub

Private Sub List2_DblClick()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    
    text2.Text = List2.Text
    List2.Visible = False
    List1.Visible = False
    RC.Open "SELECT CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as nombre_alu FROM postulantes WHERE ci_alu='" & text2.Text & "' ORDER BY ci_alu;", conn
    RC.MoveFirst
    Flag_sub = True
    Text1.Text = RC("nombre_alu")
    RC.Close
    Flag_sub = False
    Btn_Ver_Alumno.Enabled = True
    Btn_Guardar_Cambios.Enabled = False
End Sub

Private Sub List3_DblClick()
    Dim RC As ADODB.Recordset
    Text3.Text = List3.Text
    List3.Visible = False
    List4.Visible = False
    Set RC = New ADODB.Recordset
    RC.Open "SELECT rut_apo FROM `apoderados` where left(CONCAT(ape1_apo,' ',ape2_apo,' ',noms_apo)," & Len(Text3.Text) & ")='" & Text3.Text & "' ORDER BY ape1_apo, ape2_apo, noms_apo;", conn
    RC.MoveFirst
    Flag_sub = True
    Text4.Text = RC("rut_apo")
    Flag_sub = False
    Btn_Ver_Apoderado.Enabled = True
    RC.Close
    
    Btn_Guardar_Cambios.Enabled = False
      
End Sub

Private Sub List4_DblClick()
    Dim RC As ADODB.Recordset
    Text4.Text = List4.Text
    List4.Visible = False
    List3.Visible = False
    Set RC = New ADODB.Recordset
    RC.Open "SELECT CONCAT(ape1_apo,' ',ape2_apo,' ',noms_apo) as nombre_apo FROM apoderados where rut_apo='" & Text4.Text & "' ORDER BY rut_apo;", conn
    RC.MoveFirst
    Flag_sub = True
    Text3.Text = RC("nombre_apo")
    Flag_sub = False
    Btn_Ver_Apoderado.Enabled = True
    RC.Close
    
    Btn_Guardar_Cambios.Enabled = False
End Sub

Private Sub Option1_Click(Index As Integer)
    Text1.Text = ""
    text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    List1.Visible = False
    List2.Visible = False
    List3.Visible = False
    List4.Visible = False
    If Option1(Index).Value = True Then
        If Index = 0 Then
            MuestraFrame "curso"
            VaciarInfoCuadroAlumno
        ElseIf Index = 1 Then
            MuestraFrame "apoderado"
            VaciarInfoCuadroAlumno
        ElseIf Index = 2 Then
            MuestraFrame "alumno"
            VaciarInfoCuadroAlumno
        End If
    End If
    
    Frame8.Enabled = False
    Frame11.Enabled = False
    'Frame10.Enabled = False
    frm_Descuentos.Enabled = False
    Btn_Guardar_Cambios.Enabled = False
    
End Sub

'Private Sub Option2_Click(Index As Integer)
'    If Index = 2 Then
'        Option3(0).Enabled = True
'        Option3(0).Value = True
'        Frame10.Enabled = False
'    Else
'        Option3(0) = False
'        Option3(0).Enabled = False
'        Frame10.Enabled = True
'    End If
'End Sub

Private Sub Text1_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If Text1.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
    
    RC.Open "SELECT DISTINCT a.ape_pat_alu, a.ape_mat_alu, a.nom_alu FROM postulantes a, matriculas m WHERE left(CONCAT(a.ape_pat_alu,' ',a.ape_mat_alu,' ',a.nom_alu)," & Len(Text1.Text) & ")='" & Text1.Text & "' AND a.ci_alu=m.ci_alu ORDER BY a.ape_pat_alu, a.ape_mat_alu, a.nom_alu;", conn
    List1.Clear
    If RC.RecordCount > 0 Then
        While Not (RC.EOF)
            List1.AddItem RC("ape_pat_alu") & " " & RC("ape_mat_alu") & " " & RC("nom_alu")
            RC.MoveNext
        Wend
        List1.Visible = True
        List2.Visible = False
    End If
    RC.Close
    Btn_Ver_Alumno.Enabled = False
End Sub

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

Private Sub Text2_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If text2.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
    
    RC.Open "SELECT DISTINCT a.ci_alu FROM postulantes a, matriculas m WHERE left(a.ci_alu," & Len(text2.Text) & ")='" & text2.Text & "' AND a.ci_alu=m.ci_alu ORDER BY a.ci_alu;", conn
    List2.Clear
    If RC.RecordCount > 0 Then
        While Not (RC.EOF)
            List2.AddItem RC("ci_alu")
            RC.MoveNext
        Wend
        List1.Visible = False
        List2.Visible = True
    End If
    RC.Close
    Btn_Ver_Alumno.Enabled = False
End Sub

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

Private Sub Text3_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If Text3.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
        
    RC.Open "SELECT DISTINCT a.ape1_apo, a.ape2_apo, a.noms_apo FROM apoderados a, fnza_mensualidad fm where left(CONCAT(a.ape1_apo,' ',a.ape2_apo,' ',a.noms_apo)," & Len(Text3.Text) & ")='" & Text3.Text & "' and a.rut_apo=fm.run_apo ORDER BY a.ape1_apo, a.ape2_apo, a.noms_apo;", conn
    List3.Clear
    While Not (RC.EOF)
        List3.AddItem RC("ape1_apo") & " " & RC("ape2_apo") & " " & RC("noms_apo")
        RC.MoveNext
    Wend
    RC.Close
    Btn_Ver_Apoderado.Enabled = False
    List3.Visible = True
    List4.Visible = False
    
End Sub

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

Private Sub Text4_Change()
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If Text4.Text = "" Then Exit Sub
    Dim Str_Query As String
    Dim RC As ADODB.Recordset
    
    Set RC = New ADODB.Recordset
    Str_Query = "SELECT DISTINCT fm.run_apo FROM apoderados a, fnza_mensualidad fm WHERE left(a.rut_apo," & Len(Text4.Text) & ")='" & Text4.Text & "' AND a.rut_apo=fm.run_apo ORDER BY a.rut_apo;"
    RC.Open Str_Query, conn
    List4.Clear
    While Not (RC.EOF)
        List4.AddItem RC("run_apo")
        RC.MoveNext
    Wend
    RC.Close
    Btn_Ver_Apoderado.Enabled = False
    List4.Visible = True
    List3.Visible = False
    
End Sub

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

Private Function InfoPagoAlu(ByVal RunAlu As String, ByVal agno As Integer, CNX As ADODB.Connection, Optional ByVal SoloActivo As Boolean = False) As Variant
    Dim Resp() As Variant
    Dim QRY As String
    Dim rec As ADODB.Recordset
    
    ReDim Resp(1 To 12, 1 To 1)
    Resp(1, 1) = "" 'Nombre
    Resp(2, 1) = "" 'Run Alumno
    Resp(3, 1) = 0 'Porcentaje de Beca
    Resp(4, 1) = "" 'Forma de Pago
    Resp(5, 1) = "" 'Fecha de Matricula
    Resp(6, 1) = "" 'Nombre Apoderado
    Resp(7, 1) = "" 'Run Apoderado
    Resp(8, 1) = "" 'Enseñanza
    Resp(9, 1) = "" 'grado
    Resp(10, 1) = 0 'Año de Matricula
    Resp(11, 1) = "" 'Reserva Proximo año
    Resp(12, 1) = 0 'Jornada Actual
    
    If SoloActivo Then
        QRY = "SELECT concat(p.ape_pat_alu,' ', p.ape_mat_alu,' ',p.nom_alu) as nombre_alu, axa.ci_alu, if(m.ind_beca=1,100,if(m.ind_mbeca=1,50,0)) as beca_porc, if(m.ind_cup=1,'cuponera',if(m.ind_cont=1,'contado',if(m.ind_cheq=1,'cheque','ninguna'))) as forma_pago_alu, m.fec_mat, concat(a.ape1_apo,' ',a.ape2_apo,' ',a.noms_apo) as nombre_apo, axa.rut_apo, m.cod_ens, m.num_gra, m.anno_mat, if(m.reserva=1,'S',if(m.reserva=2,'R','N')) as reserva_mat, m.cod_jor " & _
              "FROM matriculas as m, postulantes as p, apoderados as a, apo_x_alu as axa WHERE axa.ci_alu='" & RunAlu & "' AND m.anno_mat='" & agno & "' AND axa.agno=m.anno_mat AND m.activo_alu='SI' AND axa.ci_alu=p.ci_alu AND axa.rut_apo=a.rut_apo AND axa.ci_alu=m.ci_alu ORDER BY m.fec_mat;"
    Else
        QRY = "SELECT concat(p.ape_pat_alu,' ', p.ape_mat_alu,' ',p.nom_alu) as nombre_alu, axa.ci_alu, if(m.ind_beca=1,100,if(m.ind_mbeca=1,50,0)) as beca_porc, if(m.ind_cup=1,'cuponera',if(m.ind_cont=1,'contado',if(m.ind_cheq=1,'cheque','ninguna'))) as forma_pago_alu, m.fec_mat, concat(a.ape1_apo,' ',a.ape2_apo,' ',a.noms_apo) as nombre_apo, axa.rut_apo, m.cod_ens, m.num_gra, m.anno_mat, if(m.reserva=1,'S',if(m.reserva=2,'R','N')) as reserva_mat, m.cod_jor " & _
              "FROM matriculas as m, postulantes as p, apoderados as a, apo_x_alu as axa WHERE axa.ci_alu='" & RunAlu & "' AND m.anno_mat='" & agno & "' AND axa.agno=m.anno_mat AND axa.ci_alu=p.ci_alu AND axa.rut_apo=a.rut_apo AND axa.ci_alu=m.ci_alu ORDER BY m.fec_mat;"
    End If
    
    Set rec = New ADODB.Recordset
    rec.Open QRY, CNX
    If rec.RecordCount > 0 Then
        rec.MoveFirst
        ReDim Preserve Resp(1 To 12, 1 To rec.RecordCount)
        For I = 1 To rec.RecordCount
            Resp(1, I) = rec!nombre_alu
            Resp(2, I) = rec!ci_alu
            Resp(3, I) = rec!beca_porc
            Resp(4, I) = rec!forma_pago_alu
            Resp(5, I) = rec!fec_mat
            Resp(6, I) = rec!nombre_apo
            Resp(7, I) = rec!rut_apo
            Resp(8, I) = rec!Cod_Ens
            Resp(9, I) = rec!Num_Gra
            Resp(10, I) = val(rec!anno_mat)
            Resp(11, I) = rec!Reserva_mat
            Resp(12, I) = rec!cod_jor
            rec.MoveNext
        Next I
    End If
    rec.Close
    InfoPagoAlu = Resp
End Function

Private Sub SeteaVistaAlumno()
    ' Vaciar la vista de Alumno.
    Frame3.Caption = ""
    Grid1.Clear
    Grid1.Rows = 2
    Grid1.FixedCols = 1
    Grid1.FormatString = "^Nº|>Nombre Alumno|^Rut Alumno|^Fecha Mat.|^Reserva|>Cod_ens|>Num_gra|^Curso Actual|>AgnoMat|>Cod Jornada|<Apoderado|^Rut Apoderado"
    Grid1.FixedCols = 1
    Grid1.ColWidth(0) = 350
    Grid1.ColWidth(1) = 0
    Grid1.ColWidth(2) = 1000
    Grid1.ColWidth(3) = 0
    Grid1.ColWidth(5) = 0
    Grid1.ColWidth(6) = 0
    Grid1.ColWidth(8) = 0
    Grid1.ColWidth(9) = 0
    Grid1.ColWidth(10) = 3000
    
End Sub

Private Sub SeteaVistaApoderado()
    ' Vaciar la vista de Alumno.
    Frame3.Caption = ""
    Grid1.Clear
    Grid1.Rows = 2
    Grid1.FixedCols = 1
    Grid1.FormatString = "^Nº|<Nombre Alumno|^Rut Alumno|^Fecha Mat.|^Reserva|>Cod_ens|>Num_gra|^Curso Actual|>AgnoMat|>Cod Jornada|>Apoderado|>Rut Apoderado"
    Grid1.FixedCols = 1
    Grid1.ColWidth(0) = 350
    Grid1.ColWidth(1) = 3000
    Grid1.ColWidth(2) = 1000
    Grid1.ColWidth(3) = 0
    Grid1.ColWidth(5) = 0
    Grid1.ColWidth(6) = 0
    Grid1.ColWidth(8) = 0
    Grid1.ColWidth(9) = 0
    Grid1.ColWidth(10) = 0
    Grid1.ColWidth(11) = 0
End Sub

Private Sub SeteaVistaCurso()
    'Vaciar la vista de Curso
    Frame3.Caption = ""
    Grid1.Clear
    Grid1.Rows = 2
    Grid1.FormatString = "^Nº|<Nombre Alumno|^Rut Alumno|^Fecha Mat.|^Reserva|>Cod_ens|>Num_gra|^Curso Actual|>AgnoMat|>Cod Jornada|<Apoderado|^Rut Apoderado"
    Grid1.FixedCols = 1
    Grid1.ColWidth(0) = 350
    Grid1.ColWidth(1) = 3000
    Grid1.ColWidth(2) = 1000
    Grid1.ColWidth(3) = 0
    Grid1.ColWidth(5) = 0
    Grid1.ColWidth(6) = 0
    Grid1.ColWidth(7) = 0
    Grid1.ColWidth(8) = 0
    Grid1.ColWidth(9) = 0
    Grid1.ColWidth(10) = 3000
End Sub

Private Sub LlenaCombosAgno()
    If Anno >= 2005 Then
        For I = 2005 To Anno
            Combo1.AddItem str(I), I - 2005
            Combo2.AddItem str(I), I - 2005
            Combo1.Text = Anno
            Combo2.Text = Anno
        Next I
    Else
        Combo1.AddItem "2005", 0
        Combo2.AddItem "2005", 0
        Combo1.Text = "2005"
        Combo2.Text = "2005"
    End If
End Sub

Private Sub VaciarInfoCuadroAlumno()
    Flag_sub = True
    Text5.Text = ""
    Text6.Text = ""
    'Check_Mat.Value = 2
    Flag_sub = False
End Sub

Private Function verifica_cheques_protestados(ci_alu As String, agno As Integer) As Boolean
    'Si el alumno tiene cheques protestados devuelve verdadero
    Dim var_sql As String
    Dim rut_apo As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    var_sql = "select rut_apo from apo_x_alu where ci_alu = '" & ci_alu & "' and agno = " & agno & " limit 1"
    objRS.Open var_sql, conn
    rut_apo = objRS("rut_apo")
    objRS.Close
    var_sql = "select distinct concat(rut,'-',digito) as rut from fnza_protestados" _
            & " where concat(rut,'-',digito) = '" & rut_apo & "'"
    objRS.Open var_sql, conn
    If Not objRS.EOF Then
        verifica_cheques_protestados = True
    Else
        verifica_cheques_protestados = False
    End If
    objRS.Close
End Function



