VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form_proc_Cursos_hue 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Procesos"
   ClientHeight    =   5925
   ClientLeft      =   1605
   ClientTop       =   1785
   ClientWidth     =   6975
   Icon            =   "Form_proc_curso_hue.frx":0000
   LinkTopic       =   "Form3"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   Moveable        =   0   'False
   ScaleHeight     =   5925
   ScaleWidth      =   6975
   Begin MSFlexGridLib.MSFlexGrid grdproc_cursos 
      Height          =   1695
      Left            =   9240
      TabIndex        =   29
      Top             =   2760
      Width           =   7455
      _ExtentX        =   13150
      _ExtentY        =   2990
      _Version        =   393216
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Frame Frame_Mat_OK 
      Caption         =   "NO ES POSIBLE CONTINUAR CON LA MATRICULA"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   3615
      Left            =   120
      TabIndex        =   24
      Top             =   3840
      Visible         =   0   'False
      Width           =   6855
      Begin VB.CommandButton Cmb_Docs_REc 
         Caption         =   "Recibir Documentos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   435
         Left            =   2400
         TabIndex        =   15
         Top             =   3000
         Visible         =   0   'False
         Width           =   2115
      End
      Begin VB.Frame Frame_Mat_Ok_Doc 
         Caption         =   "Faltan  documentos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1935
         Left            =   1800
         TabIndex        =   25
         Top             =   960
         Visible         =   0   'False
         Width           =   3375
         Begin VB.CheckBox Chk_Doc_4 
            Caption         =   "Fotos"
            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        =   14
            Top             =   1560
            Value           =   1  'Checked
            Width           =   855
         End
         Begin VB.CheckBox Chk_Doc_3 
            Caption         =   "Cert. de estudi - Ultimo año cursado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   240
            TabIndex        =   13
            Top             =   1200
            Value           =   1  'Checked
            Width           =   2895
         End
         Begin VB.CheckBox Chk_Doc_2 
            Caption         =   "Informe de notas parciales"
            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        =   12
            Top             =   840
            Value           =   1  'Checked
            Width           =   2295
         End
         Begin VB.CheckBox Chk_Doc_1 
            Caption         =   "Cert.de nacimiento"
            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        =   11
            Top             =   480
            Value           =   1  'Checked
            Width           =   1695
         End
      End
      Begin VB.CommandButton Btn_show_Morosidad 
         Caption         =   "Morosidad"
         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            =   4680
         TabIndex        =   9
         Top             =   360
         Width           =   2055
      End
      Begin VB.CommandButton Btn_show_Conducta 
         Caption         =   "Conducta"
         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            =   2400
         TabIndex        =   8
         Top             =   360
         Width           =   2055
      End
      Begin VB.CommandButton Btn_show_Doc 
         Caption         =   "Faltan documentos"
         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            =   120
         TabIndex        =   7
         Top             =   360
         Width           =   2055
      End
      Begin VB.Frame Frame_Mat_Ok_Conducta 
         Caption         =   "Problemas de conducta"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1935
         Left            =   360
         TabIndex        =   26
         Top             =   960
         Visible         =   0   'False
         Width           =   6135
         Begin VB.TextBox Txt_obs 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   735
            Left            =   240
            TabIndex        =   10
            Top             =   720
            Width           =   5655
         End
      End
   End
   Begin VB.Frame frm_Descuentos 
      BorderStyle     =   0  'None
      Caption         =   "Descuentos"
      Height          =   2265
      Left            =   240
      TabIndex        =   56
      Top             =   360
      Visible         =   0   'False
      Width           =   6615
      Begin VB.CommandButton btn_volver 
         Caption         =   "< volver"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   0
         TabIndex        =   64
         Top             =   1920
         Width           =   975
      End
      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          =   480
         Left            =   0
         TabIndex        =   57
         Top             =   720
         Visible         =   0   'False
         Width           =   2295
      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          =   1740
         ItemData        =   "Form_proc_curso_hue.frx":2A8B2
         Left            =   1440
         List            =   "Form_proc_curso_hue.frx":2A8B9
         Style           =   1  'Checkbox
         TabIndex        =   58
         Top             =   0
         Width           =   5175
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Presionar CTRL para seleecionar multiples descuentos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   1440
         TabIndex        =   60
         Top             =   1920
         Width           =   3945
      End
      Begin VB.Label lbl_descuentos 
         Caption         =   "Descuentos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   0
         TabIndex        =   59
         Top             =   0
         Width           =   855
      End
   End
   Begin VB.Frame Frame_Mat 
      Caption         =   "Matricular 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          =   3675
      Left            =   120
      TabIndex        =   18
      Top             =   120
      Width           =   6855
      Begin VB.ComboBox cb_valor_mat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   3120
         TabIndex        =   72
         Top             =   3240
         Width           =   975
      End
      Begin VB.ComboBox cmb_tp_mensualidad 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   4920
         TabIndex        =   68
         Top             =   2280
         Width           =   1815
      End
      Begin VB.ComboBox cmb_tp_incorporacion 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   4920
         TabIndex        =   67
         Top             =   1800
         Width           =   1815
      End
      Begin VB.ComboBox cbx_cuota_incorporacion 
         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_proc_curso_hue.frx":2A8D4
         Left            =   5400
         List            =   "Form_proc_curso_hue.frx":2A8D6
         TabIndex        =   66
         Text            =   "NO"
         Top             =   2760
         Width           =   1335
      End
      Begin VB.CommandButton btn_ver_descuentos 
         Caption         =   "Ver"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   2640
         TabIndex        =   63
         Top             =   2760
         Visible         =   0   'False
         Width           =   855
      End
      Begin VB.ComboBox cbx_descuentos 
         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          =   330
         ItemData        =   "Form_proc_curso_hue.frx":2A8D8
         Left            =   1560
         List            =   "Form_proc_curso_hue.frx":2A8E2
         TabIndex        =   61
         Text            =   "NO"
         Top             =   2760
         Width           =   855
      End
      Begin VB.ListBox Lst_nom_alu_mat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   900
         Left            =   1560
         TabIndex        =   1
         Top             =   600
         Visible         =   0   'False
         Width           =   5175
      End
      Begin VB.ComboBox cmb_AnhoPos 
         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_proc_curso_hue.frx":2A8EE
         Left            =   5760
         List            =   "Form_proc_curso_hue.frx":2A8F0
         TabIndex        =   55
         Text            =   "2012"
         Top             =   720
         Width           =   975
      End
      Begin VB.TextBox txt_mod 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   2280
         MaxLength       =   21
         TabIndex        =   36
         Top             =   1440
         Width           =   2415
      End
      Begin VB.TextBox txt_mod_nivel 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   1560
         MaxLength       =   21
         TabIndex        =   35
         Top             =   1440
         Width           =   735
      End
      Begin VB.TextBox txt_fec_pos 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   3795
         MaxLength       =   10
         TabIndex        =   33
         Top             =   720
         Width           =   975
      End
      Begin VB.ComboBox cmb_tipo_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_proc_curso_hue.frx":2A8F2
         Left            =   1560
         List            =   "Form_proc_curso_hue.frx":2A8F4
         TabIndex        =   30
         Top             =   2280
         Width           =   1695
      End
      Begin VB.ComboBox Cmb_Jor_mat 
         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_proc_curso_hue.frx":2A8F6
         Left            =   1560
         List            =   "Form_proc_curso_hue.frx":2A8F8
         TabIndex        =   5
         Top             =   1800
         Width           =   1695
      End
      Begin VB.TextBox Txt_jor_alu 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   4680
         MaxLength       =   21
         TabIndex        =   4
         Top             =   1440
         Width           =   2055
      End
      Begin MSComCtl2.DTPicker DTP_fec_mat 
         Height          =   375
         Left            =   840
         TabIndex        =   3
         Top             =   3240
         Width           =   1215
         _ExtentX        =   2143
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         CustomFormat    =   "dd/MM/yyyy"
         Format          =   51838979
         CurrentDate     =   37666
      End
      Begin VB.TextBox Txt_num_Mat 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   1560
         MaxLength       =   5
         TabIndex        =   6
         Top             =   1080
         Width           =   1335
      End
      Begin VB.TextBox Txt_rut_alu_mat 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   1560
         MaxLength       =   8
         TabIndex        =   2
         Top             =   720
         Width           =   975
      End
      Begin VB.CommandButton Btn_Can_Mat 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5640
         TabIndex        =   17
         Top             =   3180
         Width           =   1095
      End
      Begin VB.CommandButton Btn_Ace_Mat 
         Caption         =   "Matricular"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4440
         TabIndex        =   16
         Top             =   3180
         Width           =   1095
      End
      Begin VB.TextBox Txt_Dig_alu_mat 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   2640
         MaxLength       =   1
         TabIndex        =   19
         Top             =   720
         Width           =   255
      End
      Begin VB.TextBox Txt_nom_alu_mat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   1560
         MaxLength       =   95
         TabIndex        =   0
         Top             =   360
         Width           =   5175
      End
      Begin VB.Label Label6 
         Caption         =   "Valor 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            =   2280
         TabIndex        =   71
         Top             =   3240
         Width           =   975
      End
      Begin VB.Label Label5 
         Caption         =   "T.P. Incorporación"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3480
         TabIndex        =   70
         Top             =   1800
         Width           =   1335
      End
      Begin VB.Label Label4 
         Caption         =   "T.P. Mensualidad"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3480
         TabIndex        =   69
         Top             =   2280
         Width           =   1335
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "Cuota incorporación"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   3720
         TabIndex        =   65
         Top             =   2760
         Width           =   1455
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "Descuentos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   120
         TabIndex        =   62
         Top             =   2760
         Width           =   870
      End
      Begin VB.Label Label19 
         Caption         =   "Para el 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            =   4800
         TabIndex        =   34
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label18 
         Caption         =   "Postuló el"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3000
         TabIndex        =   32
         Top             =   720
         Width           =   855
      End
      Begin VB.Line Line1 
         BorderColor     =   &H8000000C&
         X1              =   0
         X2              =   6795
         Y1              =   3120
         Y2              =   3120
      End
      Begin VB.Label Label17 
         Caption         =   "T.P. Matricula"
         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        =   31
         Top             =   2280
         Width           =   975
      End
      Begin VB.Label Label11 
         Caption         =   "Matricular en"
         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        =   28
         Top             =   1800
         Width           =   975
      End
      Begin VB.Label Label9 
         Caption         =   "Postula a"
         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        =   27
         Top             =   1440
         Width           =   1455
      End
      Begin VB.Label Label10 
         Caption         =   "Nro. de matrícula"
         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        =   23
         Top             =   1080
         Width           =   1335
      End
      Begin VB.Label Label15 
         Caption         =   "Rut"
         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        =   22
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label Label13 
         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            =   120
         TabIndex        =   21
         Top             =   360
         Width           =   1215
      End
      Begin VB.Label Label12 
         Caption         =   "Fec. 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        =   20
         Top             =   3240
         Width           =   855
      End
   End
   Begin VB.Frame fra_des_alu 
      Caption         =   "Desmatricular Alumnos sin Curso"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   6615
      Left            =   120
      TabIndex        =   37
      Top             =   120
      Visible         =   0   'False
      Width           =   9015
      Begin VB.Frame frm_inf_con 
         Caption         =   "Información Consultada"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   4815
         Left            =   120
         TabIndex        =   38
         Top             =   1680
         Width           =   8775
         Begin VB.TextBox Txt_jor 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   3600
            TabIndex        =   43
            Text            =   "Text1"
            Top             =   4320
            Visible         =   0   'False
            Width           =   1575
         End
         Begin VB.TextBox Txt_Alu 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1800
            TabIndex        =   42
            Top             =   4320
            Width           =   495
         End
         Begin VB.CommandButton com_des 
            Caption         =   "Desmatricular"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   5520
            TabIndex        =   41
            Top             =   4320
            Width           =   1335
         End
         Begin VB.CommandButton btn_car 
            Caption         =   "Cargar Alumnos"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   480
            TabIndex        =   40
            Top             =   2040
            Visible         =   0   'False
            Width           =   1455
         End
         Begin VB.CommandButton com_salir 
            Caption         =   "Salir"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   7320
            TabIndex        =   39
            Top             =   4320
            Width           =   1335
         End
         Begin MSFlexGridLib.MSFlexGrid grd_alu 
            Height          =   3975
            Left            =   120
            TabIndex        =   54
            Top             =   240
            Width           =   8535
            _ExtentX        =   15055
            _ExtentY        =   7011
            _Version        =   393216
            Cols            =   5
            FixedCols       =   0
            FormatString    =   "Apellido paterno     | Apellido materno     | Nombres                                 | R.U.N         | Fecha Matrícula"
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
         End
         Begin VB.Label lbl_alu 
            Caption         =   "Total Alumnos"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   44
            Top             =   4320
            Width           =   1215
         End
      End
      Begin VB.Frame frm_dat_alu 
         Caption         =   "Datos a Buscar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   1335
         Left            =   120
         TabIndex        =   45
         Top             =   240
         Width           =   8775
         Begin VB.ComboBox cmb_jor_alu 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   5280
            Style           =   2  'Dropdown List
            TabIndex        =   49
            Top             =   840
            Width           =   2055
         End
         Begin VB.ComboBox cmb_niv 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   5280
            Style           =   2  'Dropdown List
            TabIndex        =   48
            Top             =   480
            Width           =   855
         End
         Begin VB.ComboBox cmb_mod 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   1200
            Style           =   2  'Dropdown List
            TabIndex        =   47
            Top             =   480
            Width           =   2535
         End
         Begin VB.ComboBox cmb_ano 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   1200
            Style           =   2  'Dropdown List
            TabIndex        =   46
            Top             =   840
            Width           =   1455
         End
         Begin VB.Label Label21 
            Caption         =   "Jornada"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   4200
            TabIndex        =   53
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_niv 
            Caption         =   "Nivel"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   4200
            TabIndex        =   52
            Top             =   480
            Width           =   975
         End
         Begin VB.Label lbl_mod 
            Caption         =   "Modalidad"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   51
            Top             =   480
            Width           =   975
         End
         Begin VB.Label lbl_ano 
            Caption         =   "Año"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   50
            Top             =   840
            Width           =   975
         End
      End
   End
