VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_ConsultaProfesores 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Consulta Profesores"
   ClientHeight    =   6420
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   10860
   Icon            =   "Form_ConsultaProfesores.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6420
   ScaleWidth      =   10860
   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            =   5160
      TabIndex        =   0
      Top             =   720
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.ListBox lst_Profesores 
      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           =   3735
   End
   Begin VB.CommandButton btn_Ver 
      Caption         =   "Ver"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   6840
      Picture         =   "Form_ConsultaProfesores.frx":2A8B2
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   240
      Width           =   1215
   End
   Begin VB.CommandButton btnOtroProfesor 
      Caption         =   "Otro Profesor"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   8160
      Picture         =   "Form_ConsultaProfesores.frx":2AE29
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   240
      Width           =   1215
   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          =   735
      Left            =   9480
      Picture         =   "Form_ConsultaProfesores.frx":2B37E
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   240
      Width           =   1215
   End
   Begin VB.Frame Frame_Apo_Caja 
      Caption         =   "Datos del Profesor"
      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        =   2
      Top             =   120
      Width           =   6615
      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            =   5040
         TabIndex        =   21
         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        =   19
         Top             =   360
         Width           =   3735
      End
      Begin VB.Label Label2 
         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            =   4560
         TabIndex        =   4
         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        =   3
         Top             =   360
         Width           =   735
      End
   End
   Begin TabDlg.SSTab sst_Busqueda 
      Height          =   5055
      Left            =   120
      TabIndex        =   8
      Top             =   1200
      Width           =   10575
      _ExtentX        =   18653
      _ExtentY        =   8916
      _Version        =   393216
      Tab             =   2
      TabsPerRow      =   5
      TabHeight       =   520
      Enabled         =   0   'False
      ForeColor       =   12582912
      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
      TabCaption(0)   =   "Personal"
      TabPicture(0)   =   "Form_ConsultaProfesores.frx":2B6E6
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "frm_DatosAlumno"
      Tab(0).ControlCount=   1
      TabCaption(1)   =   "Cursos"
      TabPicture(1)   =   "Form_ConsultaProfesores.frx":2B702
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "Frame3"
      Tab(1).Control(1)=   "Frame2"
      Tab(1).Control(2)=   "Frame1"
      Tab(1).ControlCount=   3
      TabCaption(2)   =   "Asignaturas"
      TabPicture(2)   =   "Form_ConsultaProfesores.frx":2B71E
      Tab(2).ControlEnabled=   -1  'True
      Tab(2).Control(0)=   "Frame_Mov_Matricula"
      Tab(2).Control(0).Enabled=   0   'False
      Tab(2).Control(1)=   "Frame4"
      Tab(2).Control(1).Enabled=   0   'False
      Tab(2).ControlCount=   2
      Begin VB.Frame Frame4 
         Caption         =   "Año"
         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        =   36
         Top             =   480
         Width           =   2895
         Begin VB.CommandButton cmd_ver_asignaturas 
            Caption         =   "Ver Asignaturas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1320
            TabIndex        =   38
            Top             =   240
            Width           =   1335
         End
         Begin VB.ComboBox cb_agno_asignaturas 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            TabIndex        =   37
            Text            =   "Combo1"
            Top             =   240
            Width           =   975
         End
      End
      Begin VB.Frame Frame_Mov_Matricula 
         Caption         =   "Listado de Asignaturas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   3615
         Left            =   120
         TabIndex        =   34
         Top             =   1320
         Width           =   10335
         Begin MSHierarchicalFlexGridLib.MSHFlexGrid grid_asignaturas 
            Height          =   3255
            Left            =   120
            TabIndex        =   35
            Top             =   240
            Width           =   10095
            _ExtentX        =   17806
            _ExtentY        =   5741
            _Version        =   393216
            FixedCols       =   0
            FocusRect       =   0
            FillStyle       =   1
            GridLines       =   2
            SelectionMode   =   1
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            _NumberOfBands  =   1
            _Band(0).Cols   =   2
         End
      End
      Begin VB.Frame Frame3 
         Caption         =   "Total de alumnos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   735
         Left            =   -74880
         TabIndex        =   31
         Top             =   4200
         Width           =   2895
         Begin VB.Label lbl_total_alumnos 
            Height          =   375
            Left            =   2160
            TabIndex        =   33
            Top             =   240
            Width           =   615
         End
         Begin VB.Label Label3 
            Caption         =   "Total de alumnos del año:"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   32
            Top             =   240
            Width           =   1935
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   735
         Left            =   -74880
         TabIndex        =   28
         Top             =   480
         Width           =   2775
         Begin VB.CommandButton cmd_ver_cursos 
            Caption         =   "Ver Cursos"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1320
            TabIndex        =   30
            Top             =   240
            Width           =   1215
         End
         Begin VB.ComboBox cb_agno_curso 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            TabIndex        =   29
            Text            =   "Combo1"
            Top             =   240
            Width           =   975
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "Listado de Cursos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   2535
         Left            =   -74880
         TabIndex        =   26
         Top             =   1440
         Width           =   10335
         Begin MSHierarchicalFlexGridLib.MSHFlexGrid grid_cursos 
            Height          =   2175
            Left            =   120
            TabIndex        =   27
            Top             =   240
            Width           =   10095
            _ExtentX        =   17806
            _ExtentY        =   3836
            _Version        =   393216
            FocusRect       =   0
            FillStyle       =   1
            SelectionMode   =   1
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            _NumberOfBands  =   1
            _Band(0).Cols   =   2
         End
      End
      Begin VB.Frame frm_DatosAlumno 
         Caption         =   "Datos Personales"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   2415
         Left            =   -74880
         TabIndex        =   9
         Top             =   840
         Visible         =   0   'False
         Width           =   10455
         Begin VB.TextBox txt_ApePat 
            Height          =   285
            Left            =   960
            Locked          =   -1  'True
            TabIndex        =   16
            Top             =   360
            Width           =   3975
         End
         Begin VB.TextBox txt_ApeMat 
            Height          =   285
            Left            =   6240
            Locked          =   -1  'True
            TabIndex        =   15
            Top             =   360
            Width           =   3975
         End
         Begin VB.TextBox txt_Nombres 
            Height          =   285
            Left            =   960
            Locked          =   -1  'True
            TabIndex        =   14
            Top             =   720
            Width           =   3975
         End
         Begin VB.TextBox txt_Rut 
            Height          =   285
            Left            =   6240
            Locked          =   -1  'True
            TabIndex        =   13
            Top             =   720
            Width           =   1815
         End
         Begin VB.TextBox txt_Direccion 
            Height          =   285
            Left            =   960
            Locked          =   -1  'True
            TabIndex        =   12
            Top             =   1080
            Width           =   3975
         End
         Begin VB.TextBox txt_Comuna 
            Height          =   285
            Left            =   6240
            Locked          =   -1  'True
            TabIndex        =   11
            Top             =   1080
            Width           =   1815
         End
         Begin VB.TextBox txt_Telefono 
            Height          =   285
            Left            =   960
            Locked          =   -1  'True
            TabIndex        =   10
            Top             =   1440
            Width           =   1815
         End
         Begin VB.Label Label4 
            Caption         =   "Ap.Pat."
            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           =   615
         End
         Begin VB.Label Label5 
            Caption         =   "Ap.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            =   5400
            TabIndex        =   24
            Top             =   360
            Width           =   615
         End
         Begin VB.Label Label7 
            Caption         =   "Nombres"
            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             =   720
            Width           =   735
         End
         Begin VB.Label Label8 
            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            =   5400
            TabIndex        =   22
            Top             =   720
            Width           =   375
         End
         Begin VB.Label Label11 
            Caption         =   "Direcció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            =   120
            TabIndex        =   20
            Top             =   1080
            Width           =   735
         End
         Begin VB.Label Label12 
            Caption         =   "Comuna"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   5400
            TabIndex        =   18
            Top             =   1080
            Width           =   735
         End
         Begin VB.Label Label23 
            Caption         =   "Teléfono"
            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             =   1440
            Width           =   735
         End
      End
   End
