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 = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Object = "{9FE8BEE1-8569-4532-8518-BB32F08FC1EB}#2.0#0"; "dtF4.ocx"
Begin VB.Form FCO5020 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Genera Proceso Reportes"
   ClientHeight    =   6750
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8595
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "FCO5020 Genera Reportes.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6750
   ScaleWidth      =   8595
   Begin VB.Frame fraFrame 
      Caption         =   "Orden"
      Height          =   945
      Index           =   6
      Left            =   5535
      TabIndex        =   32
      Top             =   5055
      Width           =   2910
      Begin VB.OptionButton optAlf 
         Caption         =   "Alfabético"
         Height          =   240
         Left            =   225
         TabIndex        =   33
         Top             =   405
         Value           =   -1  'True
         Width           =   1030
      End
      Begin VB.OptionButton optNum 
         Caption         =   "Numérico"
         Height          =   240
         Left            =   1650
         TabIndex        =   34
         Top             =   405
         Width           =   1030
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Filtro Trabajadores"
      Height          =   1080
      Index           =   5
      Left            =   5535
      TabIndex        =   25
      Top             =   3930
      Width           =   2910
      Begin VB.TextBox txtTrabDde 
         Height          =   315
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   27
         Top             =   285
         Width           =   1155
      End
      Begin VB.TextBox txtTrabHta 
         Height          =   315
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   30
         Top             =   630
         Width           =   1155
      End
      Begin DataTec_F4.dtF4 dtF4TraD 
         Height          =   375
         Left            =   2400
         TabIndex        =   28
         Top             =   240
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   661
      End
      Begin DataTec_F4.dtF4 dtF4TraH 
         Height          =   375
         Left            =   2400
         TabIndex        =   31
         Top             =   640
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   661
      End
      Begin VB.Label lblLabels 
         BackStyle       =   0  'Transparent
         Caption         =   "Desde"
         Height          =   300
         Index           =   4
         Left            =   135
         TabIndex        =   26
         Top             =   300
         Width           =   600
      End
      Begin VB.Label lblLabels 
         BackStyle       =   0  'Transparent
         Caption         =   "Hasta"
         Height          =   300
         Index           =   5
         Left            =   135
         TabIndex        =   29
         Top             =   645
         Width           =   600
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Filtro Agrupación Principal"
      Height          =   1080
      Index           =   4
      Left            =   5535
      TabIndex        =   18
      Top             =   2745
      Width           =   2910
      Begin VB.TextBox txtDatoHta 
         Height          =   315
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   23
         Top             =   630
         Width           =   1155
      End
      Begin VB.TextBox txtDatoDde 
         Height          =   315
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   20
         Top             =   270
         Width           =   1155
      End
      Begin DataTec_F4.dtF4 dtF4DtoD 
         Height          =   375
         Left            =   2400
         TabIndex        =   21
         Top             =   240
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   661
      End
      Begin DataTec_F4.dtF4 dtF4DtoH 
         Height          =   375
         Left            =   2400
         TabIndex        =   24
         Top             =   640
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   661
      End
      Begin VB.Label lblLabels 
         BackStyle       =   0  'Transparent
         Caption         =   "Hasta"
         Height          =   300
         Index           =   7
         Left            =   135
         TabIndex        =   22
         Top             =   645
         Width           =   600
      End
      Begin VB.Label lblLabels 
         BackStyle       =   0  'Transparent
         Caption         =   "Desde"
         Height          =   300
         Index           =   6
         Left            =   135
         TabIndex        =   19
         Top             =   285
         Width           =   600
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Clasificación y Cortes"
      Height          =   1695
      Index           =   3
      Left            =   5535
      TabIndex        =   8
      Top             =   945
      Width           =   2910
      Begin VB.TextBox txtAgrup1 
         Height          =   315
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   10
         Top             =   345
         Width           =   1155
      End
      Begin VB.TextBox txtAgrup2 
         Height          =   315
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   13
         Top             =   750
         Width           =   1155
      End
      Begin VB.TextBox txtAgrup3 
         Height          =   315
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   16
         Top             =   1140
         Width           =   1155
      End
      Begin DataTec_F4.dtF4 dtF4Agr 
         Height          =   375
         Index           =   0
         Left            =   2400
         TabIndex        =   11
         Top             =   360
         Width           =   375
         _ExtentX        =   661
         _ExtentY        =   661
      End
      Begin DataTec_F4.dtF4 dtF4Agr 
         Height          =   375
         Index           =   1
         Left            =   2400
         TabIndex        =   14
         Top             =   760
         Width           =   375
         _ExtentX        =   661
         _ExtentY        =   661
      End
      Begin DataTec_F4.dtF4 dtF4Agr 
         Height          =   375
         Index           =   2
         Left            =   2400
         TabIndex        =   17
         Top             =   1150
         Width           =   375
         _ExtentX        =   661
         _ExtentY        =   661
      End
      Begin VB.Label lblLabels 
         BackStyle       =   0  'Transparent
         Caption         =   "Agr. Principal"
         Height          =   300
         Index           =   1
         Left            =   135
         TabIndex        =   9
         Top             =   360
         Width           =   1050
      End
      Begin VB.Label lblLabels 
         BackStyle       =   0  'Transparent
         Caption         =   "Cód. Agr. 2"
         Height          =   300
         Index           =   2
         Left            =   135
         TabIndex        =   12
         Top             =   750
         Width           =   1035
      End
      Begin VB.Label lblLabels 
         BackStyle       =   0  'Transparent
         Caption         =   "Cód. Agr. 3"
         Height          =   300
         Index           =   3
         Left            =   135
         TabIndex        =   15
         Top             =   1140
         Width           =   1005
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Rutas (Lectura/Escritura)"
      Height          =   2340
      Index           =   2
      Left            =   120
      TabIndex        =   5
      Top             =   3675
      Width           =   5310
      Begin FPSpread.vaSpread sprRUT 
         Height          =   1875
         Left            =   165
         OleObjectBlob   =   "FCO5020 Genera Reportes.frx":030A
         TabIndex        =   6
         Top             =   285
         Width           =   4710
      End
      Begin DataTec_F4.dtF4 dtF4Rut 
         Height          =   375
         Left            =   4920
         TabIndex        =   7
         Top             =   480
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   661
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Parámetros Entrada"
      Height          =   2700
      Index           =   1
      Left            =   120
      TabIndex        =   2
      Top             =   915
      Width           =   5325
      Begin FPSpread.vaSpread sprPAR 
         Height          =   2220
         Left            =   165
         OleObjectBlob   =   "FCO5020 Genera Reportes.frx":04E3
         TabIndex        =   3
         Top             =   285
         Width           =   4710
      End
      Begin DataTec_F4.dtF4 dtF4Par 
         Height          =   375
         Left            =   4920
         TabIndex        =   4
         Top             =   480
         Width           =   375
         _ExtentX        =   661
         _ExtentY        =   661
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Reporte a Generar"
      Height          =   720
      Index           =   0
      Left            =   120
      TabIndex        =   0
      Top             =   135
      Width           =   5340
      Begin VB.ComboBox cboReportes 
         Height          =   330
         Left            =   120
         Style           =   2  'Dropdown List
         TabIndex        =   1
         Top             =   240
         Width           =   5130
      End
   End
   Begin Crystal.CrystalReport crpReporte 
      Left            =   5865
      Top             =   345
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   6330
      Top             =   285
      _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           =   "FCO5020 Genera Reportes.frx":06BC
   End
