VERSION 5.00
Begin VB.Form Form_Vacantes 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Edicion de Vacantes"
   ClientHeight    =   8445
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   3270
   FillColor       =   &H80000002&
   ForeColor       =   &H00FF0000&
   Icon            =   "Form_Vacantes.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   8445
   ScaleWidth      =   3270
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   13
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   30
      Text            =   "Text1"
      Top             =   5880
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   12
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   29
      Text            =   "Text1"
      Top             =   5520
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   11
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   28
      Text            =   "Text1"
      Top             =   5160
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   10
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   27
      Text            =   "Text1"
      Top             =   4800
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   9
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   26
      Text            =   "Text1"
      Top             =   4440
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   8
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   25
      Text            =   "Text1"
      Top             =   4080
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   7
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   24
      Text            =   "Text1"
      Top             =   3720
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   6
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   23
      Text            =   "Text1"
      Top             =   3360
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   5
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   22
      Text            =   "Text1"
      Top             =   3000
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   4
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   21
      Text            =   "Text1"
      Top             =   2640
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   3
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   20
      Text            =   "Text1"
      Top             =   2280
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   2
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   19
      Text            =   "Text1"
      Top             =   1920
      Width           =   615
   End
   Begin VB.TextBox txt_lista 
      Height          =   285
      Index           =   1
      Left            =   1560
      MaxLength       =   3
      TabIndex        =   18
      Text            =   "Text1"
      Top             =   1560
      Width           =   615
   End
   Begin VB.Frame Frame1 
      Caption         =   "Edición de Vacantes"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000001&
      Height          =   7815
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2535
      Begin VB.ComboBox Combo1 
         Height          =   315
         Left            =   120
         TabIndex        =   64
         Text            =   "Combo1"
         Top             =   360
         Width           =   2175
      End
      Begin VB.CommandButton btnGuardar 
         Caption         =   "Guardar"
         Height          =   615
         Left            =   240
         Picture         =   "Form_Vacantes.frx":2A8B2
         Style           =   1  'Graphical
         TabIndex        =   63
         Top             =   6600
         Width           =   1695
      End
      Begin VB.TextBox txt_lista 
         Height          =   285
         Index           =   14
         Left            =   1440
         MaxLength       =   3
         TabIndex        =   59
         Text            =   "Text1"
         Top             =   6120
         Visible         =   0   'False
         Width           =   615
      End
      Begin VB.TextBox txt_lista 
         Height          =   285
         Index           =   0
         Left            =   1440
         MaxLength       =   3
         TabIndex        =   17
         Text            =   "Text1"
         Top             =   1080
         Width           =   615
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   14
         Left            =   120
         TabIndex        =   62
         Top             =   6120
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   14
         Left            =   360
         TabIndex        =   61
         Top             =   6120
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   14
         Left            =   720
         TabIndex        =   60
         Top             =   6120
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   13
         Left            =   840
         TabIndex        =   58
         Top             =   5760
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   12
         Left            =   960
         TabIndex        =   57
         Top             =   5400
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   11
         Left            =   960
         TabIndex        =   56
         Top             =   5040
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   10
         Left            =   960
         TabIndex        =   55
         Top             =   4680
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   9
         Left            =   960
         TabIndex        =   54
         Top             =   4320
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   8
         Left            =   960
         TabIndex        =   53
         Top             =   3960
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   7
         Left            =   960
         TabIndex        =   52
         Top             =   3600
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   6
         Left            =   960
         TabIndex        =   51
         Top             =   3240
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   5
         Left            =   960
         TabIndex        =   50
         Top             =   2880
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   4
         Left            =   960
         TabIndex        =   49
         Top             =   2520
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   3
         Left            =   960
         TabIndex        =   48
         Top             =   2160
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   2
         Left            =   960
         TabIndex        =   47
         Top             =   1800
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   1
         Left            =   960
         TabIndex        =   46
         Top             =   1440
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_numero 
         Caption         =   "Label1"
         Height          =   255
         Index           =   0
         Left            =   960
         TabIndex        =   45
         Top             =   1080
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   13
         Left            =   480
         TabIndex        =   44
         Top             =   5760
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   12
         Left            =   600
         TabIndex        =   43
         Top             =   5400
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   11
         Left            =   600
         TabIndex        =   42
         Top             =   5040
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   10
         Left            =   600
         TabIndex        =   41
         Top             =   4680
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   9
         Left            =   600
         TabIndex        =   40
         Top             =   4320
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   8
         Left            =   600
         TabIndex        =   39
         Top             =   3960
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   7
         Left            =   600
         TabIndex        =   38
         Top             =   3600
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   6
         Left            =   600
         TabIndex        =   37
         Top             =   3240
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   5
         Left            =   600
         TabIndex        =   36
         Top             =   2880
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   4
         Left            =   600
         TabIndex        =   35
         Top             =   2520
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   3
         Left            =   600
         TabIndex        =   34
         Top             =   2160
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   2
         Left            =   600
         TabIndex        =   33
         Top             =   1800
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   1
         Left            =   600
         TabIndex        =   32
         Top             =   1440
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_cod 
         Caption         =   "Label1"
         Height          =   255
         Index           =   0
         Left            =   600
         TabIndex        =   31
         Top             =   1080
         Visible         =   0   'False
         Width           =   375
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   13
         Left            =   120
         TabIndex        =   16
         Top             =   5760
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   12
         Left            =   120
         TabIndex        =   15
         Top             =   5400
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   11
         Left            =   120
         TabIndex        =   14
         Top             =   5040
         Width           =   975
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   10
         Left            =   120
         TabIndex        =   13
         Top             =   4680
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   9
         Left            =   120
         TabIndex        =   12
         Top             =   4320
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   8
         Left            =   120
         TabIndex        =   11
         Top             =   3960
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   7
         Left            =   120
         TabIndex        =   10
         Top             =   3600
         Width           =   1215
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   6
         Left            =   120
         TabIndex        =   9
         Top             =   3240
         Width           =   1215
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   5
         Left            =   120
         TabIndex        =   8
         Top             =   2880
         Width           =   1215
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   4
         Left            =   120
         TabIndex        =   7
         Top             =   2520
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   3
         Left            =   120
         TabIndex        =   6
         Top             =   2160
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   2
         Left            =   120
         TabIndex        =   5
         Top             =   1800
         Width           =   1215
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   1
         Left            =   120
         TabIndex        =   4
         Top             =   1440
         Width           =   1095
      End
      Begin VB.Label lbl_lista 
         Caption         =   "Label1"
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   3
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label Vacantes 
         Caption         =   "Vacantes"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1440
         TabIndex        =   2
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Niveles 
         Caption         =   "Niveles"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   720
         Width           =   615
      End
   End