End
Attribute VB_Name = "Form_ConsultaProfesores"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim f_nom_pro, f_rut_pro As Boolean

Private Sub Btn_Cancelar_Click()
    Unload Me
End Sub

Private Sub Btn_Ver_Click()
    sst_Busqueda.Enabled = True
    sst_Busqueda.Tab = 0
    frm_DatosAlumno.Visible = True
    llena_datos_personales_profesor
    Btn_Ver.Enabled = False
End Sub

Private Sub btnOtroProfesor_Click()
    limpiar
End Sub

Private Sub cmd_ver_asignaturas_Click()
    llena_asignaturas
End Sub

Private Sub cmd_ver_cursos_Click()
    llena_cursos
End Sub

Private Sub Form_Load()
    Dim i As Integer
    For i = 2005 To Year(Date)
        cb_agno_curso.AddItem i
        cb_agno_asignaturas.AddItem i
    Next i
    cb_agno_curso.Text = Year(Date)
    cb_agno_asignaturas.Text = Year(Date)
'    Btn_Ver_Click
'    limpiar
'    sst_Busqueda.Enabled = True
'    sst_Busqueda.Tab = 0
'    frm_DatosAlumno.Visible = True
End Sub

Private Sub lst_Profesores_DblClick()
    Dim RC As ADODB.Recordset
    Dim var_sql As String
    txt_NombreCompleto.Text = lst_Profesores.Text
    lst_Profesores.Visible = False
    lst_Rut.Visible = False
    Set RC = New ADODB.Recordset
    var_sql = "SELECT rut_prof FROM `profesores` where" _
            & " concat(ape1_prof,' ',ape2_prof,' ',noms_prof) = '" _
            & txt_NombreCompleto.Text & "'"
    RC.Open var_sql, conn
    RC.MoveFirst
    'Flag_Sub = True
    txt_RutBusqueda.Text = RC("rut_prof")
    'Flag_Sub = False
    Btn_Ver.Enabled = True
    RC.Close
    If txt_NombreCompleto.Text <> "" And txt_RutBusqueda.Text <> "" Then
        txt_NombreCompleto.Locked = True
        txt_RutBusqueda.Locked = True
    End If