End
Attribute VB_Name = "Form_proc_Cursos_hue"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim jornada, Cod_Ens, Num_Gra As String

Private Sub Btn_Ace_Mat_Click()
Dim b_rut_apo As String
Dim conecta As Boolean
Dim rut_apoderado As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
Dim var_sql As String
Dim apoderado As String
Dim Situacion As String
On Error GoTo SaltoError:
Dim apo As String
Dim cole As String
Dim repactacion As String
Dim log As Boolean
Dim R As Integer
Dim grado, curso, accion_realizada As String
Dim AnhoPos As String
Dim pagos As String
Dim Num_MAT As Long
Dim accion_detalle As String
Dim sw_cheques As Boolean
Dim log_mensaje As String

If Cmb_Jor_mat = "" Then MsgBox "Debe seleccionar una jornada", vbExclamation + vbOKOnly, Ges - Col, , "": Cmb_Jor_mat.SetFocus:   Exit Sub
If Me.cmb_tipo_pago = "" Then MsgBox "Debe seleccionar tipo de pago de la matricula":  Me.cmb_tipo_pago.SetFocus: Exit Sub
If Me.cmb_tp_mensualidad = "" Then MsgBox "Debe seleccionar tipo de pago de las mensualidades":  Me.cmb_tipo_pago.SetFocus: Exit Sub
If cbx_cuota_incorporacion.Text <> "NO" And Me.cmb_tp_incorporacion = "" Then MsgBox "Debe seleccionar tipo de pago de la cuota de la cuota de incorporación":  Me.cmb_tipo_pago.SetFocus: Exit Sub

    ' Validad valor matricula que sea seelccionado
    If cb_valor_mat.Text = "" And cmb_AnhoPos >= 2023 Then
        MsgBox "Debe seleccionar el valor de la matricula", vbInformation
        Exit Sub
    End If

If Cmb_Jor_mat <> "" Then Joralu = DevuelveCampo("jornadas", "", "cod_jor", "des_jor = '" & Me.Cmb_Jor_mat & "'", conn)
repactacion = ""

var_sql = "SELECT RIGHT(rut_apo,9) AS rut_cero,rut_apo,COUNT(RIGHT(rut_apo,9))" _
        & " From apoderados" _
        & " GROUP BY RIGHT(rut_apo,9)" _
        & " HAVING COUNT(rut_apo) > 1"
objRS.Open var_sql, conn
While Not objRS.EOF
    var_sql = "delete FROM apoderados WHERE rut_apo = '" & objRS("rut_apo") & "'"
    rut_apoderado = objRS("rut_apo")
    conn.Execute var_sql
    objRS.MoveNext
Wend
objRS.Close

var_sql = "update apo_x_alu set rut_apo = concat('0',rut_apo) where length(rut_apo) = 9 and mid(rut_apo,9,1) <> '-'"
conn.Execute var_sql
var_sql = "update apoderados set rut_apo = concat('0',rut_apo) where length(rut_apo) = 9 and mid(rut_apo,9,1) <> '-'"
conn.Execute var_sql
var_sql = "update fnza_mensualidad set run_apo = concat('0',run_apo) where length(run_apo) = 9 and mid(run_apo,9,1) <> '-'"
conn.Execute var_sql
var_sql = "update fnza_cuponeras set rut_apo = concat('0',rut_apo) where length(rut_apo) = 9 and mid(rut_apo,9,1) <> '-'"
conn.Execute var_sql
var_sql = "update fnza_cheques_recibidos set run_apo = concat('0',run_apo) where length(run_apo) = 9 and mid(run_apo,9,1) <> '-'"
conn.Execute var_sql
var_sql = "update fnza_boletas set run_apo = concat('0',run_apo) where length(run_apo) = 9 and mid(run_apo,9,1) <> '-'"
conn.Execute var_sql




AnhoPos = Me.cmb_AnhoPos.Text

