VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{B02F3647-766B-11CE-AF28-C3A2FBE76A13}#2.5#0"; "ss32x25.ocx"
Object = "{48932A52-981F-101B-A7FB-4A79242FD97B}#2.0#0"; "Tab32x20.ocx"
Begin VB.Form FCO1010 
   Caption         =   "Parametros Fiscales"
   ClientHeight    =   6540
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11850
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "FCO1010 Parametros.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6540
   ScaleWidth      =   11850
   Begin TabproLib.vaTabPro tbpTab 
      Height          =   5610
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   11580
      _Version        =   131072
      _ExtentX        =   20426
      _ExtentY        =   9895
      _StockProps     =   100
      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
      BackColor       =   -2147483633
      AlignTextH      =   1
      AlignTextV      =   1
      ThreeDText      =   2
      ApplyTo         =   2
      ActiveTabBold   =   -1  'True
      OffsetFromClientTop=   -1  'True
      BookShowMetalSpine=   -1  'True
      BookRingShowHole=   -1  'True
      BookCornerGuardWidth=   105
      BookCornerGuardLength=   405
      TabShapeApplyTo =   2
      DrawFocusRect   =   2
      TabCaption      =   "FCO1010 Parametros.frx":030A
      Begin VB.ComboBox cboCuales 
         Height          =   330
         ItemData        =   "FCO1010 Parametros.frx":0601
         Left            =   285
         List            =   "FCO1010 Parametros.frx":0617
         Style           =   2  'Dropdown List
         TabIndex        =   2
         Top             =   465
         Width           =   2055
      End
      Begin FPSpread.vaSpread sprALA 
         Height          =   4575
         Left            =   285
         TabIndex        =   1
         Top             =   825
         Width           =   10815
         _Version        =   131077
         _ExtentX        =   19076
         _ExtentY        =   8070
         _StockProps     =   64
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MaxCols         =   1
         MaxRows         =   1
         SpreadDesigner  =   "FCO1010 Parametros.frx":0673
      End
      Begin FPSpread.vaSpread sprPAR 
         Height          =   4815
         Left            =   -26144
         TabIndex        =   3
         Top             =   -20399
         Width           =   10815
         _Version        =   131077
         _ExtentX        =   19076
         _ExtentY        =   8493
         _StockProps     =   64
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MaxCols         =   1
         MaxRows         =   1
         SpreadDesigner  =   "FCO1010 Parametros.frx":07CC
      End
      Begin FPSpread.vaSpread sprRET 
         Height          =   4815
         Left            =   -26144
         TabIndex        =   4
         Top             =   -20399
         Width           =   10815
         _Version        =   131077
         _ExtentX        =   19076
         _ExtentY        =   8493
         _StockProps     =   64
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MaxCols         =   1
         MaxRows         =   1
         SpreadDesigner  =   "FCO1010 Parametros.frx":0901
      End
      Begin FPSpread.vaSpread sprOTR 
         Height          =   4815
         Left            =   -26144
         TabIndex        =   5
         Top             =   -20399
         Width           =   10815
         _Version        =   131077
         _ExtentX        =   19076
         _ExtentY        =   8493
         _StockProps     =   64
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MaxCols         =   1
         MaxRows         =   1
         SpreadDesigner  =   "FCO1010 Parametros.frx":0A36
      End
      Begin VB.Image imgListaALA 
         Height          =   480
         Left            =   11160
         Picture         =   "FCO1010 Parametros.frx":0B6B
         Top             =   1080
         Width           =   480
      End
      Begin VB.Image imgListaOTR 
         Height          =   480
         Left            =   -26639
         Picture         =   "FCO1010 Parametros.frx":0E75
         Top             =   -16559
         Width           =   480
      End
      Begin VB.Image imgListaRET 
         Height          =   480
         Left            =   -26639
         Picture         =   "FCO1010 Parametros.frx":117F
         Top             =   -16559
         Width           =   480
      End
      Begin VB.Image imgListaPAR 
         Height          =   480
         Left            =   -26639
         Picture         =   "FCO1010 Parametros.frx":1489
         Top             =   -16559
         Width           =   480
      End
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   240
      Top             =   6000
      _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           =   "FCO1010 Parametros.frx":1793
   End
End
Attribute VB_Name = "FCO1010"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
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 objBitaALA As New ADAMBitacora.Bitacora
Private objBitaPAR As New ADAMBitacora.Bitacora
Private objBitaRET As New ADAMBitacora.Bitacora
Private objBitaOTR As New ADAMBitacora.Bitacora

Private MsSqlAla As String

Private MbE1 As Boolean
Private MbE2 As Boolean
Private MbE3 As Boolean
Private MbE4 As Boolean

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlalta": Altas
        Case "tlbaja": Bajas
        Case "tltrabaja": TrabajarCon
        Case "tlrenueva": RenuevaDatos
        Case "tlguarda": GuardaCambios
        Case "tlsalida": Unload Me
    End Select
End Sub

Private Sub abToolbar_PreCustomizeMenu(ByVal Cancel As ActiveBarLibraryCtl.ReturnBool)
    Cancel = True
End Sub