End Sub

Private Sub lst_Rut_DblClick()
    Dim var_sql As String
    Dim RC As ADODB.Recordset
    txt_RutBusqueda.Text = lst_Rut.Text
    lst_Profesores.Visible = False
    lst_Rut.Visible = False
    Set RC = New ADODB.Recordset
     var_sql = "SELECT distinct concat(ape1_prof,' ',ape2_prof,' ',noms_prof) nombre_prof" _
            & " FROM `profesores` where" _
            & " rut_prof = '" & txt_RutBusqueda.Text & "'"
            
    RC.Open var_sql, conn
    RC.MoveFirst
    'Flag_Sub = True
    txt_NombreCompleto.Text = RC("nombre_prof")
    'Flag_Sub = False
    Btn_Ver.Enabled = True
    RC.Close
    If txt_NombreCompleto.Text <> "" And txt_RutBusqueda.Text <> "" Then
        txt_NombreCompleto.Locked = True
        txt_RutBusqueda.Locked = True
    End If
End Sub

Private Sub txt_NombreCompleto_Change()
'txt_NombreCompleto_Click
If f_nom_pro = True Then
    Dim var_sql As String
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    'If Flag_Sub Then Exit Sub
    'If txt_nom_apo.Text = "" Then Exit Sub
       
    Set RC = New ADODB.Recordset
     
    var_sql = "SELECT distinct ape1_prof,ape2_prof,noms_prof" _
            & " FROM profesores p,asi_x_cur_prof axcp where" _
            & " p.rut_prof = axcp.rut_prof and" _
            & " concat(ape1_prof,' ',ape2_prof,' ',noms_prof) like '" _
            & txt_NombreCompleto.Text & "%'"
    RC.Open var_sql, conn
    lst_Profesores.Clear
    While Not (RC.EOF)
        lst_Profesores.AddItem RC("ape1_prof") & " " & RC("ape2_prof") & " " & RC("noms_prof")
        RC.MoveNext
    Wend
    RC.Close
    Btn_Ver.Enabled = False
    lst_Profesores.Visible = True
    lst_Rut.Visible = False
