VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form_terminoant 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Término anticipado de Año Escolar"
   ClientHeight    =   3510
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9255
   Icon            =   "Form_terminoant.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3510
   ScaleWidth      =   9255
   Begin VB.Frame fraAsiAlum 
      Height          =   3255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   9015
      Begin VB.ListBox list_rut 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1530
         Left            =   5040
         TabIndex        =   1
         Top             =   840
         Visible         =   0   'False
         Width           =   1455
      End
      Begin VB.ListBox list_nombre 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1530
         Left            =   240
         TabIndex        =   2
         Top             =   840
         Visible         =   0   'False
         Width           =   4575
      End
      Begin VB.CommandButton cmb_aceptar 
         Caption         =   "Termino anticipado"
         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          =   420
         Left            =   120
         TabIndex        =   20
         Top             =   2640
         Width           =   1575
      End
      Begin VB.CommandButton cmb_cancelar 
         Caption         =   "Anular Termino Anticipado"
         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          =   420
         Left            =   3600
         TabIndex        =   19
         Top             =   2640
         Width           =   1575
      End
      Begin VB.Frame Frame_individual 
         Height          =   1335
         Left            =   120
         TabIndex        =   10
         Top             =   1200
         Width           =   5055
         Begin VB.TextBox txt_mod_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            =   1680
            TabIndex        =   15
            Top             =   240
            Width           =   3255
         End
         Begin VB.TextBox txt_letra_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            =   1320
            TabIndex        =   14
            Top             =   240
            Width           =   255
         End
         Begin VB.TextBox txt_estado_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            =   960
            TabIndex        =   13
            Top             =   960
            Width           =   3975
         End
         Begin VB.TextBox txt_apo_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            =   960
            TabIndex        =   12
            Top             =   600
            Width           =   3975
         End
         Begin VB.TextBox txt_nivel_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            =   960
            TabIndex        =   11
            Top             =   240
            Width           =   255
         End
         Begin VB.Label Label17 
            Caption         =   "Estado"
            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        =   18
            Top             =   960
            Width           =   855
         End
         Begin VB.Label Label15 
            Caption         =   "Apoderado"
            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        =   17
            Top             =   600
            Width           =   855
         End
         Begin VB.Label Label14 
            Caption         =   "Curso"
            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        =   16
            Top             =   240
            Width           =   495
         End
      End
      Begin VB.Frame frmFormaLista 
         Height          =   1095
         Left            =   120
         TabIndex        =   4
         Top             =   120
         Width           =   8775
         Begin VB.TextBox txt_nombre 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   120
            TabIndex        =   7
            Top             =   480
            Width           =   4575
         End
         Begin VB.TextBox txt_rut 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   4920
            TabIndex        =   6
            Top             =   480
            Width           =   1455
         End
         Begin VB.CommandButton cmb_cambia 
            Caption         =   "Cambiar Alumno"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   420
            Left            =   6960
            TabIndex        =   5
            Top             =   360
            Width           =   1575
         End
         Begin VB.Label Label1 
            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        =   9
            Top             =   240
            Width           =   735
         End
         Begin VB.Label Label2 
            Caption         =   "Run:"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   4920
            TabIndex        =   8
            Top             =   240
            Width           =   495
         End
      End
      Begin VB.CommandButton cmb_calir 
         Caption         =   "Salir"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   420
         Left            =   7680
         TabIndex        =   3
         Top             =   2640
         Width           =   1215
      End
      Begin VB.Frame Frame1 
         Height          =   1335
         Left            =   5280
         TabIndex        =   21
         Top             =   1200
         Width           =   3615
         Begin VB.TextBox txt_motivo 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   720
            MaxLength       =   20
            TabIndex        =   22
            Top             =   720
            Width           =   2775
         End
         Begin MSComCtl2.DTPicker cb_fecha 
            Height          =   300
            Left            =   1560
            TabIndex        =   23
            Top             =   360
            Width           =   1935
            _ExtentX        =   3413
            _ExtentY        =   529
            _Version        =   393216
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Format          =   146604033
            CurrentDate     =   40869
         End
         Begin VB.Label Label3 
            Caption         =   "Fecha De Retiro"
            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        =   25
            Top             =   360
            Width           =   1575
         End
         Begin VB.Label Label4 
            Caption         =   "Motivo"
            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        =   24
            Top             =   720
            Width           =   615
         End
      End
   End