Private Sub cboCuales_Click()
    MsSqlAla = _
    " SELECT secuencia, descripcion, dato, tipo, '' tipo_dato, campo, '' campo_concepto, dato_largo" & _
    " FROM vw_fdt_parametros" & _
    " WHERE pais = 'COL' And compania='" & GsCveCia & "' And parametro = 'autoliq'"
    Select Case cboCuales.ListIndex
        Case 1
            MsSqlAla = MsSqlAla & " AND secuencia IN (5,15,16,25,26)"
        Case 2
            MsSqlAla = MsSqlAla & " AND secuencia IN (2,3,4,13,14,19,27,28,30,31,38,39)"
        Case 3
            MsSqlAla = MsSqlAla & " AND secuencia IN (9,12,17,33,34,35,36)"
        Case 4
            MsSqlAla = MsSqlAla & " AND secuencia IN (8,10,11,18,20)"
        Case 5
            MsSqlAla = MsSqlAla & " AND secuencia IN (21,22,23,24,29)"
    End Select
    MsSqlAla = MsSqlAla & " ORDER BY secuencia"
    RenuevaDatosALA
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF5: RenuevaDatos
        Case vbKeyF6: Altas
        Case vbKeyF7: Bajas
        Case vbKeyF9: TrabajarCon
        Case vbKeyF11: GuardaCambios
        Case vbKeyF12: abToolbar.Bands(1).TrackPopup -1, -1
    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
    
    GAdam.ObtieneColores
    Set clsSpread = New NSpread
    'AsignaIconos abToolbar, 3, LALTA, LBAJA, LTRABAJA, LRENUEVA, LGUARDA, LSALIDA
    AsignaIconos abToolbar, 3, LTRABAJA, LRENUEVA, LGUARDA, LSALIDA
    CreaBitacoras
    
    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 = 11970
        MiY = 7050
        Me.Width = MiX
        Me.Height = MiY
    End If
    
    Caption = GsDsn & " / " & GsAbreviaturaCia & " - Parámetros Fiscales"
    
    cboCuales.ListIndex = 0
    MsSqlAla = _
    " SELECT secuencia, descripcion, dato, tipo, '' tipo_dato, campo, '' campo_concepto, dato_largo" & _
    " FROM vw_fdt_parametros" & _
    " WHERE pais = 'COL' And compania='" & GsCveCia & "' And parametro = 'autoliq'"
        
    MbE1 = True
    MbE2 = False
    MbE3 = False
    MbE4 = False
        
    RenuevaDatos
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If iDeseaGuardar = vbCancel Then Cancel = 1: Exit Sub
    
    Set Mado = Nothing
    Set objBitaALA = Nothing
    Set objBitaPAR = Nothing
    Set objBitaRET = Nothing
    Set objBitaOTR = Nothing
    Set clsSpread = Nothing
    Gtc(MiCx).ihijas = Gtc(MiCx).ihijas - 1
    Set FCO1010 = Nothing
End Sub

Private Sub Form_Resize()
    If Me.WindowState <> 1 Then
        tbpTab.Width = Width - 390
        tbpTab.Height = Height - 1440
        
        'Autoliquidación
        sprALA.Width = tbpTab.Width - 765
        sprALA.Height = tbpTab.Height - 1035
        imgListaALA.Left = sprALA.Width + 405
        GAdam.AjustaSpread sprALA, 8
        
        'Parafiscales
        sprPAR.Width = sprALA.Width
        sprPAR.Height = sprALA.Height
        imgListaPAR.Left = sprPAR.Width + 405
        GAdam.AjustaSpread sprPAR, 8
        
        'Retención
        sprRET.Width = sprALA.Width
        sprRET.Height = sprALA.Height
        imgListaRET.Left = sprRET.Width + 405
        GAdam.AjustaSpread sprRET, 8
        
        'Otros
        sprOTR.Width = sprALA.Width
        sprOTR.Height = sprALA.Height
        imgListaOTR.Left = sprOTR.Width + 405
        GAdam.AjustaSpread sprOTR, 8
    End If
End Sub

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

Private Sub imgListaALA_Click()
    EjecutaF4 sprALA, objBitaALA
End Sub

Private Sub imgListaOTR_Click()
    EjecutaF4 sprOTR, objBitaOTR
End Sub

Private Sub imgListaPAR_Click()
    EjecutaF4 sprPAR, objBitaPAR
End Sub

Private Sub imgListaRET_Click()
    EjecutaF4 sprRET, objBitaRET
End Sub

Private Sub CambioSpread(spread As Control, Bitacora As Object)
Dim Aux As Variant
Dim nValor As Byte
Dim nValorAnt As Byte

  With spread
    If .ActiveCol = 5 Then
        .GetText .ActiveCol, .ActiveRow, Aux
        .Col = 4: .Row = .ActiveRow
        nValor = Val(Left(Aux, 2))
        .Text = nValor
     
        .Col = 3
        .Row = .ActiveRow
        .Text = ""
     
        .Col = 7: .Row = .ActiveRow
        .CellType = 8: .TypeComboBoxIndex = -1
        .TypeComboBoxString = "ninguno"
        .TypeComboBoxString = "referencia"
        .TypeComboBoxString = "referencia2"
        .TypeComboBoxString = "fecha"
        .TypeComboBoxString = "fecha2"
        .TypeComboBoxString = "tiempo"
        .TypeComboBoxString = "factor_01"
        .TypeComboBoxString = "factor_02"
        .TypeComboBoxString = "factor_03"
        .TypeComboBoxString = "importe"
        
        If (nValor = 0 Or nValor = 7 Or nValor = 2 Or nValor = 5) Then   'para conceptos y agrupacion de conceptos
            .Col = 7: .Row = .ActiveRow: .Lock = False
            .BackColor = vbWhite
            .TypeComboBoxCurSel = 0
        Else
            .Col = 7: .Row = .ActiveRow: .Lock = True
            .BackColor = vbButtonShadow
            .TypeComboBoxCurSel = 0
            .Col = 6: .Row = .ActiveRow: .Text = "0"
        End If
        
        'si se ha escogido un dato de agr se debe verificar que la fila anterior es una agr de trabajadores
        If nValor = 9 Then
            If .ActiveRow <> 27 And .ActiveRow <> 28 And .ActiveRow <> 37 Then
                .Col = 4: .Row = .ActiveRow - 1
                nValorAnt = Val(.Text)
                If nValorAnt <> 1 Then
                    clsMsgbox.Mensaje "Intenta configurar un Dato de Agr y la fila anterior no es una Agrupacion de Trabajadores.", mAceptar, minforma, GsTitMsg
                    .Col = 4: .Row = .ActiveRow: .Text = "1"
                    .Col = 5: .Row = .ActiveRow
                    .TypeComboBoxCurSel = 0
                End If
            End If
        End If
                    
    End If
    
    If .ActiveCol = 7 Then
      .GetText .Col, .ActiveRow, Aux

      .Col = 6: .Row = .ActiveRow
      Select Case Trim(CStr(Aux))
          Case "": .Text = "0"
          Case "ninguno": .Text = "0"
          Case "referencia": .Text = "1"
          Case "referencia2": .Text = "2"
          Case "fecha": .Text = "3"
          Case "fecha2": .Text = "4"
          Case "tiempo": .Text = "5"
          Case "factor_01": .Text = "6"
          Case "factor_02": .Text = "7"
          Case "factor_03": .Text = 8
          Case "importe": .Text = 9
      End Select
    End If
    
  End With
  Bitacora.mCambia

End Sub

Private Sub sprALA_Change(ByVal Col As Long, ByVal Row As Long)

If MbE1 Then CambioSpread sprALA, objBitaALA
If MbE2 Then CambioSpread sprPAR, objBitaPAR
If MbE3 Then CambioSpread sprRET, objBitaRET
If MbE4 Then CambioSpread sprOTR, objBitaOTR

End Sub