End If
End Sub

Private Sub txt_NombreCompleto_Click()
    f_nom_pro = True
    f_rut_pro = False
End Sub

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

Private Sub txt_RutBusqueda_Change()
'txt_RutBusqueda_Click
If f_rut_pro = True Then
    'If Flag_Sub Then Exit Sub
    'If txt_rut_apo.Text = "" Then Exit Sub
    Dim Str_Query As String
    Dim RC As ADODB.Recordset
    
    Set RC = New ADODB.Recordset
    Str_Query = "SELECT distinct p.rut_prof FROM profesores p,asi_x_cur_prof axcp where" _
            & " p.rut_prof = axcp.rut_prof and p.rut_prof like '" _
            & txt_RutBusqueda.Text & "%'"
    RC.Open Str_Query, conn
    lst_Rut.Clear
    While Not (RC.EOF)
        lst_Rut.AddItem RC("rut_prof")
        RC.MoveNext
    Wend
    RC.Close
    Btn_Ver.Enabled = False
    lst_Rut.Visible = True
    lst_Profesores.Visible = False
End If
End Sub

Private Sub txt_RutBusqueda_Click()
    f_rut_pro = True
    f_nom_pro = False
End Sub

Private Sub llena_datos_personales_profesor()
    Dim var_sql As String
    Dim Comuna As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    var_sql = "select p.*,cg.comuna as 'com'" _
            & " from profesores p left join codigos__geograficos cg" _
            & " on p.comuna_prof = cg.cod_geo" _
            & " where rut_prof = '" & txt_RutBusqueda.Text & "'"
    objRS.Open var_sql, conn
    If Not objRS.EOF Then
        If Not IsNull(objRS("com")) Then
            Comuna = objRS("com")
        Else
            Comuna = ""
        End If
        txt_ApePat.Text = objRS("ape1_prof")
        txt_ApeMat.Text = objRS("ape2_prof")
        txt_Nombres.Text = objRS("noms_prof")
        txt_rut.Text = objRS("rut_prof")
        txt_Direccion.Text = objRS("dir_prof")
        txt_Comuna.Text = Comuna
        txt_Telefono = objRS("fon_prof")
    End If
End Sub

