VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{CDF3B183-D408-11CE-AE2C-0080C786E37D}#2.1#0"; "Edt32x20.ocx"
Begin VB.Form FCO3010 
   Caption         =   "Ejecución de Traslados"
   ClientHeight    =   1560
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3450
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "EjecutarTraslados.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   1560
   ScaleWidth      =   3450
   Begin EditLib.fpLongInteger txtMes 
      Height          =   315
      Left            =   2400
      TabIndex        =   5
      Top             =   510
      Width           =   735
      _Version        =   131072
      _ExtentX        =   1296
      _ExtentY        =   556
      _StockProps     =   68
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      ThreeDInsideStyle=   1
      ThreeDInsideHighlightColor=   -2147483633
      ThreeDInsideShadowColor=   -2147483642
      ThreeDInsideWidth=   1
      ThreeDOutsideStyle=   1
      ThreeDOutsideHighlightColor=   16777215
      ThreeDOutsideShadowColor=   -2147483632
      ThreeDOutsideWidth=   1
      ThreeDFrameWidth=   0
      BorderStyle     =   0
      BorderColor     =   -2147483642
      BorderWidth     =   1
      ButtonDisable   =   0   'False
      ButtonHide      =   0   'False
      ButtonIncrement =   1
      ButtonMin       =   1
      ButtonMax       =   100
      ButtonStyle     =   1
      ButtonWidth     =   0
      ButtonWrap      =   -1  'True
      ButtonDefaultAction=   -1  'True
      ThreeDText      =   0
      ThreeDTextHighlightColor=   -2147483633
      ThreeDTextShadowColor=   -2147483632
      ThreeDTextOffset=   1
      AlignTextH      =   2
      AlignTextV      =   1
      AllowNull       =   0   'False
      NoSpecialKeys   =   3
      AutoAdvance     =   0   'False
      AutoBeep        =   0   'False
      CaretInsert     =   0
      CaretOverWrite  =   3
      UserEntry       =   0
      HideSelection   =   -1  'True
      InvalidColor    =   -2147483637
      InvalidOption   =   0
      MarginLeft      =   3
      MarginTop       =   3
      MarginRight     =   3
      MarginBottom    =   3
      NullColor       =   -2147483637
      OnFocusAlignH   =   0
      OnFocusAlignV   =   0
      OnFocusNoSelect =   0   'False
      OnFocusPosition =   0
      ControlType     =   0
      Text            =   "0"
      MaxValue        =   "12"
      MinValue        =   "1"
      NegFormat       =   1
      NegToggle       =   0   'False
      Separator       =   ""
      UseSeparator    =   0   'False
      IncInt          =   1
      BorderGrayAreaColor=   -2147483637
      ThreeDOnFocusInvert=   0   'False
      ThreeDFrameColor=   -2147483633
      Appearance      =   0
      BorderDropShadow=   0
      BorderDropShadowColor=   -2147483632
      BorderDropShadowWidth=   3
      MouseIcon       =   "EjecutarTraslados.frx":030A
   End
   Begin EditLib.fpLongInteger txtAnio 
      Height          =   315
      Left            =   2400
      TabIndex        =   4
      Top             =   120
      Width           =   735
      _Version        =   131072
      _ExtentX        =   1296
      _ExtentY        =   556
      _StockProps     =   68
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      ThreeDInsideStyle=   1
      ThreeDInsideHighlightColor=   -2147483633
      ThreeDInsideShadowColor=   -2147483642
      ThreeDInsideWidth=   1
      ThreeDOutsideStyle=   1
      ThreeDOutsideHighlightColor=   16777215
      ThreeDOutsideShadowColor=   -2147483632
      ThreeDOutsideWidth=   1
      ThreeDFrameWidth=   0
      BorderStyle     =   0
      BorderColor     =   -2147483642
      BorderWidth     =   1
      ButtonDisable   =   0   'False
      ButtonHide      =   0   'False
      ButtonIncrement =   1
      ButtonMin       =   1
      ButtonMax       =   100
      ButtonStyle     =   1
      ButtonWidth     =   0
      ButtonWrap      =   -1  'True
      ButtonDefaultAction=   -1  'True
      ThreeDText      =   0
      ThreeDTextHighlightColor=   -2147483633
      ThreeDTextShadowColor=   -2147483632
      ThreeDTextOffset=   1
      AlignTextH      =   2
      AlignTextV      =   1
      AllowNull       =   0   'False
      NoSpecialKeys   =   3
      AutoAdvance     =   0   'False
      AutoBeep        =   0   'False
      CaretInsert     =   0
      CaretOverWrite  =   3
      UserEntry       =   0
      HideSelection   =   -1  'True
      InvalidColor    =   -2147483637
      InvalidOption   =   0
      MarginLeft      =   3
      MarginTop       =   3
      MarginRight     =   3
      MarginBottom    =   3
      NullColor       =   -2147483637
      OnFocusAlignH   =   0
      OnFocusAlignV   =   0
      OnFocusNoSelect =   0   'False
      OnFocusPosition =   0
      ControlType     =   0
      Text            =   "0"
      MaxValue        =   "2078"
      MinValue        =   "2002"
      NegFormat       =   1
      NegToggle       =   0   'False
      Separator       =   ""
      UseSeparator    =   0   'False
      IncInt          =   1
      BorderGrayAreaColor=   -2147483637
      ThreeDOnFocusInvert=   0   'False
      ThreeDFrameColor=   -2147483633
      Appearance      =   0
      BorderDropShadow=   0
      BorderDropShadowColor=   -2147483632
      BorderDropShadowWidth=   3
      MouseIcon       =   "EjecutarTraslados.frx":0326
   End
   Begin VB.CheckBox chkFPO 
      Caption         =   "&FPO"
      Height          =   255
      Left            =   240
      TabIndex        =   1
      Top             =   480
      Width           =   735
   End
   Begin VB.CheckBox chkEPS 
      Caption         =   "&EPS"
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   735
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   0
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      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
      Bands           =   "EjecutarTraslados.frx":0342
   End
   Begin VB.Label lblMes 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "&Mes:"
      Height          =   210
      Left            =   1920
      TabIndex        =   3
      Top             =   555
      Width           =   345
   End
   Begin VB.Label lblAnio 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "&Año:"
      Height          =   210
      Left            =   1920
      TabIndex        =   2
      Top             =   120
      Width           =   345
   End