If val(AnhoPos) < Year(Date) Then
    Err.Raise vbObjectError + 800, "From_proc_Cursos.Btn_Ace_Mat_Click", "Imposible matricular a un alumno en el año " & AnhoPos & "."
    Exit Sub
End If

Select Case Me.cmb_tipo_pago.ListIndex
    Case 0: pagos = ", '1', '0', '0', '0'"
    Case 1: pagos = ", '0', '1', '0', '0'"
    Case 2: pagos = ", '0', '0', '1', '0'"
    Case 3: pagos = ", '0', '0', '0', '1'"
End Select
'pagos = ",'0','0','0','0'"
Rut_ALu = Me.Txt_rut_alu_mat & "-" & Me.Txt_Dig_alu_mat


    var_sql = "SELECT IF(LENGTH(condicional) > 1,'condicional','caducidad') as situacion FROM fnza_bloqueados_condicionales WHERE rut = '" & Rut_ALu & "'"
    '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
            MsgBox "El alumno no puede ser matriculado porque tiene CADUCIDAD de matricula", vbInformation
            Exit Sub
        End If
    End If

'Verifica cheques y PAT
    conecta = ConectarBDSiempre(connLN, "192.168.7.91", "comunes_gescol", "groot", "kripplefight", True)
    
    var_sql = "SELECT rut_apo FROM apo_x_ins WHERE ci_alu = '" & Rut_ALu & "'"
    rec.Open var_sql, conn
    b_rut_apo = rec("rut_apo")
    rec.Close
    
    var_sql = "SELECT motivo,c.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 Sra. Katherine Cortes, comunicarse al fono 6319510", vbInformation
        
        Else
            MsgBox "El apoderado no puede matricular por " & rec("motivo") & " en " & rec("nombre") _
            & ", si desea matricular necesita autorizacion de Sra. Katherine Cortes, comunicarse al fono 6319510", vbInformation
        End If
        Exit Sub
    End If
    rec.Close
    
'    var_sql = "SELECT motivo FROM `fnza_lista_negra_alumnos` where ci_alu = '" & Rut_ALu & "' and autorizado = 0"
    var_sql = "SELECT motivo, colegio as nombre FROM `fnza_lista_negra_alumnos` where ci_alu = '" & Rut_ALu & "' and bloqueado = 1"
    rec.Open var_sql, connLN
    If rec.RecordCount > 0 Then
        Nom_colegio = DevuelveCampo("establecimientos", "", "nom_est", "colegio ='" & rec("nombre") & "'", conn)
        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 Sra. Katherine Cortes, comunicarse al fono 6319510", vbInformation
        Else
            MsgBox "El alumno no puede ser matriculado porque el " & rec("motivo") & " en " & Nom_colegio _
                & ", si desea matricular necesita autorizacion de Sra. Katherine Cortes, comunicarse al fono 6319510", vbInformation
        End If
        Exit Sub
    End If
    rec.Close
    connLN.Close
    
    b_noms_apo = DevuelveCampo("apoderados", "", "concat(ape1_apo,' ',ape2_apo,' ',noms_apo)", "rut_apo ='" & b_rut_apo & "'", conn)
    
   
    
        ''''''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 = " & cmb_AnhoPos
    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 = " & cmb_AnhoPos
    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 < 125000 And cmb_tp_incorporacion.Text = "Cheques" And cbx_cuota_incorporacion <> "NO" 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 < 89900 And cmb_tipo_pago.Text = "Cheques" Then
        MsgBox "La matricula NO se puede realizar, los cheques deben ser ingresados al sistema", vbInformation
        'Load Form_Ingreso_Cheques
        'Form_Ingreso_Cheques.cmb_agno.Text = 2020
        sw_cheques = False
        '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
        'Load Form_Ingreso_Cheques
        'Form_Ingreso_Cheques.cmb_agno.Text = 2020
        sw_cheques = False
        'Exit Sub
    End If
    
    If sw_cheques = False Then
        Load Form_Ingreso_Cheques
        Form_Ingreso_Cheques.Flag_Sub_True
        Form_Ingreso_Cheques.Text1.Text = Txt_nom_alu_mat.Text
        Form_Ingreso_Cheques.text2.Text = Rut_ALu
        Form_Ingreso_Cheques.Flag_Sub_False
        Form_Ingreso_Cheques.Text1.Locked = True
        Form_Ingreso_Cheques.text2.Locked = True
        Form_Ingreso_Cheques.Text11 = b_noms_apo
        Form_Ingreso_Cheques.Text12 = b_rut_apo
        Form_Ingreso_Cheques.Show
        Exit Sub
    End If
    
    


