VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{AB3877A8-B7B2-11CF-9097-444553540000}#1.0#0"; "gtdate32.ocx"
Begin VB.Form FCO2030A 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Alta de Traslados Administradoras"
   ClientHeight    =   2295
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6810
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Traslados Administradoras_A.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2295
   ScaleWidth      =   6810
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtFPONueva 
      Height          =   315
      Left            =   1440
      TabIndex        =   8
      Top             =   810
      Width           =   975
   End
   Begin VB.TextBox txtFPOActual 
      Height          =   285
      Left            =   1440
      Locked          =   -1  'True
      TabIndex        =   5
      Top             =   450
      Width           =   975
   End
   Begin VB.TextBox txtTrabajador 
      Height          =   285
      Left            =   1440
      TabIndex        =   0
      Top             =   90
      Width           =   975
   End
   Begin GTMaskDate.GTMaskDate fpFecha 
      Height          =   300
      HelpContextID   =   722
      Left            =   1440
      TabIndex        =   10
      Top             =   1170
      Width           =   1320
      _Version        =   65537
      _ExtentX        =   2328
      _ExtentY        =   529
      _StockProps     =   77
      BackColor       =   -2147483643
      BeginProperty NullFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty CalFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty CalCaptionFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty CalDayCaptionFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty ToolTipFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   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           =   "Traslados Administradoras_A.frx":030A
   End
   Begin VB.Label lblFPONueva 
      BackStyle       =   0  'Transparent
      Caption         =   "Nombre del Fondo"
      ForeColor       =   &H00800000&
      Height          =   255
      Left            =   3240
      TabIndex        =   9
      Top             =   870
      Width           =   3495
   End
   Begin VB.Image imgListaFPO 
      Height          =   375
      Index           =   0
      Left            =   2625
      Top             =   765
      Width           =   405
   End
   Begin VB.Image imgListaTra 
      Height          =   375
      Index           =   0
      Left            =   2640
      Top             =   90
      Width           =   405
   End
   Begin VB.Label lblFPOActual 
      BackStyle       =   0  'Transparent
      Caption         =   "Nombre del Fondo"
      ForeColor       =   &H00800000&
      Height          =   255
      Left            =   3240
      TabIndex        =   7
      Top             =   495
      Width           =   3495
   End
   Begin VB.Label lblTrab 
      BackStyle       =   0  'Transparent
      Caption         =   "Nombre del paisano"
      ForeColor       =   &H00800000&
      Height          =   255
      Left            =   3240
      TabIndex        =   6
      Top             =   135
      Width           =   3495
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "Fecha"
      Height          =   255
      Index           =   3
      Left            =   360
      TabIndex        =   4
      Top             =   1170
      Width           =   975
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "xxx Nueva"
      Height          =   255
      Index           =   2
      Left            =   360
      TabIndex        =   3
      Top             =   825
      Width           =   975
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "xxx Actual"
      Height          =   255
      Index           =   1
      Left            =   360
      TabIndex        =   2
      Top             =   450
      Width           =   975
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "Trabajador"
      Height          =   255
      Index           =   0
      Left            =   345
      TabIndex        =   1
      Top             =   90
      Width           =   975
   End
   Begin VB.Image imgListaTra 
      Height          =   375
      Index           =   1
      Left            =   2640
      Top             =   90
      Width           =   405
   End
   Begin VB.Image imgListaFPO 
      Height          =   375
      Index           =   1
      Left            =   2625
      Top             =   765
      Width           =   405
   End
End
Attribute VB_Name = "FCO2030A"
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 MBCambio As Boolean
Private MbFocoForm As Boolean
Private MsCodAgr As String

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlguarda"
            If bValidarDatos Then GuardaCambios: Unload Me
        Case "tlsalida"
            If MBCambio Then
                If clsMsgbox.Mensaje("¿Desea guardar los cambios?", mSiNoCancelar, mConfirma, GsTitMsg) = vbYes Then
                    GuardaCambios
                End If
            End If
            Unload Me
    End Select