End
Attribute VB_Name = "FCO3010"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MAdo As ODBC.ODBCDirecto
Private Micx As Integer 'Conexión
Private MiX As Integer 'Ancho de la forma
Private MiY As Integer 'Alta de la forma

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlejecuta": Procesar
        Case "tlsalida": Unload Me
    End Select
End Sub

Private Sub chkEPS_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then SendEnter
End Sub

Private Sub chkFPO_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then SendEnter
End Sub

Private Sub chkSucursal_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then SendEnter
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF11: Procesar
    End Select
End Sub

Private Sub Form_Load()
    GbAError = False
    Me.Tag = GiVenMax%
    Gven(Val(Me.Tag)).icx = Gicx%
    Micx = Gven(Val(Me.Tag)).icx
    Set MAdo = Gtc(Micx).Ado
    Me.Icon = LoadPicture(sIconoForma)
    
    'Checa nivel de seguridad
    Gven(Val(Me.Tag)).iNivSeguridad = iObtenNivSeguridad(GsOper, GsUid, Micx)
    If Gven(Val(Me.Tag)).iNivSeguridad = 0 Then
        Screen.MousePointer = vbDefault
        Me.Top = -10000
        GbAError = True
        Exit Sub
    End If
        
    If Not MDIChild Then
        WindowState = 0
        Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
        Screen.MousePointer = vbDefault
    End If
    
    'Tamaño de la forma
    If Me.WindowState = 0 Then
        MiX = 3570
        MiY = 1965
        Me.Width = MiX
        Me.Height = MiY
    End If

    AsignaIconos abToolbar, 3, LEJECUTA, LSALIDA
    
    txtAnio = IIf(Month(Date) = 12, Year(Date) - 1, Year(Date))
    txtMes = IIf(Month(Date) = 1, 12, Month(Date) - 1)
    
End Sub

Private Function DatosInvalidos() As Boolean
    DatosInvalidos = (Val(txtAnio) = 0 Or Val(txtMes) = 0)
    If DatosInvalidos Then
        If Val(txtAnio) = 0 Then
            clsMsgbox.Mensaje "Debe definir el año", mAceptar, mAdvierte, GsTitMsg
            txtAnio.SetFocus
        Else
            clsMsgbox.Mensaje "Debe definir el mes", mAceptar, mAdvierte, GsTitMsg
            txtMes.SetFocus
        End If
    End If
End Function

Private Sub Procesar()
    On Error GoTo AclararError
    Dim sSql As String
    If chkEPS.Value = vbUnchecked And chkFPO.Value = vbUnchecked Then
        clsMsgbox.Mensaje "No hay nada seleccionado para procesar", mAceptar, mAdvierte, GsTitMsg
        Exit Sub
    End If
    If DatosInvalidos Then Exit Sub
    
    If chkEPS.Value = vbChecked Then
        MAdo.Sql = "sp_fco_proc_traslados_eps '" & GsCveCia & "'," & txtAnio & "," & txtMes
        Screen.MousePointer = vbDefault
        If clsMsgbox.Mensaje("¿Confirma que desea efectuar el proceso de traslados de EPS?", mSiNoCancelar, mConfirma, GsTitMsg) = vbYes Then
            Screen.MousePointer = vbHourglass
            If MAdo.ExecSQL = -1 Then GoTo AclararError
            Screen.MousePointer = vbDefault
            clsMsgbox.Mensaje "Los traslados de EPS han sido realizados", mAceptar, minforma, GsTitMsg
        End If
    End If
    
    If chkFPO.Value = vbChecked Then
        MAdo.Sql = "sp_fco_proc_traslados_fpo '" & GsCveCia & "'," & txtAnio & "," & txtMes
        Screen.MousePointer = vbDefault
        If clsMsgbox.Mensaje("¿Confirma que desea efectuar el proceso de traslados de Fondo de Pensiones?", mSiNoCancelar, mConfirma, GsTitMsg) = vbYes Then
            Screen.MousePointer = vbHourglass
            If MAdo.ExecSQL = -1 Then GoTo AclararError
            Screen.MousePointer = vbDefault
            clsMsgbox.Mensaje "Los traslados de FPO han sido realizados", mAceptar, minforma, GsTitMsg
        End If
    End If
    
    Exit Sub
AclararError:
    Screen.MousePointer = vbDefault
    If Err > 0 Then
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set MAdo = Nothing
    Gtc(Micx).ihijas = Gtc(Micx).ihijas - 1
    Set FCO3010 = Nothing

End Sub

Private Sub Form_Unload(Cancel As Integer)
    If GbExterno Then End
End Sub

Private Sub txtAnio_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub

Private Sub txtMes_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendEnter
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub
