VERSION 5.00
Object = "{00025600-0000-0000-C000-000000000046}#4.6#0"; "crystl32.ocx"
Begin VB.Form Form_observacion_retiro 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Observación retiro"
   ClientHeight    =   2250
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   9780
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2250
   ScaleWidth      =   9780
   Begin Crystal.CrystalReport cr_obs 
      Left            =   5760
      Top             =   1080
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   262150
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Imprimir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   8400
      TabIndex        =   8
      Top             =   1200
      Width           =   1215
   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        =   7
      Top             =   720
      Visible         =   0   'False
      Width           =   4695
   End
   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            =   6600
      TabIndex        =   6
      Top             =   720
      Visible         =   0   'False
      Width           =   1335
   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        =   1
      Top             =   120
      Width           =   8055
      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            =   6480
         TabIndex        =   3
         Top             =   360
         Width           =   1335
      End
      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        =   2
         Top             =   360
         Width           =   4695
      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            =   5880
         TabIndex        =   5
         Top             =   360
         Width           =   615
      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        =   4
         Top             =   360
         Width           =   735
      End
   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            =   8400
      Picture         =   "Form_observacion_retiro.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   120
      Width           =   1215
   End
End
Attribute VB_Name = "Form_observacion_retiro"
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
   'cb_ubicacion.Text = ""
   'txt_observacion.Text = ""
   lst_Rut.Visible = False
   lst_Alumnos.Visible = False
End Sub



Private Sub Command1_Click()

    Call LimpiaFormulas(cr_obs, 30)
    cr_obs.ReportFileName = App.Path & "\Rpt\alumno_baja.rpt"
    cr_obs.Formulas(0) = "ci_alu = '" & txt_RutBusqueda & "'"
    cr_obs.Formulas(1) = "establecimiento = '" & DevuelveCampo("establecimientos", "", "nom_est", "1 = 1", conn) & "'"
    cr_obs.Formulas(2) = "Fech_Retiro = '" & DevuelveCampo("matriculas", "", "fec_retiro", "ci_alu = '" & txt_RutBusqueda & "' AND fec_retiro <> '1111-11-11'", conn) & "'"
    cr_obs.Formulas(3) = "anno = '" & Anno & "'"
    cr_obs.Formulas(4) = "alumno = '" & DevuelveCampo("postulantes", "", "CONCAT(nom_alu, ' ',ape_pat_alu, ' ',ape_mat_alu)", "ci_alu = '" & txt_RutBusqueda & "'", conn) & "'"
    cr_obs.Formulas(5) = "curso = '" & DevuelveCampo("alu_x_cur", "", "CONCAT(num_gra, ' ', let_cur)", "ci_alu = '" & txt_RutBusqueda & "' AND agno = '" & Anno & "'", conn) & "'"
    cr_obs.Formulas(6) = "ensenanza = '" & DevuelveCampo("alu_x_cur", "", "IF(cod_ens = 996, 'Otros Tipos (Pre Kinder)', IF(cod_ens = 010, 'Educación Parvularia', IF(cod_ens = 110,'Educación General Básica',if( cod_ens = 310,'Educación Media H/C niños y jóvenes','Play Group'))))", "ci_alu = '" & txt_RutBusqueda & "' AND agno = '" & Anno & "'", conn) & "'"
    cr_obs.Formulas(7) = "nombrecolegio = '" & DevuelveCampo("establecimientos", "", "nom_est", "1 = 1", conn) & "'"
    cr_obs.Formulas(8) = "direccioncolegio = '" & DevuelveCampo("establecimientos", "", "dir_est", "1 = 1", conn) & "'"
    cr_obs.Formulas(9) = "comunacolegio = '" & DevuelveCampo("establecimientos", "", "localidad_est", "1 = 1", conn) & "'"
    cr_obs.Formulas(10) = "hora = '" & Time & "'"
    
    cr_obs.Destination = crptToWindow
    cr_obs.Action = 1
    
End Sub

Private Sub Form_Load()
'    cb_ubicacion.AddItem "PRINCIPAL"
'    cb_ubicacion.AddItem "ANEXO"
'
'    CODBC = devuelvecampo("cfg", "", "valor", "param = 'CODBC'", conn)
'
'    If CODBC <> "LON001" And CODBC <> "LIN001" Then
'        cb_ubicacion.Visible = False
'        Label3.Visible = False
'    End If
    
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,matriculas as c where concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) = '" _
           & lst_Alumnos.Text & "' and p.ci_alu = c.ci_alu and c.anno_mat = " & 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
    