Private Sub sprALA_Click(ByVal Col As Long, ByVal Row As Long)
  MbE1 = True
  MbE2 = False
  MbE3 = False
  MbE4 = False

End Sub

Private Sub sprALA_DblClick(ByVal Col As Long, ByVal Row As Long)
    If Col < 3 Then TrabajarCon
End Sub

Private Sub sprALA_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then imgListaALA_Click
End Sub

Private Sub sprOTR_Change(ByVal Col As Long, ByVal Row As Long)
  If MbE1 Then CambioSpread sprALA, objBitaALA
  If MbE2 Then CambioSpread sprPAR, objBitaPAR
  If MbE3 Then CambioSpread sprRET, objBitaRET
  If MbE4 Then CambioSpread sprOTR, objBitaOTR

End Sub

Private Sub sprOTR_Click(ByVal Col As Long, ByVal Row As Long)
  MbE1 = False
  MbE2 = False
  MbE3 = False
  MbE4 = True

End Sub

Private Sub sprOTR_DblClick(ByVal Col As Long, ByVal Row As Long)
    If Col < 3 Then TrabajarCon
End Sub

Private Sub sprOTR_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then imgListaOTR_Click
End Sub

Private Sub sprPAR_Change(ByVal Col As Long, ByVal Row As Long)

  If MbE1 Then CambioSpread sprALA, objBitaALA
  If MbE2 Then CambioSpread sprPAR, objBitaPAR
  If MbE3 Then CambioSpread sprRET, objBitaRET
  If MbE4 Then CambioSpread sprOTR, objBitaOTR

End Sub

Private Sub sprPAR_Click(ByVal Col As Long, ByVal Row As Long)
  MbE1 = False
  MbE2 = True
  MbE3 = False
  MbE4 = False

End Sub

Private Sub sprPAR_DblClick(ByVal Col As Long, ByVal Row As Long)
    If Col < 3 Then TrabajarCon
End Sub

Private Sub sprPAR_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then imgListaPAR_Click
End Sub

Private Sub sprRET_Change(ByVal Col As Long, ByVal Row As Long)
  If MbE1 Then CambioSpread sprALA, objBitaALA
  If MbE2 Then CambioSpread sprPAR, objBitaPAR
  If MbE3 Then CambioSpread sprRET, objBitaRET
  If MbE4 Then CambioSpread sprOTR, objBitaOTR

End Sub

Private Sub sprRET_Click(ByVal Col As Long, ByVal Row As Long)
  MbE1 = False
  MbE2 = False
  MbE3 = True
  MbE4 = False

End Sub

Private Sub sprRET_DblClick(ByVal Col As Long, ByVal Row As Long)
    If Col < 3 Then TrabajarCon
End Sub

Private Sub sprRET_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then imgListaRET_Click
End Sub

Private Sub ConfiguraSpread(Indicador As Byte)
    Select Case Indicador
        Case 0
            With sprALA
                .Visible = False
                .Action = 28
                GAdam.ConfiguracionSpread sprALA
                .ColWidth(1) = 8
                .ColWidth(2) = 30
                .ColWidth(3) = 10
                .ColWidth(5) = 14
                .ColWidth(7) = 10
                .ColWidth(8) = 15
                .SetText 1, 0, "Secuencia"
                .SetText 2, 0, "Descripcion"
                .SetText 3, 0, "Valor"
                .SetText 4, 0, "Tipo Oculto": .Col = 4: .ColHidden = True
                .SetText 5, 0, "Tipo"
                .SetText 6, 0, "Campo Oculto": .Col = 6: .ColHidden = True
                .SetText 7, 0, "Campo" ': .Col = 7: .ColHidden = True
                .SetText 8, 0, "Valor Texto"
                ConfiguraSpreadJCL sprALA
            End With
        Case 1
            With sprPAR
                .Visible = False
                .Action = 28
                GAdam.ConfiguracionSpread sprPAR
                .ColWidth(1) = 8
                .ColWidth(2) = 30
                .ColWidth(3) = 10
                .ColWidth(5) = 14
                .ColWidth(7) = 10
                .ColWidth(8) = 15
                .SetText 1, 0, "Secuencia"
                .SetText 2, 0, "Descripcion"
                .SetText 3, 0, "Valor"
                .SetText 4, 0, "Tipo Oculto": .Col = 4: .ColHidden = True
                .SetText 5, 0, "Tipo"
                .SetText 6, 0, "Campo Oculto": .Col = 6: .ColHidden = True
                .SetText 7, 0, "Campo" ': .Col = 7: .ColHidden = True
                .SetText 8, 0, "Valor Texto"
                ConfiguraSpreadJCL sprPAR
            End With
        Case 2
            With sprRET
                .Visible = False
                .Action = 28
                GAdam.ConfiguracionSpread sprRET
                .ColWidth(1) = 8
                .ColWidth(2) = 30
                .ColWidth(3) = 10
                .ColWidth(5) = 14
                .ColWidth(7) = 10
                .ColWidth(8) = 15
                .SetText 1, 0, "Secuencia"
                .SetText 2, 0, "Descripcion"
                .SetText 3, 0, "Valor"
                .SetText 4, 0, "Tipo Oculto": .Col = 4: .ColHidden = True
                .SetText 5, 0, "Tipo"
                .SetText 6, 0, "Campo Oculto": .Col = 6: .ColHidden = True
                .SetText 7, 0, "Campo" ': .Col = 7: .ColHidden = True
                .SetText 8, 0, "Valor Texto"
                ConfiguraSpreadJCL sprRET
            End With
        Case 3
            With sprOTR
                .Visible = False
                .Action = 28
                GAdam.ConfiguracionSpread sprOTR
                .ColWidth(1) = 8
                .ColWidth(2) = 30
                .ColWidth(3) = 10
                .ColWidth(5) = 14
                .ColWidth(7) = 10
                .ColWidth(8) = 15
                .SetText 1, 0, "Secuencia"
                .SetText 2, 0, "Descripcion"
                .SetText 3, 0, "Valor"
                .SetText 4, 0, "Tipo Oculto": .Col = 4: .ColHidden = True
                .SetText 5, 0, "Tipo"
                .SetText 6, 0, "Campo Oculto": .Col = 6: .ColHidden = True
                .SetText 7, 0, "Campo" ': .Col = 7: .ColHidden = True
                .SetText 8, 0, "Valor Texto"
                ConfiguraSpreadJCL sprOTR
            End With
    End Select
End Sub

Private Sub Altas()