End
Attribute VB_Name = "FCO5020"
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 MsReportes() As String 'JCL DIC-29-06 Antes se llamaba Medios
Private MsCodRep As String 'JCL DIC-29-06 Antes se llamaba CodInter
Private MiNumDecimales As Integer ' Número de decimales
Private MiIdProc As Integer 'JCL DIC-29-06 Antes se llamaba GIdProc

Private MbAgr1_OK As Boolean
Private MbAgr2_OK As Boolean
Private MbAgr3_OK As Boolean
Private MbTraDde_OK As Boolean
Private MbTraHta_OK As Boolean
Private MbDtoDde_OK As Boolean
Private MbDtoHta_OK As Boolean

Private Enum Datos
    Agrupacion1
    Agrupacion2
    Agrupacion3
    TrabajadorDesde
    TrabajadorHasta
    DatoDesde
    DatoHasta
End Enum
'JCL Sep.23/05. Nombre de Archivo Según Parámetros
Private MsParametros() As String

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

Private Sub cboReportes_Click()
    If cboReportes.ListIndex = -1 Then Exit Sub
    
    BorrarIdRep
    MsCodRep = MsReportes(0, cboReportes.ListIndex)
    RenuevaDatos
    On Error Resume Next
    With sprPAR
        .SetFocus
        .Row = 1
        .Col = 4
        .Action = 0
    End With
End Sub

Private Sub dtF4Agr_Click(Index As Integer)
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT agrupacion, descripcion" & _
    " FROM agrupaciones_trab WHERE 1=1"
    GsParamIN(1) = "agrupacion"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Agrupación"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Agrupaciones de Trabajadores"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        Select Case Index
            Case 0
                txtAgrup1 = GsParamOUT(0)
                MbAgr1_OK = True
            Case 1
                txtAgrup2 = GsParamOUT(0)
                MbAgr2_OK = True
            Case 2
                txtAgrup3 = GsParamOUT(0)
                MbAgr3_OK = True
        End Select
    End If
End Sub

Private Sub dtF4Par_Click()
    EjecutaF4 sprPAR
End Sub

Private Sub dtF4RUT_Click()
    Dim Aux As Variant
    Dim sRuta As String
    With sprRUT
        If .ActiveCol = 4 Then
            .GetText .ActiveCol, .ActiveRow, Aux
            sRuta = Aux
            sRuta = sCambiarSlash(sRuta, 2)
            GsDatoAux = sRuta
            frmCarpeta.Show 1
            If GsDatoAux <> "" Then
                .Col = 4: .Row = .ActiveRow: .Text = sCambiarSlash(GsDatoAux, 1)
            End If
        End If
    End With
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF5: RenuevaDatos
        Case vbKeyF11: Procesar
        Case vbKeyF12: abToolbar.Bands(1).TrackPopup -1, -1
        Case vbKeyF4
            If LCase(ActiveControl.Name) = "txtagrup1" Then dtF4Agr_Click 0
            If LCase(ActiveControl.Name) = "txtagrup2" Then dtF4Agr_Click 1
            If LCase(ActiveControl.Name) = "txtagrup3" Then dtF4Agr_Click 2
            If LCase(ActiveControl.Name) = "txttrabdde" Then dtF4TraD_Click
            If LCase(ActiveControl.Name) = "txttrabhta" Then dtF4TraH_Click
            If LCase(ActiveControl.Name) = "txtdatodde" Then dtF4DtoD_Click
            If LCase(ActiveControl.Name) = "txtdatohta" Then dtF4DtoH_Click
    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
       
    '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
    
    'Asigna Iconos al ToolBar
    AsignaIconos abToolbar, 3, LEJECUTA, LRENUEVA, LSALIDA
    
    'Recupera constantes de Colores para los Spreads (cuando se activan o inactivan)
    GAdam.ObtieneColores
    
    'Tamaño de la forma
    Width = 8685 'JCL DIC-29-06 Desaparecen variables MiX y MiY
    Height = 7125
            
    'Decimales según panel de control
    MiNumDecimales = iNumeroDecimalesImporte
            
    MiIdProc = 0
    MsCodRep = "0"
    RecuperaListaMedios
    RenuevaDatos
    sprPAR.ShadowColor = GAdam.GLSPREADINACTIVO
    sprRUT.ShadowColor = GAdam.GLSPREADINACTIVO
    Screen.MousePointer = vbDefault
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    BorrarIdRep
    Set MAdo = Nothing
    Set FCO5020 = Nothing
    Gtc(MiCx).ihijas = Gtc(MiCx).ihijas - 1
End Sub

Private Sub sprPAR_GotFocus()
    With sprPAR
        .ShadowColor = GAdam.GLSPREADACTIVO
        .ShadowText = GAdam.GLTEXTOACTIVO
    End With
    With sprRUT
        .ShadowColor = GAdam.GLSPREADINACTIVO
        .ShadowText = GAdam.GLTEXTOINACTIVO
    End With
End Sub

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

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

Private Sub sprRUT_GotFocus()
    With sprRUT
        .ShadowColor = GAdam.GLSPREADACTIVO
        .ShadowText = GAdam.GLTEXTOACTIVO
    End With
    With sprPAR
        .ShadowColor = GAdam.GLSPREADINACTIVO
        .ShadowText = GAdam.GLTEXTOINACTIVO
    End With
End Sub

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

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

