VERSION 5.00
Begin VB.Form Form_Ingreso_de_becas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cambio de Becas"
   ClientHeight    =   2325
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7395
   Icon            =   "Form_Ingreso_de_becas.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2325
   ScaleWidth      =   7395
   Begin VB.ListBox lst_Rut 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   900
      Left            =   4440
      TabIndex        =   0
      Top             =   720
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.ListBox lst_Alumnos 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   900
      Left            =   840
      TabIndex        =   1
      Top             =   720
      Visible         =   0   'False
      Width           =   2895
   End
   Begin VB.Frame Frame1 
      Caption         =   "Ingreso de Becas"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1215
      Left            =   120
      TabIndex        =   9
      Top             =   960
      Width           =   5775
      Begin VB.CommandButton cmd_ingresar 
         Caption         =   "Asignar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4440
         TabIndex        =   12
         Top             =   600
         Width           =   1215
      End
      Begin VB.OptionButton Option2 
         Caption         =   "Beca Libre Disponibilidad"
         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             =   840
         Width           =   2535
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Beca Socioeconomica"
         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        =   10
         Top             =   360
         Width           =   2055
      End
   End
   Begin VB.Frame Frame_Apo_Caja 
      Caption         =   "Datos del 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          =   735
      Left            =   120
      TabIndex        =   4
      Top             =   120
      Width           =   5775
      Begin VB.TextBox txt_NombreCompleto 
         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
         TabIndex        =   6
         Top             =   360
         Width           =   2895
      End
      Begin VB.TextBox txt_RutBusqueda 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   4320
         TabIndex        =   5
         Top             =   360
         Width           =   1335
      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        =   8
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "R.u.t."
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3840
         TabIndex        =   7
         Top             =   360
         Width           =   615
      End
   End
   Begin VB.CommandButton btn_Cancelar 
      Caption         =   "Cancelar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   6000
      Picture         =   "Form_Ingreso_de_becas.frx":2A8B2
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   1320
      Width           =   1215
   End
   Begin VB.CommandButton btnOtroProfesor 
      Caption         =   "Otro Alumno"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   6000
      Picture         =   "Form_Ingreso_de_becas.frx":2AC1A
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   240
      Width           =   1215
   End
End
Attribute VB_Name = "Form_Ingreso_de_becas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Btn_Cancelar_Click()
    Unload Me
End Sub

Private Sub btnOtroProfesor_Click()
    txt_RutBusqueda.Locked = False
    txt_NombreCompleto.Locked = False
    txt_RutBusqueda.Text = ""
    txt_NombreCompleto.Text = ""
    Option1.Value = False
    Option2.Value = False
    lst_Rut.Visible = False
    lst_Alumnos.Visible = False
End Sub

Private Sub cmd_ingresar_Click()
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim tipo_anterior As String
    Dim tipo_nuevo As String
    Dim indice_media_beca As Integer
    Dim indice_beca As Integer
    Dim accion_realizada As String
    Dim var_sql As String
    Dim log As Boolean
    Dim descuento_hermano As Long
    Dim porcentaje As Integer
    Dim sw As Boolean

    If Option1.Value = False And Option2.Value = False Then
        MsgBox "Debe seleccionar un tipo de Beca", vbInformation
        Exit Sub
    End If
 
' If txt_porcentaje.Text = "" And Option3.Value <> True Then
'    MsgBox "Debe ingresar porcentaje de beca Beca", vbInformation
'    Exit Sub
' End If
 
 
    'Obtengo datos para log
    var_sql = "select * from matriculas WHERE " & _
            "ci_alu='" & Trim(txt_RutBusqueda.Text) & "' AND " & _
            " anno_mat='" & Anno & "' order by fec_mat desc LIMIT 1;"
    objRS.Open var_sql, conn
    
    If objRS("ind_cup") = 1 Then tipo_anterior = "cuponera"
    If objRS("ind_cheq") = 1 Then tipo_anterior = "cheque"
    If objRS("ind_cont") = 1 Then tipo_anterior = "contado"
    If objRS("ind_beca") = 1 Then tipo_anterior = "100% beca"
    If objRS("ind_mbeca") = 1 Then tipo_anterior = "50% beca"
    If objRS("ind_beca") = 1 Then porcentaje = 100
    If objRS("ind_mbeca") = 1 Then porcentaje = 50
   
    indice_media_beca = IIf(IsNull(objRS("ind_mbeca")), 0, objRS("ind_mbeca"))
    indice_beca = IIf(IsNull(objRS("ind_beca")), 0, objRS("ind_beca"))
    
    If Not (objRS("ind_beca") = 1 Or objRS("ind_mbeca") = 1) Then
        objRS.Close
        MsgBox "No se puede cambiar la beca, porque el alumno no cuenta con este beneficio", vbInformation
        Exit Sub
    End If
    objRS.Close
    'Fin obtengo log
        