End
Attribute VB_Name = "Form_terminoant"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Flag_sub As Boolean

Private Sub cmb_aceptar_Click()
    Dim sql As String
    If MsgBox("¿Está seguro de dar término anticipado al alumno tradato?", vbYesNo) = vbYes Then
        sql = "UPDATE alu_x_cur SET razon_termino = '" & Trim(txt_motivo.Text) & "', term_anticipado ='" & Format(cb_fecha.Value, "yyyy-mm-dd") & "' WHERE ci_alu = '" & Trim(txt_rut.Text) & "' AND ucase(activo_alu)='SI' AND fec_cam ='1111-11-11' AND agno = " & Anno
        conn.Execute sql
    End If
End Sub

Private Sub cmb_calir_Click()
    Unload Me
End Sub

Private Sub cmb_cambia_Click()
    Flag_sub = True
    txt_rut.Locked = False
    txt_rut.Text = ""
    txt_nombre.Locked = False
    txt_nombre.Text = ""
    txt_estado_alu.Text = ""
    txt_motivo.Text = ""
    txt_mod_alu.Text = ""
    txt_apo_alu.Text = ""
    txt_nivel_alu.Text = ""
    txt_letra_alu.Text = ""
    cb_fecha.Value = Date
    cmb_aceptar.Enabled = False
    cmb_Cancelar.Enabled = False
    Flag_sub = False
End Sub

Private Sub cmb_cancelar_Click()
    If MsgBox("Esta seguro que desea anular el retiro anticipado del alumno tratado?", vbYesNo) = vbYes Then
        sql = "UPDATE alu_x_cur SET razon_termino = '', term_anticipado ='1111-11-11' WHERE ci_alu = '" & Trim(txt_rut.Text) & "' AND ucase(activo_alu)='SI' AND fec_cam ='1111-11-11' AND agno =" & Anno & ";"
        conn.Execute sql
        txt_motivo.Text = ""
        cb_fecha.Value = Date
    End If
End Sub

Private Sub list_nombre_Click()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    
    txt_nombre.Text = list_nombre.Text
    list_nombre.Visible = False
    list_rut.Visible = False
    RC.Open "SELECT ci_alu FROM postulantes WHERE left(CONCAT(ape_Pat_alu,' ',ape_Mat_alu,' ',nom_alu)," & Len(txt_nombre.Text) & ")='" & txt_nombre.Text & "' ORDER BY ape_pat_alu, ape_mat_alu, nom_alu;", conn
    RC.MoveFirst
    Flag_sub = True
    txt_rut.Text = RC("ci_alu")
    RC.Close
    Flag_sub = False
    txt_rut.Locked = True
    txt_nombre.Locked = True
    llena_info_adicional
End Sub

Private Sub list_rut_Click()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    
    txt_rut.Text = list_rut.Text
    list_nombre.Visible = False
    list_rut.Visible = False
    RC.Open "SELECT CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as nombre_alu FROM postulantes WHERE ci_alu='" & txt_rut.Text & "' ORDER BY ci_alu;", conn
    RC.MoveFirst
    Flag_sub = True
    txt_nombre.Text = RC("nombre_alu")
    RC.Close
    Flag_sub = False
    txt_nombre.Locked = True
    txt_rut.Locked = True
    llena_info_adicional
End Sub

