VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form_Ficha_DefEval 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Definicion de Fechas de Evaluación"
   ClientHeight    =   4365
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9015
   Icon            =   "FechasEvaluacion.frx":0000
   LinkTopic       =   "Form3"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4365
   ScaleWidth      =   9015
   Begin VB.Frame Frame1 
      Caption         =   "Fecha de Evaluación"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   4095
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   8775
      Begin VB.Frame frmFecha 
         Caption         =   "Nueva Fecha"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   2895
         Left            =   1080
         TabIndex        =   5
         Top             =   600
         Visible         =   0   'False
         Width           =   6615
         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            =   4800
            MaxLength       =   5
            TabIndex        =   17
            Text            =   "120"
            Top             =   1680
            Width           =   1455
         End
         Begin VB.ComboBox cmbagno 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            ItemData        =   "FechasEvaluacion.frx":2A8B2
            Left            =   4800
            List            =   "FechasEvaluacion.frx":2A8C8
            Style           =   2  'Dropdown List
            TabIndex        =   14
            Top             =   1200
            Width           =   1455
         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          =   495
            Left            =   4800
            Style           =   1  'Graphical
            TabIndex        =   13
            Top             =   2280
            Width           =   1575
         End
         Begin VB.CommandButton btn_aceptar 
            Caption         =   "&Aceptar"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   495
            Left            =   3120
            Style           =   1  'Graphical
            TabIndex        =   11
            Top             =   2280
            Width           =   1575
         End
         Begin VB.ComboBox cmbHora 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            ItemData        =   "FechasEvaluacion.frx":2A8DE
            Left            =   3120
            List            =   "FechasEvaluacion.frx":2A91C
            Sorted          =   -1  'True
            Style           =   2  'Dropdown List
            TabIndex        =   9
            Top             =   1200
            Width           =   1575
         End
         Begin MSComCtl2.MonthView fechaevalfinal 
            Height          =   2520
            Left            =   120
            TabIndex        =   6
            Top             =   240
            Width           =   2490
            _ExtentX        =   4392
            _ExtentY        =   4445
            _Version        =   393216
            ForeColor       =   -2147483630
            BackColor       =   -2147483633
            Appearance      =   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
            StartOfWeek     =   253558786
            CurrentDate     =   43332
            MinDate         =   38353
         End
         Begin VB.Label Label4 
            Caption         =   "Cupos:"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   4200
            TabIndex        =   16
            Top             =   1680
            Width           =   615
         End
         Begin VB.Label Label3 
            Alignment       =   2  'Center
            Caption         =   "Año De Postulació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            =   4800
            TabIndex        =   15
            Top             =   960
            Width           =   1575
         End
         Begin VB.Label lblFecha 
            BackColor       =   &H8000000E&
            BorderStyle     =   1  'Fixed Single
            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            =   3120
            TabIndex        =   12
            Top             =   600
            Width           =   3135
         End
         Begin VB.Label Label2 
            Caption         =   "Hora:"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   3120
            TabIndex        =   10
            Top             =   960
            Width           =   1575
         End
         Begin VB.Label lblFecha 
            BackColor       =   &H8000000E&
            BorderStyle     =   1  'Fixed Single
            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            =   3120
            TabIndex        =   7
            Top             =   360
            Width           =   3135
         End
         Begin VB.Label Label1 
            Caption         =   "Fecha:"
            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        =   8
            Top             =   120
            Width           =   3015
         End
      End
      Begin VB.CommandButton Command3 
         Caption         =   "&Eliminar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   915
         Left            =   6960
         Picture         =   "FechasEvaluacion.frx":2A989
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   1320
         Width           =   1695
      End
      Begin VB.CommandButton Command1 
         Caption         =   "&Definir Nueva Fecha"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   915
         Left            =   6960
         Picture         =   "FechasEvaluacion.frx":2AFEC
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   240
         Width           =   1695
      End
      Begin VB.PictureBox picBOX 
         AutoRedraw      =   -1  'True
         AutoSize        =   -1  'True
         BackColor       =   &H8000000C&
         BorderStyle     =   0  'None
         Height          =   1020
         Left            =   1920
         Picture         =   "FechasEvaluacion.frx":2B675
         ScaleHeight     =   1020
         ScaleWidth      =   3150
         TabIndex        =   2
         Top             =   1680
         Width           =   3150
      End
      Begin MSFlexGridLib.MSFlexGrid msfgfeceval 
         Height          =   3735
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   6735
         _ExtentX        =   11880
         _ExtentY        =   6588
         _Version        =   393216
         Cols            =   5
         FixedCols       =   0
         BackColorSel    =   16761024
         ForeColorSel    =   -2147483640
         FillStyle       =   1
         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
   End
