VERSION 5.00
Object = "{00025600-0000-0000-C000-000000000046}#4.6#0"; "crystl32.ocx"
Begin VB.Form Form_Convenios 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Imprimir Convenios"
   ClientHeight    =   2205
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4665
   Icon            =   "Form_Convenios.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2205
   ScaleWidth      =   4665
   Begin Crystal.CrystalReport cr_convenios 
      Left            =   2160
      Top             =   240
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   262150
   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       =   &H00C00000&
      Height          =   735
      Left            =   3000
      TabIndex        =   7
      Top             =   120
      Width           =   1575
      Begin VB.ComboBox cb_agno 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   240
         TabIndex        =   8
         Text            =   "Combo1"
         Top             =   240
         Width           =   1095
      End
   End
   Begin VB.CommandButton cmd_Salir 
      Caption         =   "Salir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3120
      TabIndex        =   6
      Top             =   1560
      Width           =   1335
   End
   Begin VB.CommandButton cmd_Imprimir 
      Caption         =   "Imprimir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3120
      TabIndex        =   5
      Top             =   1080
      Width           =   1335
   End
   Begin VB.Frame Frame1 
      Caption         =   "Seleccione Convenio"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1935
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2655
      Begin VB.OptionButton Option1 
         Caption         =   "Convenio Municipalidad"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   3
         Left            =   240
         TabIndex        =   4
         Top             =   1320
         Width           =   2175
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Convenio Investigaciones"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   2
         Left            =   240
         TabIndex        =   3
         Top             =   960
         Width           =   2295
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Convenio Carabineros"
         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        =   2
         Top             =   720
         Width           =   2055
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Convenio Jardin"
         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        =   1
         Top             =   360
         Value           =   -1  'True
         Width           =   1695
      End
   End
End
Attribute VB_Name = "Form_Convenios"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd_imprimir_Click()
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql, est, dir, conv As String
    var_sql = "SELECT nom_est,dir_est FROM establecimientos"
    objRS.Open var_sql, conn
    var_sql = "drop table if exists temp_convenios;"
    conn.Execute var_sql
    If Not objRS.EOF Then
        est = objRS("nom_est")
        dir = objRS("dir_est")
    End If
    objRS.Close
    
    If Option1(0).Value = True Then
        var_sql = "create table temp_convenios type = MyISAM" _
                & " select p.ci_alu,concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as 'Nombre_Alumno'," _
                & "run_apo as 'Rut_Apo',concat(axc.num_gra,' ',axc.let_cur,' '," _
                & "if(axc.cod_ens='996','PK',if(axc.cod_ens='010','K','EB'))) as 'Curso','CONVENIO JARDIN' as 'Convenio',jardin as 'Jardín'" _
                & " from postulantes p,alu_x_cur axc,fnza_convenio_jardin fcj" _
                & " where p.ci_alu = axc.ci_alu and p.ci_alu = fcj.run_alu and axc.agno = fcj.agno and fcj.agno = " & cb_agno.Text & " and activo_alu = 'SI'"
        conn.Execute var_sql
    Else
        If Option1(1).Value = True Then conv = "1"
        If Option1(2).Value = True Then conv = "2"
        If Option1(3).Value = True Then conv = "3"
        var_sql = "create table temp_convenios type = MyISAM" _
                & " select p.ci_alu as 'Rut_Alu',concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as 'Nombre_Alumno'," _
                & "a.rut_apo as 'Rut_Apo',concat(ape1_apo,' ',ape2_apo,' ',noms_apo) as 'Nombre_Apoderado'," _
                & "concat(axc.num_gra,' ',axc.let_cur,' '," _
                & "if(axc.cod_ens='996','PK',if(axc.cod_ens='010','K','EB'))) as 'Curso',des_conv as 'Tipo_Convenio'" _
                & " from postulantes p,alu_x_cur axc,apo_x_alu axa,apoderados a,convenios c" _
                & " Where p.ci_alu = axc.ci_alu And p.ci_alu = axa.ci_alu And axa.Rut_apo = a.Rut_apo And axc.agno = axa.agno And axc.agno = " & cb_agno.Text _
                & " and a.cod_conv = c.cod_conv and activo_alu = 'SI'  and a.cod_conv = '" & conv & "'"
        conn.Execute var_sql
    End If
         
    Call LimpiaFormulas(cr_convenios, 30)
    If Option1(0).Value = True Then
        cr_convenios.ReportFileName = App.Path & "\Rpt\fnza_convenios_jardin.rpt"
    Else
        cr_convenios.ReportFileName = App.Path & "\Rpt\fnza_convenios.rpt"
    End If
    
    cr_convenios.Formulas(3) = "est = '" & est & "'"
    cr_convenios.Formulas(4) = "dir = '" & dir & "'"
        
    cr_convenios.Destination = crptToWindow
    
    cr_convenios.Action = 1
   
End Sub

Private Sub cmd_Salir_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Dim I As Integer
    For I = 2005 To Anno
        cb_agno.AddItem I
    Next I
    cb_agno.Text = Anno
End Sub