If MbE1 Then AltasReal sprALA, objBitaALA
If MbE2 Then AltasReal sprPAR, objBitaPAR
If MbE3 Then AltasReal sprRET, objBitaRET
If MbE4 Then AltasReal sprOTR, objBitaOTR

End Sub

Private Sub Bajas()

If MbE1 Then BajasReal sprALA, objBitaALA
If MbE2 Then BajasReal sprPAR, objBitaPAR
If MbE3 Then BajasReal sprRET, objBitaRET
If MbE4 Then BajasReal sprOTR, objBitaOTR

End Sub

Private Sub AltasReal(spread As Control, Bitacora As Object)
Dim nValor As Byte

  With spread
      .VirtualMode = True
      Bitacora.mAgrega
      .VirtualMode = False
        
      .Col = 4: .Row = .ActiveRow: .Text = "1"
      If .Text <> "" Then
        nValor = Val(.Value)
      Else
        nValor = 255
      End If
          
      .Col = 5: .Row = .ActiveRow:
      .CellType = 8: .TypeComboBoxIndex = -1
      .TypeComboBoxString = "00.Concepto"
      .TypeComboBoxString = "01.Agr. Trab."
      .TypeComboBoxString = "02.Agr. Conc."
      .TypeComboBoxString = "03.Var. Trab."
      .TypeComboBoxString = "04.Valor"
      .TypeComboBoxString = "05.Agr. Conc."
      .TypeComboBoxString = "06.Tipo Nom."
      .TypeComboBoxString = "07.Concepto"
      .TypeComboBoxString = "08.Var Nom."
      .TypeComboBoxString = "09.Dato Agr. Trab."
      .TypeComboBoxString = "10.Si/No"
      .TypeComboBoxString = "11.Sistema Horario"
      .TypeComboBoxString = "12.Col. Trab."
      .TypeComboBoxString = "13.Rel. Laboral"
      .TypeComboBoxString = "14.Tabla Impuestos"
      .TypeComboBoxString = "15.Clase Nom."
      .TypeComboBoxString = "16.Texto Largo"
      .TypeComboBoxCurSel = nValor
      
      .Col = 7: .Row = .ActiveRow
          .Lock = False
          .CellType = 8: .TypeComboBoxIndex = -1
          .TypeComboBoxString = "ninguno"
          .TypeComboBoxString = "referencia"
          .TypeComboBoxString = "referencia2"
          .TypeComboBoxString = "fecha"
          .TypeComboBoxString = "fecha2"
          .TypeComboBoxString = "tiempo"
          .TypeComboBoxString = "factor_01"
          .TypeComboBoxString = "factor_02"
          .TypeComboBoxString = "factor_03"
          .TypeComboBoxString = "importe"
      .Col = 6: .Row = .ActiveRow: .Text = "1"
      If .Text <> "" Then
        nValor = Val(.Value)
      Else
        nValor = 0
      End If
      
      If nValor > 0 Then
          .Col = 7: .Row = .ActiveRow
          .TypeComboBoxCurSel = nValor - 1
      End If
      
      .Col = 1: .Row = .ActiveRow: .Lock = True
  End With

End Sub

Private Sub BajasReal(spread As Control, Bitacora As Object)
    If spread.VirtualMaxRows <= 0 Then Exit Sub
    Bitacora.mBorra
End Sub


Private Sub CreaBitacoras()
    objBitaALA.mCreaBitacora sprALA, Mado.lhEnv, Mado.lhDbc, Mado.lhstmt, Mado
    objBitaALA.mTablaSPInfo 0, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'autoliq'", 1, 3, 4, 6, 2, 8
    objBitaALA.mTablaSPInfo 1, "sp_fdt_del_parametros", "'COL'", "'" & GsCveCia & "'", "'autoliq'", 1
    objBitaALA.mTablaSPInfo 2, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'autoliq'", 1, 3, 4, 6, 2, 8
    objBitaALA.mColNoNulls 1
   
    objBitaPAR.mCreaBitacora sprPAR, Mado.lhEnv, Mado.lhDbc, Mado.lhstmt, Mado
    objBitaPAR.mTablaSPInfo 0, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'parafiscal'", 1, 3, 4, 6, 2, 8
    objBitaPAR.mTablaSPInfo 1, "sp_fdt_del_parametros", "'COL'", "'" & GsCveCia & "'", "'parafiscal'", 1
    objBitaPAR.mTablaSPInfo 2, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'parafiscal'", 1, 3, 4, 6, 2, 8
    objBitaPAR.mColNoNulls 1
      
    objBitaRET.mCreaBitacora sprRET, Mado.lhEnv, Mado.lhDbc, Mado.lhstmt, Mado
    objBitaRET.mTablaSPInfo 0, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'retencion'", 1, 3, 4, 6, 2, 8
    objBitaRET.mTablaSPInfo 1, "sp_fdt_del_parametros", "'COL'", "'" & GsCveCia & "'", "'retencion'", 1
    objBitaRET.mTablaSPInfo 2, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'retencion'", 1, 3, 4, 6, 2, 8
    objBitaRET.mColNoNulls 1

    objBitaOTR.mCreaBitacora sprOTR, Mado.lhEnv, Mado.lhDbc, Mado.lhstmt, Mado
    objBitaOTR.mTablaSPInfo 0, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'otros'", 1, 3, 4, 6, 2, 8
    objBitaOTR.mTablaSPInfo 1, "sp_fdt_del_parametros", "'COL'", "'" & GsCveCia & "'", "'otros'", 1
    objBitaOTR.mTablaSPInfo 2, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'otros'", 1, 3, 4, 6, 2, 8
    objBitaOTR.mColNoNulls 1
                
End Sub

Private Sub GuardaCambios()
    Screen.MousePointer = vbHourglass
    If sprALA.VirtualMaxRows > 0 Then GbRen = objBitaALA.mActualizaBD
    If sprPAR.VirtualMaxRows > 0 Then GbRen = objBitaPAR.mActualizaBD
    If sprOTR.VirtualMaxRows > 0 Then GbRen = objBitaOTR.mActualizaBD
    If sprRET.VirtualMaxRows > 0 Then GbRen = objBitaRET.mActualizaBD
    objBitaALA.mVaciaBuffer
    objBitaPAR.mVaciaBuffer
    objBitaRET.mVaciaBuffer
    objBitaOTR.mVaciaBuffer
    Screen.MousePointer = vbDefault
End Sub

