VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.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 FCO1080T 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   4800
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8880
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Reportes Definicion_T.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4800
   ScaleWidth      =   8880
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtProcBorrado 
      Height          =   285
      Left            =   1920
      MaxLength       =   30
      TabIndex        =   4
      Top             =   720
      Width           =   2835
   End
   Begin VB.TextBox txtDescripcion 
      Height          =   315
      Left            =   1920
      TabIndex        =   1
      Top             =   75
      Width           =   4215
   End
   Begin VB.TextBox txtProcGenera 
      Height          =   285
      Left            =   1920
      MaxLength       =   30
      TabIndex        =   3
      Top             =   405
      Width           =   2835
   End
   Begin TabproLib.vaTabPro tbpTab 
      Height          =   2985
      Left            =   90
      TabIndex        =   5
      Top             =   1200
      Width           =   8655
      _Version        =   131072
      _ExtentX        =   15266
      _ExtentY        =   5265
      _StockProps     =   100
      BackColor       =   -2147483633
      OffsetFromClientTop=   -1  'True
      BookCornerGuardWidth=   105
      BookCornerGuardLength=   405
      TabCaption      =   "Reportes Definicion_T.frx":030A
      Begin FPSpread.vaSpread sprPAR 
         Height          =   2220
         Left            =   -23114
         TabIndex        =   6
         Top             =   -17699
         Width           =   7935
         _Version        =   131077
         _ExtentX        =   13996
         _ExtentY        =   3916
         _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  =   "Reportes Definicion_T.frx":0548
      End
      Begin FPSpread.vaSpread sprRUT 
         Height          =   2220
         Left            =   -23099
         TabIndex        =   7
         Top             =   -17744
         Width           =   7935
         _Version        =   131077
         _ExtentX        =   13996
         _ExtentY        =   3916
         _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  =   "Reportes Definicion_T.frx":06A1
      End
      Begin FPSpread.vaSpread sprENT 
         Height          =   2220
         Left            =   150
         TabIndex        =   8
         Top             =   525
         Width           =   7935
         _Version        =   131077
         _ExtentX        =   13996
         _ExtentY        =   3916
         _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  =   "Reportes Definicion_T.frx":07FA
      End
      Begin FPSpread.vaSpread sprUSU 
         Height          =   2220
         Left            =   -23114
         TabIndex        =   10
         Top             =   -17699
         Width           =   7935
         _Version        =   131077
         _ExtentX        =   13996
         _ExtentY        =   3916
         _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  =   "Reportes Definicion_T.frx":0953
      End
      Begin VB.Image imgListaRUT 
         Height          =   480
         Left            =   -23609
         Picture         =   "Reportes Definicion_T.frx":0AAC
         Top             =   -15989
         Width           =   480
      End
      Begin VB.Image imgListaParam 
         Height          =   480
         Left            =   -23609
         Picture         =   "Reportes Definicion_T.frx":0DB6
         Top             =   -15944
         Width           =   480
      End
   End
   Begin MSComDlg.CommonDialog dlgRuta 
      Left            =   7410
      Top             =   90
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Proc. Borrado Tablas"
      Height          =   210
      Index           =   0
      Left            =   120
      TabIndex        =   9
      Top             =   705
      Width           =   1530
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   7935
      Top             =   30
      _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           =   "Reportes Definicion_T.frx":10C0
   End
   Begin VB.Label lblLabels 
      Caption         =   "Descripción del Archivo"
      Height          =   255
      Index           =   10
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   1815
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Proc. Generación"
      Height          =   210
      Index           =   14
      Left            =   120
      TabIndex        =   2
      Top             =   390
      Width           =   1260
   End
End
Attribute VB_Name = "FCO1080T"
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 MsCodInter As String
Private MsParametro As String

Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
Private MoBitaENT As New ADAMBitacora.Bitacora
Private MoBitaRUT As New ADAMBitacora.Bitacora
Private MoBitaPAR As New ADAMBitacora.Bitacora
Private MoBitaUSU As New ADAMBitacora.Bitacora