Private Sub txtAgrup1_GotFocus()
    txtAgrup1.SelStart = 0
    txtAgrup1.SelLength = Len(txtAgrup1)
End Sub

Private Sub txtAgrup1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtAgrup1) <> "" Then
            ValidarExistencia Agrupacion1, MbAgr1_OK
            If Not MbAgr1_OK Then Exit Sub
        End If
        KeyAscii = 0
        SendEnter
    End If
End Sub

Private Sub txtAgrup2_GotFocus()
    txtAgrup2.SelStart = 0
    txtAgrup2.SelLength = Len(txtAgrup2)
End Sub

Private Sub txtAgrup2_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtAgrup2) <> "" Then
            ValidarExistencia Agrupacion2, MbAgr2_OK
            If Not MbAgr2_OK Then Exit Sub
        End If
        KeyAscii = 0
        SendEnter
    End If
End Sub

Private Sub txtAgrup3_GotFocus()
    txtAgrup3.SelStart = 0
    txtAgrup3.SelLength = Len(txtAgrup3)
End Sub

Private Sub txtAgrup3_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtAgrup3) <> "" Then
            ValidarExistencia Agrupacion3, MbAgr3_OK
            If Not MbAgr3_OK Then Exit Sub
        End If
        KeyAscii = 0
        SendEnter
    End If
End Sub

Private Sub txtTrabDde_GotFocus()
    txtTrabDde.SelStart = 0
    txtTrabDde.SelLength = Len(txtTrabDde)
End Sub

Private Sub txtTrabDde_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtTrabDde) <> "" Then
            ValidarExistencia TrabajadorDesde, MbTraDde_OK
            If Not MbTraDde_OK Then Exit Sub
        End If
        Me.txtTrabHta = Me.txtTrabDde
        KeyAscii = 0
        SendEnter
    End If
End Sub

Private Sub txtTrabHta_GotFocus()
    txtTrabHta.SelStart = 0
    txtTrabHta.SelLength = Len(txtTrabHta)
End Sub

Private Sub txtTrabHta_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtTrabHta) <> "" Then
            ValidarExistencia TrabajadorHasta, MbTraHta_OK
            If Not MbTraHta_OK Then Exit Sub
        End If
        KeyAscii = 0
        SendEnter
    End If
End Sub

Private Sub txtDatoDde_GotFocus()
    txtDatoDde.SelStart = 0
    txtDatoDde.SelLength = Len(txtDatoDde)
End Sub

Private Sub txtDatoDde_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtDatoDde) <> "" Then
            ValidarExistencia DatoDesde, MbDtoDde_OK
            If Not MbDtoDde_OK Then Exit Sub
        End If
        Me.txtDatoHta = Me.txtDatoDde
        KeyAscii = 0
        SendEnter
    End If
End Sub

Private Sub txtDatoHta_GotFocus()
    txtDatoHta.SelStart = 0
    txtDatoHta.SelLength = Len(txtDatoHta)
End Sub

Private Sub txtDatoHta_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtDatoHta) <> "" Then
            ValidarExistencia DatoHasta, MbDtoHta_OK
            If Not MbDtoHta_OK Then Exit Sub
        End If
        KeyAscii = 0
        SendEnter
    End If
End Sub

Private Sub dtF4TraD_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT A.trabajador, REPLACE(A.nombre, '/', ' ')" & _
    " FROM trabajadores A, trabajadores_grales B" & _
    " WHERE A.trabajador = B.trabajador" & _
    " AND B.compania = '" & GsCveCia & "'" & _
    " AND B.sit_trabajador = 1" & _
    " AND B.clase_nomina IN " & _
    " (SELECT clase_nomina FROM rel_usu_clase_nom" & _
    " WHERE usuario = '" & GsUid & "')" & _
    " AND A.trabajador NOT IN" & _
    " (SELECT x.trabajador FROM rel_trab_agr x, rel_usu_agr_trab y" & _
    " WHERE x.compania = '" & GsCveCia & "'" & _
    " AND x.agrupacion = y.agrupacion AND x.dato = y.dato" & _
    " AND y.usuario = '" & GsUid & "')"
    GsParamIN(1) = "A.trabajador"
    GsParamIN(2) = "A.nombre"
    GsParamIN(3) = "Trabajador"
    GsParamIN(4) = "Nombre"
    GsParamIN(5) = "Trabajadores"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        txtTrabDde = GsParamOUT(0)
        MbTraDde_OK = True
        txtTrabHta = GsParamOUT(0)
        MbTraHta_OK = True
    End If
End Sub

Private Sub dtF4TraH_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT A.trabajador, REPLACE(A.nombre, '/', ' ')" & _
    " FROM trabajadores A, trabajadores_grales B" & _
    " WHERE A.trabajador = B.trabajador" & _
    " AND B.compania = '" & GsCveCia & "'" & _
    " AND B.sit_trabajador = 1" & _
    " AND LTrim(A.trabajador) >= '" & Trim(txtTrabDde) & "'" & _
    " AND B.clase_nomina IN " & _
    " (SELECT clase_nomina FROM rel_usu_clase_nom" & _
    " WHERE usuario = '" & GsUid & "')" & _
    " AND A.trabajador NOT IN" & _
    " (SELECT x.trabajador FROM rel_trab_agr x, rel_usu_agr_trab y" & _
    " WHERE x.compania = '" & GsCveCia & "'" & _
    " AND x.agrupacion = y.agrupacion AND x.dato = y.dato" & _
    " AND y.usuario = '" & GsUid & "')"
    GsParamIN(1) = "A.trabajador"
    GsParamIN(2) = "A.nombre"
    GsParamIN(3) = "Trabajador"
    GsParamIN(4) = "Nombre"
    GsParamIN(5) = "Trabajadores"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        txtTrabHta = GsParamOUT(0)
        MbTraHta_OK = True
    End If
End Sub

Private Sub dtF4DtoD_Click()
    If Not MbAgr1_OK And Trim(txtAgrup1) <> "" Then ValidarExistencia ClaseNomina, MbAgr1_OK
    If Not MbAgr1_OK Then Exit Sub
    
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT dato, descripcion" & _
    " FROM datos_agr_trab" & _
    " WHERE agrupacion = '" & txtAgrup1 & "'" & _
    " AND dato NOT IN " & _
    " (SELECT dato FROM rel_usu_agr_trab " & _
    " WHERE agrupacion = '" & txtAgrup1 & "'" & _
    " AND usuario = '" & GsUid & "')"
    GsParamIN(1) = "dato"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Dato"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Datos de la agrupacion '" & Trim(txtAgrup1) & "'"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        txtDatoDde = GsParamOUT(0)
        MbDtoDde_OK = True
        txtDatoHta = GsParamOUT(0)
        MbDtoHta_OK = True
    End If