Private Function iDeseaGuardar() As Integer
    If objBitaALA.pTransActual + objBitaPAR.pTransActual + objBitaRET.pTransActual + objBitaOTR.pTransActual > 0 Then 'si existen transacciones
        iDeseaGuardar = clsMsgbox.Mensaje("¿ Desea Guardar los Cambios ?", mSiNoCancelar, mConfirma, "ADAM", 6)
        Select Case iDeseaGuardar
           Case vbYes
              GuardaCambios
              If GbRen = False Then iDeseaGuardar = 2
           Case vbNo
              objBitaALA.mVaciaBuffer
              objBitaPAR.mVaciaBuffer
              objBitaRET.mVaciaBuffer
              objBitaOTR.mVaciaBuffer
        End Select
    Else
        iDeseaGuardar = 1
    End If
End Function

Private Sub RenuevaDatos()
    If iDeseaGuardar = 2 Then Exit Sub 'Cancelar
    RenuevaDatosALA
    RenuevaDatosPar
    RenuevaDatosRET
    RenuevaDatosOTR
End Sub

Private Sub RenuevaDatosALA()
    Dim i As Integer
    Dim nValor As Byte
    Dim nCampo As Byte
    
    ConfiguraSpread 0
    Mado.Sql = MsSqlAla
    If Not Mado.SendSQL Then Exit Sub
    clsSpread.LlenaSpread 0, sprALA, Mado, Mado.lhDbc, Mado.lhstmt
    
    With sprALA
        .Col = 1: .Row = -1: .Lock = True
        .Col = 2: .Row = -1: .Lock = True
        .Col = 7: .Row = -1: .Lock = True
        For i = 1 To .VirtualMaxRows
            .Col = 4: .Row = i
            If .Text <> "" Then
              nValor = Val(.Value)
            Else
              nValor = 255
            End If
            .Col = 6: .Row = i
            If .Text <> "" Then
              nCampo = Val(.Value)
            Else
              nCampo = 255
            End If
            
            .Col = 5: .Row = i
            .CellType = 8: .TypeComboBoxIndex = -1
            If nValor = 0 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 0
            End If
            If nValor = 2 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 1
            End If
            If nValor = 9 Then
                .TypeComboBoxString = "09.Dato Agr. Trab."
                .TypeComboBoxString = "13.Rel. Laboral"
                .TypeComboBoxCurSel = 0
            End If
            If nValor = 13 Then
                .TypeComboBoxString = "09.Dato Agr. Trab."
                .TypeComboBoxString = "13.Rel. Laboral"
                .TypeComboBoxCurSel = 1
            End If
            If nValor <> 0 And nValor <> 2 And nValor <> 9 And nValor <> 13 Then
                Select Case nValor
                    Case 1: .TypeComboBoxString = "01.Agr. Trab."
                    Case 3: .TypeComboBoxString = "03.Var. Trab."
                    Case 4: .TypeComboBoxString = "04.Valor"
                    Case 5: .TypeComboBoxString = "05.Agr. Conc."
                    Case 6: .TypeComboBoxString = "06.Tipo Nom."
                    Case 7: .TypeComboBoxString = "07.Concepto"
                    Case 8: .TypeComboBoxString = "08.Var Nom."
                    Case 9: .TypeComboBoxString = "09.Dato Agr. Trab."
                    Case 10: .TypeComboBoxString = "10.Si/No"
                    Case 11: .TypeComboBoxString = "11.Sistema Horario"
                    Case 12: .TypeComboBoxString = "12.Col. Trab."
                    Case 13: .TypeComboBoxString = "13.Rel. Laboral"
                    Case 14: .TypeComboBoxString = "14.Tabla Impuestos"
                    Case 15: .TypeComboBoxString = "15.Clase Nom."
                    Case 16: .TypeComboBoxString = "16.Texto Largo"
                End Select
                .TypeComboBoxCurSel = 0
                .Lock = True
            End If
                        
          .Col = 7: .Row = i
          If (nValor = 0 Or nValor = 7 Or nValor = 2 Or nValor = 5) And nCampo <> 0 Then  'para conceptos y agrupacion de conceptos
              .Lock = False
              .CellType = 8: .TypeComboBoxIndex = -1
              .TypeComboBoxString = "ninguno"
              .TypeComboBoxString = "referencia"
              .TypeComboBoxString = "referencia2"
              .TypeComboBoxString = "fecha"
              .TypeComboBoxString = "fecha2"
              .TypeComboBoxString = "tiempo"
              .TypeComboBoxString = "factor_01"
              .TypeComboBoxString = "factor_02"
              .TypeComboBoxString = "factor_03"
              .TypeComboBoxString = "importe"
          Else
              .Lock = True
              .BackColor = vbButtonShadow
          End If
          .Col = 6: .Row = i
          If .Text <> "" Then
            nValor = Val(.Value)
          Else
            nValor = 0
          End If
          If nValor > 0 Then
              .Col = 7: .Row = i
              .TypeComboBoxCurSel = nValor ' - 1
          End If
      Next i
      .Col = 1: .Row = -1: .Lock = True
                        
    End With
    GAdam.AjustaSpread sprALA, 2
End Sub