Private MbRenovar As Boolean
Private MbE1 As Boolean
Private MbE2 As Boolean
Private MbE3 As Boolean
Private MBCambio As Boolean

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlalta": Altas
        Case "tlbaja": Bajas
        Case "tlrenueva": RenuevaDatos
        Case "tlguarda": GuardarCambios
        Case "tlsalida": Unload Me
    End Select
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 vbKeyF11: GuardarCambios
        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)
       
    GAdam.ObtieneColores
    Set clsSpread = New NSpread
    AsignaIconos abToolbar, 3, LALTA, LBAJA, LRENUEVA, LGUARDA, LSALIDA
    
    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 = 8970
        MiY = 5175
        Me.Width = MiX
        Me.Height = MiY
    End If
            
    MsCodInter = GsDatoAux
    MsParametro = "report_" & Val(MsCodInter)
    
    MbE1 = False
    MbE2 = False
    MbE3 = False
        
    CreaBitacoras
    RenuevaDatos
    MBCambio = False
    
    Screen.MousePointer = vbDefault
End Sub

Private Sub CreaBitacoras()

  MoBitaENT.mCreaBitacora sprENT, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
  MoBitaENT.mTablaSPInfo 0, "sp_fco_upd_reportes_par", "" & MsCodInter & "", 1, 2, 3, 4
  MoBitaENT.mTablaSPInfo 1, "sp_fco_del_reportes_par", "" & MsCodInter & "", 1
  MoBitaENT.mTablaSPInfo 2, "sp_fco_upd_reportes_par", "" & MsCodInter & "", 1, 2, 3, 4
  MoBitaENT.mColNoNulls 1

  MoBitaRUT.mCreaBitacora sprRUT, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
  MoBitaRUT.mTablaSPInfo 0, "sp_fdt_upd_rutas", "'" & GsOper & "'", "" & MsCodInter & "", 1, 2, 4, 5, 6
  MoBitaRUT.mTablaSPInfo 1, "sp_fdt_del_rutas", "'" & GsOper & "'", "" & MsCodInter & "", 1, 2
  MoBitaRUT.mTablaSPInfo 2, "sp_fdt_upd_rutas", "'" & GsOper & "'", "" & MsCodInter & "", 1, 2, 4, 5, 6
  MoBitaRUT.mColNoNulls 1

  MoBitaPAR.mCreaBitacora sprPAR, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
  MoBitaPAR.mTablaSPInfo 0, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'" & MsParametro & "'", 1, 3, 4, 6, 2
  MoBitaPAR.mTablaSPInfo 1, "sp_fdt_del_parametros", "'COL'", "'" & GsCveCia & "'", "'" & MsParametro & "'", 1
  MoBitaPAR.mTablaSPInfo 2, "sp_fdt_upd_parametros", "'COL'", "'" & GsCveCia & "'", "'" & MsParametro & "'", 1, 3, 4, 6, 2
  MoBitaPAR.mColNoNulls 1

  MoBitaUSU.mCreaBitacora sprUSU, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
  MoBitaUSU.mTablaSPInfo 2, "sp_fco_upd_reportes_aut", "'" & GsCveCia & "'", "" & MsCodInter & "", 1, 2
  MoBitaUSU.mColNoNulls 1

End Sub

Private Sub RecuperaDatos()
    MAdo.Sql = "SELECT descripcion, proc_generacion, proc_borrado FROM fco_reportes WHERE cod_rep = '" & MsCodInter & "'"
    MAdo.SendSQL
    
    If Not MAdo.EOF Then
      txtDescripcion = MAdo.GetField(1)
      txtProcGenera = MAdo.GetField(2)
      txtProcBorrado = MAdo.GetField(3)
    
    End If

End Sub

Private Sub RenuevaDatos()
    If iDeseaGuardar = 2 Then Exit Sub 'Cancelar
    RecuperaDatos
    RenuevaDatosEnt
    RenuevaDatosRut
    RenuevaDatosPar
    RenuevaDatosUsu
End Sub

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