If Not ExistReg("MATRICULAS", "CI_ALU ='" & Rut_ALu & "' AND ACTIVO_ALU ='SI' AND ANNO_MAT='" & Anno & "'", conn) Then
    If Not (CompruebaValoresParaMatricula(Cod_Ens, Num_Gra, val(AnhoPos), conn)) Then
        MsgBox "EL ALUMNO RUT " & Rut_ALu & " NO PUEDE SER MATRICULADO PUES NO ESTA DEFINIDO EL ARANCEL DEL AÑO " & AnhoPos & ".", vbCritical + vbOKOnly, "ALERTA"
        Exit Sub
    End If
    
    'REPLACE INTO : Inserta y si existe reemplaza
    conn.Execute "REPLACE INTO apo_x_alu(ci_alu,rut_apo,parent_apo,agno) SELECT ci_alu,rut_apo,parent_apo," & Trim(cmb_AnhoPos.Text) & " as agno FROM apo_x_ins where ci_alu='" & Rut_ALu & "';"
    
    'Verifica deuda 2011 gescol y exage
    mat_con_deuda = DevuelveCampo("usuarios", "", "matricular_con_deuda", "AUT_NOMBRE_USUARIO ='" & Nom_usu_ses & "'", conn)
    cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    colegio = IIf(cole = "FAR001", "Farfana_2005", IIf(cole = "LON001", "Maipu_2005", IIf(cole = "SNB001", "Sanbernardo_2005", "otro")))
    
    'If verifica_deuda(Grid1.TextMatrix(Grid1.Row, 2)) = True Or deuda_exage("20187452-1", colegio) = True Then
    'If verifica_deuda(Trim(Rut_ALu)) = True Or deuda_exage(Trim(Rut_ALu), colegio) = True Then
    If verifica_deuda(Trim(Rut_ALu), 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
                        'MsgBox "Alumno No puede ser matriculado porque el apoderado tiene cheques protestados, en " & arr_deuda(2), vbCritical
                    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
                    conn.Execute "DELETE FROM apo_x_alu WHERE ci_alu='" & Rut_ALu & "' and agno=" & Trim(cmb_AnhoPos.Text) & ";"
                    Exit Sub
                    
        Else
                If MsgBox("Alumno con deuda, ¿El alumno realizó repactación?", vbYesNo, "Atención") = vbNo Then
                    Check_confirma.Value = 0
                    conn.Execute "DELETE FROM apo_x_alu WHERE ci_alu='" & Rut_ALu & "' and agno=" & Trim(cmb_AnhoPos.Text) & ";"
                    Exit Sub
                End If
        End If
    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
            
    If pagos = "" Then pagos = ", '0', '0', '0', '0'"
            
    conn.Execute "INSERT INTO MATRICULAS(usuario_ingreso,forma_pago,fp_incorporacion,fp_matricula,fp_mensualidad," _
               & "fec_mat_r,CI_ALU, ACTIVO_ALU, NUM_MAT," _
               & "FEC_MAT, COD_ENS, cod_jor, anno_mat," _
               & "ind_cup, ind_cheq, ind_pac, ind_cont," _
               & "Num_gra, ind_beca, ind_mbeca, fec_retiro,confirmado) " & _
    "values('" & Nom_com_usu_ses & "','" & Me.cmb_tipo_pago.Text & "','" & Me.cmb_tp_incorporacion.Text & "','" & Me.cmb_tipo_pago.Text & "','" & Me.cmb_tp_mensualidad.Text & "','" _
    & fecha_real & "','" & Rut_ALu & "', 'SI', '00000', '" _
    & Format(DTP_Fec_Mat, "yyyy-mm-dd") & "', '" & Cod_Ens & "', '" & Joralu & "', '" & AnhoPos _
    & "'" & pagos & ",'" & Num_Gra & "', 0, 0, '1111-11-11', 'SI')"
    
    'conn.Execute "INSERT INTO MATRICULAS(forma_pago,fp_incorporacion,fp_matricula,fp_mensualidad,fec_mat_r,CI_ALU, ACTIVO_ALU, NUM_MAT, FEC_MAT, COD_ENS, cod_jor, anno_mat,  ind_cup, ind_cheq, ind_pac, ind_cont, Num_gra, ind_beca, ind_mbeca, fec_retiro,confirmado) " & _
    '"values('" & Me.cmb_tipo_pago.Text & "','" & Me.cmb_tp_incorporacion.Text & "','" & Me.cmb_tipo_pago.Text & "','" & Me.cmb_tp_mensualidad.Text & "','" & fecha_real & "','" & Rut_ALu & "', 'SI', '00000', '" & Format(DTP_Fec_Mat, "yyyy-mm-dd") & "', '" & Cod_Ens & "', '" & Joralu & "', '" & AnhoPos & "'" & pagos & ",'" & Num_Gra & "', 0, 0,'1111-11-11', 'SI')"
    conn.Execute "UPDATE postulantes Set MATRICULADO_ALU ='1'  where CI_ALU = '" & Rut_ALu & "'"
    conn.Execute "UPDATE vac_x_nivel Set ocu_vac =ocu_vac + 1, DIS_VAC =TOTAL_VAC - OCU_VAC where COD_ENS = '" & Cod_Ens & "' AND NUM_GRA ='" & Num_Gra & "' AND cod_jor ='" & Joralu & "' and agno = " & AnhoPos
    conn.Execute "UPDATE postulaciones SET anno_pos_alu='" & AnhoPos & "' WHERE ci_alu='" & Rut_ALu & "' AND Fec_pos='" & Format(Me.txt_fec_pos.Text, "yyyy-mm-dd") & "';"
    conn.Execute "DELETE FROM apo_x_ins WHERE ci_alu='" & Rut_ALu & "';"
    
    Form_proc_Cursos.DTP_Fec_Mat.Enabled = False
    Form_proc_Cursos.Cmb_Jor_mat.Enabled = False
    Me.Txt_nom_alu_mat.Enabled = True
    Me.Txt_nom_alu_mat.SetFocus
    'cbx_descuentos_click()
    
    
    ' Insertar Log de insercion de matricula.
                Select Case Cod_Ens
                    Case "996"
                        grado = "PK"
                    Case "010"
                        grado = "K"
                    Case "110"
                        grado = "EB"
                    Case "310"
                        grado = "EM"
                End Select
                curso = CStr(Num_Gra) & "º " & grado
                accion_realizada = "El alumno fue matriculado en " & curso _
                                & ", para el período " & AnhoPos & repactacion
                log = Inserta_Vitacora_Alumno(CStr(Rut_ALu), accion_realizada)
    ' Fin Log.
    
    '********** Registro de operaciones ***********
     Call RegOpe("MAT", Trim(Left("MATRICULAS@" & Rut_ALu & "@" & Me.Txt_nom_alu_mat & String(100, " "), 100)), conn)
    '********** FIN Registro de operaciones ***********
    
    'Enviar en una variable los id de los descuentos
    Dim ids_descuentos As String

    ids_descuentos = ""
    For I = 0 To Me.lst_descuentos_nombre.ListCount - 1
        If Me.lst_descuentos_nombre.Selected(I) Then
            ids_descuentos = ids_descuentos & Me.lst_descuentos_nombre.ItemData(I) & ","
        End If
    Next I

    ' #######################
    ' Aqui se realiza la llamada al procedimiento
    ' para recalcular y regenerar la cuotas en fnza_detalle_mensualidad y fnza_mensualidad.
    
    StrSql = "update matriculas set ind_cheq = 0,ind_cont=0 where anno_mat = " & val(AnhoPos) & " and ci_alu = '" & Rut_ALu & "'"
    conn.Execute StrSql
    
    ' Log finanza
          accion_detalle = "El usuario selecciono para el año " & AnhoPos & _
          " para matricula: " & Me.cmb_tipo_pago.Text _
          & ", mensualidad: " & Me.cmb_tp_mensualidad.Text _
          & ", cuota incorporación: " & Me.cmb_tp_incorporacion.Text
          Call Inserta_Vitacora_Finanza(CStr(Rut_ALu), b_rut_apo, "Forma de Pago", accion_detalle, 0, 0)
    ' Fin Log
    
    
    RecalculaCuota_Alu Rut_ALu, val(AnhoPos), conn
    CorrigeValorNuevo Rut_ALu, val(AnhoPos), Anno, conn
    ' #######################
    
    
'INICIO ACTUALIZACION HUECHURABA
'--------------------------------------------------------------------------------------------------
    ' 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 & "'"
    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 & "' and anno_mat = " & AnhoPos
    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
    
    ' Inserta la cuota de incoporacion si esta especificado en el combobox
    If Me.cbx_cuota_incorporacion.Text <> "NO" Then
        
        StrSql = "DELETE FROM fnza_detalle_mensualidad " _
               & " WHERE run_alu = '" & Rut_ALu & "' AND agno = " & AnhoPos & " AND concepto = 'inco'"
        conn.Execute StrSql
        
        StrSql = "DELETE FROM fnza_mensualidad" _
               & " WHERE run_apo = '" & b_rut_apo & "' AND agno = " & AnhoPos & " AND mes = 1"
        conn.Execute StrSql
        
        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, '" & cbx_cuota_incorporacion.Text & "' as MONTO_TOTAL, MONTO_EXEN_HNO, MONTO_EXEN_BCA, MONTO_EXEN_DESC, MONTO_EXEN_CONV, MONTO_EXEN_TIPO_PAGO, '" & cbx_cuota_incorporacion.Text & "' 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 = '10' "
        conn.Execute (StrSql)
        
        'Comprobar si existe fnza_mensualidad
        StrSql = "select count(*) as cuantos from fnza_mensualidad where run_apo = '" & rut_apo & "' and mes = 1 and agno = " & AnhoPos
        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+" & cbx_cuota_incorporacion.Text & " 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' and agno = " & AnhoPos & ") as MONTO_MENS," & _
                "    ABONO_MENS , FECH_PAGO, ESTADO_MENS, " & _
                "    '1' as MES,AGNO " & _
                " from fnza_mensualidad where agno=" & AnhoPos & " and run_apo = '" & rut_apo & "' and mes = 10"
            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"


    ' 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
    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, ",", ".") & _
                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='esco'"
    conn.Execute (StrSql)
    End If

    ''' Modifico valor matricula al seleccionado por cordinador
    StrSql = "UPDATE fnza_detalle_mensualidad SET monto_total = " & cb_valor_mat.Text & ",monto_tot_cuota = " & cb_valor_mat.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_mat.Text & ",'" & Nom_com_usu_ses & "')"
    conn.Execute (StrSql)
    
    
    '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")
                x100_incorporacion = Rst("porciento_cuota_incorporacion")
                
                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 )" & _
                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='ct00'"
                    conn.Execute (StrSql)
                End If
                ' mensualidad
                If x100_mensualidad > 0 Then
                    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)
                    
                    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
                    
                End If
                'incorporacion
                If x100_incorporacion > 0 Then
                    StrSql = "update fnza_detalle_mensualidad set " & _
                            " MONTO_EXEN_DESC = MONTO_EXEN_DESC + ((MONTO_TOT_CUOTA*" & x100_incorporacion & "/100))," & _
                            " MONTO_TOT_CUOTA = MONTO_TOTAL - ( MONTO_EXEN_DESC ) " & _
                            " where run_alu = '" & Rut_ALu & "' and agno = '" & AnhoPos & "' and concepto='inco'"
                    conn.Execute (StrSql)
                End If
                
                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)
            End If
        End If
    Next I
    
    ' 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
'--------------------------------------------------------------------------------------------------
    MsgBox "El proceso de matricula fue realizado exitosamente", vbInformation, "Mensaje de GesCol"
    
     '''' 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
    
Else
    MsgBox "El alumno ya se encuentra matriculado. NO es posible matricularlo nuevamente.", vbExclamation + vbOKOnly, "Mensaje de GesCol"
End If

Busqueda = 1
Me.Txt_rut_alu_mat = ""
Me.Txt_Dig_alu_mat = ""
Me.DTP_Fec_Mat.Value = Date
Me.Txt_nom_alu_mat.Text = ""
Me.Txt_jor_alu.Text = ""
Me.Txt_num_Mat.Text = ""
Me.txt_fec_pos.Text = ""
Me.cmb_AnhoPos.Text = ""
Me.Cmb_Jor_mat.Text = ""
Me.cmb_tipo_pago.Text = ""
Me.cmb_tp_incorporacion.Text = ""
Me.cmb_tp_mensualidad.Text = ""

Me.lst_descuentos_nombre.Clear
Me.lst_descuentos_conflicto.Clear
Me.frm_Descuentos.Visible = False 'esconde frame descuentos


'Me.Label25.Caption = "Seleccione un registrtro ..."
    Exit Sub
SaltoError:

    If Err.Number = (vbObjectError + 800) Then
        MsgBox Err.Description, vbCritical, "ALERTA DE VALIDACIÓN"
        Exit Sub
    End If
    
    MsgBox Err.Number & vbCrLf & vbCrLf & Err.Description & vbCrLf & vbCrLf & Err.Source, vbExclamation, "ALERTA DE ANOMALÍA"
    
    Resume
End Sub



Private Sub Btn_Can_Mat_Click()
Unload Me
End Sub

Private Sub btn_car_Click()