End Sub

Private Sub dtF4DtoH_Click()
    If Not MbAgr1_OK And Trim(txtAgrup1) <> "" Then ValidarExistencia ClaseNomina, MbAgr1_OK
    If Not MbAgr1_OK Then Exit Sub
    
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT dato, descripcion" & _
    " FROM datos_agr_trab" & _
    " WHERE agrupacion = '" & txtAgrup1 & "'" & _
    " AND dato >= '" & txtDatoDde & "'" & _
    " AND dato NOT IN " & _
    " (SELECT dato FROM rel_usu_agr_trab " & _
    " WHERE agrupacion = '" & txtAgrup1 & "'" & _
    " AND usuario = '" & GsUid & "')"
    GsParamIN(1) = "dato"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Dato"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Datos de la agrupacion '" & Trim(txtAgrup1) & "'"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        txtDatoHta = GsParamOUT(0)
        MbDtoHta_OK = True
    End If
End Sub

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

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

Private Sub BorrarIdRep()
    Dim sProc As String
    
    On Error GoTo NoPude
    If MiIdProc <> 0 Then
        'Por si el programador no crea reporte de borrado de tablas, borramos la tabla del proceso
        MAdo.Sql = "DELETE fco_reportes_proc " & _
        "WHERE id_rep = " & MiIdProc & " AND " & _
        "usuariow = '" & GsUid & "' AND " & _
        "cod_rep = " & MsCodRep
        MAdo.SendSQL
        If UCase(Left(GsDsn, 3)) = "ORA" Then
            MAdo.Sql = "COMMIT"
            MAdo.SendSQL
        End If
    
        'Llamada al procedimiento
        MAdo.Sql = "sp_fco_del_reportes_tablas " & _
        MiIdProc & ",'" & GsUid & "'," & MsCodRep
        
        If MAdo.ExecSQL = -1 Then GoTo NoPude
    End If
    Exit Sub
NoPude:
    Screen.MousePointer = vbDefault
    If Err > 0 Then
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub EjecutaF4(Spread As Control)
    'JCL DIC-29-06 USO DE CLASE LISTA
    Dim vaux As Variant
    Dim vAgr As Variant
    Dim Lista As New cdtLista
    
    If Spread.ActiveCol <> 4 Then Exit Sub
    Screen.MousePointer = vbHourglass
    
    Spread.GetText 3, Spread.ActiveRow, vaux
    
    With Lista
        .Campo2 = "descripcion"
        .Titulo2 = "Descripcion"
        Select Case Val(vaux)
            Case 1 'compañias
                .Sql = _
                "SELECT c.compania, c.nombre_cia " & _
                " FROM companias c, aut_companias ac " & _
                " WHERE c.compania = ac.compania AND " & _
                " ac.usuario = '" & GsUid & "'"
    
                .Campo1 = "c.compania"
                .Campo2 = "c.nombre_cia"
                .Titulo1 = "Compañia"
                .TituloVentana = "Compañias"
        
            Case 2 'trabajador
                .Sql = _
                "SELECT a.trabajador, replace(a.nombre,'/',' ') as nombre" & _
                " FROM trabajadores a, trabajadores_grales b" & _
                " WHERE a.trabajador = b.trabajador AND " & _
                " b.compania = '" & GsCveCia & "'"
    
                .Campo1 = "a.trabajador"
                .Campo2 = "nombre"
                .Titulo1 = "Trabajador"
                .TituloVentana = "Listado de Trabajadores"
        
            Case 3 'concepto
                .Sql = _
                " SELECT concepto, descripcion" & _
                " FROM conceptos_ns" & _
                " WHERE compania = '" & GsCveCia & "'"
                .Campo1 = "concepto"
                .Titulo1 = "Concepto"
                .TituloVentana = "Conceptos de Nomina"
                
            Case 4 'agr de conceptos
                .Sql = "SELECT agr_conceptos, descripcion" & _
                " FROM agr_conceptos_ns WHERE 1=1"
                .Campo1 = "agr_conceptos"
                .Titulo1 = "Agrupación"
                .TituloVentana = "Agrupaciones de Conceptos"
                
            Case 5 'Agr de trabajadores
                .Sql = "SELECT agrupacion, descripcion" & _
                " FROM agrupaciones_trab where 1=1"
                .Campo1 = "agrupacion"
                .Titulo1 = "Agrupación"
                .TituloVentana = "Agrupaciones de Trabajadores"
    
            Case 6 'Dato Agr trab
                Spread.GetText 4, Spread.ActiveRow - 1, vAgr
                .Sql = "SELECT dato, descripcion" & _
                " FROM datos_agr_trab where agrupacion = '" & vAgr & "'"
                .Campo1 = "dato"
                .Titulo1 = "Dato"
                .TituloVentana = "Datos de Agrupación"
            
            Case 7 'clase de nomina
                .Sql = "SELECT a.clase_nomina, descripcion" & _
                " FROM clases_nomina a, rel_usu_clase_nom b" & _
                " WHERE a.clase_nomina = b.clase_nomina" & _
                " AND b.usuario = '" & GsUid & "' "
                .Campo1 = "a.clase_nomina"
                .Titulo1 = "Clase Nómina"
                .TituloVentana = "Clases de Nómina"
            
            Case 8  'tipo de nomina
                .Sql = "SELECT tipo_nomina, descripcion" & _
                " FROM tipos_nomina where 1=1"
                .Campo1 = "tipo_nomina"
                .Titulo1 = "Tipo de Nomina"
                .TituloVentana = "Tipos de Nomina"
            
            Case 13
                If MAdo.DBMS = "SQLSERVER" Then
                    .Sql = "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%'"
                    .Campo1 = "convert(numeric,substring(variable,9,2))"
                Else
                    .Sql = "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%'"
                    .Campo1 = "To_Number(Substr(variable,9,2))"
                End If
                .Campo2 = "descripcion_var"
                .Titulo1 = "Variable"
                .TituloVentana = "Variables del Trabajador"
            
            Case 14
                If MAdo.DBMS = "SQLSERVER" Then
                    .Sql = "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%'"
                    .Campo1 = "convert(numeric,substring(variable,9,2))"
                Else
                    .Sql = "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%'"
                    .Campo1 = "To_Number(Substr(variable,9,2))"
                End If
                .Campo2 = "descripcion_var"
                .Titulo1 = "Variable"
                .TituloVentana = "Variables de Nomina"
            
            Case 15
                .Sql = "SELECT coleccion, descripcion" & _
                " FROM colecciones where 1=1"
                .Campo1 = "coleccion"
                .Titulo1 = "Colección"
                .TituloVentana = "Colecciones"
                
            Case 16
                .Sql = "SELECT sucursal, descripcion" & _
                " FROM vw_fco_sucursales_cia" & _
                " WHERE compania='" & GsCveCia & "'"
                
                .Campo1 = "dato"
                .Titulo1 = "Codigo"
                .TituloVentana = "Sucursales"
                            
            Case 18
                .Sql = "SELECT ciudad, nombre" & _
                " FROM fdt_ciudades_pago"
                .Campo1 = "ciudad"
                .Campo2 = "nombre"
                .Titulo1 = "Codigo"
                .TituloVentana = "Ciudades"
                
            Case 19
                .Sql = " SELECT a.numero_liquidacion, replace(b.nombre, '/', ' ') nombre" & _
                " FROM liquidaciones_enc a, trabajadores b" & _
                " WHERE a.trabajador = b.trabajador" & _
                " AND a.compania = '" & GsCveCia & "'"
                .Campo1 = "numero_liquidacion"
                .Campo2 = "nombre"
                .Titulo1 = "Nro Liquidacion"
                .Titulo2 = "Nombre"
                .TituloVentana = "Liquidaciones"
            Case 22
                .Sql = " SELECT presupuesto, descripcion" & _
                " FROM presupuestos"
                .Campo1 = "presupuesto"
                .Campo2 = "descripcion"
                .Titulo1 = "Presupuesto"
                .Titulo2 = "Descripcion"
                .TituloVentana = "Presupuestos"
                