End
Attribute VB_Name = "Form_Vacantes"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub BtnGuardar_Click()
Dim var_sql
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim arrValor1(15) As Integer
Dim arrNiveles(15) As String
Dim arrValor2(15) As Integer
Dim cont As Integer
Dim contGlobal As Integer ' es para saber cuantos cursos estana activados en primera instancia
Dim accion As String

contGlobal = 0
cont = 0

'1.- lleno el primer arreglo con los datos originales
    var_sql = "SELECT a.cod_ens AS codigo, c.NUM_GRA numero, CONCAT(c.NUM_GRA,'° ',a.des_ens_abrev)   AS grado,a.cod_des AS letra , a.des_ens,b.vacantes,b.agno FROM codigos_ensenanza a INNER JOIN vacantes b INNER JOIN grados c ON   a.cod_ens = b.cod_ens AND  b.cod_ens =c.cod_ens AND  b.num_gra =  c.num_gra where agno = '" & Me.Combo1.Text & "' ORDER BY a.ord_ens,b.NUM_GRA "
    objRS.Open var_sql, conn

While Not objRS.EOF
        contGlobal = cont
        arrValor1(cont) = objRS("vacantes")
        arrNiveles(cont) = objRS("grado")
        cont = cont + 1
        objRS.MoveNext
Wend
objRS.Close

    