If Me.cmb_ano.Text <> "" And Me.cmb_jor_alu.Text <> "" And Me.cmb_mod <> "" And Me.cmb_niv <> "" Then
    Me.Txt_Alu.Text = 0
    Me.grd_alu.Clear
    Me.grd_alu.FormatString = "Apellido paterno     | Apellido materno     | Nombres                                 | R.U.N              | Fecha Matricula"
    CodModalidad = DevuelveCampo("codigos_ensenanza", "des_ens", "cod_ens", "des_ens = '" & Me.cmb_mod.Text & "'", conn)
    Ngrado = Me.cmb_niv.Text
    jornada = DevuelveCampo("jornadas", "", "cod_jor", "des_jor = '" & Me.cmb_jor_alu.Text & "'", conn)
    Set rssin = New ADODB.Recordset
    rssin.CursorLocation = adUseClient
    a = "select p.ape_pat_alu, p.ape_mat_alu, p.nom_alu, p.ci_alu,m.cod_jor,m.fec_mat " & _
    "from  postulantes p, matriculas m " & _
    "LEFT OUTER JOIN alu_x_cur ax ON m.ci_alu=ax.ci_alu AND ax.activo_alu='SI' AND ax.agno=m.anno_mat AND ax.agno = " & val(Me.cmb_ano) & " " & _
    "WHERE p.ci_alu = m.ci_alu and m.activo_alu = 'SI' and m.cod_ens = '" & CodModalidad & " ' and m.num_gra = '" & Ngrado & "' and m.cod_jor = '" & jornada & "' and m.anno_mat = " & val(Me.cmb_ano) & " AND ISNULL(ax.ci_alu) " & _
    "ORDER BY ape_pat_alu, ape_mat_alu, nom_alu, ci_alu,fec_mat ASC"
    
    rssin.Open a, conn
    c = 1
    Me.grd_alu.Rows = 2
    Me.grd_alu.Enabled = False
    If rssin.RecordCount > 0 Then
        ReDim alusin(rssin.RecordCount, 4)
        While Not rssin.EOF
                Me.grd_alu.Row = c
                Me.grd_alu.Col = 0
                Me.grd_alu.Text = rssin("ape_pat_alu")
                Me.grd_alu.Col = 1
                Me.grd_alu.Text = rssin("ape_mat_alu")
                Me.grd_alu.Col = 2
                Me.grd_alu.Text = rssin("nom_alu")
                Me.grd_alu.Col = 3
                Me.grd_alu.Text = rssin("ci_alu")
                Me.grd_alu.Col = 4
                Me.grd_alu.Text = rssin("fec_mat")
                alusin(c, 0) = rssin("ape_pat_alu")
                alusin(c, 1) = rssin("ape_mat_alu")
                alusin(c, 2) = rssin("nom_alu")
                alusin(c, 3) = rssin("ci_alu")
                alusin(c, 4) = rssin("fec_mat")
                c = c + 1

              Me.grd_alu.Rows = Me.grd_alu.Rows + 1
                Me.grd_alu.Enabled = True
            rssin.MoveNext
        Wend
        Me.Txt_Alu.Text = c - 1
      If Me.grd_alu.Rows > 2 Then
            Me.grd_alu.RemoveItem (Me.grd_alu.Rows)
       End If
    End If
    rssin.Close
    Set rssin = Nothing
Else
    MsgBox ("Faltan opciones por seleccionar")
End If
End Sub




Private Sub Btn_show_Conducta_Click()
Frame_Mat_Ok_Doc.Visible = False
Frame_Mat_Ok_Conducta.Visible = True
End Sub

Private Sub Btn_show_Doc_Click()
Frame_Mat_Ok_Doc.Visible = True
Cmb_Docs_REc.Visible = True
Frame_Mat_Ok_Conducta.Visible = False
End Sub

Private Sub btn_ver_descuentos_Click()
    Me.frm_Descuentos.Visible = True
End Sub

Private Sub btn_volver_Click()
    Me.frm_Descuentos.Visible = False
End Sub



Private Sub cbx_descuentos_Click()
    If Me.cbx_descuentos.Text = "SI" Then
        Me.btn_ver_descuentos.Visible = True
    ElseIf Me.cbx_descuentos.Text = "NO" Then
        Me.btn_ver_descuentos.Visible = False
    End If
End Sub

Private Sub Chk_Doc_1_Click()
If Me.Chk_Doc_1.Value = 0 Or Me.Chk_Doc_2.Value = 0 Or Me.Chk_Doc_3.Value = 0 Or Me.Chk_Doc_4.Value = 0 Then
    Me.Cmb_Docs_REc.Enabled = False
Else
    Me.Cmb_Docs_REc.Enabled = True
End If

End Sub

Private Sub Chk_Doc_2_Click()
If Me.Chk_Doc_1.Value = 0 Or Me.Chk_Doc_2.Value = 0 Or Me.Chk_Doc_3.Value = 0 Or Me.Chk_Doc_4.Value = 0 Then
    Me.Cmb_Docs_REc.Enabled = False
Else
    Me.Cmb_Docs_REc.Enabled = True
End If

End Sub

Private Sub Chk_Doc_3_Click()
If Me.Chk_Doc_1.Value = 0 Or Me.Chk_Doc_2.Value = 0 Or Me.Chk_Doc_3.Value = 0 Or Me.Chk_Doc_4.Value = 0 Then
    Me.Cmb_Docs_REc.Enabled = False
Else
    Me.Cmb_Docs_REc.Enabled = True
End If

End Sub

Private Sub Chk_Doc_4_Click()
If Me.Chk_Doc_1.Value = 0 Or Me.Chk_Doc_2.Value = 0 Or Me.Chk_Doc_3.Value = 0 Or Me.Chk_Doc_4.Value = 0 Then
    Me.Cmb_Docs_REc.Enabled = False
Else
    Me.Cmb_Docs_REc.Enabled = True
End If
End Sub



Private Sub cmb_ano_Click()
Call limpia_form_proc_cursos1
End Sub

Private Sub Cmb_Docs_REc_Click()
Rut_ALu = Me.Txt_rut_alu_mat & "-" & Me.Txt_Dig_alu_mat
a = "UPDATE POSTULANTES Set V_CER_NAC = " & Chk_Doc_1 & ", V_INF_NOT_PAR = " & Chk_Doc_2 & ", V_CER_EST_ULT_CUR = " & Chk_Doc_3 & ", V_FOTOS = " & Chk_Doc_4 & " where CI_ALU=" & "'" & Rut_ALu & "'"
conn.Execute a
MsgBox ("El o los documentos fueron recibidos exitosamente")
a = DocsOk(Me.Txt_rut_alu_mat & "-" & Me.Txt_Dig_alu_mat)
If a = True Then
    Btn_Ace_Mat.Enabled = True
    Frame_Mat_OK.Visible = False
    Form_proc_Cursos.Height = 3650
    Form_proc_Cursos.Width = 7230
End If

End Sub





Private Sub cmb_jor_alu_Click()
Dim AF As String
CodModalidad = DevuelveCampo("codigos_ensenanza", "des_ens", "cod_ens", "des_ens = '" & Me.cmb_mod.Text & "'", conn)
Ngrado = Me.cmb_niv.Text
jornada = Me.cmb_jor_alu.Text
AF = "where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "'"
Call btn_car_Click
End Sub

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

Private Sub Cmb_Jor_mat_LostFocus()
If Cmb_Jor_mat <> "" Then Joralu = DevuelveCampo("jornadas", "", "cod_jor", "des_jor = '" & Me.cmb_jor_alu.Text & "'", conn)
End Sub






Private Sub cmb_mod_Click()
Dim t As Integer
Call limpia_form_proc_cursos1
If Len(Me.cmb_mod.Text) <> 0 Then
 nivel = DevuelveCampo("codigos_ensenanza", "des_ens", "num_gra_max", "des_ens = " & "'" & Me.cmb_mod.Text & "'", conn)
 Me.cmb_niv.Enabled = True
 Me.cmb_niv.Clear
 For t = 1 To val(nivel)
    Me.cmb_niv.AddItem t
 Next t
End If
End Sub

Private Sub cmb_mod_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Len(Me.cmb_mod.Text) <> 0 Then
    Me.cmb_niv.Enabled = True
    Me.cmb_niv.SetFocus
End If
End Sub

Private Sub cmb_niv_Click()
Call limpia_form_proc_cursos1
End Sub

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

Private Sub com_des_Click()
Dim t, iniCiclo, finCiclo As Integer
Dim rutalumno, StrSql As String
Dim Beca, annno As String
Dim CodJornada As String
Dim fechas As Date
Dim fechamat As String
Dim accion_realizada As String
Dim log As Boolean