Private Sub RenuevaDatosEnt()
Dim i As Integer
Dim nValor As Byte
'DCR-JUL-6-07: para cambio en Eficacia
Dim nValorSTD As Byte
Dim nValorEFI As Byte

    With sprENT
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprENT
        .ColWidth(1) = 6
        .ColWidth(2) = 6
        .ColWidth(3) = 30
        .ColWidth(4) = 0
        .ColWidth(5) = 20
        
        .SetText 1, 0, "Secuencia"
        .SetText 2, 0, "Orden"
        .SetText 3, 0, "Descripcion"
        .SetText 4, 0, "Tipo Oculto": .Col = 4: .ColHidden = True
        .SetText 5, 0, "Tipo"
                
        .Col = 1: .TypeEditLen = 3: .TypeEditCharCase = 2
        .Col = 2: .TypeEditLen = 3: .TypeEditCharCase = 2
        .Col = 3: .TypeEditLen = 40
                                
        .ScrollBars = ScrollBarsBoth
        ConfiguraSpreadJCL sprENT
    End With
    
    MAdo.Sql = "SELECT secuencia, orden, tit_campo, tipo_campo, '' tipo_dato FROM fco_reportes_par " & _
               "WHERE cod_rep = " & MsCodInter
    If Not MAdo.SendSQL Then Exit Sub
    
    clsSpread.LlenaSpread 0, sprENT, MAdo, MAdo.lhDbc, MAdo.lhstmt

    With sprENT
      .Col = 1: .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 = 5: .Row = i
          .CellType = 8: .TypeComboBoxIndex = -1
          .TypeComboBoxString = "01.Compañia"
          .TypeComboBoxString = "02.trabajador"
          .TypeComboBoxString = "03.Concepto"
          .TypeComboBoxString = "04.Agr. Conc."
          .TypeComboBoxString = "05.Agr. Trab"
          .TypeComboBoxString = "06.Dato Agr. Trab"
          .TypeComboBoxString = "07.Clase Nom"
          .TypeComboBoxString = "08.Tipo Nom"
          .TypeComboBoxString = "09.Val Entero"
          .TypeComboBoxString = "10.Val Decimales"
          .TypeComboBoxString = "11.Val Alfa"
          .TypeComboBoxString = "12.Fecha"
          .TypeComboBoxString = "13.Var. Trab."
          .TypeComboBoxString = "14.Var. Nom."
          .TypeComboBoxString = "15.Col. Trab."
          .TypeComboBoxString = "16.Sucursales"
          .TypeComboBoxString = "17.Si/No"
          .TypeComboBoxString = "18.Ciudades Pago (Embargos)"
          .TypeComboBoxString = "19. Nro Liquidacion (NI)"
          .TypeComboBoxString = "20.Año"
          .TypeComboBoxString = "21.Mes"
          .TypeComboBoxString = "22.Presupuesto"
          
'          'agregamos el nuevo parametro para eficacia
'          'DCR-JUL-6-2007: Para eficacia manejo unos codigos diferentes, por si se
'          'aumentan en el estandar de los clientes, listas mayores de 22, poder seguir
'          'teniendolas aqui, y manejar las de eficacia adicionales que salgan
'          nValorSTD = 22  'OJO: este valor, si la lista aumenta, debe irse cambiando, por ahora queda en 22 que el ultimo es presupuesto
'          nValorEFI = 1   'OJO: este valor, va aumentando, dependiendo que tantas listas propias de Eficacia resulten, por ahora solo hay una que es la 51, si surge otra se aumenta en 1
'          .TypeComboBoxString = "51.Empresas"
          
          If nValor < 50 Then
             .TypeComboBoxCurSel = nValor - 1
          Else
             .TypeComboBoxCurSel = (nValorSTD + nValorEFI) - 1
          End If
      
      Next i
    End With

End Sub

Private Sub RenuevaDatosRut()
Dim i As Integer
Dim nValor As Byte

    With sprRUT
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprRUT
        .ColWidth(1) = 6
        .ColWidth(2) = 0
        .ColWidth(3) = 12
        .ColWidth(4) = 20
        .ColWidth(5) = 40
        .ColWidth(6) = 20
        
        .SetText 1, 0, "Secuencia"
        .SetText 2, 0, "Tipo Oculto": .Col = 2: .ColHidden = True
        .SetText 3, 0, "Tipo"
        .SetText 4, 0, "Archivo"
        .SetText 5, 0, "Ruta (Lectura/Escritura)"
        .SetText 6, 0, "Tabla/Vista"
                
        .Col = 1: .TypeEditLen = 3
        .Col = 4: .TypeEditLen = 50
        .Col = 5: .TypeEditLen = 500
        .Col = 6: .TypeEditLen = 30
                                
        .ScrollBars = ScrollBarsBoth
        ConfiguraSpreadJCL sprRUT
    End With
    
    MAdo.Sql = "SELECT secuencia, tipo, '' tipo_dato, archivo, ruta, tabla FROM fdt_rutas " & _
               "WHERE operacion = '" & GsOper & "' AND codigo = " & MsCodInter
    If Not MAdo.SendSQL Then Exit Sub
    
    clsSpread.LlenaSpread 0, sprRUT, MAdo, MAdo.lhDbc, MAdo.lhstmt

    With sprRUT
      .Col = 1: .Row = -1: .Lock = True
      .Col = 3: .Row = -1: .Lock = True
      .Col = 5: .Row = -1: .Lock = True
        
      For i = 1 To .VirtualMaxRows
          .Col = 2: .Row = i
          If .Text <> "" Then
            nValor = Val(.Value)
          Else
            nValor = 255
          End If
      
          .Col = 3: .Row = i
          .CellType = 8: .TypeComboBoxIndex = -1
          .TypeComboBoxString = "01. Reportes"
          .TypeComboBoxString = "02. Medio Magn."
          .TypeComboBoxCurSel = nValor - 1
          
          If nValor = 2 Then 'es medio magnetico
            .Col = 6: .Row = i: .Lock = True
            .BackColor = vbButtonShadow
            .Col = 4: .Row = i: .Lock = False
          Else
            .Col = 6: .Row = i: .Lock = False
            .BackColor = vbWhite
            .Col = 4: .Row = i: .Lock = True
          End If
      Next i
    End With