Private Sub RenuevaDatosPar()
    Dim i As Integer
    Dim nValor As Byte
    Dim nCampo As Byte
    
    ConfiguraSpread 1
    
    Mado.Sql = _
    " SELECT secuencia, descripcion, dato, tipo, '' tipo_dato, campo, '' campo_concepto, dato_largo" & _
    " FROM vw_fdt_parametros" & _
    " WHERE pais = 'COL' And compania='" & GsCveCia & "' And parametro = 'parafiscal'" & _
    " ORDER BY secuencia"
    If Not Mado.SendSQL Then Exit Sub
    clsSpread.LlenaSpread 0, sprPAR, Mado, Mado.lhDbc, Mado.lhstmt
    
    With sprPAR
        .Col = 1: .Row = -1: .Lock = True
        .Col = 2: .Row = -1: .Lock = True
        .Col = 7: .Row = -1: .Lock = True
        For i = 1 To .VirtualMaxRows
            .Col = 4: .Row = i
            If .Text <> "" Then
              nValor = Val(.Value)
            Else
              nValor = 255
            End If
            .Col = 6: .Row = i
            If .Text <> "" Then
              nCampo = Val(.Value)
            Else
              nCampo = 255
            End If
            
            .Col = 5: .Row = i
            .CellType = 8: .TypeComboBoxIndex = -1
            If nValor = 0 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 0
            End If
            If nValor = 2 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 1
            End If
            If nValor <> 0 And nValor <> 2 Then
                Select Case nValor
                    Case 1: .TypeComboBoxString = "01.Agr. Trab."
                    Case 3: .TypeComboBoxString = "03.Var. Trab."
                    Case 4: .TypeComboBoxString = "04.Valor"
                    Case 5: .TypeComboBoxString = "05.Agr. Conc."
                    Case 6: .TypeComboBoxString = "06.Tipo Nom."
                    Case 7: .TypeComboBoxString = "07.Concepto"
                    Case 8: .TypeComboBoxString = "08.Var Nom."
                    Case 9: .TypeComboBoxString = "09.Dato Agr. Trab."
                    Case 10: .TypeComboBoxString = "10.Si/No"
                    Case 11: .TypeComboBoxString = "11.Sistema Horario"
                    Case 12: .TypeComboBoxString = "12.Col. Trab."
                    Case 13: .TypeComboBoxString = "13.Rel. Laboral"
                    Case 14: .TypeComboBoxString = "14.Tabla Impuestos"
                    Case 15: .TypeComboBoxString = "15.Clase Nom."
                    Case 16: .TypeComboBoxString = "16.Texto Largo"
                End Select
                .TypeComboBoxCurSel = 0
                .Lock = True
            End If
            
                        
          .Col = 7: .Row = i
          If (nValor = 0 Or nValor = 7 Or nValor = 2 Or nValor = 5) And nCampo <> 0 Then  'para conceptos y agrupacion de conceptos
              .Lock = False
              .CellType = 8: .TypeComboBoxIndex = -1
              .TypeComboBoxString = "ninguno"
              .TypeComboBoxString = "referencia"
              .TypeComboBoxString = "referencia2"
              .TypeComboBoxString = "fecha"
              .TypeComboBoxString = "fecha2"
              .TypeComboBoxString = "tiempo"
              .TypeComboBoxString = "factor_01"
              .TypeComboBoxString = "factor_02"
              .TypeComboBoxString = "factor_03"
              .TypeComboBoxString = "importe"
          Else
              .Lock = True
              .BackColor = vbButtonShadow
          End If
          .Col = 6: .Row = i
          If .Text <> "" Then
            nValor = Val(.Value)
          Else
            nValor = 0
          End If
          If nValor > 0 Then
              .Col = 7: .Row = i
              .TypeComboBoxCurSel = nValor ' - 1
          End If
                    
        Next i
    End With
    GAdam.AjustaSpread sprPAR, 2
End Sub

Private Sub RenuevaDatosRET()
    Dim i As Integer
    Dim nValor As Byte
    Dim nSecuencia As Byte
    Dim nCampo As Byte
    
    ConfiguraSpread 2
    
    Mado.Sql = _
    " SELECT secuencia, descripcion, dato, tipo, '' tipo_dato, campo, '' campo_concepto, dato_largo" & _
    " FROM vw_fdt_parametros" & _
    " WHERE pais = 'COL' And compania='" & GsCveCia & "' And parametro='retencion'" & _
    " ORDER BY secuencia"
    
    If Not Mado.SendSQL Then Exit Sub
    clsSpread.LlenaSpread 0, sprRET, Mado, Mado.lhDbc, Mado.lhstmt
    
    With sprRET
        .Col = 1: .Row = -1: .Lock = True
        .Col = 2: .Row = -1: .Lock = True
        For i = 1 To .VirtualMaxRows
            .Col = 1: .Row = i: nSecuencia = Val(.Value)
            .Col = 4: .Row = i
            If .Text <> "" Then
              nValor = Val(.Value)
            Else
              nValor = 255
            End If
            .Col = 6: .Row = i
            If .Text <> "" Then
              nCampo = Val(.Value)
            Else
              nCampo = 255
            End If
            
            .Col = 5: .Row = i
            .CellType = 8: .TypeComboBoxIndex = -1
            If nValor = 0 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 0
            End If
            If nValor = 2 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 1
            End If
            If nValor <> 0 And nValor <> 2 Then
                Select Case nValor
                    Case 1: .TypeComboBoxString = "01.Agr. Trab."
                    Case 3: .TypeComboBoxString = "03.Var. Trab."
                    Case 4: .TypeComboBoxString = "04.Valor"
                    Case 5: .TypeComboBoxString = "05.Agr. Conc."
                    Case 6: .TypeComboBoxString = "06.Tipo Nom."
                    Case 7: .TypeComboBoxString = "07.Concepto"
                    Case 8: .TypeComboBoxString = "08.Var Nom."
                    Case 9: .TypeComboBoxString = "09.Dato Agr. Trab."
                    Case 10: .TypeComboBoxString = "10.Si/No"
                    Case 11: .TypeComboBoxString = "11.Sistema Horario"
                    Case 12: .TypeComboBoxString = "12.Col. Trab."
                    Case 13: .TypeComboBoxString = "13.Rel. Laboral"
                    Case 14: .TypeComboBoxString = "14.Tabla Impuestos"
                    Case 15: .TypeComboBoxString = "15.Clase Nom."
                    Case 16: .TypeComboBoxString = "16.Texto Largo"
                End Select
                .TypeComboBoxCurSel = 0
                .Lock = True
            End If
                                    
          .Col = 7: .Row = i
          If (nValor = 0 Or nValor = 7 Or nValor = 2 Or nValor = 5) And nCampo <> 0 Then  'para conceptos y agrupacion de conceptos
              .Lock = False
              .CellType = 8: .TypeComboBoxIndex = -1
              .TypeComboBoxString = "ninguno"
              .TypeComboBoxString = "referencia"
              .TypeComboBoxString = "referencia2"
              .TypeComboBoxString = "fecha"
              .TypeComboBoxString = "fecha2"
              .TypeComboBoxString = "tiempo"
              .TypeComboBoxString = "factor_01"
              .TypeComboBoxString = "factor_02"
              .TypeComboBoxString = "factor_03"
              .TypeComboBoxString = "importe"
          Else
              .Lock = True
              .BackColor = vbButtonShadow
          End If
          .Col = 6: .Row = i
          If .Text <> "" Then
            nValor = Val(.Value)
          Else
            nValor = 0
          End If
          If nValor > 0 Then
              .Col = 7: .Row = i
              .TypeComboBoxCurSel = nValor ' - 1
          End If
                    
        Next i
    End With
    GAdam.AjustaSpread sprRET, 2
End Sub