If MsgBox("¿ Está seguro que Desea Desmatricular?", vbYesNo + vbQuestion) = vbYes Then
    If Me.Txt_jor <> "" Then
        CodModalidad = DevuelveCampo("codigos_ensenanza", "des_ens", "cod_ens", "des_ens = '" & Me.cmb_mod.Text & "'", conn)
        Ngrado = Me.cmb_niv.Text
        If Me.grd_alu.Row > Me.grd_alu.RowSel Then
            iniCiclo = Me.grd_alu.Row
            finCiclo = Me.grd_alu.RowSel
        ElseIf Me.grd_alu.RowSel > Me.grd_alu.Row Then
            iniCiclo = Me.grd_alu.RowSel
            finCiclo = Me.grd_alu.Row
        Else
            iniCiclo = Me.grd_alu.Row
            finCiclo = Me.grd_alu.RowSel
        End If
        
        For t = iniCiclo To finCiclo Step -1
            'RutAlumno = alusin(t, 3)
            rutalumno = Me.grd_alu.TextMatrix(t, 3)
            fechamat = Format(Me.grd_alu.TextMatrix(t, 4), "yyyy-mm-dd")
            If t <= 2 And Me.grd_alu.Rows = 2 Then
                Me.grd_alu.Clear
                Me.grd_alu.FormatString = "Apellido paterno     | Apellido materno     | Nombres                                 | R.U.N              | Fecha Matricula"
            Else
                Me.grd_alu.RemoveItem (t)
            End If
            StrSql = "DELETE FROM matriculas where ci_alu ='" & rutalumno & "' and anno_mat=" & Trim(cmb_ano.Text) & " and activo_alu='SI' and fec_mat='" & Format(fechamat, "yyyy-mm-dd") & "';"
            conn.Execute StrSql
            StrSql = "UPDATE  postulantes SET matriculado_alu ='0'  where ci_alu='" & rutalumno & "'"
            conn.Execute StrSql
            
            'Insertar log
                accion_realizada = "La matricula del alumno para el periodo " & cmb_ano.Text _
                                 & " fue anulada"
                log = Inserta_Vitacora_Alumno(CStr(rutalumno), accion_realizada)
            'Fin de log
            
         ' If ExistReg("becas", "run_alu= '" & RutSinCurso & "' and tipo_beca = '" & beca & "' and agno_escolar = '" & annno & "'  and fecha = '" & fechas & "'", conn) Then
          Set rs = New ADODB.Recordset
          rs.CursorLocation = adUseClient
          rs.Open "select * from becas where run_alu= '" & rutalumno & "' and agno =" & val(Me.cmb_ano), conn
          ' Si encontró registro en tabla de becados
          If rs.RecordCount > 0 Then
              conn.Execute "INSERT INTO BECAS_REASIGNAR(tipo_beca, agno_escolar,monto_excencion, fecha, run_alu) values('" & rs!tipo_beca & "' , " & rs!agno & " ,  " & rs!monto_excencion & " , '" & Format(Date, "yyyy-mm-dd") & "' , '" & rutalumno & "')"
              MsgBox "Alumno Selecionado Tenia Beca Se guardara para ser Reasignada", vbCritical, "ALERTA DE VALIDACIÓN"
              StrSql = "DELETE FROM BECAS where RUN_ALU ='" & rutalumno & "' and agno =" & val(Me.cmb_ano)
              conn.Execute StrSql
          Else
              'MsgBox "Alumno Selecionado no Tiene Beca", vbCritical, "ALERTA DE VALIDACIÓN"
          End If
          
          Set rs = New ADODB.Recordset
          rs.CursorLocation = adUseClient
          rs.Open "select fm.run_apo, fd.folio_dtll, fd.mes, fd.monto_tot_cuota from fnza_detalle_mensualidad fd, fnza_mensualidad fm where fd.folio_mens=fm.folio_mens and fd.run_alu= '" & rutalumno & "' and fd.agno = " & val(Me.cmb_ano) & " and ucase(fd.concepto)='CT00' order by fd.mes asc limit 1", conn
          'Si Encontró Cuota 00
          If rs.RecordCount > 0 Then '
            ' Si Pagó cuota 00
            If Not dtll_impago(rs!folio_dtll, conn) Then
                MsgBox "Alumno Desmatriculado Canceló Cuota 00. Se debe realizar una devolución de dinero", vbInformation, "ATENCIÓN"
            End If
          End If
            ' desmatricular en tablas de finanzas
            Call RecalculaCuota_Alu_Retiro(rutalumno, CDate(fechamat), conn, val(cmb_ano.Text))
            
          'End If
          rs.Close: Set rs = Nothing
        
        Next t
        btn_car_Click
    Else
        MsgBox "Alumno Selecionado Tiene Beca", vbCritical, "ALERTA DE VALIDACIÓN"
    End If
End If
End Sub

Private Sub com_salir_Click()
    Unload Me
End Sub

Private Sub Combo1_Change()

End Sub

Private Sub Command1_Click()

    For I = 0 To Me.lst_descuentos_nombre.ListCount - 1
    
        If Me.lst_descuentos_nombre.Selected(I) = True Then
            cad = cad & List1.List(I) & ", "
        End If
    
    Next I

End Sub

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

Private Sub Form_Load()
Dim cole As String

Me.Top = 1000
Me.Left = 2000

Me.DTP_Fec_Mat.Value = Date
Busqueda = 1
'Form_proc_Cursos.KeyPreview = True

Set rs = New ADODB.Recordset
Set rsSinCurso = New ADODB.Recordset
Set rsConCurso = New ADODB.Recordset


' 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



'Agrego cuota de incorporación
cbx_descuentos.Enabled = True
cbx_cuota_incorporacion.Clear
cbx_cuota_incorporacion.Text = "NO"
cbx_cuota_incorporacion.AddItem "NO"
cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
If cole = "HUE001" Then
    cbx_cuota_incorporacion.AddItem 271000
    cbx_cuota_incorporacion.AddItem 170000
    cbx_cuota_incorporacion.AddItem 250000
    cbx_cuota_incorporacion.AddItem 150000
    cbx_cuota_incorporacion.AddItem 125000
    cbx_cuota_incorporacion.AddItem 75000
Else
    cbx_cuota_incorporacion.AddItem 208000
    cbx_cuota_incorporacion.AddItem 150000
    cbx_cuota_incorporacion.AddItem 120000
    cbx_cuota_incorporacion.AddItem 90000
    cbx_cuota_incorporacion.AddItem 190000
    cbx_cuota_incorporacion.AddItem 130000
    cbx_cuota_incorporacion.AddItem 100000
    cbx_cuota_incorporacion.AddItem 70000
End If


If ManTab = "mat" Then
    'Form_proc_Cursos.Height = 3650 '3360
    'Form_proc_Cursos.Width = 7230
    'Call Form_main.HideFRameProcCursos
    'Call llenacombo(Form_proc_Cursos.Cmb_Jor_mat, "jornadas", "des_jor", "order by des_jor", conn)

    'Me.cmb_tipo_pago.AddItem "Cuponera"
    ' Matricula
    Me.cmb_tipo_pago.AddItem "Cheques"
    'Me.cmb_tipo_pago.AddItem "Efectivo"
    Me.cmb_tipo_pago.AddItem "Credito"
    Me.cmb_tipo_pago.AddItem "Debito"
    Me.cmb_tipo_pago.AddItem "Transferencia"
    
    ' Incorporacion
    Me.cmb_tp_incorporacion.AddItem "Cheques"
    'Me.cmb_tp_incorporacion.AddItem "Efectivo"
    Me.cmb_tp_incorporacion.AddItem "Credito"
    Me.cmb_tp_incorporacion.AddItem "Debito"
    Me.cmb_tp_incorporacion.AddItem "Transferencia"
    
    ' Mensualidad
    Me.cmb_tp_mensualidad.AddItem "Cheques"
    Me.cmb_tp_mensualidad.AddItem "Cuponera"
    'Me.cmb_tp_mensualidad.AddItem "Efectivo"
    Me.cmb_tp_mensualidad.AddItem "Credito"
    Me.cmb_tp_mensualidad.AddItem "Debito"
    Me.cmb_tp_mensualidad.AddItem "Transferencia"
    Me.cmb_tp_mensualidad.AddItem "Pagare"

    
 
         
        
    'cheque
'contado
'PAT
'Credito
'Debito
'Transferencia
 
    cmb_AnhoPos.AddItem Anno
    cmb_AnhoPos.AddItem Anno + 1
    
    'Form_proc_Cursos.Frame_Mat.Visible = True
    'Form_proc_Cursos.DTP_Fec_Mat.Enabled = False
    'Form_proc_Cursos.Cmb_Jor_mat.Enabled = False
    'CentrarForma Me
    Form_proc_Cursos.Hide

If Form_NFicha_PRoceso.proceso <> 0 And Form_NFicha_PRoceso.run_actual <> "" Then

Dim rsmat As ADODB.Recordset
Set rsmat = New ADODB.Recordset
rsmat.Open "Select ps.*, p.APE_PAT_ALU, p.APE_MAT_ALU, p.NOM_ALU, p.CI_ALU, p.COD_ENS, p.NUM_GRA " _
& " from postulaciones ps, postulantes p where p.ci_alu = '" & Form_NFicha_PRoceso.run_actual & "' and ps.ci_alu = p.ci_alu", conn

Indi = 0
Busqueda = 0
Apellido1 = rsmat("APE_PAT_ALU")
Apellido2 = rsmat("APE_MAT_ALU")
nombre = rsmat("NOM_ALU")
rut$ = rsmat("CI_ALU")