'            'Las de Eficacia
'            Case 51
'                .Sql = "SELECT empresa, nombre" & _
'                " FROM vw_de_fco_empresas"
'                .Campo1 = "empresa"
'                .Campo2 = "nombre"
'                .Titulo1 = "Empresa"
'                .TituloVentana = "Empresas"
                        
            Case Else
                Screen.MousePointer = vbDefault
                Exit Sub
        End Select
        .Orden = ""
        .MostrarLista
    
        If Trim(.Valor1) <> "" Then
            With Spread
                .Col = 4: .Row = .ActiveRow: .Text = Lista.Valor1
            End With
        End If
    End With
    
    Set Lista = Nothing
End Sub

Private Sub MostrarError(Texto As String, Control As Control)
    On Error Resume Next
    Screen.MousePointer = vbDefault
    clsMsgbox.Mensaje Texto, mAceptar, mAdvierte, GsTitMsg
    Control.SetFocus
End Sub

Private Sub MostrarMM()
Dim sTabla As String
Dim sRuta As String
Dim sArchivo As String
Dim i As Integer
Dim Aux As Variant
Dim iTipo As Integer
Dim iSec As Integer
Dim iRetVal As Long
Dim sFuncSub As String

On Error GoTo RutaNoExiste

If Mid$(UCase(GsDsn), 1, 3) = "ORA" Then
    sFuncSub = "SubStr"
Else
    sFuncSub = "SubString"
End If

With sprRUT
    For i = 1 To .VirtualMaxRows
        .GetText 2, i, Aux
        iTipo = CInt(Aux)
        .Col = 1: .Row = i
        If Val(.Value) = 1 And iTipo = 2 Then  'si esta seleccionado y ademas es reporte
          .GetText 3, i, Aux
          sArchivo = CStr(Aux)
          .GetText 4, i, Aux
          sRuta = CStr(Aux)
          sRuta = sCambiarSlash(sRuta, 2)
          .GetText 5, i, Aux
          sTabla = CStr(Aux)
          .GetText 6, i, Aux
          iSec = CInt(Aux)

          MAdo.Sql = "SELECT " & sFuncSub & "(registros,1,500)," & sFuncSub & "(registros, 501, 500), " & _
                    "" & sFuncSub & "(registros,1001,500)," & sFuncSub & "(registros, 1501, 500) " & _
                    "FROM " & sTabla & " " & _
                    " WHERE id_rep = " & MiIdProc & " AND usuariow = '" & GsUid & "'" & _
                    " AND cod_rep = " & MsCodRep & " AND sec_archivo = " & iSec & " " & _
                    " ORDER BY secuencia "
          
          If Not MAdo.SendSQL Then GoTo Finaliza
           
          'JCL Sep.23/05. Nombre de Archivo Según Parámetros
          sArchivo = sInterpretaTags(sArchivo)
          If Dir(sRuta, vbDirectory) = "" Then MkDir (sRuta)  'Si no existe la ruta crearla
           
          sRuta = sRuta & "\" & sArchivo
          Open sRuta For Output As #1
          Do Until MAdo.EOF
              Print #1, MAdo.GetField(1) & MAdo.GetField(2) & MAdo.GetField(3) & MAdo.GetField(4)
              MAdo.Mnext
          Loop
          Close #1
                      
          'JCL Sep.23/05. Que ejecute el programa por defecto y no siempre Notepad.exe
          'Esto me es útil para que los archivos csv los abra con Excel (requerimiento de Encajes).
          'iRetVal = Shell("NOTEPAD.EXE " & sRuta, vbNormalFocus)
          iRetVal = ShellExecute(Me.hwnd, "Open", sRuta, "", "", 1)

        End If
    Next i
End With

Exit Sub

RutaNoExiste:
    If Err = 76 Then
        sRuta = "C:"
        Resume Next
    Else
        Screen.MousePointer = vbDefault
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If

Finaliza:
    Screen.MousePointer = vbDefault

End Sub