' si el permiso contiene un 1 puede updatear
         
    var_sql = "SELECT permisos_vacantes AS permiso FROM usuarios WHERE AUT_NOMBRE_USUARIO = '" & Nom_usu_ses & "' "

    conn.Execute var_sql

    objRS.Open var_sql, conn
    
    valor = objRS("permiso")
    objRS.Close
    

     If valor = 1 Then
    
       For i = 0 To (lbl_lista.count - 1)
        ' log
        ' hist_vitacora_alumno('','la vacante')
               
        var_sql = "UPDATE vacantes SET vacantes = '" & txt_lista(i).Text & "' WHERE cod_ens = '" & lbl_cod(i) & "' AND num_gra = '" & lbl_numero(i) & "' AND agno = '" & Me.Combo1.Text & "'"
        conn.Execute var_sql
                               
       Next
    
        MsgBox "Vacantes Editadas Satisfactoriamente"
        
     Else
        MsgBox "Usted no Tiene Permisos para Ejecutar ésta Acción"
        Unload Me
     End If

    
    ' 2 .- lleno el segundo arreglo con los datos nuevos
    If valor = 1 Then
        var_sql = "SELECT a.cod_ens AS codigo, c.NUM_GRA numero, CONCAT(c.NUM_GRA,'° ',a.des_ens_abrev)   AS grado,a.cod_des AS letra , a.des_ens,b.vacantes,b.agno FROM codigos_ensenanza a INNER JOIN vacantes b INNER JOIN grados c ON   a.cod_ens = b.cod_ens AND  b.cod_ens =c.cod_ens AND  b.num_gra =  c.num_gra where agno = '" & Me.Combo1.Text & "' ORDER BY a.ord_ens,b.NUM_GRA "
        objRS.Open var_sql, conn
        
        
        cont = 0
        While Not objRS.EOF
        
            arrValor2(cont) = objRS("vacantes")
            
            cont = cont + 1
            objRS.MoveNext
        Wend
        objRS.Close
        
    End If
    
        If valor = 1 Then
            For i = 0 To 15
     
                    If arrValor1(i) <> arrValor2(i) Then
                       ' MsgBox "El nivel: " & arrNiveles(i) & ":" & "tenia " & arrValor1(i) & " vacantes " & "fueron remplazadas por: " & arrValor2(i) & " vacantes"
                         accion = "El nivel: " & arrNiveles(i) & ", Año " & Me.Combo1.Text & ", constaba con: " & arrValor1(i) & " vacantes " & "fueron remplazadas por: " & arrValor2(i) & " vacantes"
                         X = Inserta_Vitacora_Alumno("", accion)
                    End If
                Next
            Unload Me
        End If

End Sub

Private Sub Combo1_Click()
Dim var_sql
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
cont = 0


    var_sql = "SELECT a.cod_ens AS codigo, c.NUM_GRA numero, CONCAT(c.NUM_GRA,'° ',a.des_ens_abrev)   AS grado,a.cod_des AS letra , a.des_ens,b.vacantes,b.agno FROM codigos_ensenanza a INNER JOIN vacantes b INNER JOIN grados c ON   a.cod_ens = b.cod_ens AND  b.cod_ens =c.cod_ens AND  b.num_gra =  c.num_gra where agno = '" & Me.Combo1.Text & "' ORDER BY a.ord_ens,b.NUM_GRA "
            
    objRS.Open var_sql, conn

While Not objRS.EOF
       
        
        lbl_lista(cont) = objRS("grado")
        txt_lista(cont) = objRS("vacantes")
        lbl_cod(cont) = objRS("codigo")
        lbl_numero(cont) = objRS("numero")
      
        cont = cont + 1

         If cont = 15 Then
         lbl_lista(14).Visible = True
         txt_lista(14).Visible = True
         End If
         
        objRS.MoveNext
Wend
objRS.Close

End Sub

Private Sub Form_Load()

Dim var_sql
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
cont = 0
Dim i As Integer

For i = 2014 To Year(Date) + 1
Me.Combo1.AddItem i
Next
Me.Combo1.Text = Year(Date)

    var_sql = "SELECT a.cod_ens AS codigo, c.NUM_GRA numero, CONCAT(c.NUM_GRA,'° ',a.des_ens_abrev)   AS grado,a.cod_des AS letra , a.des_ens,b.vacantes,b.agno FROM codigos_ensenanza a INNER JOIN vacantes b INNER JOIN grados c ON   a.cod_ens = b.cod_ens AND  b.cod_ens =c.cod_ens AND  b.num_gra =  c.num_gra where agno = '" & Me.Combo1.Text & "' ORDER BY a.ord_ens,b.NUM_GRA "
            
    objRS.Open var_sql, conn

While Not objRS.EOF
       
        
        lbl_lista(cont) = objRS("grado")
        txt_lista(cont) = objRS("vacantes")
        lbl_cod(cont) = objRS("codigo")
        lbl_numero(cont) = objRS("numero")
     
        cont = cont + 1

         If cont = 15 Then
         lbl_lista(14).Visible = True
         txt_lista(14).Visible = True
         End If
         
        objRS.MoveNext
Wend
objRS.Close

End Sub

Private Sub txt_lista_KeyPress(Index As Integer, KeyAscii As Integer)
strvalid = "1234567890"

KeyAscii = Asc(Chr(KeyAscii))

If (KeyAscii > 10) Then
    If InStr(strvalid, Chr(KeyAscii)) = 0 Then
    KeyAscii = 0
    End If
End If

End Sub