'    ' Obtengo descuento hermano
'    var_sql = "SELECT monto_exen_hno" _
'            & " FROM fnza_detalle_mensualidad" _
'            & " where run_alu = '" & Trim(txt_RutBusqueda.Text) _
'            & "' and agno = " & Anno & " and mes = 4"
'    objRS.Open var_sql, conn
'    descuento_hermano = objRS("monto_exen_hno")
'    objRS.Close
'    ' Fin obtengo hermano
        
    'If Option1.Value = True And (txt_porcentaje.Text = 100 Or txt_porcentaje.Text = 50) Then
    
    
    
    If Option1.Value = True Then
        var_sql = "update matriculas set tercio = 'NO'," _
                & "tercio_por = 0" _
                & " where ci_alu = '" & txt_RutBusqueda.Text & "' and anno_mat = " & Anno
        conn.Execute var_sql
        var_sql = "update fnza_detalle_mensualidad set tercio = 'NO'" _
                & " where run_alu = '" & txt_RutBusqueda.Text & "' and agno = " & Anno
        conn.Execute var_sql
    Else
        var_sql = "update matriculas set tercio = 'SI'," _
                & "tercio_por = " & porcentaje _
                & " where ci_alu = '" & txt_RutBusqueda.Text & "' and anno_mat = " & Anno
        conn.Execute var_sql
        var_sql = "update fnza_detalle_mensualidad set tercio = 'SI'" _
                & " where run_alu = '" & txt_RutBusqueda.Text & "' and agno = " & Anno
        conn.Execute var_sql
    End If
           
    
    Option1.Value = False
    Option2.Value = False
'    Option3.Value = False
'    lbl_porcentaje.Visible = False
'    txt_porcentaje.Text = ""
'    txt_porcentaje.Visible = False
    MsgBox "La Beca fue cambiada satisfactoriamente", vbInformation

End Sub

Private Sub lst_Alumnos_dblClick()
    'Dim dig As String
    'dig = digito(lst_Alumnos.ItemData(lst_Alumnos.ListIndex))
    'Dim Rut As String
    Dim varsql As String
    
    'Rut = lst_Alumnos.ItemData(lst_Alumnos.ListIndex) & "-" & dig
    
    Dim objRS As ADODB.Recordset
    varsql = "SELECT p.ci_alu" _
           & " FROM postulantes as p,alu_x_cur as c where concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) = '" _
           & lst_Alumnos.Text & "' and p.ci_alu = c.ci_alu and c.agno = " & Anno

    Set objRS = New ADODB.Recordset
    objRS.Open varsql, conn
    If Not objRS.EOF Then
        txt_NombreCompleto.Text = lst_Alumnos.Text
        txt_RutBusqueda.Text = objRS("ci_alu")
    End If
    objRS.Close
    lst_Rut.Clear
    lst_Rut.Visible = False
    If txt_RutBusqueda.Text <> "" And txt_NombreCompleto.Text <> "" Then
        txt_RutBusqueda.Locked = True
        txt_NombreCompleto.Locked = True
    End If
    Option1.Value = False
    Option2.Value = False
   ' Option3.Value = False
   ' lbl_porcentaje.Visible = False
   ' txt_porcentaje.Text = ""
    'txt_porcentaje.Visible = False
    

    
End Sub

Private Sub lst_Alumnos_LostFocus()
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset

    var_sql = "select * from matriculas WHERE " & _
            "ci_alu='" & Trim(txt_RutBusqueda.Text) & "' AND " & _
            " anno_mat='" & Anno & "' order by fec_mat desc LIMIT 1;"
    objRS.Open var_sql, conn
    
    If objRS("tercio") = "SI" Then
        Option1.Value = False
        Option2.Value = True
    Else
        Option1.Value = True
        Option2.Value = False
    End If
        
    objRS.Close
End Sub