End
Attribute VB_Name = "Form_Ficha_DefEval"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Numero As Integer
Private Sub btn_aceptar_Click()
If Not versiestafecha() Then
    Dim grabardatos As ADODB.Command
    
    Set grabardatos = New ADODB.Command
    
    grabardatos.CommandType = adCmdText
    grabardatos.ActiveConnection = conn
    grabardatos.CommandText = "INSERT INTO FECHASEVALUACION SET eval_fechora='" & Format(Me.lblFecha(0).Caption, "YYYY-mm-dd") & "  " & cmbHora.Text & "', agno_postulacion=" & cmbagno.Text & ",cupos=" & Text1.Text
    grabardatos.Execute
    llenarGrillaFec
    Me.frmFecha.Enabled = False
    Me.frmFecha.Visible = False
    
     llenarGrillaFec
Else
    MsgBox "La Fecha programada ya existe para el año asignado", , "Monitor de Fechas"
End If
End Sub

Private Sub btn_Cancelar_Click()
    frmFecha.Visible = False
    frmFecha.Enabled = False
       llenarGrillaFec
    
End Sub

Private Sub Command1_Click()
    Me.frmFecha.Enabled = True
    Me.frmFecha.Visible = True
    Me.lblFecha(0).Caption = Format(Me.fechaevalfinal.Value, "dd-mm-YYYY")
    Me.lblFecha(1).Caption = Format(Me.fechaevalfinal.Value, "long date")
    cmbHora.ListIndex = 0
    cmbagno.ListIndex = Year(Date) - 2018
    Me.cmbagno.ListIndex = Year(Date) - (2018 + 1)
End Sub


Private Sub Command3_Click()
    Dim busque As ADODB.Recordset
    Dim borre As ADODB.Command
    Dim fechax, horax As String
    Set busque = New ADODB.Recordset
    Me.msfgfeceval.Col = 1
    fechax = Format(Trim(Me.msfgfeceval.Text), "YYYY-mm-dd")
    Me.msfgfeceval.Col = 2
    horax = Format(Trim(Me.msfgfeceval.Text), "HH:MM:SS")
    Me.msfgfeceval.Col = 3
    agnox = Trim(Me.msfgfeceval.Text)
    
    busque.Open "select count(vii_hor_eval) as total_enc from postulaciones where vii_hor_eval='" & fechax & " " & horax & "' and anno_pos_alu=" & agnox, conn
    
    If busque!total_enc > 0 Then
        MsgBox "No se puede borra dicha fecha ya que existen alumnos con esa fecha de evaluación", vbOKOnly, "Eliminacion de Fechas"
        busque.Close
        Exit Sub
    Else
        Set borre = New ADODB.Command
        borre.ActiveConnection = conn
        borre.CommandType = adCmdText
        borre.CommandText = "Delete from fechasevaluacion where eval_fechora='" & fechax & " " & horax & "' and agno_postulacion=" & agnox
        borre.Execute
        busque.Close
        llenarGrillaFec
    End If
    
    
    Me.msfgfeceval.Col = 0
    Me.msfgfeceval.ColSel = Me.msfgfeceval.Cols - 1
End Sub

Private Sub fechaevalfinal_DateClick(ByVal DateClicked As Date)
    Me.lblFecha(0).Caption = Format(Me.fechaevalfinal.Value, "dd-mm-YYYY")
    Me.lblFecha(1).Caption = Format(Me.fechaevalfinal.Value, "long date")
    Me.cmbagno.ListIndex = Year(DateClicked) - (2018)