End Sub

Private Sub RenuevaDatosPar()

  Dim i As Integer
  Dim nValor As Byte
  Dim nCampo As Byte
  
  With sprPAR
      .Visible = False
      .Action = 28
      GAdam.ConfiguracionSpread sprPAR
      .ColWidth(1) = 8
      .ColWidth(2) = 28.8
      .ColWidth(3) = 6.5
      .ColWidth(4) = 0
      .ColWidth(5) = 12
      .ColWidth(6) = 0
      .ColWidth(7) = 8
      .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
      .ScrollBars = ScrollBarsBoth
      
      ConfiguraSpreadJCL sprPAR
  End With
  
  MAdo.Sql = _
  " SELECT secuencia, descripcion, dato, tipo, '' tipo_dato, campo, '' campo_concepto" & _
  " FROM vw_fdt_parametros" & _
  " WHERE pais = 'COL' And compania='" & GsCveCia & "' And parametro = '" & MsParametro & "'" & _
  " ORDER BY secuencia"
  If Not MAdo.SendSQL Then Exit Sub
  clsSpread.LlenaSpread 0, sprPAR, MAdo, MAdo.lhDbc, MAdo.lhstmt
  
  With sprPAR
      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
          .TypeComboBoxString = "01.Agr. Trab."
          .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.Tabla Ppto"
                              
          Select Case nValor
              Case 1: .TypeComboBoxCurSel = 0
              Case 3: .TypeComboBoxCurSel = 1
              Case 4: .TypeComboBoxCurSel = 2
              Case 5: .TypeComboBoxCurSel = 3
              Case 6: .TypeComboBoxCurSel = 4
              Case 7: .TypeComboBoxCurSel = 5
              Case 8: .TypeComboBoxCurSel = 6
              Case 9: .TypeComboBoxCurSel = 7
              Case 10: .TypeComboBoxCurSel = 8
              Case 11: .TypeComboBoxCurSel = 9
              Case 12: .TypeComboBoxCurSel = 10
              Case 13: .TypeComboBoxCurSel = 11
              Case 14: .TypeComboBoxCurSel = 12
              Case 15: .TypeComboBoxCurSel = 13
              Case 16: .TypeComboBoxCurSel = 14
          End Select
          
          .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 sprPAR, 5

End Sub