Private Sub lst_Rut_Click()
    txt_RutBusqueda.Text = lst_Rut.Text
    lst_Rut.Visible = False
    Dim objRS As ADODB.Recordset
    Dim varsql As String
    varsql = "SELECT ape_pat_alu,ape_mat_alu,nom_alu" _
           & " FROM postulantes p,matriculas m where" _
           & " m.ci_alu='" & txt_RutBusqueda.Text & "' and " _
           & " p.ci_alu = m.ci_alu "

    Set objRS = New ADODB.Recordset
        objRS.Open varsql, conn
    If Not objRS.EOF Then
        txt_NombreCompleto.Text = objRS("ape_pat_alu") & " " & objRS("ape_mat_alu") & " " & objRS("nom_alu")
    End If
    objRS.Close
    lst_Alumnos.Visible = False
    lst_Rut.Clear
    If txt_RutBusqueda.Text <> "" And txt_NombreCompleto.Text <> "" Then
        txt_RutBusqueda.Locked = True
        txt_NombreCompleto.Locked = True
    End If
    Option1.Value = False
    Option2.Value = False

End Sub

Private Sub lst_Rut_LostFocus()
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset

    var_sql = "select * from matriculas WHERE " & _
            "ci_alu='" & Trim(txt_RutBusqueda.Text) & "' AND " & _
            " anno_mat='" & Anno & "' order by fec_mat desc LIMIT 1;"
    objRS.Open var_sql, conn
    
    If objRS("tercio") = "SI" Then
        Option1.Value = False
        Option2.Value = True
    Else
        Option1.Value = True
        Option2.Value = False
    End If
        
    objRS.Close
End Sub

'Private Sub Option1_Click()
'    lbl_porcentaje.Visible = True
'    txt_porcentaje.Visible = True
'End Sub

'Private Sub Option2_Click()
'    lbl_porcentaje.Visible = True
'    txt_porcentaje.Visible = True
'End Sub

'Private Sub Option3_Click()
'    lbl_porcentaje.Visible = False
'    txt_porcentaje.Visible = False
'End Sub

Private Sub txt_NombreCompleto_Change()
    If txt_NombreCompleto.Text <> "" Then
    Dim varsql As String
    'lst_Rut.Visible = False
    Dim objRC As ADODB.Recordset
    Dim rut As Long
    Set objRS = New ADODB.Recordset
    varsql = "SELECT distinct p.CI_ALU,APE_PAT_ALU,APE_MAT_ALU,NOM_ALU" _
           & " FROM postulantes p,matriculas m" _
           & " where concat(APE_PAT_ALU,' ',ape_mat_alu,' ',nom_alu) LIKE '" & txt_NombreCompleto.Text & "%'" _
           & " and p.ci_alu = m.ci_alu and anno_mat = " & Anno _
           & " order by ape_pat_alu,ape_mat_alu,nom_alu"
    objRS.Open varsql, conn
    lst_Alumnos.Clear
    If Not objRS.EOF Then
        lst_Alumnos.Visible = True
    End If
    While Not objRS.EOF
        lst_Alumnos.AddItem objRS("APE_PAT_ALU") & " " & objRS("APE_MAT_ALU") & " " & objRS("NOM_ALU")
        rut = Mid(objRS("CI_ALU"), 1, 8)
        lst_Alumnos.ItemData(lst_Alumnos.NewIndex) = rut
        objRS.MoveNext
    Wend
    objRS.Close
    End If
End Sub

Private Sub txt_RutBusqueda_Change()
    If txt_RutBusqueda.Text <> "" Then
    Dim varsql As String
    lst_Rut.Visible = False
    lst_Alumnos.Visible = False
    Dim objRC As ADODB.Recordset
    Dim rut As Long
    Set objRS = New ADODB.Recordset
    varsql = "SELECT distinct m.CI_ALU" _
           & " FROM postulantes p,matriculas m" _
           & " where p.CI_ALU LIKE '" & txt_RutBusqueda & "%'" _
           & " and p.ci_alu = m.ci_alu and m.anno_mat = " & Anno
    objRS.Open varsql, conn
    lst_Rut.Clear
    If Not objRS.EOF Then
        lst_Rut.Visible = True
    End If
    While Not objRS.EOF
        lst_Rut.AddItem objRS("CI_ALU")
        objRS.MoveNext
    Wend
    objRS.Close
    End If
End Sub

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