VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "MSCOMCTL.OCX"
Begin VB.Form DesaPerSoc_ConsutasAvanzadas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Consulta Avanzada de Informes de Desarrollo Personal"
   ClientHeight    =   7110
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9765
   Icon            =   "DesaPerSoc_ConsutasAvanzadas.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7110
   ScaleWidth      =   9765
   Begin VB.Frame Frame_Principal 
      Caption         =   "Filtros de Búsqueda"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   6855
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   9495
      Begin TabDlg.SSTab SSTab1 
         Height          =   6375
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   9255
         _ExtentX        =   16325
         _ExtentY        =   11245
         _Version        =   393216
         Tabs            =   2
         TabHeight       =   520
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TabCaption(0)   =   "Por Nombre o Rut"
         TabPicture(0)   =   "DesaPerSoc_ConsutasAvanzadas.frx":2A8B2
         Tab(0).ControlEnabled=   -1  'True
         Tab(0).Control(0)=   "Frame_busqueda"
         Tab(0).Control(0).Enabled=   0   'False
         Tab(0).ControlCount=   1
         TabCaption(1)   =   "Por Año, Enseñanza  y Curso"
         TabPicture(1)   =   "DesaPerSoc_ConsutasAvanzadas.frx":2A8CE
         Tab(1).ControlEnabled=   0   'False
         Tab(1).Control(0)=   "Frame1"
         Tab(1).ControlCount=   1
         Begin VB.Frame Frame_busqueda 
            Caption         =   "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          =   5775
            Left            =   120
            TabIndex        =   15
            Top             =   480
            Width           =   9015
            Begin VB.CommandButton Command2 
               Caption         =   "Imprimir Informe"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   735
               Left            =   4560
               Picture         =   "DesaPerSoc_ConsutasAvanzadas.frx":2A8EA
               Style           =   1  'Graphical
               TabIndex        =   21
               Top             =   4800
               Visible         =   0   'False
               Width           =   1455
            End
            Begin VB.CommandButton Command1 
               Caption         =   "Ver Informe"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   735
               Left            =   2880
               Picture         =   "DesaPerSoc_ConsutasAvanzadas.frx":2AE47
               Style           =   1  'Graphical
               TabIndex        =   20
               Top             =   4800
               Width           =   1455
            End
            Begin VB.ListBox List2 
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   1740
               ItemData        =   "DesaPerSoc_ConsutasAvanzadas.frx":2B417
               Left            =   7320
               List            =   "DesaPerSoc_ConsutasAvanzadas.frx":2B419
               TabIndex        =   19
               TabStop         =   0   'False
               Top             =   600
               Visible         =   0   'False
               Width           =   1335
            End
            Begin VB.ListBox List1 
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   1740
               ItemData        =   "DesaPerSoc_ConsutasAvanzadas.frx":2B41B
               Left            =   1200
               List            =   "DesaPerSoc_ConsutasAvanzadas.frx":2B41D
               TabIndex        =   18
               TabStop         =   0   'False
               Top             =   600
               Visible         =   0   'False
               Width           =   5295
            End
            Begin VB.TextBox Text1 
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   285
               Left            =   1200
               TabIndex        =   17
               Top             =   360
               Width           =   5295
            End
            Begin VB.TextBox Text2 
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   285
               Left            =   7320
               TabIndex        =   16
               Top             =   360
               Width           =   1335
            End
            Begin MSFlexGridLib.MSFlexGrid MSFGinf 
               Height          =   3855
               Left            =   240
               TabIndex        =   22
               Top             =   840
               Width           =   8655
               _ExtentX        =   15266
               _ExtentY        =   6800
               _Version        =   393216
               Cols            =   10
               FixedCols       =   0
               BackColorSel    =   16761024
               ForeColorSel    =   -2147483640
               ScrollBars      =   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
            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
               Index           =   1
               Left            =   240
               TabIndex        =   24
               Top             =   360
               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            =   6840
               TabIndex        =   23
               Top             =   360
               Width           =   375
            End
         End
         Begin VB.Frame Frame1 
            Caption         =   "Filtro Avanzado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   5775
            Left            =   -74880
            TabIndex        =   2
            Top             =   480
            Width           =   9015
            Begin VB.CommandButton Command3 
               Caption         =   "Ir"
               Height          =   735
               Left            =   3840
               Picture         =   "DesaPerSoc_ConsutasAvanzadas.frx":2B41F
               Style           =   1  'Graphical
               TabIndex        =   4
               Top             =   4800
               Width           =   1455
            End
            Begin MSComctlLib.ImageCombo IMCagno 
               Height          =   345
               Left            =   600
               TabIndex        =   3
               Top             =   360
               Width           =   1215
               _ExtentX        =   2143
               _ExtentY        =   609
               _Version        =   393216
               ForeColor       =   -2147483640
               BackColor       =   -2147483643
               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
               Locked          =   -1  'True
            End
            Begin MSFlexGridLib.MSFlexGrid MSFGaec 
               Height          =   3735
               Left            =   240
               TabIndex        =   5
               Top             =   960
               Width           =   8655
               _ExtentX        =   15266
               _ExtentY        =   6588
               _Version        =   393216
               Cols            =   7
               FixedCols       =   0
               BackColorSel    =   16761024
               ForeColorSel    =   -2147483640
               ScrollBars      =   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
            End
            Begin MSComctlLib.ImageCombo IMCcod 
               Height          =   345
               Left            =   4560
               TabIndex        =   6
               Top             =   360
               Width           =   975
               _ExtentX        =   1720
               _ExtentY        =   609
               _Version        =   393216
               ForeColor       =   -2147483640
               BackColor       =   -2147483643
               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
               Locked          =   -1  'True
            End
            Begin MSComctlLib.ImageCombo IMCgra 
               Height          =   345
               Left            =   6360
               TabIndex        =   7
               Top             =   360
               Width           =   975
               _ExtentX        =   1720
               _ExtentY        =   609
               _Version        =   393216
               ForeColor       =   -2147483640
               BackColor       =   -2147483643
               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
               Locked          =   -1  'True
            End
            Begin MSComctlLib.ImageCombo IMCletra 
               Height          =   345
               Left            =   8160
               TabIndex        =   8
               Top             =   360
               Width           =   735
               _ExtentX        =   1296
               _ExtentY        =   609
               _Version        =   393216
               ForeColor       =   -2147483640
               BackColor       =   -2147483643
               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
               Locked          =   -1  'True
            End
            Begin MSComctlLib.ImageCombo IMCper 
               Height          =   345
               Left            =   2640
               TabIndex        =   9
               Top             =   360
               Width           =   735
               _ExtentX        =   1296
               _ExtentY        =   609
               _Version        =   393216
               ForeColor       =   -2147483640
               BackColor       =   -2147483643
               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
               Locked          =   -1  'True
            End
            Begin VB.Label Label3 
               Caption         =   "Enseñanza:"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   3600
               TabIndex        =   14
               Top             =   360
               Width           =   855
            End
            Begin VB.Label Label1 
               Caption         =   "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
               Index           =   0
               Left            =   240
               TabIndex        =   13
               Top             =   360
               Width           =   375
            End
            Begin VB.Label Label4 
               Caption         =   "Grado:"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   5760
               TabIndex        =   12
               Top             =   360
               Width           =   495
            End
            Begin VB.Label Label5 
               Caption         =   "Letra:"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   7680
               TabIndex        =   11
               Top             =   360
               Width           =   495
            End
            Begin VB.Label Label6 
               Caption         =   "Periodo:"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   2040
               TabIndex        =   10
               Top             =   360
               Width           =   615
            End
         End
      End
   End