Private Sub RenuevaDatosUsu()

  Dim i As Integer
  Dim nValor As Byte
  Dim nCampo As Byte
  
  With sprUSU
      .Visible = False
      .Action = 28
      GAdam.ConfiguracionSpread sprUSU
      .ColWidth(1) = 2
      .ColWidth(2) = 10
      .SetText 1, 0, " "
      .SetText 2, 0, "Usuario"
      .ScrollBars = ScrollBarsBoth
      
      ConfiguraSpreadJCL sprUSU
  End With
  
  If UCase(Left(GsDsn, 3)) = "ORA" Then
    MAdo.Sql = _
        "SELECT DISTINCT '1', u.username " & _
        "FROM sys.all_users u, fco_reportes_aut a , dba_role_privs n " & _
        "WHERE u.UserName = a.usuariow " & _
        "AND u.username = n.grantee " & _
        "AND granted_role in ('ADAMA', 'ADAMS', 'ADAME') " & _
        "AND a.compania = '" & GsCveCia & "' " & _
        "AND a.cod_rep = " & MsCodInter & " " & _
        "UNION SELECT DISTINCT '0', m.username " & _
        "FROM sys.all_users m , dba_role_privs n " & _
        "WHERE m.UserName = n.grantee " & _
        "AND granted_role in ('ADAMA', 'ADAMS', 'ADAME') " & _
        "AND m.username not in (SELECT b.usuariow FROM fco_reportes_aut b WHERE b.compania=  '" & GsCveCia & "' AND b.cod_rep = " & MsCodInter & ") order by 2"
  End If  'falta el del SQL
  
  If UCase(Left(GsDsn, 3)) = "SQL" Then
    MAdo.Sql = _
        "SELECT DISTINCT '1', cast (m.name as varchar (50)) " & _
        "FROM sysusers u, master.dbo.syslogins m, fco_reportes_aut a " & _
        "WHERE u.sid = m.sid AND m.name = a.usuariow AND a.compania = '" & GsCveCia & "' AND a.cod_rep = " & MsCodInter & " " & _
        "UNION SELECT DISTINCT '0', cast (m.name as varchar (50)) " & _
        "FROM sysusers u, master.dbo.syslogins m " & _
        "WHERE u.sid = m.sid And m.Name " & _
        "NOT IN (select b.usuariow from fco_reportes_aut b where b.compania= '" & GsCveCia & "'  And b.cod_rep = " & MsCodInter & ") order by 2"
  End If

  If Not MAdo.SendSQL Then Exit Sub
  clsSpread.LlenaSpread 0, sprUSU, MAdo, MAdo.lhDbc, MAdo.lhstmt
  
  With sprUSU
        .Col = 1: .Row = -1: .CellType = 10
        .Col = 2: .Row = -1: .Lock = True
  End With
  GAdam.AjustaSpread sprUSU, 2

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If iDeseaGuardar = vbCancel Then Cancel = 1: Exit Sub
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set MAdo = Nothing
    Set FCO1080T = Nothing
    Set clsSpread = Nothing
    Set MoBitaENT = Nothing
    Set MoBitaRUT = Nothing
    Set MoBitaPAR = Nothing
    Set MoBitaUSU = Nothing
    Gtc(MiCx).ihijas = Gtc(MiCx).ihijas - 1
End Sub

Private Sub imgListaParam_Click()
    EjecutaF4 sprPAR, MoBitaPAR
End Sub

Private Sub imgListaRut_Click()
Dim Aux As Variant
Dim sRuta As String
Dim nValor As Byte
With sprRUT
  If .ActiveCol = 5 Then
      .GetText .ActiveCol, .ActiveRow, Aux
      sRuta = Aux
      sRuta = sCambiarSlash(sRuta, 2)
  
      GsDatoAux = sRuta
      frmCarpeta.Show 1
      If GsDatoAux <> "" Then
          .Col = 5: .Row = .ActiveRow: .Text = sCambiarSlash(GsDatoAux, 1)
          MoBitaRUT.mCambia
      End If
  End If
  
  'si es reporte solo le permite escoger archivos .rpt
  If .ActiveCol = 4 Then
    On Error Resume Next
    .Col = 3: .Row = .ActiveRow
    nValor = Val(Left(.Text, 2))
    
    If nValor = 1 Then
      dlgRuta.FileName = "*.rpt"
      dlgRuta.Filter = "Reportes (*.rpt)|*.rpt"
      dlgRuta.CancelError = True
      dlgRuta.ShowOpen
      sRuta = dlgRuta.FileName
      If Len(Trim(sRuta)) > 0 And (sRuta <> "*.rpt") Then
        .Col = 4: .Row = .ActiveRow: .Text = sInterpretar(sRuta, 2)
        MoBitaRUT.mCambia
      End If
    End If
  End If
    
End With
End Sub

Private Sub sprENT_Change(ByVal Col As Long, ByVal Row As Long)
Dim Aux As Variant
Dim nValor As Byte
Dim nValorAnt As Byte

  If Col = 5 Then
    With sprENT
      .GetText Col, Row, Aux
      .Col = 4: .Row = .ActiveRow
      nValor = Val(Left(Aux, 2))
      .Text = nValor
             
      If nValor = 6 Then
          .Col = 4: .Row = .ActiveRow - 1
          nValorAnt = Val(.Text)
          If nValorAnt <> 5 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 With
  End If

  MoBitaENT.mCambia
End Sub

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

Private Sub Altas()
Dim nValor As Byte
'DCR-JUL-6-07: para cambio en Eficacia
Dim nValorSTD As Byte
Dim nValorEFI As Byte