Private Sub RenuevaDatosOTR()
    Dim i As Integer
    Dim nValor As Byte
    Dim nCampo As Byte
    
    'Otros Reportes
    ConfiguraSpread 3
    
    Mado.Sql = _
    " SELECT secuencia, descripcion, dato, tipo, '' tipo_dato, campo, '' campo_concepto, dato_largo" & _
    " FROM vw_fdt_parametros" & _
    " WHERE pais = 'COL' And compania='" & GsCveCia & "' And parametro='otros'" & _
    " ORDER BY secuencia"
    
    If Not Mado.SendSQL Then Exit Sub
    clsSpread.LlenaSpread 0, sprOTR, Mado, Mado.lhDbc, Mado.lhstmt
    
    With sprOTR
        .Col = 1: .Row = -1: .Lock = True
        .Col = 2: .Row = -1: .Lock = True
        .Col = 7: .Row = -1: .Lock = True
        For i = 1 To .VirtualMaxRows
            .Col = 4: .Row = i
            If .Text <> "" Then
              nValor = Val(.Value)
            Else
              nValor = 255
            End If
            .Col = 6: .Row = i
            If .Text <> "" Then
              nCampo = Val(.Value)
            Else
              nCampo = 255
            End If
            
            .Col = 5: .Row = i
            .CellType = 8: .TypeComboBoxIndex = -1
            If nValor = 0 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 0
            End If
            If nValor = 2 Then
                .TypeComboBoxString = "00.Concepto"
                .TypeComboBoxString = "02.Agr. Conc."
                .TypeComboBoxCurSel = 1
            End If
            If nValor <> 0 And nValor <> 2 Then
                Select Case nValor
                    Case 1: .TypeComboBoxString = "01.Agr. Trab."
                    Case 3: .TypeComboBoxString = "03.Var. Trab."
                    Case 4: .TypeComboBoxString = "04.Valor"
                    Case 5: .TypeComboBoxString = "05.Agr. Conc."
                    Case 6: .TypeComboBoxString = "06.Tipo Nom."
                    Case 7: .TypeComboBoxString = "07.Concepto"
                    Case 8: .TypeComboBoxString = "08.Var Nom."
                    Case 9: .TypeComboBoxString = "09.Dato Agr. Trab."
                    Case 10: .TypeComboBoxString = "10.Si/No"
                    Case 11: .TypeComboBoxString = "11.Sistema Horario"
                    Case 12: .TypeComboBoxString = "12.Col. Trab."
                    Case 13: .TypeComboBoxString = "13.Rel. Laboral"
                    Case 14: .TypeComboBoxString = "14.Tabla Impuestos"
                    Case 15: .TypeComboBoxString = "15.Clase Nom."
                    Case 16: .TypeComboBoxString = "16.Texto Largo"
                End Select
                .TypeComboBoxCurSel = 0
                .Lock = True
            End If
                        
          .Col = 7: .Row = i
          If (nValor = 0 Or nValor = 7 Or nValor = 2 Or nValor = 5) And nCampo <> 0 Then  'para conceptos y agrupacion de conceptos
              .Lock = False
              .CellType = 8: .TypeComboBoxIndex = -1
              .TypeComboBoxString = "ninguno"
              .TypeComboBoxString = "referencia"
              .TypeComboBoxString = "referencia2"
              .TypeComboBoxString = "fecha"
              .TypeComboBoxString = "fecha2"
              .TypeComboBoxString = "tiempo"
              .TypeComboBoxString = "factor_01"
              .TypeComboBoxString = "factor_02"
              .TypeComboBoxString = "factor_03"
              .TypeComboBoxString = "importe"
          Else
              .Lock = True
              .BackColor = vbButtonShadow
          End If
          .Col = 6: .Row = i
          If .Text <> "" Then
            nValor = Val(.Value)
          Else
            nValor = 0
          End If
          If nValor > 0 Then
              .Col = 7: .Row = i
              .TypeComboBoxCurSel = nValor ' - 1
          End If
        
        Next i
    End With
    GAdam.AjustaSpread sprOTR, 2
End Sub

Private Sub TrabajarCon()
    Dim Aux As Variant
    Select Case tbpTab.ActiveTab
        Case 0
            Screen.MousePointer = vbHourglass
            With sprALA
                .GetText 4, .ActiveRow, Aux
                If Val(Aux) = 2 Or Val(Aux) = 5 Then
                    .GetText 3, .ActiveRow, Aux
                    GsDatoAux = CStr(Aux)
                    .GetText 2, .ActiveRow, Aux
                    FCO1010T.lblTitulo = Trim(GsDatoAux) & "   " & Trim(Aux)
                Else
                    Screen.MousePointer = vbDefault
                    Exit Sub
                End If
            End With
            Screen.MousePointer = vbDefault
            FCO1010T.Show 1
        Case 1
            Screen.MousePointer = vbHourglass
            With sprPAR
                .GetText 4, .ActiveRow, Aux
                If Val(Aux) = 2 Or Val(Aux) = 5 Then
                    .GetText 3, .ActiveRow, Aux
                    GsDatoAux = CStr(Aux)
                    .GetText 2, .ActiveRow, Aux
                    FCO1010T.lblTitulo = Trim(GsDatoAux) & "   " & Trim(Aux)
                Else
                    Screen.MousePointer = vbDefault
                    Exit Sub
                End If
            End With
            Screen.MousePointer = vbDefault
            FCO1010T.Show 1
        Case 2
            Screen.MousePointer = vbHourglass
            With sprRET
                .GetText 4, .ActiveRow, Aux
                If Val(Aux) = 2 Or Val(Aux) = 5 Then
                    .GetText 3, .ActiveRow, Aux
                    GsDatoAux = CStr(Aux)
                    .GetText 2, .ActiveRow, Aux
                    FCO1010T.lblTitulo = Trim(GsDatoAux) & "   " & Trim(Aux)
                Else
                    Screen.MousePointer = vbDefault
                    Exit Sub
                End If
            End With
            Screen.MousePointer = vbDefault
            FCO1010T.Show 1
        Case 3
            Screen.MousePointer = vbHourglass
            With sprOTR
                .GetText 4, .ActiveRow, Aux
                If Val(Aux) = 2 Or Val(Aux) = 5 Then
                    .GetText 3, .ActiveRow, Aux
                    GsDatoAux = CStr(Aux)
                    .GetText 2, .ActiveRow, Aux
                    FCO1010T.lblTitulo = Trim(GsDatoAux) & "   " & Trim(Aux)
                Else
                    Screen.MousePointer = vbDefault
                    Exit Sub
                End If
            End With
            Screen.MousePointer = vbDefault
            FCO1010T.Show 1
    End Select