jornada = DevuelveCampo("jornadas", "", "des_jor", "cod_jor = '" & rsmat("COD_JOR") & "'", conn)
Cod_Ens = rsmat("COD_ENS")
Num_Gra = rsmat("NUM_GRA")

Fecpos = rsmat("FEC_POS")
AnhoPostu = rsmat("ANNO_POS_ALU")
modalidad = DevuelveCampo("codigos_ensenanza", "", "des_ens", "cod_ens ='" & Cod_Ens & "'", conn)

Me.Txt_rut_alu_mat.Text = separarut(rut$)
Me.Txt_Dig_alu_mat.Text = separadigito(rut$)
Me.Txt_nom_alu_mat.Text = Trim(Apellido1) + " " + Trim(Apellido2) + " " + Trim(nombre)
Me.txt_fec_pos.Text = Fecpos
Me.cmb_AnhoPos.Text = AnhoPostu
Me.txt_mod_nivel.Text = Num_Gra
Me.txt_mod.Text = modalidad
Txt_jor_alu = jornada

    If jornada <> "" Then
        Cmb_Jor_mat.Text = jornada
    End If

Txt_nom_alu_mat.Enabled = False
Txt_rut_alu_mat.Enabled = False
Txt_Dig_alu_mat.Enabled = False
Lst_nom_alu_mat.Visible = False
DTP_Fec_Mat.Enabled = True
Cmb_Jor_mat.Enabled = True
Txt_num_Mat.Enabled = False

Btn_Ace_Mat.Enabled = True
NumMat = DevuelveCampo("matriculas", "", "max(num_mat)", "cod_ens ='" & Cod_Ens & "'", conn)
Txt_num_Mat = FillconCero(Trim(str(val(NumMat) + 1)), 5)

a = MatriculaOK(rsmat("CI_ALU"))
If a = False Then Exit Sub

   ' Valor matricula
    'StrSql = "SELECT CONCAT(cod_ens,num_gra) AS curso FROM matriculas WHERE anno_mat = 2022 AND ci_alu = '" & Rut_ALu & "'"
'    curso_mat = DevuelveCampo("postulantes", "", "CONCAT(cod_ens,num_gra) AS curso", "ci_alu = '" & rut$ & "'", conn)
'    valor_mat_nue = DevuelveCampo("fnza_descuento", "", "matricula_nuevos", "curso = '" & curso_mat & "' and agno = " & AnhoPostu, conn)
'    valor_mat_ant = DevuelveCampo("fnza_descuento", "", "matricula", "curso = '" & curso_mat & "' and agno = " & AnhoPostu, conn)
    cb_valor_mat.Clear
    If AnhoPostu = 2024 Then
        cb_valor_mat.AddItem 298000
        cb_valor_mat.AddItem 230500
    Else
        'cb_valor_mat.AddItem 217000
        'cb_valor_mat.AddItem 190000
        'cb_valor_mat.AddItem 280000
        cb_valor_mat.AddItem 298000
    End If
    
    cb_valor_mat.Text = ""  'valor_mat_nue
    ' fin
    
rsmat.Close
End If

ElseIf ManTab = "proc_desmat" Then
    Me.cmb_ano.AddItem val(Anno)
    Me.cmb_ano.AddItem val(Anno) + 1
    Form_proc_Cursos.Height = 7415
    Form_proc_Cursos.Width = 9215
    Call Form_main.HideFRameProcCursos
    Form_proc_Cursos.fra_des_alu.Left = 120
    Form_proc_Cursos.fra_des_alu.Top = 120
    Form_proc_Cursos.fra_des_alu.Height = 7415
    Form_proc_Cursos.fra_des_alu.Width = 9215
    Form_proc_Cursos.fra_des_alu.Visible = True
    Call LlenaCombo(Form_proc_Cursos.cmb_mod, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
    Call LlenaCombo(Form_proc_Cursos.cmb_jor_alu, "jornadas", "des_jor", "order by des_jor", conn)
        CentrarForma Me
        Form_proc_Cursos.Show
    Me.Txt_Alu.Locked = True
    Me.cmb_niv.Enabled = False
    Me.grd_alu.Enabled = False
    Me.Txt_Alu.Enabled = False
End If
End Sub

'Private Sub Form_Unload(Cancel As Integer)
'If ManTab = "mat" Then
'    FormFechas.Enabled = True
'Else
'    Call menuhabilitado(True)
'End If
'End Sub

Private Sub Form_Unload(Cancel As Integer)
    If Form_NFicha_PRoceso.proceso = 1 Then
    Form_NFicha_PRoceso.Enabled = True
    End If
End Sub


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

End Sub

Private Sub lst_B_descuentos_Click()

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 Lst_nom_alu_mat_DblClick()
Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim inco As Long
var_sql = "SELECT cuota_incorporacion as i FROM fnza_descuento where agno = " & cmb_AnhoPos & " limit 1"
objRS.Open var_sql, conn

If objRS("i") <> "" Then
inco = objRS("i")
Else
    MsgBox ("No hay valores definidos para el año seleccionado")
    Exit Sub
End If

objRS.Close
cbx_cuota_incorporacion.Clear
cbx_cuota_incorporacion.Text = "NO"
cbx_cuota_incorporacion.AddItem "NO"

cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
If cole = "HUE001" Then
    cbx_cuota_incorporacion.AddItem 271000
    cbx_cuota_incorporacion.AddItem 170000
    cbx_cuota_incorporacion.AddItem 250000
    cbx_cuota_incorporacion.AddItem 150000
    cbx_cuota_incorporacion.AddItem 125000
    cbx_cuota_incorporacion.AddItem 75000
Else
    cbx_cuota_incorporacion.AddItem 208000
    cbx_cuota_incorporacion.AddItem 150000
    cbx_cuota_incorporacion.AddItem 120000
    cbx_cuota_incorporacion.AddItem 90000
    cbx_cuota_incorporacion.AddItem 190000
    cbx_cuota_incorporacion.AddItem 130000
    cbx_cuota_incorporacion.AddItem 100000
    cbx_cuota_incorporacion.AddItem 70000
End If



'cbx_cuota_incorporacion.AddItem inco
'cbx_cuota_incorporacion.AddItem 150000
'cbx_cuota_incorporacion.AddItem (inco / 2)
'cbx_cuota_incorporacion.AddItem 75000

Indi = 0
Busqueda = 0
Apellido1 = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 0)
Apellido2 = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 1)
nombre = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 2)
rut$ = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 3)
jornada = DevuelveCampo("jornadas", "", "des_jor", "cod_jor = '" & alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 4) & "'", conn)
Cod_Ens = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 5)
Num_Gra = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 6)
Fecpos = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 7)
AnhoPostu = alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 8)
modalidad = DevuelveCampo("codigos_ensenanza", "", "des_ens", "cod_ens ='" & Cod_Ens & "'", conn)

 ' Valor matricula
 'StrSql = "SELECT CONCAT(cod_ens,num_gra) AS curso FROM matriculas WHERE anno_mat = 2022 AND ci_alu = '" & Rut_ALu & "'"
 curso_mat = DevuelveCampo("postulantes", "", "CONCAT(cod_ens,num_gra) AS curso", "ci_alu = '" & rut$ & "'", conn)
 valor_mat_nue = DevuelveCampo("fnza_descuento", "", "matricula_nuevos", "curso = '" & curso_mat & "' and agno = " & AnhoPostu, conn)
 valor_mat_ant = DevuelveCampo("fnza_descuento", "", "matricula", "curso = '" & curso_mat & "' and agno = " & AnhoPostu, conn)
 ' cb_valor_mat.AddItem valor_mat_nue
 cb_valor_mat.AddItem valor_mat_ant
 cb_valor_mat.Text = ""  'valor_mat_nue
 ' fin



Me.Txt_rut_alu_mat.Text = separarut(rut$)
Me.Txt_Dig_alu_mat.Text = separadigito(rut$)
Me.Txt_nom_alu_mat.Text = Trim(Apellido1) + " " + Trim(Apellido2) + " " + Trim(nombre)
Me.txt_fec_pos.Text = Fecpos
Me.cmb_AnhoPos.Text = AnhoPostu
Me.txt_mod_nivel.Text = Num_Gra
Me.txt_mod.Text = modalidad
Txt_jor_alu = jornada
If jornada <> "" Then
    Cmb_Jor_mat.Text = jornada
End If
Txt_nom_alu_mat.Enabled = False
Txt_rut_alu_mat.Enabled = False
Txt_Dig_alu_mat.Enabled = False
Lst_nom_alu_mat.Visible = False
DTP_Fec_Mat.Enabled = True
Cmb_Jor_mat.Enabled = True
Txt_num_Mat.Enabled = False

cbx_descuentos.Enabled = True

' 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

' Verifica si existen matriculas para el alumno
    cuantos = 0
    StrSql = "select count(*) as cuantos from matriculas where ci_alu = '" & rut$ & "'"
    Set Rst = conn.Execute(StrSql)
    Do While Not Rst.EOF
        cuantos = Rst("cuantos")
        Rst.MoveNext
    Loop
    If cuantos = 0 Then
       ' Me.cbx_cuota_incorporacion.Text = "SI"
    End If