'parametros de entrada
If MbE1 Then
    With sprENT
      .VirtualMode = True
      MoBitaENT.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 = "01.Compañia"
      .TypeComboBoxString = "02.trabajador"
      .TypeComboBoxString = "03.Concepto"
      .TypeComboBoxString = "04.Agr. Conc."
      .TypeComboBoxString = "05.Agr. Trab"
      .TypeComboBoxString = "06.Dato Agr. Trab"
      .TypeComboBoxString = "07.Clase Nom"
      .TypeComboBoxString = "08.Tipo Nom"
      .TypeComboBoxString = "09.Val Entero"
      .TypeComboBoxString = "10.Val Decimales"
      .TypeComboBoxString = "11.Val Alfa"
      .TypeComboBoxString = "12.Fecha"
      .TypeComboBoxString = "13.Var. Trab."
      .TypeComboBoxString = "14.Var. Nom."
      .TypeComboBoxString = "15.Col. Trab."
      .TypeComboBoxString = "16.Sucursales"
      .TypeComboBoxString = "17.Si/No"
      .TypeComboBoxString = "18.Ciudades Pago (Embargos)"
      .TypeComboBoxString = "19. Nro Liquidacion (NI)"
      .TypeComboBoxString = "20.Año"
      .TypeComboBoxString = "21.Mes"
      .TypeComboBoxString = "22.Presupuesto"
      
'      'agregamos el nuevo parametro para eficacia
'      'DCR-JUL-6-2007: Para eficacia manejo unos codigos diferentes, por si se
'      'aumentan en el estandar de los clientes, listas mayores de 22, poder seguir
'      'teniendolas aqui, y manejar las de eficacia adicionales que salgan
'      nValorSTD = 22  'OJO: este valor, si la lista aumenta, debe irse cambiando, por ahora queda en 22 que el ultimo es presupuesto
'      nValorEFI = 1   'OJO: este valor, va aumentando, dependiendo que tantas listas propias de Eficacia resulten, por ahora solo hay una que es la 51, si surge otra se aumenta en 1
'      .TypeComboBoxString = "51.Empresas"
      
      If nValor < 50 Then
         .TypeComboBoxCurSel = nValor - 1
      Else
         .TypeComboBoxCurSel = (nValorSTD + nValorEFI) - 1
      End If
      
      .Col = 1: .Row = .ActiveRow: .Lock = True
    End With
End If

'parametros de ruta
If MbE2 Then
    With sprRUT
      .VirtualMode = True
      MoBitaRUT.mAgrega
      .VirtualMode = False
    
      .Col = 2: .Row = .ActiveRow: .Text = "1"
      If .Text <> "" Then
        nValor = Val(.Value)
      Else
        nValor = 255
      End If
  
      .Col = 3: .Row = .ActiveRow
      .CellType = 8: .TypeComboBoxIndex = -1
      .TypeComboBoxString = "01. Reportes"
      .TypeComboBoxString = "02. Medio Magn."
      .TypeComboBoxCurSel = nValor - 1
      
      If nValor = 2 Then ' si es medio magnetico
        .Col = 6: .Row = .ActiveRow: .Text = "fco_reportes_mm": .Lock = True
        .BackColor = vbButtonShadow
        .Col = 4: .Row = .ActiveRow: .Lock = False
      Else
        .Col = 6: .Row = .ActiveRow: .Lock = False
        .BackColor = vbWhite
        .Col = 4: .Row = .ActiveRow: .Lock = True
      End If
            
      .Col = 1: .Row = .ActiveRow: .Lock = True
      .Col = 5: .Row = .ActiveRow: .Lock = True
      
    End With
End If

If MbE3 Then
  With sprPAR
      .VirtualMode = True
      MoBitaPAR.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 = "01.Agr. Trab."
      .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.Tabla Ppto"
                          
      Select Case nValor
          Case 1: .TypeComboBoxCurSel = 0
          Case 3: .TypeComboBoxCurSel = 1
          Case 4: .TypeComboBoxCurSel = 2
          Case 5: .TypeComboBoxCurSel = 3
          Case 6: .TypeComboBoxCurSel = 4
          Case 7: .TypeComboBoxCurSel = 5
          Case 8: .TypeComboBoxCurSel = 6
          Case 9: .TypeComboBoxCurSel = 7
          Case 10: .TypeComboBoxCurSel = 8
          Case 11: .TypeComboBoxCurSel = 9
          Case 12: .TypeComboBoxCurSel = 10
          Case 13: .TypeComboBoxCurSel = 11
          Case 14: .TypeComboBoxCurSel = 12
          Case 15: .TypeComboBoxCurSel = 13
          Case 16: .TypeComboBoxCurSel = 14
      End Select
      
      .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 If