End
Attribute VB_Name = "DesaPerSoc_ConsutasAvanzadas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private RC As ADODB.Recordset
Private Flag_sub As Boolean
Private Sub llenardatosinfome()
    Dim Consulta, xci_alu, xnombre As String
    If text2.Text <> "" And Text1.Text <> "" Then
        Consulta = "Select * from desaper_cab where CI_ALU='" & text2.Text & "' ORDER BY AGNO,PERIODO,COD_ENS,NUM_GRA,LET_CUR"
    Else
        Exit Sub
    End If

    Dim datos As ADODB.Recordset
    
    Set datos = New ADODB.Recordset
    datos.Open Consulta, conn
    
    MSFGinf.Rows = datos.RecordCount + 1
    If datos.RecordCount > 0 Then
    With MSFGinf
    .Row = 0
    While Not datos.EOF
          .Row = .Row + 1
        .Col = 0
        .Text = datos!ci_alu
        .Col = 1
        .Text = datos!rut_prof
        .Col = 2
        .Text = datos!folio_persoc
        .Col = 3
        .Text = datos!Num_Gra
        .Col = 4
        .Text = datos!Let_Cur
        .Col = 5
        .Text = datos!periodo
        .Col = 6
        .Text = datos!agno
        .Col = 7
        .Text = datos!Cod_Ens
        .Col = 8
        
        If datos!Cod_Ens = "110" Then
            .Text = "Basica"
        ElseIf datos!Cod_Ens = "310" Then
            .Text = " Media"
        ElseIf datos!Cod_Ens = "010" Then
            .Text = "Parvularia"
        Else
            .Text = "Otro"
        End If
        
        .Col = 9
        .Text = datos!observaciones
         datos.MoveNext
       
    Wend
    End With
    End If
    datos.Close