End Sub

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

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF4
            If ActiveControl.Name = "txtTrabajador" Then
                imgListaTra_Click 0
            Else
                imgListaFPO_Click 0
            End If
        Case vbKeyF11
    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
    If GbSinRegistrar Then RegistraVersion Mado
    
    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 = 6900
        MiY = 2670
        Me.Width = MiX
        Me.Height = MiY
    End If
    
    If GsTipo = "EPS" Then
      Caption = GsDsn & " / " & GsCveCia & " - Alta de traslado de EPS"
      lblLabels(1).Caption = "EPS Actual"
      lblLabels(2).Caption = "EPS Nueva"
    Else
      Caption = GsDsn & " / " & GsCveCia & " - Alta de traslado de AFP"
      lblLabels(1).Caption = "AFP Actual"
      lblLabels(2).Caption = "AFP Nueva"
    End If
    
    AsignaIconos abToolbar, 3, LGUARDA, LSALIDA
    lblTrab = ""
    lblFPOActual = ""
    lblFPONueva = ""
    
    GAdam.ConfiguraFecha fpFecha, True
    fpFecha.Text = Date
    
    imgListaTra(0).Picture = LoadPicture(App.Path & "\images\F4a2.ico")
    imgListaTra(1).Picture = LoadPicture(App.Path & "\images\F4a1.ico")
    imgListaFPO(0).Picture = LoadPicture(App.Path & "\images\F4a2.ico")
    imgListaFPO(1).Picture = LoadPicture(App.Path & "\images\F4a1.ico")
    
    MsCodAgr = sRecuperarParamALA(Mado, IIf(GsTipo = "EPS", 21, 22))
    MBCambio = False
    MbFocoForm = True
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Not MbFocoForm Then
        imgListaTra(0).ZOrder
        imgListaFPO(0).ZOrder
    End If
    MbFocoForm = True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set Mado = Nothing
    Set FCO2030A = Nothing

End Sub

Private Sub imgListaTra_Click(Index As Integer)
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT t.trabajador, REPLACE(t.nombre,'/',' ')" & _
    " FROM trabajadores t, trabajadores_grales tg " & _
    " WHERE t.trabajador = tg.trabajador" & _
    " AND tg.compania = '" & GsCveCia & "'" & _
    " AND tg.sit_trabajador=1" & _
    " AND tg.clase_nomina in (SELECT clase_nomina FROM rel_usu_clase_nom WHERE usuario = '" & GsUid & "')"
    GsParamIN(1) = "t.trabajador"
    GsParamIN(2) = "t.nombre"
    GsParamIN(3) = "Trabajador"
    GsParamIN(4) = "Nombre"
    GsParamIN(5) = "Trabajadores"
    GsParamIN(6) = ""
    frmLista.Show 1
    txtTrabajador = GsParamOUT(0)
    lblTrab = Replace(GsParamOUT(1), "/", " ")
    If Trim(txtTrabajador) <> "" Then MBCambio = True
    HallarAdmActual
End Sub

Private Sub imgListaTra_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
    imgListaTra(1).ZOrder
    MbFocoForm = False
End Sub

Private Sub imgListaFPO_Click(Index As Integer)
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT dato, descripcion FROM datos_agr_trab WHERE agrupacion='" & MsCodAgr & "' AND dato<>'" & txtFPOActual & "'"
    GsParamIN(1) = "dato"
    GsParamIN(2) = "descripcion"
    If GsTipo = "EPS" Then
      GsParamIN(3) = "EPS"
      GsParamIN(5) = "EPS"
    Else
      GsParamIN(3) = "FPO"
      GsParamIN(5) = "FPO"
    End If
    GsParamIN(4) = "Nombre"
    GsParamIN(6) = ""
    frmLista.Show 1
    txtFPONueva = GsParamOUT(0)
    lblFPONueva = GsParamOUT(1)
    If Trim(txtFPONueva) <> "" Then MBCambio = True
End Sub

Private Sub imgListaFPO_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
    imgListaFPO(1).ZOrder
    MbFocoForm = False
End Sub

Private Sub txtFPONueva_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        Mado.Sql = _
        "SELECT dato, descripcion FROM datos_agr_trab WHERE agrupacion='" & MsCodAgr & "'" & _
        " AND ltrim(rtrim(dato))='" & LTrim(RTrim(txtFPONueva)) & "'"
        Mado.SendSQL
        If Mado.EOF Then
            Screen.MousePointer = vbDefault
            If GsTipo = "EPS" Then
                clsMsgbox.Mensaje "No existe la EPS", mAceptar, mAdvierte, GsTitMsg
            Else
                clsMsgbox.Mensaje "No existe el Fondo", mAceptar, mAdvierte, GsTitMsg
            End If
            Exit Sub
        Else
            txtFPONueva = Mado.GetField(1)
            lblFPONueva = Mado.GetField(2)
        End If
        MBCambio = True
        On Error Resume Next
        fpFecha.SetFocus
    End If