End Sub

Private Sub Bajas()

  If MbE1 Then
      If sprENT.VirtualMaxRows <= 0 Then Exit Sub
      MoBitaENT.mBorra
  End If
  
  If MbE2 Then
      If sprRUT.VirtualMaxRows <= 0 Then Exit Sub
      MoBitaRUT.mBorra
  End If
  
  If MbE3 Then
      If sprPAR.VirtualMaxRows <= 0 Then Exit Sub
      MoBitaPAR.mBorra
  End If
  
End Sub

Private Sub GuardarCambios()
  If MbE1 Then
      If sprENT.MaxRows = 0 Then Exit Sub
      Screen.MousePointer = vbHourglass
      MbRenovar = MoBitaENT.mActualizaBD
      MoBitaENT.mVaciaBuffer
      Screen.MousePointer = vbDefault
      MbE1 = False
      If MbRenovar = True Then RenuevaDatosEnt
  End If

  If MbE2 Then
      If sprRUT.MaxRows = 0 Then Exit Sub
      Screen.MousePointer = vbHourglass
      MbRenovar = MoBitaRUT.mActualizaBD
      MoBitaRUT.mVaciaBuffer
      Screen.MousePointer = vbDefault
      MbE2 = False
      If MbRenovar = True Then RenuevaDatosRut
  End If

  If MbE3 Then
      If sprPAR.MaxRows = 0 Then Exit Sub
      Screen.MousePointer = vbHourglass
      MbRenovar = MoBitaPAR.mActualizaBD
      MoBitaPAR.mVaciaBuffer
      Screen.MousePointer = vbDefault
      MbE3 = False
      If MbRenovar = True Then RenuevaDatosPar
  End If

  If sprUSU.MaxRows = 0 Then Exit Sub
  Screen.MousePointer = vbHourglass
  MbRenovar = MoBitaUSU.mActualizaBD
  MoBitaUSU.mVaciaBuffer
  Screen.MousePointer = vbDefault
  If MbRenovar = True Then RenuevaDatosUsu

  If MBCambio Then
    MAdo.Sql = "sp_fco_upd_reportes " & _
               "'" & GsCveCia & "',1, " & _
               MsCodInter & "," & _
               "'" & txtDescripcion & "', 2," & _
               "'FCO1080'," & _
               "'" & txtProcGenera & "'," & _
               "'" & txtProcBorrado & "'"
    MAdo.ExecSQL
    RecuperaDatos
  End If
    
End Sub

Private Sub sprENT_GotFocus()
    With sprENT
        .ReDraw = False
        .ShadowColor = GAdam.GLSPREADACTIVO
        .ShadowText = GAdam.GLTEXTOACTIVO
        .ReDraw = True
    End With

End Sub

Private Sub sprENT_LostFocus()
  With sprENT
      .ReDraw = False
      .ShadowColor = GAdam.GLSPREADINACTIVO
      .ShadowText = GAdam.GLTEXTOINACTIVO
      .ReDraw = True
  End With

End Sub

Private Sub sprPAR_Change(ByVal Col As Long, ByVal Row As Long)
Dim Aux As Variant
Dim nValor As Byte
Dim nValorAnt As Byte

  With sprPAR
    If Col = 5 Then
        .GetText Col, Row, 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
            .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
    
    If Col = 7 Then
      .GetText Col, Row, 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
  MoBitaPAR.mCambia

End Sub

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

End Sub

Private Sub sprPAR_GotFocus()
  With sprPAR
      .ReDraw = False
      .ShadowColor = GAdam.GLSPREADACTIVO
      .ShadowText = GAdam.GLTEXTOACTIVO
      .ReDraw = True
  End With

End Sub

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

Private Sub sprPAR_LostFocus()
  With sprPAR
      .ReDraw = False
      .ShadowColor = GAdam.GLSPREADINACTIVO
      .ShadowText = GAdam.GLTEXTOINACTIVO
      .ReDraw = True
  End With

End Sub

Private Sub sprRUT_Change(ByVal Col As Long, ByVal Row As Long)
Dim Aux As Variant
Dim sRuta As String
Dim nValor As Byte