End Sub

Private Sub EjecutaF4(spread As Control, Bitacora As Object)
    Dim vAux As Variant
    Dim vAgr As Variant
    
    If spread.ActiveCol <> 3 Then Exit Sub
    Screen.MousePointer = vbHourglass
    
    spread.GetText 4, spread.ActiveRow, vAux
    GsParamIN(2) = "descripcion"
    Select Case Val(vAux)
        Case 0, 7
            GsParamIN(0) = _
            " SELECT concepto, descripcion" & _
            " FROM conceptos_ns" & _
            " WHERE compania = '" & GsCveCia & "'"
            GsParamIN(1) = "concepto"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Concepto"
            GsParamIN(5) = "Conceptos de Nomina"
        Case 1
            GsParamIN(0) = "SELECT agrupacion, descripcion" & _
            " FROM agrupaciones_trab where 1=1"
            GsParamIN(1) = "agrupacion"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Agrupacion"
            GsParamIN(5) = "Agrupaciones de Trabajadores"
        Case 2, 5
            GsParamIN(0) = "SELECT agr_conceptos, descripcion" & _
            " FROM agr_conceptos_ns WHERE 1=1"
            GsParamIN(1) = "agr_conceptos"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Agrupacion"
            GsParamIN(5) = "Agrupaciones de Conceptos"
        Case 3
            If Mado.DBMS = "SQLSERVER" Then
                GsParamIN(0) = "SELECT convert(numeric,substring(variable,9,2)) variable, descripcion_var" & _
                " FROM defn_variables_ns WHERE compania = '" & GsCveCia & "' And" & _
                " variable like 'var_tra_%' And descripcion_var not like 'Variable_Trabajador%'"
                GsParamIN(1) = "convert(numeric,substring(variable,9,2))"
            Else
                GsParamIN(0) = "SELECT Substr(variable,9,2) variable, descripcion_var" & _
                " FROM defn_variables_ns WHERE compania = '" & GsCveCia & "' And" & _
                " variable like 'var_tra_%' And descripcion_var not like 'Variable_Trabajador%'"
                GsParamIN(1) = "Substr(variable,9,2)"
            End If
            GsParamIN(2) = "descripcion_var"
            GsParamIN(3) = "Variable"
            GsParamIN(5) = "Variables del Trabajador"
        Case 6
            GsParamIN(0) = "SELECT tipo_nomina, descripcion" & _
            " FROM tipos_nomina where 1=1"
            GsParamIN(1) = "tipo_nomina"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Tipo de Nomina"
            GsParamIN(5) = "Tipos de Nomina"
        Case 8
            If Mado.DBMS = "SQLSERVER" Then
                GsParamIN(0) = "SELECT convert(numeric,substring(variable,9,2)) variable, descripcion_var" & _
                " FROM defn_variables_ns WHERE compania = '" & GsCveCia & "' And" & _
                " variable like 'var_nom_%' And descripcion_var not like 'Variable de Nómina%'"
                GsParamIN(1) = "convert(numeric,substring(variable,9,2))"
            Else
                GsParamIN(0) = "SELECT Substr(variable,9,2) variable, descripcion_var" & _
                " FROM defn_variables_ns WHERE compania = '" & GsCveCia & "' And" & _
                " variable like 'var_nom_%' And descripcion_var not like 'Variable de Nómina%'"
                GsParamIN(1) = "Substr(variable,9,2)"
            End If
            GsParamIN(2) = "descripcion_var"
            GsParamIN(3) = "Variable"
            GsParamIN(5) = "Variables de Nomina"
        Case 9
            If spread.ActiveRow = 27 Or spread.ActiveRow = 28 Or spread.ActiveRow = 37 Then
                spread.GetText 3, 38, vAgr
            Else
                spread.GetText 3, spread.ActiveRow - 1, vAgr
            End If
            GsParamIN(0) = "SELECT dato, descripcion" & _
            " FROM datos_agr_trab where agrupacion = '" & vAgr & "'"
            GsParamIN(1) = "dato"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Dato"
            GsParamIN(5) = "Datos de Agrupación"
        Case 12
            GsParamIN(0) = "SELECT coleccion, descripcion" & _
            " FROM colecciones where 1=1"
            GsParamIN(1) = "coleccion"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Colecciones"
            GsParamIN(5) = "Colecciones"
        Case 13 'Relación Laboral
            GsParamIN(0) = "SELECT relacion_laboral, descripcion" & _
            " FROM relaciones_laborales where 1=1"
            GsParamIN(1) = "relacion_laboral"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Relación"
            GsParamIN(5) = "Relaciones Laborales"
        Case 14 'Tabla de Impuestos
            GsParamIN(0) = "SELECT DISTINCT impuesto, 'Tabla de impuesto '" & IIf(Left(UCase(GsDsn), 3) = "ORA", "||", "+") & "RTRIM(impuesto)" & _
            " FROM impuestos where 1=1"
            GsParamIN(1) = "impuesto"
            GsParamIN(2) = "'Tabla de impuesto '" & IIf(Left(UCase(GsDsn), 3) = "ORA", "||", "+") & "RTRIM(impuesto)"
            GsParamIN(3) = "Tabla"
            GsParamIN(5) = "Tablas de Impuestos"
        Case 15 'clase de nomina
            GsParamIN(0) = "SELECT clase_nomina, descripcion" & _
            " FROM clases_nomina where 1=1"
            GsParamIN(1) = "clase_nomina"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Clase de Nomina"
            GsParamIN(5) = "Clases de Nomina"
            
        Case Else
            Screen.MousePointer = vbDefault
            Exit Sub
    End Select
    GsParamIN(4) = "Descripcion"
    GsParamIN(6) = " ORDER BY 1"
    frmLista.Show 1
    If Trim(GsParamOUT(0)) <> "" Then
        With spread
            .Col = 3: .Row = .ActiveRow: .Text = GsParamOUT(0)
        End With
        Bitacora.mCambia
    End If
End Sub

Private Sub tbpTab_TabActivate(TabToActivate As Integer)
    tbpTab.Visible = False
  
  MbE1 = False
  MbE2 = False
  MbE3 = False
  MbE4 = False

  Select Case TabToActivate
      Case 0: MbE1 = True
      Case 1: MbE2 = True
      Case 2: MbE3 = True
      Case 3: MbE4 = True
  End Select

End Sub

Private Sub tbpTab_TabShown(ActiveTab As Integer)
    Form_Resize
    tbpTab.Visible = True
End Sub