Private Sub MostrarReporte()
    Dim sTabla As String
    Dim sRuta As String
    Dim sArchivo As String
    Dim i As Integer
    Dim j As Integer
    Dim Aux As Variant
    Dim iTipo As Integer
    Dim sOrden As String
    Dim sRutaRpt As String
    Dim sConsulta As String
    'Dim frmReporte As DT03_Reporte
    
    'On Error GoTo RutaNoExiste
    
    With sprRUT
        For i = 1 To sprRUT.VirtualMaxRows
            .GetText 2, i, Aux
            iTipo = CInt(Aux)
            .Col = 1: .Row = i
            If Val(.Value) = 1 And iTipo = 1 Then  'si esta seleccionado y ademas es reporte
                .GetText 3, i, Aux
                sArchivo = CStr(Aux)
                .GetText 4, i, Aux
                sRuta = CStr(Aux)
                sRuta = sCambiarSlash(sRuta, 2)
                .GetText 5, i, Aux
                sTabla = CStr(Aux)
                
                'Mostrar el reporte
                sConsulta = " SELECT * FROM " & sTabla & _
                            " WHERE id_rep = " & MiIdProc & " AND usuariow = '" & GsUid & "'" & _
                            " AND cod_rep = " & MsCodRep
                'Set frmReporte = New DT03_Reporte
                'With frmReporte
                With crpReporte
                    .WindowShowPrintSetupBtn = True
                    .WindowShowSearchBtn = True
                    .MarginLeft = 0
                    .WindowState = crptNormal
                    .WindowTitle = cboReportes.Text
                    .SQLQuery = sConsulta
                    .Connect = "DSN = " & UCase(GsDsn) & "; UID = " & GsUid & "; PWD = " & GsPwd
                    .ReportFileName = sRuta & "\" & sArchivo
                    .ReplaceSelectionFormula ""
                    If optAlf.Value Then
                        .Formulas(0) = "det_Orden = {" & sTabla & ".nombre_trab}"
                    Else
                        .Formulas(0) = "det_Orden = {" & sTabla & ".trabajador}"
                    End If
                    .Action = 1
                End With
                'Set frmReporte = Nothing
            End If
        Next i
    End With
    
    Exit Sub
RutaNoExiste:
    If Err > 0 Then
        Screen.MousePointer = vbDefault
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub Procesar()
    Dim i As Integer
    Dim sValor As String
    Dim iOrden As Integer
    Dim sSql As String
    Dim iIdProc As Integer
    Dim Aux As Variant
    Dim blnEntro As Boolean
    Dim iTipo As Integer
    
    If sprPAR.VirtualMaxRows > 0 Then
        Screen.MousePointer = vbHourglass
        
        If Not MbAgr1_OK And Trim(txtAgrup1) <> "" Then
            ValidarExistencia Agrupacion1, MbAgr1_OK
            If Not MbAgr1_OK Then Exit Sub
        End If
        If Not MbAgr2_OK And Trim(txtAgrup2) <> "" Then
            ValidarExistencia Agrupacion2, MbAgr2_OK
            If Not MbAgr2_OK Then Exit Sub
        End If
        If Not MbAgr3_OK And Trim(txtAgrup3) <> "" Then
            ValidarExistencia Agrupacion3, MbAgr3_OK
            If Not MbAgr3_OK Then Exit Sub
        End If
        If Not MbTraDde_OK And Trim(txtTrabDde) <> "" Then
            ValidarExistencia TrabajadorDesde, MbTraDde_OK
            If Not MbTraDde_OK Then Exit Sub
        End If
        If Not MbTraHta_OK And Trim(txtTrabHta) <> "" Then
            ValidarExistencia TrabajadorHasta, MbTraHta_OK
            If Not MbTraHta_OK Then Exit Sub
        End If
        
        BorrarIdRep
        'Hallar un id para este proceso
        Randomize
        iIdProc = Int((32000 * Rnd) + 1)
        MiIdProc = iIdProc
        
        blnEntro = False
        'Grabando los datos de parametros sobre los cuales se basará el procedimiento
        With sprPAR
            For i = 1 To .VirtualMaxRows
                .GetText 3, i, Aux
                iTipo = CStr(Aux)
        
                .GetText 4, i, Aux
                sValor = CStr(Aux)
        
                'JCL Sep.23/05. Nombre de Archivo Según Parámetros
                ReDim Preserve MsParametros(i)
                MsParametros(i) = sValor
                
                If Len(Trim(sValor)) > 0 Then
                    blnEntro = True
                End If
        
                .GetText 1, i, Aux
                iOrden = Val(Aux)
        
                '***OJO: si el tipo es fecha, svalor debe guardarse como formato yyyymmdd
                If iTipo = 12 Then
                    sValor = Format(sValor, "yyyymmdd")
                End If
        
                If iTipo = 17 Then 'Se envia S o N
                    sValor = Left(sValor, 1)
                End If
        
                sSql = " INSERT INTO fco_reportes_proc (id_rep, usuariow, cod_rep, orden, valor) " & _
                " VALUES (" & MiIdProc & ",'" & GsUid & "'," & MsCodRep & "," & iOrden & ",'" & sValor & "')"
        
                MAdo.Sql = sSql
                MAdo.SendSQL
            Next i
        End With
        
        'si al menos se digito un parametro, entonces se ejecuta el sp
        If blnEntro Then
            'Llamada al procedimiento
            MAdo.Sql = "sp_fco_gen_reportes_proc " & _
            MiIdProc & ",'" & GsUid & "'," & MsCodRep & "," & _
            "'" & txtTrabDde & "'," & _
            "'" & txtTrabHta & "','" & txtAgrup1 & "'," & _
            "'" & txtAgrup2 & "','" & txtAgrup3 & "'," & _
            "'" & txtDatoDde & "','" & txtDatoHta & "'"
        
            'Si selecciono alguno para mostrar el reporte  y no hay error
            If MAdo.ExecSQL = -1 Then GoTo NoPude
        
            MostrarReporte
            MostrarMM
        End If
        Screen.MousePointer = vbDefault
    End If
    Exit Sub
NoPude:
    Screen.MousePointer = vbDefault
    If Err > 0 Then
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub RecuperaListaMedios()
    cboReportes.Clear
    Erase MsReportes
    MAdo.Sql = "SELECT a.cod_rep, a.descripcion " & _
               "FROM fco_reportes a, fco_reportes_cias b " & _
               "WHERE a.cod_rep = b.cod_rep AND b.compania = '" & GsCveCia & "' AND operacion = 'FCO1080' " & _
               "AND b.cod_rep IN (SELECT cod_rep FROM fco_reportes_aut WHERE compania = '" & GsCveCia & "' AND usuariow = '" & GsUid & "') " & _
               "ORDER BY a.cod_rep"

    If Not MAdo.SendSQL Then Exit Sub
    
    Do Until MAdo.EOF
        cboReportes.AddItem MAdo.GetField(2)  'Descripcion
        ReDim Preserve MsReportes(6, cboReportes.NewIndex)
        MsReportes(0, cboReportes.NewIndex) = MAdo.GetField(1)
        MAdo.Mnext
    Loop