With sprRUT

  If Col = 3 Then
      .GetText Col, Row, Aux
      .Col = 2: .Row = .ActiveRow
      nValor = Val(Left(Aux, 2))
      .Text = nValor
      
      If nValor = 2 Then ' si es medio magnetico
        .Col = 6: .Row = .ActiveRow: .Text = "fco_reportes_mm": .Lock = True
        .BackColor = vbButtonShadow
        .Col = 4: .Row = .ActiveRow: .Lock = False
      Else
        .Col = 6: .Row = .ActiveRow: .Lock = False
        .BackColor = vbWhite
        .Col = 4: .Row = .ActiveRow: .Lock = True
      End If
  End If

  If Col = 5 Then
      .GetText Col, Row, Aux
      sRuta = Aux
      .Text = sCambiarSlash(sRuta, 1)

  End If
End With
  
  MoBitaRUT.mCambia

End Sub

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

End Sub

Private Sub sprRUT_GotFocus()
    With sprRUT
        .ReDraw = False
        .ShadowColor = GAdam.GLSPREADACTIVO
        .ShadowText = GAdam.GLTEXTOACTIVO
        .ReDraw = True
    End With

End Sub

Private Sub sprRUT_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then imgListaRut_Click
End Sub

Private Sub sprRUT_LostFocus()
    With sprRUT
        .ReDraw = False
        .ShadowColor = GAdam.GLSPREADINACTIVO
        .ShadowText = GAdam.GLTEXTOINACTIVO
        .ReDraw = True
    End With

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(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(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 To_Number(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) = "To_Number(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(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 To_Number(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) = "To_Number(Substr(variable,9,2))"
            End If
            GsParamIN(2) = "descripcion_var"
            GsParamIN(3) = "Variable"
            GsParamIN(5) = "Variables de Nomina"
        Case 9
            Spread.GetText 3, Spread.ActiveRow - 1, vAgr
            GsParamIN(0) = "SELECT dato, descripcion" & _
            " FROM datos_agr_trab where agrupacion = '" & vAgr & "'"
            GsParamIN(1) = "dato"
            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(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 16 'Tabla presupuestal
            GsParamIN(0) = "SELECT tabla, descripcion" & _
            " FROM tablas_apl_pp where 1=1"
            GsParamIN(1) = "tabla"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Tablas Presupuestales"
            GsParamIN(5) = "Tablas Presupuestales"
            
        Case Else
            Screen.MousePointer = vbDefault
            Exit Sub
    End Select
    GsParamIN(4) = "Descripcion"
    GsParamIN(6) = ""
    frmLista.Show 1
    If Trim(GsParamOUT(0)) <> "" Then
        'Spread.SetText 3, Spread.ActiveRow, GsParamOUT(0) Extrañamente no funciona
        With Spread
            .Col = 3: .Row = .ActiveRow: .Text = GsParamOUT(0)
        End With
        Bitacora.mCambia
    End If
End Sub

Private Sub txtDescripcion_Change()
  MBCambio = True
End Sub

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

Private Sub txtProcGenera_Change()
  MBCambio = True
End Sub

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

End Sub

Private Function sInterpretar(Texto As String, Tipo As Byte) As String
    'Tipo 1: Ruta, Tipo 2: Archivo
    Dim i As Integer
    Dim j As Integer
    
    i = Len(Texto)
    j = 0
    While i > 0
        If Mid$(Texto, i, 1) = "\" Then
            j = i
            i = 0
        Else
            i = i - 1
        End If
    Wend
    If j = 0 Then
        sInterpretar = ""
    Else
        Select Case Tipo
            Case 1
                sInterpretar = Left$(Texto, j - 1)
            Case 2
                sInterpretar = Mid$(Texto, j + 1)
        End Select
    End If
End Function

Private Sub sprUSU_Change(ByVal Col As Long, ByVal Row As Long)
    MoBitaUSU.mCambia
End Sub

Private Sub sprUSU_Click(ByVal Col As Long, ByVal Row As Long)
    If Col = 1 Then MoBitaUSU.mCambia
End Sub

Private Sub sprUSU_GotFocus()
  With sprUSU
      .ReDraw = False
      .ShadowColor = GAdam.GLSPREADACTIVO
      .ShadowText = GAdam.GLTEXTOACTIVO
      .ReDraw = True
  End With

End Sub

Private Sub sprUSU_LostFocus()
  With sprUSU
      .ReDraw = False
      .ShadowColor = GAdam.GLSPREADINACTIVO
      .ShadowText = GAdam.GLTEXTOINACTIVO
      .ReDraw = True
  End With

End Sub