' fin verifica


Btn_Ace_Mat.Enabled = True
NumMat = DevuelveCampo("matriculas", "", "max(num_mat)", "cod_ens ='" & Cod_Ens & "'", conn)
Txt_num_Mat = FillconCero(Trim(str(val(NumMat) + 1)), 5)

a = MatriculaOK(alumnossincurso(Me.Lst_nom_alu_mat.ListIndex, 3))
If a = False Then Exit Sub

End Sub

'Private Sub Lst_nom_alu_mat_GotFocus()
'Me.Btn_Ace_Mat.Enabled = False
'End Sub
Private Sub Lst_nom_alu_mat_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call Lst_nom_alu_mat_DblClick


End Sub

Private Sub Lst_nom_alu_mat_LostFocus()
Me.Btn_Ace_Mat.Enabled = True
End Sub

Private Sub Txt_nom_alu_mat_Change()
'If Trim(Txt_rut_alu_mat) = "" Then
'    Me.Btn_Ace_Mat.Enabled = False
'Else
'    Me.Btn_Ace_Mat.Enabled = True
'End If

If Busqueda = 1 Then
  rs.CursorLocation = adUseClient

Lst_nom_alu_mat.Clear
If Not ((Chr(KeyAscii) >= "A" And Chr(KeyAscii) <= "Z") Or (Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z")) Then
    KeyAscii = 0
    If Me.Txt_nom_alu_mat.Text <> "" Then
      Criterio = "'" + Me.Txt_nom_alu_mat.Text + Consulta + "%'"
      rs.Open "SELECT ape_pat_alu, ape_mat_alu, nom_alu, P.ci_alu, VIII_SIT_FIN_ALU, PS.cod_jor, PS.fec_pos, PS.anno_pos_alu, cod_ens, num_gra FROM postulantes P, POSTULACIONES PS where P.CI_ALU = PS.CI_ALU AND ape_pat_alu like " & Criterio & " AND VIII_SIT_FIN_ALU ='A' and MATRICULADO_ALU <> '1' order by ape_pat_alu, ape_mat_alu", conn
      'rs.FindFirst "des_pre like " + Criterio
            'rs.MoveFirst
        Lst_nom_alu_mat.Visible = False
        'Me.Txt_cod_mod.Text = ""
        If rs.RecordCount > 0 Then
            Indi = 0
            ReDim alumnossincurso(rs.RecordCount, 9)
            c = 0
            While Not rs.EOF
                Lst_nom_alu_mat.AddItem rs("ape_pat_alu") + " " + rs("ape_mat_alu") + " " + rs("nom_alu")
                alumnossincurso(c, 0) = rs("ape_pat_alu")
                alumnossincurso(c, 1) = rs("ape_mat_alu")
                alumnossincurso(c, 2) = rs("nom_alu")
                alumnossincurso(c, 3) = rs("ci_alu")
                alumnossincurso(c, 4) = rs("cod_jor")
                alumnossincurso(c, 5) = rs("cod_ens")
                alumnossincurso(c, 6) = rs("num_gra")
                alumnossincurso(c, 7) = rs("fec_pos")
                alumnossincurso(c, 8) = rs("anno_pos_alu")
                Lst_nom_alu_mat.Visible = True
                rs.MoveNext
                c = c + 1
            Wend
        Else
            
            Indi = 0
        End If
        rs.Close
    Else
    Lst_nom_alu_mat.Visible = False
    Me.Txt_nom_alu_mat.Enabled = True
    Me.Txt_rut_alu_mat.Text = ""
    Me.Txt_Dig_alu_mat.Enabled = True
    Me.Txt_Dig_alu_mat.Text = ""

    End If
    
End If
End If

End Sub

Private Sub Txt_nom_alu_mat_KeyPress(KeyAscii As Integer)

'Busqueda = 1
If KeyAscii = 27 Then
    Txt_nom_alu_mat.Text = ""
    Lst_nom_alu_mat.Visible = False
    KeyAscii = 0
ElseIf KeyAscii = 13 And Len(Trim(Me.Txt_nom_alu_mat.Text)) <> 0 Then
        'Call Btn_Ace_res_pos_Click
ElseIf ((Chr(KeyAscii) >= "A" And Chr(KeyAscii) <= "Z") Or (Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z")) Then Exit Sub
ElseIf (Chr(KeyAscii) >= "0" And Chr(KeyAscii) <= "9") Then Exit Sub
ElseIf KeyAscii = 8 Then Exit Sub
ElseIf KeyAscii = 32 Then Exit Sub
ElseIf Me.Txt_nom_alu_mat.Text = "" Then
        If KeyAscii = 37 Then Exit Sub
End If
    KeyAscii = 0: Exit Sub

End Sub
Public Function MatriculaOK(ci_alu As String) As Boolean
MatriculaOK = True 'Inicializa por defecto Matrícula
'revisa Si Es un alumno matriculado
If ExistReg("MATRICULAS", "CI_ALU ='" & ci_alu & "' AND ACTIVO_ALU ='SI'", conn) Then
  'Si Es un alumno matriculado hace lo siguiente:
    'revisa Si existe orden para cancelar la matricula
    If ExistReg("matriculas", "CI_ALU ='" & ci_alu & "' AND CANCELADO", conn) Then
        MatriculaOK = False
        Form_proc_Cursos.Btn_show_Conducta.Enabled = True
        a$ = "ACTIVO_ALU ='si' AND CANCELADO =1 AND CI_ALU ='" & ci_alu & "'"
        Txt_obs = DevuelveCampo("MATRICULAS", "", "OBS_CANCELADO", a$, conn)
               
    Else
        MatriculaOK = True
    End If
    'FIN revisa Si existe orden para cancelar la matricula
    a = DocsOk(ci_alu) 'revisa Si faltan documentos
'FIN revisa Si Es un alumno matriculado
Else
'Si Es un Postulante
a = DocsOk(ci_alu) 'revisa Si faltan documentos
End If



'If MatriculaOK = False Or a = False Then
'            MatriculaOK = False
            Form_proc_Cursos.Height = 7455
            Form_proc_Cursos.Width = 7230
            Form_proc_Cursos.Frame_Mat_OK.Left = 120
            Form_proc_Cursos.Frame_Mat_OK.Top = 3000
            Form_proc_Cursos.Frame_Mat_OK.Height = 3970
            Form_proc_Cursos.Frame_Mat_OK.Width = 6855
            Form_proc_Cursos.Frame_Mat_OK.Visible = True
            CentrarForma Me

'End If



End Function

Public Function DocsOk(Rut_ALu As String) As Boolean
rs.CursorLocation = adUseClient
    Sql = "SELECT V_CER_NAC, V_INF_NOT_PAR, V_CER_EST_ULT_CUR, V_FOTOS, VIII_SIT_FIN_ALU FROM POSTULANTES P, POSTULACIONES PS where P.CI_ALU = PS.CI_ALU AND PS.CI_ALU ='" & Rut_ALu & "' AND VIII_SIT_FIN_ALU ='A' ORDER BY FEC_POS DESC"
    rs.Open Sql, conn, adOpenKeyset
    
    If rs.RecordCount > 0 Then
        Form_proc_Cursos.Chk_Doc_1.Value = rs(0)
        Form_proc_Cursos.Chk_Doc_2.Value = rs(1)
        Form_proc_Cursos.Chk_Doc_3.Value = rs(2)
        Form_proc_Cursos.Chk_Doc_4.Value = rs(3)
   
        If rs(0) = 1 Then Form_proc_Cursos.Chk_Doc_1.Enabled = False
        If rs(1) = 1 Then Form_proc_Cursos.Chk_Doc_2.Enabled = False
        If rs(2) = 1 Then Form_proc_Cursos.Chk_Doc_3.Enabled = False
        If rs(3) = 1 Then Form_proc_Cursos.Chk_Doc_4.Enabled = False
   
        If rs(0) = 1 Then
            Form_proc_Cursos.Btn_show_Doc.Enabled = True
            DocsOk = True
        Else
            Form_proc_Cursos.Btn_show_Doc.Enabled = True
            Btn_Ace_Mat.Enabled = False
            DocsOk = False
        End If
        'For i = 0 To 3
        '    If rs(i) = 0 Then
        '        Form_proc_Cursos.Btn_show_Doc.Enabled = True
        '        Btn_Ace_Mat.Enabled = False
        '
        '        DocsOk = False
        '        Exit For
        '    Else
        '        DocsOk = True
        '    End If
        'Next i
    End If
    rs.Close
End Function

Sub limpia_form_proc_cursos1()
    Me.Txt_Alu.Text = 0
    Me.grd_alu.Rows = 2
    Me.grd_alu.Clear
    Me.grd_alu.FormatString = "Apellido paterno     | Apellido materno     | Nombres                                 | R.U.N              | Fecha Matricula"
    Me.cmb_jor_alu.ListIndex = -1
    Me.grd_alu.Enabled = False
End Sub

Private Function verifica_cheques_protestados(ci_alu As String) 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 = '" & cmb_AnhoPos.Text & "'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