'    CODBC = devuelvecampo("cfg", "", "valor", "param = 'CODBC'", conn)
'
'    If CODBC = "LON001" Or CODBC = "LIN001" Then
'        varsql = "SELECT local_escolar FROM matriculas WHERE anno_mat = " & Anno & " AND ci_alu = '" & txt_RutBusqueda.Text & "'"
'        objRS.Open varsql, conn
'        cb_ubicacion.Text = objRS("local_escolar")
'        objRS.Close
'    End If
'
'    varsql = "SELECT observaciones FROM alu_x_cur WHERE agno = " & Anno & " AND ci_alu = '" & txt_RutBusqueda.Text & "'"
'    objRS.Open varsql, conn
'    If Not objRS.EOF Then
'    txt_observacion.Text = objRS("observaciones")
'    End If
'    objRS.Close
    

    
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_Alumnos_LostFocus()
'    Dim objRS As ADODB.Recordset
'    Set objRS = New ADODB.Recordset
'    Dim varsql As String
'
'    CODBC = devuelvecampo("cfg", "", "valor", "param = 'CODBC'", conn)
'
'    If CODBC = "LON001" Or CODBC = "LIN001" Then
'        varsql = "SELECT local_escolar FROM matriculas WHERE anno_mat = " & Anno & " AND ci_alu = '" & txt_RutBusqueda.Text & "'"
'        objRS.Open varsql, conn
'        cb_ubicacion.Text = objRS("local_escolar")
'        objRS.Close
'    End If
'
'''    varsql = "SELECT observaciones FROM alu_x_cur WHERE agno = " & Anno & " AND ci_alu = '" & txt_RutBusqueda.Text & "'"
'''    objRS.Open varsql, conn
'''    If Not objRS.EOF Then
'''    txt_observacion.Text = objRS("observaciones")
'''    End If
'''    objRS.Close
'
'End Sub

Private Sub lst_Rut_DblClick()
    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 and anno_mat = " & Anno

    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 lst_Rut_LostFocus()
''    Dim objRS As ADODB.Recordset
''    Set objRS = New ADODB.Recordset
''    Dim varsql As String
''
''    CODBC = devuelvecampo("cfg", "", "valor", "param = 'CODBC'", conn)
''
''    If CODBC = "LON001" Or CODBC = "LIN001" Then
''        varsql = "SELECT local_escolar FROM matriculas WHERE anno_mat = " & Anno & " AND ci_alu = '" & txt_RutBusqueda.Text & "'"
''        objRS.Open varsql, conn
''        cb_ubicacion.Text = objRS("local_escolar")
''        objRS.Close
''    End If
''
''    varsql = "SELECT observaciones FROM alu_x_cur WHERE agno = " & Anno & " AND ci_alu = '" & txt_RutBusqueda.Text & "'"
''    objRS.Open varsql, conn
''    If Not objRS.EOF Then
''        txt_observacion.Text = objRS("observaciones")
''    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"
           
    varsql = "SELECT distinct p.ci_alu, ape_pat_alu, ape_mat_alu, nom_alu" _
            & " FROM postulantes p, matriculas m, cursos c, alu_x_cur ac" _
            & " Where p.ci_alu = m.ci_alu And m.ci_alu = ac.ci_alu" _
            & " AND m.activo_alu = ac.activo_alu AND ac.cod_ens = c.cod_ens AND ac.num_gra = c.num_gra AND ac.let_cur = c.let_cur" _
            & " AND m.activo_alu = 'NO' AND ac.fec_cam ='1111-11-11' AND ac.agno=c.agno AND ac.agno=m.anno_mat AND ac.agno = " & Anno _
            & " and concat(APE_PAT_ALU,' ',ape_mat_alu,' ',nom_alu) LIKE '" & txt_NombreCompleto.Text & "%'" _
            & " 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
           
       varsql = "SELECT distinct p.ci_alu, ape_pat_alu, ape_mat_alu, nom_alu" _
            & " FROM postulantes p, matriculas m, cursos c, alu_x_cur ac" _
            & " Where p.ci_alu = m.ci_alu And m.ci_alu = ac.ci_alu" _
            & " AND m.activo_alu = ac.activo_alu AND ac.cod_ens = c.cod_ens AND ac.num_gra = c.num_gra AND ac.let_cur = c.let_cur" _
            & " AND m.activo_alu = 'NO' AND ac.fec_cam ='1111-11-11' AND ac.agno=c.agno AND ac.agno=m.anno_mat AND ac.agno = " & Anno _
            & " and p.CI_ALU LIKE '" & txt_RutBusqueda & "%'" _
            & " ORDER BY ape_pat_alu, ape_mat_alu, nom_alu"
        
    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