Public Sub llena_cursos()
    Dim var_sql As String
    Dim i, total_alumnos As Integer
    Dim Comuna As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    var_sql = "SELECT c.num_gra as 'Nº Grado',c.let_cur as 'Letra'," _
            & "cod_des as 'Nivel',acp.agno as 'Año',c.cod_ens as 'Total Alumnos'" _
            & ",c.rut_prof as 'tipo de profesor'" _
            & " FROM cursos as c, asi_x_cur_prof as acp,codigos_ensenanza ce" _
            & " Where c.Cod_Ens = acp.Cod_Ens And c.Num_Gra = acp.Num_Gra And" _
            & " c.Let_Cur = acp.Let_Cur And c.agno = acp.agno And acp.Cod_Ens = ce.Cod_Ens" _
            & " and acp.rut_prof = '" & txt_RutBusqueda.Text & "'" _
            & " and acp.agno = " & cb_agno_curso.Text _
            & " group by c.agno,c.num_gra,c.let_cur,c.cod_ens" _
            & " order by c.agno desc,c.cod_ens,c.num_gra,c.let_cur"
    objRS.Open var_sql, conn
    If Not objRS.EOF Then
        Call Rec2Grid(objRS, grid_cursos, True)
        objRS.Close
        total_alumnos = 0
        For i = 1 To grid_cursos.Rows - 1
            var_sql = "select mat.num_gra,mat.cod_des,axc.let_cur,axc.agno,axc.cod_ens" _
            & " From (select *" _
            & " from matriculas m,codigos_ensenanza ce" _
            & " where m.cod_ens = ce.cod_ens and m.anno_mat = " & grid_cursos.TextMatrix(i, 4) _
            & " and activo_alu = 'SI' and confirmado = 'SI') as mat" _
            & " left join alu_x_cur axc on mat.ci_alu = axc.ci_alu and" _
            & " mat.anno_mat = axc.agno and mat.fec_mat = axc.fec_mat and" _
            & " mat.activo_alu = axc.activo_alu And mat.Cod_Ens = axc.Cod_Ens And" _
            & " mat.Num_Gra = axc.Num_Gra" _
            & " where mat.num_gra = " & grid_cursos.TextMatrix(i, 1) _
            & " and axc.let_cur = '" & grid_cursos.TextMatrix(i, 2) _
            & "' and axc.cod_ens = '" & grid_cursos.TextMatrix(i, 5) _
            & "' and axc.agno = " & grid_cursos.TextMatrix(i, 4)
            objRS.Open var_sql, conn
            total_alumnos = total_alumnos + objRS.RecordCount
            grid_cursos.TextMatrix(i, 5) = objRS.RecordCount
            objRS.Close
        Next i
        lbl_total_alumnos.Caption = total_alumnos
        For i = 1 To grid_cursos.Rows - 1
            If grid_cursos.TextMatrix(i, 6) = txt_RutBusqueda.Text Then
                grid_cursos.TextMatrix(i, 6) = "PROFESOR JEFE"
            Else
                grid_cursos.TextMatrix(i, 6) = "PROFESOR DE CATEDRA"
            End If
        Next i
        grid_cursos.ColWidth(6) = 2050
        grid_cursos.Row = 1
        grid_cursos.Col = 1
        grid_cursos.ColSel = 6
    Else
        objRS.Close
        MsgBox "La busqueda no arrojo resultados para el año seleccionado", vbInformation
        grid_cursos.Rows = 2
        grid_cursos.ClearStructure
        lbl_total_alumnos = 0
    End If
End Sub

Private Sub Rec2Grid(ByRef REC As ADODB.Recordset, ByRef grid As Object, Optional ByVal Numeracion As Boolean = True)
    grid.ClearStructure
    If REC.RecordCount > 0 Then
        grid.Cols = REC.Fields.count + 1
        grid.Rows = REC.RecordCount + 1
        grid.FixedCols = 1
        grid.FixedRows = 1
        grid.TextMatrix(0, 0) = "Nº"
        grid.ColWidth(0) = IIf(Numeracion, TextWidth(grid.TextMatrix(0, 0)) + 100, 0)
        For i = 1 To REC.Fields.count
            grid.TextMatrix(0, i) = UCase(REC.Fields(i - 1).Name)
            grid.ColWidth(i) = TextWidth(grid.TextMatrix(0, i)) + 100
        Next i
        REC.MoveFirst
        For i = 1 To REC.RecordCount
            'progreso.Value = i
            grid.TextMatrix(i, 0) = i
            grid.ColWidth(0) = IIf(Numeracion, IIf(TextWidth(grid.TextMatrix(i, 0)) + 100 > grid.ColWidth(0), TextWidth(grid.TextMatrix(i, 0)) + 100, grid.ColWidth(0)), 0)
            For j = 1 To REC.Fields.count
                grid.TextMatrix(i, j) = IIf(IsNull(REC(j - 1)), "Null", REC(j - 1))
                grid.ColWidth(j) = IIf(TextWidth(grid.TextMatrix(i, j)) + 100 > grid.ColWidth(j), TextWidth(grid.TextMatrix(i, j)) + 100, grid.ColWidth(j))
            Next j
            REC.MoveNext
        Next i
    Else
        grid.Cols = 2
        grid.Rows = 2
    End If