End Sub

Private Sub Command1_Click()
    Dim colegio As String
    Dim nombre As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    Dim xnfolio As Long
    Dim xagno As Integer
    Dim xnumgra, xcod_ens As String
    
    MSFGinf.Col = 2
    xnfolio = val(MSFGinf.Text)
    MSFGinf.Col = 7
    xcod_ens = MSFGinf.Text
    MSFGinf.Col = 3
    xnumgra = MSFGinf.Text
    MSFGinf.Col = 6
    xagno = val(MSFGinf.Text)
    MSFGinf.Col = 4
    xletra = MSFGinf.Text
    
    var_sql = "SELECT nombre,colegio" _
            & " From hist_cod_colegio" _
            & " where colegio = (select valor from cfg where param = 'codbc')"
    objRS.Open var_sql, conn
    colegio = objRS("colegio")
    nombre = objRS("nombre")
    objRS.Close
    
    If xcod_ens = "110" And val(xnumgra) < 5 Then
             '************************IMPRESION DE INFORME PARA ALUMNOS DE NB1-NB2-NB3-NB4*******************
            If colegio = "LIN001" Then
                Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\informe_desaper110_lincoln.rpt"
            Else
                Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\informe_desaper110.rpt"
            End If
            Form_main.CrystalReport.WindowState = crptMaximized
            Form_main.CrystalReport.WindowTitle = "Informe De Desarrollo Personal y Social"
            Form_main.CrystalReport.ReplaceSelectionFormula ("")
            Form_main.CrystalReport.Formulas(0) = "colegio = '" & nombre & "'"
            Form_main.CrystalReport.Formulas(1) = "fecha = '" & Format(Now, "dd/mm/yyyy") & "'"
            Form_main.CrystalReport.Formulas(2) = "hora = '" & Format(Now, "hh:mm AM/PM") & "'"
            
            Form_main.CrystalReport.ReplaceSelectionFormula ("{desaper_cab.folio_persoc}=" & xnfolio)
            Form_main.CrystalReport.Destination = crptToWindow
            Form_main.CrystalReport.Action = 1
        '************************FIN IMPRESION DE INFORME PARA ALUMNOS DE NB1-NB2-NB3-NB4
        ElseIf xcod_ens = "110" And val(xnumgra) > 4 Then
        '************************IMPRESION DE INFORME PARA ALUMNOS DE NB5-NB6-NB7-NB8*******************
            If colegio = "LIN001" Then
                Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\informe_desaper1108_lincoln.rpt"
            Else
                Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\informe_desaper1108.rpt"
            End If
            Form_main.CrystalReport.WindowState = crptMaximized
            Form_main.CrystalReport.WindowTitle = "Informe De Desarrollo Personal y Social"
            Form_main.CrystalReport.ReplaceSelectionFormula ("")
            
            Form_main.CrystalReport.Formulas(0) = "colegio = '" & nombre & "'"
            Form_main.CrystalReport.Formulas(1) = "fecha = '" & Format(Now, "dd/mm/yyyy") & "'"
            Form_main.CrystalReport.Formulas(2) = "hora = '" & Format(Now, "hh:mm AM/PM") & "'"
            
            Form_main.CrystalReport.ReplaceSelectionFormula ("{desaper_cab.folio_persoc}=" & xnfolio)
            Form_main.CrystalReport.Destination = crptToWindow
            Form_main.CrystalReport.Action = 1
        '************************FIN IMPRESION DE INFORME PARA ALUMNOS DE NB5-NB6-NB7-NB8*******************
        ElseIf xcod_ens = "310" Then
        '************************IMPRESION DE INFORME PARA ALUMNOS DE NM1 - NM2 - NM3 ******************
            If colegio = "LIN001" Then
                Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\informe_desaper310_lincoln.rpt"
            Else
                '' Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\informe_desaper310.rpt"
                Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\informe_desaper310_pud.rpt"
                '' informe_desaper310_pud
            End If
            Form_main.CrystalReport.WindowState = crptMaximized
            Form_main.CrystalReport.WindowTitle = "Informe De Desarrollo Personal y Social"
            Form_main.CrystalReport.ReplaceSelectionFormula ("")
            
            Form_main.CrystalReport.Formulas(0) = "colegio = '" & nombre & "'"
            Form_main.CrystalReport.Formulas(1) = "fecha = '" & Format(Now, "dd/mm/yyyy") & "'"
            Form_main.CrystalReport.Formulas(2) = "hora = '" & Format(Now, "hh:mm AM/PM") & "'"
            
            Form_main.CrystalReport.ReplaceSelectionFormula ("{desaper_cab.folio_persoc}=" & xnfolio)
            Form_main.CrystalReport.Destination = crptToWindow
            Form_main.CrystalReport.Action = 1
        '************************FIN IMPRESION DE INFORME PARA ALUMNOS DE NM1 - NM2 - NM3 ******************
        End If

    