Private Sub txt_nombre_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If txt_nombre.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
    RC.Open "SELECT DISTINCT a.ape_pat_alu, a.ape_mat_alu, a.nom_alu FROM postulantes a, matriculas m WHERE left(CONCAT(a.ape_pat_alu,' ',a.ape_mat_alu,' ',a.nom_alu)," & Len(txt_nombre.Text) & ")='" & txt_nombre.Text & "' AND a.ci_alu=m.ci_alu AND m.activo_alu = 'SI' AND m.anno_mat = date_format(current_date,'%Y') ORDER BY a.ape_pat_alu, a.ape_mat_alu, a.nom_alu;", conn
    list_nombre.Clear
    If RC.RecordCount > 0 Then
        While Not (RC.EOF)
            list_nombre.AddItem RC("ape_pat_alu") & " " & RC("ape_mat_alu") & " " & RC("nom_alu")
            RC.MoveNext
        Wend
        list_nombre.Visible = True
        list_rut.Visible = False
    End If
    RC.Close
End Sub

Private Sub txt_rut_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If txt_rut.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
    
    RC.Open "SELECT DISTINCT a.ci_alu FROM postulantes a, matriculas m WHERE left(a.ci_alu," & Len(txt_rut.Text) & ")='" & txt_rut.Text & "' AND a.ci_alu=m.ci_alu AND m.activo_alu = 'SI' AND m.anno_mat = date_format(current_date,'%Y') ORDER BY a.ci_alu;", conn
    list_rut.Clear
    If RC.RecordCount > 0 Then
        While Not (RC.EOF)
            list_rut.AddItem RC("ci_alu")
            RC.MoveNext
        Wend
        list_nombre.Visible = False
        list_rut.Visible = True
    End If
    RC.Close
End Sub

Private Sub llena_info_adicional()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    cmb_aceptar.Enabled = True
    cmb_Cancelar.Enabled = True
    Indi = 0
    Busqueda = 0
    Busqueapo = 0
    RutApo = devuelvecampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & txt_rut.Text & "' and agno = " & Anno, conn)
    nombreapo = devuelvecampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = devuelvecampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = devuelvecampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
        
    If ExistReg("alu_x_cur", "ci_alu = '" & txt_rut.Text & "' and ucase(activo_alu)='SI' and agno=" & Anno, conn) Then
        RC.Open "select ci_alu, cod_ens, num_gra, let_cur, razon_termino, term_anticipado from alu_x_cur where ci_alu = '" & txt_rut.Text & "' and ucase(activo_alu)='SI' and agno=" & Anno, conn
        Me.txt_nivel_alu.Text = RC("num_gra")
        Me.txt_letra_alu.Text = RC("let_cur")
        If Not IsNull(RC("razon_termino")) Then
            If Len(RC("razon_termino")) > 0 Then
                txt_motivo.Text = RC("razon_termino")
                cb_fecha.Value = RC("term_anticipado")
            End If
        End If
        Me.txt_mod_alu.Text = devuelvecampo("codigos_ensenanza", "", "Des_ens", "cod_ens = '" & RC("cod_ens") & "'", conn)
        Me.txt_apo_alu.Text = nombreapo & " " & ape1apo & " " & ape2apo
        Me.txt_estado_alu.Text = "ACTIVO"
        RC.Close
    Else
        RC.Open "select ci_alu, cod_ens, num_gra, let_cur from alu_x_cur where ci_alu = '" & txt_rut.Text & "' and ucase(activo_alu)='NO' and fec_cam ='1111-11-11' and agno=" & Anno & ";", conn
        If RC.RecordCount > 0 Then
            Me.txt_nivel_alu.Text = RC("num_gra")
            Me.txt_letra_alu.Text = RC("let_cur")
            Me.txt_mod_alu.Text = devuelvecampo("codigos_ensenanza", "", "Des_ens", "cod_ens = '" & RC("cod_ens") & "'", conn)
            Me.txt_apo_alu.Text = nombreapo & " " & ape1apo & " " & ape2apo
            Me.txt_estado_alu.Text = "RETIRADO"
        End If
        RC.Close
    End If
End Sub