End Sub

Public Sub llena_asignaturas()
    Dim i As Integer
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    var_sql = "SELECT concat(c.num_gra,' ',c.let_cur,' ',cod_des) as 'Curso'," _
            & "c.agno as 'Año',s.nom_sec as 'Sector',acp.cod_asi as 'Cod. Asig.'," _
            & "a.nom_asi as 'Asignatura',des_sit_prof as 'Sit. Profesor'" _
            & " FROM cursos as c, asi_x_cur_prof as acp, sectores as s, subsectores as a," _
            & "profesores as p,codigos_ensenanza ce,sitprof_x_asi spxa,sit_prof sp" _
            & " Where c.Cod_Ens = acp.Cod_Ens And c.Num_Gra = acp.Num_Gra And c.Let_Cur = acp.Let_Cur" _
            & " And c.agno = acp.agno And acp.cod_sec = s.cod_sec And acp.cod_sec = a.cod_sec And" _
            & " acp.cod_asi = a.cod_asi And acp.Cod_Ens = a.Cod_Ens And acp.Num_Gra = a.Num_Gra And" _
            & " acp.rut_prof = p.rut_prof And acp.Cod_Ens = ce.Cod_Ens" _
            & " and acp.cod_sec = spxa.cod_sec and acp.cod_asi = spxa.cod_asi and" _
            & " acp.cod_ens = spxa.cod_ens and acp.num_gra = spxa.num_gra and" _
            & " acp.rut_prof = spxa.rut_prof and" _
            & " acp.agno = spxa.agno And spxa.cod_sit_prof = sp.cod_sit_prof" _
            & " and acp.rut_prof = '" & txt_RutBusqueda.Text _
            & "' and acp.agno = " & cb_agno_asignaturas.Text _
            & " order by c.agno desc,c.cod_ens,c.num_gra,c.let_cur"
    objRS.Open var_sql, conn
    If Not objRS.EOF Then
        Call Rec2Grid(objRS, grid_asignaturas, True)
        For i = 1 To grid_asignaturas.Rows - 1
            grid_asignaturas.Row = i
            grid_asignaturas.Col = 1
            grid_asignaturas.CellAlignment = 1
        Next i
        grid_asignaturas.Row = 1
        grid_asignaturas.Col = 1
        grid_asignaturas.ColSel = 6
    Else
        MsgBox "La busqueda no arrojo resultados para el año consultado", vbInformation
        grid_asignaturas.Rows = 2
        grid_asignaturas.ClearStructure
    End If
    objRS.Close
End Sub

Public Sub limpiar()
    frm_DatosAlumno.Visible = False
    sst_Busqueda.Tab = 0
    sst_Busqueda.Enabled = False
    
    txt_NombreCompleto.Locked = False
    txt_RutBusqueda.Locked = False
    f_nom_pro = False
    f_rut_pro = False
    txt_NombreCompleto.Text = ""
    txt_RutBusqueda.Text = ""
    txt_ApePat.Text = ""
    txt_ApeMat.Text = ""
    txt_Nombres.Text = ""
    txt_rut.Text = ""
    txt_Direccion.Text = ""
    txt_Telefono.Text = ""
    txt_Comuna.Text = ""
    grid_asignaturas.Rows = 2
    grid_asignaturas.ClearStructure
    grid_cursos.Rows = 2
    grid_cursos.ClearStructure
End Sub