End Sub

Private Sub Command3_Click()
   Dim xrut As String
   MSFGaec.Col = 0
   xrut = MSFGaec.Text
   text2.Text = xrut
   List2.Text = xrut
   List2_DblClick
   
   SSTab1.Tab = 0
End Sub

Private Sub Form_Load()
    Set RC = New ADODB.Recordset
    Flag_sub = False
    Me.Show
    Call Formatogrilla
    Call Formatogrilla2
    Call llenaragnos
    Call llenarperi
    Call llenarcodens
End Sub

Private Sub IMCcod_Change()
 If IMCcod.Text = "*" And IMCper.Text <> "*" Then
      imcgra.ComboItems.Clear
      IMCletra.ComboItems.Clear
      imcgra.ComboItems.Add 1, , "*"
      IMCletra.ComboItems.Add 1, , "*"
      llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " Order by 3,7,4,5,6"
 End If
End Sub

Private Sub IMCcod_Click()
    If IMCcod.Text = "*" And IMCper.Text <> "*" Then
        imcgra.ComboItems.Clear
        IMCletra.ComboItems.Clear
        imcgra.ComboItems.Add 1, , "*"
        IMCletra.ComboItems.Add 1, , "*"
        llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " Order by 3,7,4,5,6"
    ElseIf IMCcod.Text <> "*" And IMCper.Text <> "*" Then
        llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " and c.cod_ens='" & IMCcod.Text & "' Order by 3,7,4,5,6"
        llenarnumgra
    End If
End Sub

Private Sub IMCgra_Click()
    If imcgra.Text = "*" And IMCcod.Text <> "*" And IMCper.Text <> "*" Then
        IMCletra.ComboItems.Clear
        IMCletra.ComboItems.Add 1, , "*"
        llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " and c.cod_ens='" & IMCcod.Text & "' Order by 3,7,4,5,6"
    ElseIf imcgra.Text <> "*" And IMCcod.Text <> "*" And IMCper.Text <> "*" Then
        llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " and c.cod_ens='" & IMCcod.Text & "' and c.num_gra='" & imcgra.Text & "' Order by 3,7,4,5,6"
        llenarletra
    End If
 End Sub