End Sub

Private Sub Form_Load()
    Numero = 120
    llenarGrillaFec
    Me.fechaevalfinal.MinDate = Date
   
End Sub

Private Sub llenarGrillaFec()
    Dim fechaseval As ADODB.Recordset
    Dim indx As Integer
    
    indx = 1
    
    Set fechaseval = New ADODB.Recordset
    
    fechaseval.Open "Select date_format(eval_fechora,'%d-%m-%Y') as fechaev, date_format(eval_fechora,'%H:%i') as horaev, agno_postulacion as agnoev, cupos from fechasevaluacion order by agno_postulacion desc, eval_fechora desc", conn
    
    Me.msfgfeceval.Row = 0
    Me.msfgfeceval.ColWidth(0) = 0
    Me.msfgfeceval.ColWidth(1) = 2000
    Me.msfgfeceval.Col = 1
    Me.msfgfeceval.CellFontBold = True
    Me.msfgfeceval.CellAlignment = 1
    Me.msfgfeceval.Text = "Fecha de Evaluación"
    
    Me.msfgfeceval.ColWidth(2) = 1700
    Me.msfgfeceval.Col = 2
    Me.msfgfeceval.CellFontBold = True
    Me.msfgfeceval.CellAlignment = 1
    Me.msfgfeceval.Text = "Hora de Evaluación"
    Me.msfgfeceval.CellAlignment = 2
    
    Me.msfgfeceval.ColWidth(3) = 1700
    Me.msfgfeceval.Col = 3
    Me.msfgfeceval.CellFontBold = True
    Me.msfgfeceval.CellAlignment = 1
    Me.msfgfeceval.Text = "Año Postulación"
    
    Me.msfgfeceval.ColWidth(4) = 1000
    Me.msfgfeceval.Col = 4
    Me.msfgfeceval.CellFontBold = True
    Me.msfgfeceval.CellAlignment = 1
    Me.msfgfeceval.Text = "Cupos"
    
    If fechaseval.RecordCount > 0 Then
        Me.picBOX.Visible = False
        
        With Me.msfgfeceval
            .Rows = fechaseval.RecordCount + 1
            While Not fechaseval.EOF
                .Row = indx
                .Col = 1
                .CellAlignment = 3
                .Text = fechaseval!fechaev
                .Col = 2
                .CellAlignment = 3
                .Text = fechaseval!horaev
                .Col = 3
                .CellAlignment = 3
                .Text = fechaseval!agnoev
                .Col = 4
                .CellAlignment = 3
                .Text = fechaseval!cupos
                indx = indx + 1
                fechaseval.MoveNext
            Wend
        End With
    End If
    
        
    Me.msfgfeceval.ColSel = Me.msfgfeceval.Cols - 1
    
 Me.Show
 fechaseval.Close
    
End Sub


Private Sub msfgfeceval_Click()
     Me.msfgfeceval.ColSel = Me.msfgfeceval.Cols - 1
End Sub

Private Sub Text1_Change()
If Text1.Text = "" Then Text1.Text = 1
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If (Chr(KeyAscii) >= "0" And Chr(KeyAscii) <= "9") Or KeyAscii = 8 Then Exit Sub
KeyAscii = 0
End Sub

Private Function versiestafecha() As Boolean
Dim X As Integer
versiestafecha = False

For X = 1 To Me.msfgfeceval.Rows - 1
    Me.msfgfeceval.Col = 1
    If Trim(Me.lblFecha(0).Caption) = Trim(Me.msfgfeceval.Text) Then
        Me.msfgfeceval.Col = 2
        If Trim(Me.cmbHora.Text) = Trim(Me.msfgfeceval.Text) Then
            Me.msfgfeceval.Col = 3
            If Trim(Me.cmbagno.Text) = Trim(Me.msfgfeceval.Text) Then
                versiestafecha = True
            End If
        End If
    End If
Next

                
    
End Function