End Sub

Private Sub txtTrabajador_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        Screen.MousePointer = vbHourglass
        Mado.Sql = _
        " SELECT t.trabajador, nombre" & _
        " FROM Trabajadores t, Trabajadores_grales tg" & _
        " WHERE t.trabajador = tg.trabajador" & _
        " AND tg.compania = '" & GsCveCia & "'" & _
        " AND ltrim(rtrim(t.trabajador)) ='" & LTrim(RTrim(txtTrabajador)) & "'"
        Mado.SendSQL
        If Mado.EOF Then
            Screen.MousePointer = vbDefault
            clsMsgbox.Mensaje "No existe el trabajador", mAceptar, mAdvierte, GsTitMsg
            Exit Sub
        Else
            txtTrabajador = Mado.GetField(1)
            lblTrab = Replace(Mado.GetField(2), "/", " ")
            HallarAdmActual
        End If
        MBCambio = True
        Screen.MousePointer = vbDefault
    End If
End Sub

Private Function bValidarDatos() As Boolean
    Dim sMensaje As String
    
    bValidarDatos = True
    If Trim(txtTrabajador) = "" Then bValidarDatos = False: sMensaje = "el Trabajador"
    If Trim(txtFPONueva) = "" Then bValidarDatos = False: sMensaje = "el Fondo nuevo"
    'If Trim(fpFecha) = "" Then bValidarDatos = False: SMensaje = "Fecha"
    
    If Not bValidarDatos Then clsMsgbox.Mensaje "Antes de guardar debe definir " & sMensaje, mAceptar, mAdvierte, GsTitMsg
End Function

Private Sub GuardaCambios()
On Error GoTo AclararError

    If GsTipo = "EPS" Then
      Mado.Sql = "sp_fco_alta_traslados_eps " & _
      "'" & GsCveCia & "','" & txtTrabajador & "','" & txtFPOActual & "'," & _
      "'" & txtFPONueva & "','" & Format(fpFecha.Text, "yyyymmdd") & "'"
    Else
      Mado.Sql = "sp_fco_alta_traslados_fpo " & _
      "'" & GsCveCia & "','" & txtTrabajador & "','" & txtFPOActual & "'," & _
      "'" & txtFPONueva & "','" & Format(fpFecha.Text, "yyyymmdd") & "'"
    End If
    
    If Mado.ExecSQL = -1 Then GoTo AclararError
    
    GsTrabajador = txtTrabajador
    
    Exit Sub
    
AclararError:
    Screen.MousePointer = vbDefault
    If Err > 0 Then
        clsMsgbox.Mensaje Err & " " & Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub HallarAdmActual()
    If GsTipo = "EPS" Then
      HallarEPSActual
    Else
      HallarFPOActual
    End If

End Sub

Private Sub HallarFPOActual()
    Mado.Sql = _
    " SELECT Dato, Descripcion" & _
    " FROM vw_fco_fpo_trabajador" & _
    " WHERE  ltrim(rtrim(trabajador))='" & Trim(txtTrabajador) & "'" & _
    "   AND  compania ='" & GsCveCia & "'"
    Mado.SendSQL
    If Not Mado.EOF Then
        txtFPOActual = Mado.GetField(1)
        lblFPOActual = Mado.GetField(2)
        txtFPONueva.SetFocus
    End If
End Sub

Private Sub HallarEPSActual()
    Mado.Sql = _
    " SELECT Dato, Descripcion" & _
    " FROM vw_fco_eps_trabajador" & _
    " WHERE  ltrim(rtrim(trabajador))='" & Trim(txtTrabajador) & "'" & _
    " AND  compania ='" & GsCveCia & "'"
    Mado.SendSQL
    If Not Mado.EOF Then
        txtFPOActual = Mado.GetField(1)
        lblFPOActual = Mado.GetField(2)
        txtFPONueva.SetFocus
    End If
End Sub