Private Sub IMCletra_Click()
If IMCletra.Text = "*" And imcgra.Text <> "*" And IMCcod.Text <> "*" And IMCper.Text <> "*" Then
    llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " and c.cod_ens='" & IMCcod.Text & "' and c.num_gra='" & imcgra.Text & "' Order by 3,7,4,5,6"
ElseIf IMCletra.Text <> "*" And imcgra.Text <> "*" And IMCcod.Text <> "*" And IMCper.Text <> "*" Then
    llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " and c.cod_ens='" & IMCcod.Text & "' and c.num_gra='" & imcgra.Text & "' and c.let_cur='" & IMCletra.Text & "' Order by 3,7,4,5,6"
End If
End Sub

Private Sub IMCper_Change()
If IMCper.Text = "*" And imcagno.Text <> "*" Then
       imcgra.ComboItems.Clear
       IMCletra.ComboItems.Clear
       IMCcod.ComboItems.Clear
       imcgra.ComboItems.Add 1, , "*"
       IMCletra.ComboItems.Add 1, , "*"
       llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " order by 3,7,4,5,6"
End If
End Sub

Private Sub IMCper_Click()
    If IMCper.Text = "*" Then
       imcgra.ComboItems.Clear
       IMCletra.ComboItems.Clear
       IMCcod.ComboItems.Clear
       imcgra.ComboItems.Add 1, , "*"
       IMCletra.ComboItems.Add 1, , "*"
       llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " order by 3,7,4,5,6"
    Else
       'MsgBox "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & IMCagno.Text & " and c.periodo=" & IMCper.Text & " order by 3,7,4,5,6"
       llenargrilla2 "Select c.ci_alu,CONCAT(p.ape_pat_alu,' ',p.ape_mat_alu,' ',p.nom_alu) as nombre,c.agno,c.cod_ens,c.num_gra,c.let_cur,c.periodo from desaper_cab c, postulantes p  where  c.ci_alu=p.ci_alu and c.agno=" & imcagno.Text & " and c.periodo=" & IMCper.Text & " order by 3,7,4,5,6"
       llenarcodens
    End If
End Sub

Private Sub List1_DblClick()
    Text1.Text = List1.Text
    List1.Visible = False
    List2.Visible = False
    RC.CursorLocation = adUseClient
    RC.Open "SELECT ci_alu FROM postulantes where left(CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu)," & Len(Text1.Text) & ")='" & Text1.Text & "' ORDER BY ape_pat_alu, ape_mat_alu,nom_alu;", conn
    RC.MoveFirst
    Flag_sub = True
    text2.Text = RC("ci_alu")
    Flag_sub = False
    RC.Close
    Call llenardatosinfome
End Sub

Private Sub List2_DblClick()
    text2.Text = List2.Text
    List1.Visible = False
    List2.Visible = False
    RC.CursorLocation = adUseClient
    RC.Open "SELECT CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as nombre_alu FROM postulantes where ci_alu='" & text2.Text & "' ORDER BY ci_alu;"
    RC.MoveFirst
    Flag_sub = True
    Text1.Text = RC!nombre_alu
    RC.Close
    Flag_sub = False
   Call llenardatosinfome
End Sub


Private Sub MSFGaec_DblClick()
   Dim xrut As String
   MSFGaec.Col = 0
   xrut = MSFGaec.Text
   text2.Text = xrut
   List2.Text = xrut
   List2_DblClick
   
   SSTab1.Tab = 0
End Sub