End Sub

Private Sub RenuevaDatos()
    RenuevaDatosPar
    RenuevaDatosRut
End Sub

Private Sub RenuevaDatosPar()
    Dim i As Integer
    Dim iValor As Byte
    Dim k As Integer 'JCL DIC-29-06, DCR JUL-8-07, se cambia a integer en vez de byte
    
    With sprPAR
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprPAR
        .ColWidth(1) = 0
        .ColWidth(2) = 25
        .ColWidth(3) = 0
        
        .SetText 1, 0, "Orden Oculto": .Col = 1: .ColHidden = True
        .SetText 2, 0, "Descripcion"
        .SetText 3, 0, "Tipo Oculto": .Col = 3: .ColHidden = True
        .SetText 4, 0, "Valor"
        
        .ScrollBars = ScrollBarsBoth
        ConfiguraSpreadJCL sprPAR
        .EditEnterAction = EditEnterActionDown
        .ProcessTab = False
    End With
    
    MAdo.Sql = _
    "SELECT orden, tit_campo, tipo_campo, '' Valor FROM fco_reportes_par " & _
    "WHERE cod_rep = " & MsCodRep
    If Not MAdo.SendSQL Then Exit Sub
    
    Dim clsSpread As New NSpread 'JCL DIC-29-06
    clsSpread.LlenaSpread 0, sprPAR, MAdo, MAdo.lhDbc, MAdo.lhstmt
    Set clsSpread = Nothing 'JCL DIC-29-06
            
    With sprPAR
        'JCL DIC-29-06 Ajustando el ancho de la columna 4
        If sprPAR.MaxRows > 7 Then
            .ColWidth(4) = 11.7
        Else
            .ColWidth(4) = 13.9
        End If
        .Col = 2: .Row = -1: .Lock = True
        
        For i = 1 To .VirtualMaxRows
            .Row = i
            
            .Col = 3
            If .Text <> "" Then
                iValor = Val(.Value)
            Else
                iValor = 255
            End If
            
            'configurando la columna 4
            .Col = 4
            Select Case iValor
                Case 1 'compañia 'JCL DIC-29-06
                    MAdo.Sql = "SELECT compania FROM aut_companias WHERE usuario = '" & GsUid & "' ORDER BY 1"
                    MAdo.SendSQL
                    .CellType = 8: .TypeComboBoxIndex = -1
                    .TypeComboBoxString = ""
                    k = 0
                    Do Until MAdo.EOF
                        .TypeComboBoxString = MAdo.GetField(1)
                        k = k + 1
                        MAdo.Mnext
                    Loop
                    If k = 1 Then
                        .CellType = 1
                        .Text = MAdo.GetField(1)
                        .Lock = True
                    End If
                Case 4 'JCL DIC-29-06 (Agr. de Conceptos)
                    .CellType = 1
                    .TypeEditCharCase = 2
                    .TypeEditLen = 3
                Case 5 'JCL DIC-29-06 (Agr. de Trabajadores)
                    .CellType = 1
                    .TypeEditCharCase = 2
                    .TypeEditLen = 10
                Case 6 'JCL DIC-29-06 (Dato de Agrupación)
                    .CellType = 1
                    .TypeEditCharCase = 2
                    .TypeEditLen = 10
                Case 7 'JCL DIC-29-06 (Clase de Nómina)
                    MAdo.Sql = "SELECT clase_nomina FROM rel_usu_clase_nom WHERE usuario = '" & GsUid & "' ORDER BY 1"
                    MAdo.SendSQL
                    .CellType = 8: .TypeComboBoxIndex = -1
                    .TypeComboBoxString = ""
                    k = 0
                    Do Until MAdo.EOF
                        .TypeComboBoxString = MAdo.GetField(1)
                        k = k + 1
                        MAdo.Mnext
                    Loop
                    If k = 1 Then
                        .CellType = 1
                        .Text = MAdo.GetField(1)
                        .Lock = True
                    End If
                Case 8 'JCL DIC-29-06 (Tipo de Nómina)
                    MAdo.Sql = "SELECT tipo_nomina FROM tipos_nomina ORDER BY 1"
                    MAdo.SendSQL
                    .CellType = 8: .TypeComboBoxIndex = -1
                    .TypeComboBoxString = ""
                    Do Until MAdo.EOF
                        .TypeComboBoxString = MAdo.GetField(1)
                        MAdo.Mnext
                    Loop
                Case 9  'valor entero
                    .CellType = 3
                Case 10  'valor numerico con decimales
                    .CellType = 2: .TypeFloatSeparator = True:
                    .TypeFloatDecimalPlaces = MiNumDecimales: .TypeFloatMax = "99999999999999999": .TypeFloatMin = "0.00"
                Case 12
                    .CellType = 0   'Date
                    .TypeDateMin = "01011900"
                    .TypeDateMax = "12312078"
                    .TypeDateCentury = True
                    .TypeSpin = True
                Case 17
                    .CellType = 8: .TypeComboBoxIndex = -1
                    .TypeComboBoxString = "Si"
                    .TypeComboBoxString = "No"
                Case 20 'JCL DIC-29-06
                    .CellType = 3
                    .TypeIntegerMax = 2079 'Hasta Aquí aguanta el smalldatetime de SQL
                    .TypeIntegerMin = 2000
                Case 21 'JCL DIC-29-06
                    .CellType = 3
                    .TypeIntegerMax = 12
                    .TypeIntegerMin = 1
                Case 22 'DCR-JUN-15-07 (Presupuesto)
                    .CellType = 1
                    .TypeEditCharCase = 2
                    .TypeEditLen = 10
            End Select
        Next i
    End With
End Sub