Private Sub Text1_Change()
   If Flag_sub Then Exit Sub
    If Text1.Text = "" Then Exit Sub
    
    RC.CursorLocation = adUseClient
    RC.Open "SELECT DISTINCT ape_pat_alu,ape_mat_alu,nom_alu FROM postulantes where left(CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu)," & Len(Text1.Text) & ")='" & Text1.Text & "' ORDER BY ape_pat_alu, ape_mat_alu,nom_alu", conn
   
    List1.Clear
    While Not (RC.EOF)
        List1.AddItem RC("ape_pat_alu") & " " & RC("ape_mat_alu") & " " & RC("nom_alu")
        RC.MoveNext
    Wend
    RC.Close
    List1.Visible = True
    List2.Visible = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If (List1.ListCount = 0) Then
            Exit Sub
        End If
        List1.Selected(0) = True
        Flag_sub = True
        Text1.Text = List1.Text
        Flag_sub = False
        'Call List1_DblClick
    End If
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Text2_Change()
 If Flag_sub Then Exit Sub
    If text2.Text = "" Then Exit Sub
    
    RC.CursorLocation = adUseClient
    RC.Open "SELECT DISTINCT p.ci_alu FROM postulantes p where left(p.ci_alu," & Len(text2.Text) & ")='" & text2.Text & "' ORDER BY p.ci_alu;", conn
    List2.Clear
    While Not (RC.EOF)
        List2.AddItem RC("ci_alu")
        RC.MoveNext
    Wend
    RC.Close
    List2.Visible = True
    List1.Visible = False
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If (List2.ListCount = 0) Then
            Exit Sub
        End If
        List1.Selected(0) = True
        Flag_sub = True
        text2.Text = List2.Text
        Flag_sub = False
        'Call List1_DblClick
    End If
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub Formatogrilla()
    With MSFGinf
        .ColWidth(0) = 0    'CI_ALUMNO
        .ColWidth(1) = 0    'CI_PROFESOR
        .ColWidth(2) = 950  'NUMERO DE FOLIO
        .ColWidth(3) = 650  'NUM_GRA
        .ColWidth(4) = 630 'LETRA
        .ColWidth(5) = 890  'PÈRIODO O SEMESTRE
        .ColWidth(6) = 468  'AGNO
        .ColWidth(7) = 0    'Codigo de Enseñanza oculto
        .ColWidth(8) = 1050  'descripcion ENSEÑANSA
        .ColWidth(9) = 4800 'OBSERVACIONES
        .Col = 0
        .Row = 0
        .CellFontBold = True
        .Text = "CI_ALU"
        .Col = 1
        .CellFontBold = True
        .Text = "CI_PROF"
        .Col = 2
        .CellFontBold = True
        .Text = "Nº Folio"
        .Col = 3
        .CellFontBold = True
        .Text = "Curso"
        .Col = 4
        .CellFontBold = True
        .Text = "Letra"
        .Col = 5
        .CellFontBold = True
        .Text = "Semestre"
        .Col = 6
        .CellFontBold = True
        .Text = "Año"
        .Col = 7
        .CellFontBold = True
        .Text = "COD_ENS"
        .Col = 8
        .CellFontBold = True
        .Text = "Enseñanza"
        .Col = 9
        .CellFontBold = True
        .Text = "Observaciones"
    End With
    
End Sub
Private Sub Formatogrilla2()
    With MSFGaec
        .Row = 0
        .ColWidth(0) = 0   ' CIALU
        .ColWidth(1) = 450 ' AGNO
        .ColWidth(2) = 800  'PERIODO
        .ColWidth(3) = 750 ' COD_ENS
        .ColWidth(4) = 650 ' Grado
        .ColWidth(5) = 630  'Letra
        .ColWidth(6) = 4900 'Apellido, nombres
    
        .Col = 0
        .CellFontBold = True
        .Text = "CI"
        .Col = 1
        .CellFontBold = True
        .Text = "Año"
        .Col = 2
        .CellFontBold = True
        .Text = "Semestre"
        .Col = 3
        .CellFontBold = True
        .Text = "Codigo Enseñanza"
        .Col = 4
        .CellFontBold = True
        .Text = "Grado"
        .Col = 5
        .CellFontBold = True
        .Text = "Letra"
        .Col = 6
        .CellFontBold = True
        .Text = "Apellidos y Nombres"
    End With
End Sub
Private Sub llenaragnos()
Dim agnos As ADODB.Recordset
Dim I As Integer
Set agnos = New ADODB.Recordset
agnos.Open "Select agno from desaper_cab group by agno", conn
I = 1
If agnos.RecordCount > 0 Then

    While Not agnos.EOF
        imcagno.ComboItems.Add I, , agnos!agno
        agnos.MoveNext
        I = I + 1
    Wend
 imcagno.SelectedItem = imcagno.ComboItems.Item(1)