Private Sub RenuevaDatosRut()
    Dim i As Integer
    Dim iValor As Byte
    
    With sprRUT
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprRUT
        
        .ColWidth(1) = 2
        .ColWidth(2) = 0
        .ColWidth(3) = 14
        .ColWidth(4) = 25
        .ColWidth(5) = 0
        .ColWidth(6) = 0
        
        .SetText 1, 0, " "
        .SetText 2, 0, "Tipo Oculto": .Col = 2: .ColHidden = True
        .SetText 3, 0, "Archivo"
        .SetText 4, 0, "Ruta (Lectura/Escritura)"
        .SetText 5, 0, "Tabla Oculta": .Col = 5: .ColHidden = True
        .SetText 6, 0, "Secuencia Oculta": .Col = 6: .ColHidden = True
        
        .Col = 3: .TypeEditLen = 50
        .Col = 4: .TypeEditLen = 500
        
        .ScrollBars = ScrollBarsBoth
        ConfiguraSpreadJCL sprRUT
        .ProcessTab = False
    End With
    
    MAdo.Sql = _
    "SELECT 1, tipo, archivo, ruta, tabla, secuencia FROM fdt_rutas " & _
    "WHERE operacion = 'FCO1080' AND codigo = " & MsCodRep & " ORDER BY tipo"
    If Not MAdo.SendSQL Then Exit Sub
    
    Dim clsSpread As New NSpread 'JCL DIC-29-06
    clsSpread.LlenaSpread 0, sprRUT, MAdo, MAdo.lhDbc, MAdo.lhstmt
    Set clsSpread = Nothing 'JCL DIC-29-06
    
    With sprRUT
        For i = 1 To .VirtualMaxRows
            .Col = 2: .Row = i
            If .Text <> "" Then
                iValor = Val(.Value)
            Else
                iValor = 255
            End If
            
            If iValor = 1 Then 'es un reporte, no se puede cambiar
                .Col = 3: .Row = i: .Lock = True
                .Col = 4: .Row = i: .Lock = True
            End If
            .Col = 1: .Row = -1: .CellType = 10
        Next i
    End With
End Sub

Private Function sInterpretaTags(Archivo) As String
'JCL Sep.23/05. Nombre de Archivo Según Parámetros
'DCR Sep.27/05. Se modifica, para que si se escribe abc_<1>_<2>, respete el nombre abc y solo reemplace los tags
    On Error Resume Next
    
    Dim sCad As String
    Dim i As Integer
    Dim sVal As String
    
    sCad = ""
    For i = 1 To Len(Archivo)
        'si la letra a leer es diferente a los signos de mayor y menor, arme la cadena
        If (Mid(Archivo, i, 1) <> "<") And (Mid(Archivo, i, 1) <> ">") Then
            If i > 1 Then
              'si la letra que esta leyendo no esta entre dos signos de mayor y menor
              If Mid(Archivo, i - 1, 1) <> "<" And Mid(Archivo, i + 1, 1) <> ">" Then
                    sCad = sCad & Mid(Archivo, i, 1)
              End If
            Else
              sCad = sCad & Mid(Archivo, i, 1)
            End If
        End If
        
        If i > 1 Then
          'si la letra que esta leyendo esta entre dos signos de mayor y menor, busque el parametro
          If Mid(Archivo, i - 1, 1) = "<" And Mid(Archivo, i + 1, 1) = ">" Then
             sVal = Mid(Archivo, i, 1)
             sCad = sCad & MsParametros(Val(sVal))
          End If
        End If
    Next i
    sInterpretaTags = sCad
End Function

Private Sub ValidarExistencia(Dato As Datos, Variable As Boolean)
    Screen.MousePointer = vbHourglass
    Variable = True
    Select Case Dato
        Case Agrupacion1
            MAdo.Sql = "SELECT agrupacion FROM agrupaciones_trab WHERE agrupacion = '" & txtAgrup1 & "'"
        Case Agrupacion2
            MAdo.Sql = "SELECT agrupacion FROM agrupaciones_trab WHERE agrupacion = '" & txtAgrup2 & "'"
        Case Agrupacion3
            MAdo.Sql = "SELECT agrupacion FROM agrupaciones_trab WHERE agrupacion = '" & txtAgrup3 & "'"
        Case TrabajadorDesde
            MAdo.Sql = "SELECT trabajador FROM trabajadores_grales" & _
            " WHERE compania = '" & GsCveCia & "'" & _
            " AND RTRIM(LTRIM(trabajador)) = '" & Trim(txtTrabDde) & "'"
        Case TrabajadorHasta
            MAdo.Sql = "SELECT trabajador FROM trabajadores_grales" & _
            " WHERE compania = '" & GsCveCia & "'" & _
            " AND RTRIM(LTRIM(trabajador)) = '" & Trim(txtTrabHta) & "'"
        Case DatoDesde
            MAdo.Sql = "SELECT dato FROM datos_agr_trab" & _
            " WHERE agrupacion = '" & txtAgrup1 & "'" & _
            " AND dato = '" & txtDatoDde & "'" & _
            " AND dato NOT IN " & _
            " (SELECT dato FROM rel_usu_agr_trab WHERE agrupacion = '" & txtAgrup1 & "'" & _
            " AND usuario = '" & GsUid & "')"
        Case DatoHasta
            MAdo.Sql = "SELECT dato FROM datos_agr_trab" & _
            " WHERE agrupacion = '" & txtAgrup1 & "'" & _
            " AND dato = '" & txtDatoHta & "'" & _
            " AND dato NOT IN " & _
            " (SELECT dato FROM rel_usu_agr_trab WHERE agrupacion = '" & txtAgrup1 & "'" & _
            " AND usuario = '" & GsUid & "')"
    End Select
    MAdo.SendSQL
    If MAdo.EOF Then
        Variable = False
        Select Case Dato
            Case Agrupacion1: MostrarError "No existe la agrupación principal", txtAgrup1
            Case Agrupacion2: MostrarError "No existe la agrupación 2", txtAgrup2
            Case Agrupacion3: MostrarError "No existe la agrupación 3", txtAgrup3
            Case TrabajadorDesde
                    MostrarError "El trabajador no existe", txtTrabDde
            Case TrabajadorHasta
                    MostrarError "El trabajador no existe", txtTrabHta
            Case DatoDesde: MostrarError "No existe el dato para la agrupación principal o está restringido", txtDatoDde
            Case DatoHasta: MostrarError "No existe el dato para la agrupación principal o está restringido", txtDatoHta
        End Select
    Else
        Select Case Dato
            Case Agrupacion1: txtAgrup1 = MAdo.GetField(1)
            Case Agrupacion2: txtAgrup2 = MAdo.GetField(1)
            Case Agrupacion3: txtAgrup3 = MAdo.GetField(1)
            Case DatoDesde: txtDatoDde = MAdo.GetField(1)
            Case DatoHasta: txtDatoHta = MAdo.GetField(1)
            Case TrabajadorDesde: txtTrabDde = MAdo.GetField(1)
            Case TrabajadorHasta: txtTrabHta = MAdo.GetField(1)
        End Select
    End If
    Screen.MousePointer = vbDefault
End Sub