End If
agnos.Close
End Sub
Private Sub llenarcodens()
Dim Codens As ADODB.Recordset
Dim I As Integer
IMCcod.ComboItems.Clear

Set Codens = New ADODB.Recordset

If IMCper.Text = "*" Or IMCper.Text = "" Then
    Codens.Open "Select cod_ens from desaper_cab where agno=" & imcagno.Text & " group by 1", conn
Else
    Codens.Open "Select cod_ens from desaper_cab where agno=" & imcagno.Text & " and periodo= " & IMCper.Text & " group by 1", conn
End If
I = 2
IMCcod.ComboItems.Add 1, , "*"
If Codens.RecordCount > 0 Then

    While Not Codens.EOF
        IMCcod.ComboItems.Add I, , Codens!Cod_Ens
        Codens.MoveNext
        I = I + 1
    Wend
End If
Set IMCcod.SelectedItem = IMCcod.ComboItems.Item(1)
Codens.Close
End Sub
Private Sub llenargrilla2(sqlstring As String)
MSFGaec.Rows = 1
Dim datos As ADODB.Recordset
Dim X As Integer

Set datos = New ADODB.Recordset
datos.Open sqlstring, conn

MSFGaec.Rows = datos.RecordCount + 1
X = 0
If datos.RecordCount > 0 Then
    While Not datos.EOF
        X = X + 1
        MSFGaec.Row = X
        MSFGaec.Col = 0
        MSFGaec.Text = datos!ci_alu
        MSFGaec.Col = 1
        MSFGaec.Text = datos!agno
        MSFGaec.Col = 2
        MSFGaec.Text = datos!periodo
        MSFGaec.Col = 3
        MSFGaec.Text = datos!Cod_Ens
        MSFGaec.Col = 4
        MSFGaec.Text = datos!Num_Gra
        MSFGaec.Col = 5
        MSFGaec.Text = datos!Let_Cur
        MSFGaec.Col = 6
        MSFGaec.Text = datos!nombre
        datos.MoveNext
    Wend
End If
End Sub
Private Sub llenarperi()
Dim Per As ADODB.Recordset
Dim I As Integer

IMCper.ComboItems.Clear

Set Per = New ADODB.Recordset

Per.Open "Select periodo from desaper_cab where agno=" & imcagno.Text & " group by 1", conn
I = 2
IMCper.ComboItems.Add 1, , "*"
If Per.RecordCount > 0 Then
    While Not Per.EOF
        IMCper.ComboItems.Add I, , Per!periodo
        Per.MoveNext
        I = I + 1
    Wend
End If
Per.Close
Set IMCper.SelectedItem = IMCper.ComboItems.Item(1)
End Sub
Private Sub llenarnumgra()
Dim gra As ADODB.Recordset
Dim I As Integer

imcgra.ComboItems.Clear

Set gra = New ADODB.Recordset

gra.Open "Select num_gra from desaper_cab where agno=" & imcagno.Text & " and periodo=" & IMCper.Text & " and cod_ens='" & IMCcod.Text & "' group by 1", conn
I = 2
imcgra.ComboItems.Add 1, , "*"
If gra.RecordCount > 0 Then
    While Not gra.EOF
        imcgra.ComboItems.Add I, , gra!Num_Gra
        gra.MoveNext
        I = I + 1
    Wend
End If
Set imcgra.SelectedItem = imcgra.ComboItems(1)
End Sub
Private Sub llenarletra()
Dim letr As ADODB.Recordset
Dim I As Integer

IMCletra.ComboItems.Clear

Set letr = New ADODB.Recordset

letr.Open "Select let_cur from desaper_cab where agno=" & imcagno.Text & " and periodo=" & IMCper.Text & " and cod_ens='" & IMCcod.Text & "' and num_gra='" & imcgra.Text & "' group by 1", conn
I = 2
IMCletra.ComboItems.Add 1, , "*"
If letr.RecordCount > 0 Then
    While Not letr.EOF
        IMCletra.ComboItems.Add I, , letr!Let_Cur
        letr.MoveNext
        I = I + 1
    Wend
End If
Set IMCletra.SelectedItem = IMCletra.ComboItems(1)

End Sub

Private Sub Text4_Change()

End Sub
