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 = "{AB3877A8-B7B2-11CF-9097-444553540000}#1.0#0"; "gtdate32.ocx"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Begin VB.Form FCO3051 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Archivo para Bancos NI"
   ClientHeight    =   7695
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7815
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Medios Bancos NI.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7695
   ScaleWidth      =   7815
   Begin FPSpread.vaSpread sprDatos 
      Height          =   2865
      Left            =   225
      OleObjectBlob   =   "Medios Bancos NI.frx":030A
      TabIndex        =   6
      Top             =   1230
      Width           =   7335
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Rutas (Lectura/Escritura)"
      Height          =   1725
      Index           =   1
      Left            =   225
      TabIndex        =   18
      Top             =   4185
      Width           =   7350
      Begin FPSpread.vaSpread sprRUT 
         Height          =   1305
         Left            =   150
         OleObjectBlob   =   "Medios Bancos NI.frx":04E3
         TabIndex        =   19
         Top             =   285
         Width           =   6750
      End
      Begin VB.Image imgListaRUT 
         Height          =   480
         Left            =   6960
         Picture         =   "Medios Bancos NI.frx":06BC
         Top             =   300
         Width           =   480
      End
   End
   Begin VB.CheckBox chkFiltrar 
      Caption         =   "Filtrar trabajadores con cuenta del banco"
      Height          =   285
      Left            =   225
      TabIndex        =   17
      Top             =   6705
      Value           =   1  'Checked
      Width           =   3450
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Resultados del proceso"
      Height          =   1080
      Index           =   2
      Left            =   4875
      TabIndex        =   12
      Top             =   5970
      Width           =   2700
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Trabajadores"
         Height          =   210
         Index           =   1
         Left            =   120
         TabIndex        =   14
         Top             =   315
         Width           =   960
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Valor Total"
         Height          =   210
         Index           =   2
         Left            =   150
         TabIndex        =   13
         Top             =   660
         Width           =   780
      End
      Begin VB.Label lblNroTrab 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   1110
         TabIndex        =   9
         Top             =   330
         Width           =   495
      End
      Begin VB.Label lblValorTotal 
         Alignment       =   1  'Right Justify
         BackStyle       =   0  'Transparent
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   1110
         TabIndex        =   10
         Top             =   660
         Width           =   1455
      End
   End
   Begin VB.TextBox txtResponsable 
      Height          =   285
      Left            =   1230
      MaxLength       =   20
      TabIndex        =   8
      Top             =   6345
      Width           =   3135
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Medio a Generar"
      Height          =   720
      Index           =   0
      Left            =   240
      TabIndex        =   11
      Top             =   75
      Width           =   6615
      Begin VB.ComboBox cboMedios 
         Height          =   330
         Left            =   120
         Style           =   2  'Dropdown List
         TabIndex        =   0
         Top             =   240
         Width           =   6255
      End
   End
   Begin VB.TextBox txtBusca1 
      Height          =   315
      Left            =   465
      TabIndex        =   1
      Top             =   870
      Width           =   735
   End
   Begin VB.TextBox txtBusca2 
      Height          =   315
      Left            =   1215
      TabIndex        =   2
      Top             =   870
      Width           =   975
   End
   Begin VB.TextBox txtBusca3 
      Height          =   315
      Left            =   2205
      TabIndex        =   3
      Top             =   870
      Width           =   2775
   End
   Begin VB.OptionButton optRecientes 
      Caption         =   "Recientes"
      Height          =   255
      Index           =   0
      Left            =   5625
      TabIndex        =   4
      Top             =   870
      Value           =   -1  'True
      Width           =   1095
   End
   Begin VB.OptionButton optRecientes 
      Caption         =   "Todas"
      Height          =   255
      Index           =   1
      Left            =   6705
      TabIndex        =   5
      Top             =   870
      Width           =   855
   End
   Begin Crystal.CrystalReport crpReporte 
      Left            =   6975
      Top             =   465
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
   Begin GTMaskDate.GTMaskDate txtFecha 
      Height          =   315
      HelpContextID   =   722
      Left            =   1245
      TabIndex        =   7
      ToolTipText     =   "Fecha de Envio"
      Top             =   6000
      Width           =   1215
      _Version        =   65537
      _ExtentX        =   2143
      _ExtentY        =   556
      _StockProps     =   77
      BackColor       =   -2147483643
      KeepFocusOnError=   -1  'True
      CaretPicture    =   "Medios Bancos NI.frx":09C6
      BeginProperty NullFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ValidateType    =   1
      ValidateRangeHigh=   "12/31/2500"
      ValidateRangeLow=   "01/01/2003"
      BeginProperty CalFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty CalCaptionFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      CalDayCaption1  =   "D"
      CalDayCaption2  =   "L"
      CalDayCaption3  =   "M"
      CalDayCaption4  =   "M"
      CalDayCaption5  =   "J"
      CalDayCaption6  =   "V"
      BeginProperty CalDayCaptionFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty ToolTipFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Fecha"
      Height          =   210
      Index           =   3
      Left            =   225
      TabIndex        =   16
      Top             =   6000
      Width           =   450
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Responsable"
      Height          =   210
      Index           =   12
      Left            =   210
      TabIndex        =   15
      Top             =   6360
      Width           =   945
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   6960
      Top             =   -15
      _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           =   "Medios Bancos NI.frx":09E2
   End
End
Attribute VB_Name = "FCO3051"
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 MbFirst As Boolean
Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
Private MsSql As String
Private MsCondicion As String
Private MsOrden As String
Private MsAscDesc As String
Private MsBusca1 As String
Private MsBusca2 As String
Private MsBusca3 As String
Private MbNoRenovar As Boolean
Private MiIdRep As Integer
Private MsMedios() As String

Private MiNumDecimales As Integer        ' Número de decimales
Private MsCodInter As String
Private MbError As Boolean

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlseltodo": SeleccionaRegistros sprDatos, "1"
        Case "tlselnada": SeleccionaRegistros sprDatos, "0"
        Case "tlrenueva": RenuevaDatos
        Case "tlordena": OrdenarDatos
        Case "tlejecuta": Procesa
        Case "tlsalida": Unload Me
    End Select
End Sub

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

Private Sub cboMedios_Click()
    If cboMedios.ListIndex = -1 Then Exit Sub
    
    MsCodInter = MsMedios(0, cboMedios.ListIndex)
        
    lblNroTrab = ""
    lblValorTotal = ""
    
    txtResponsable = MsMedios(1, cboMedios.ListIndex)
    
    RenuevaDatosRut
        
    Me.txtBusca1.SetFocus
    
End Sub

Private Sub cboMedios_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then cboMedios_Click
End Sub

Private Sub Form_Activate()
    If MbFirst Then ZOrder: MbFirst = False
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF5: RenuevaDatos
        Case vbKeyF11: Procesa
        Case vbKeyF12: abToolbar.Bands(1).TrackPopup -1, -1
    End Select
End Sub

Private Sub Form_Load()
    MbFirst = True
    GbAError = False
    Me.Tag = GiVenMax%
    Gven(Val(Me.Tag)).icx = Gicx%
    MiCx = Gven(Val(Me.Tag)).icx
    Set MAdo = Gtc(MiCx).Ado
    If GbSinRegistrar Then RegistraVersion MAdo
    
    'Checa nivel de seguridad
    Gven(Val(Me.Tag)).iNivSeguridad = iObtenNivSeguridad(GsOper, GsUid, MiCx)
    If Gven(Val(Me.Tag)).iNivSeguridad = 0 Then
        Screen.MousePointer = vbDefault
        Me.Top = -10000
        GbAError = True
        Exit Sub
    End If
        
    GAdam.ObtieneColores
    Set clsSpread = New NSpread
    AsignaIconos abToolbar, 3, LSELTODO, LSELNADA, LRENUEVA, LORDENA, LEJECUTA, LSALIDA
    ToolInicioGrupo abToolbar, 3, True, 2, 4, 5
    
    'Decimales según panel de control
    MiNumDecimales = iNumeroDecimalesImporte
    
    Height = 8070
    Width = 7905
    
    If Not MDIChild Then
        WindowState = 0
        Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
        Screen.MousePointer = vbDefault
    End If
        
    Caption = GsDsn & " / " & GsAbreviaturaCia & " - Archivo para Bancos - NI"
    'GAdam.ConfiguraGtDate txtFecha
    GAdam.ConfiguraFecha txtFecha, True
    
    txtFecha.Text = Date
    MsCodInter = "0"
        
    MsSql = "SELECT ' ', numero_liquidacion, trabajador, nombre, tipo_nomina, fecha_liquidacion, neto" & _
    " FROM vw_ri_liquidaciones WHERE compania = '" & GsCveCia & "'"
    MsCondicion = " AND reciente = 1"
    MsOrden = " ORDER BY 2 "
    MsAscDesc = "DESC"
    MsBusca1 = ""
    MsBusca2 = ""
    MsBusca3 = ""
    
    RecuperaListaMedios
    RenuevaDatos
    With sprDatos
        .Row = 0
        .Col = 2
        .Text = "Nro. ^"
    End With
    
    MbNoRenovar = False

End Sub

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

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

Private Sub optRecientes_Click(Index As Integer)
    If MbNoRenovar Then Exit Sub
    If Index = 1 Then
        'MsCondicion = ""
        MsCondicion = " AND 1=2"
    Else
        MsCondicion = " AND reciente = 1"
    End If
    RenuevaDatos
End Sub

Private Sub optRecientes_KeyPress(Index As Integer, KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then optRecientes_Click (Index)
End Sub

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

Private Sub txtBusca1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtBusca2) = "" Then MsBusca2 = ""
        If Trim(txtBusca3) = "" Then MsBusca3 = ""
        If Trim(txtBusca1) <> "" Then
            MsBusca1 = " AND numero_liquidacion >= " & Val(txtBusca1)
            If Me.optRecientes(1).Value = True Then MsCondicion = ""
        Else
            MsBusca1 = ""
            If Me.optRecientes(1).Value = True Then MsCondicion = "AND 1=2"
        End If
        MbNoRenovar = True
        optRecientes(1).Value = True
        'MsCondicion = ""
        RenuevaDatos
        MbNoRenovar = False
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub

Private Sub txtBusca2_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtBusca1) = "" Then MsBusca2 = ""
        If Trim(txtBusca3) = "" Then MsBusca3 = ""
        If Trim(txtBusca2) <> "" Then
            MsBusca2 = " AND trabajador LIKE '%" & txtBusca2 & "%'"
            If Me.optRecientes(1).Value = True Then MsCondicion = ""
        Else
            MsBusca2 = ""
            If Me.optRecientes(1).Value = True Then MsCondicion = "AND 1=2"
        End If
        MbNoRenovar = True
        optRecientes(1).Value = True
        'MsCondicion = ""
        RenuevaDatos
        MbNoRenovar = False
    Else
        KeyAscii = iValidarDato(KeyAscii, "0123456789", True, True)
    End If
End Sub

Private Sub txtBusca3_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Trim(txtBusca1) = "" Then MsBusca2 = ""
        If Trim(txtBusca2) = "" Then MsBusca3 = ""
        If Trim(txtBusca3) <> "" Then
            MsBusca3 = " AND nombre LIKE '%" & txtBusca3 & "%'"
            If Me.optRecientes(1).Value = True Then MsCondicion = ""
        Else
            MsBusca3 = ""
            If Me.optRecientes(1).Value = True Then MsCondicion = "AND 1=2"
        End If
        MbNoRenovar = True
        optRecientes(1).Value = True
        'MsCondicion = ""
        RenuevaDatos
        MbNoRenovar = False
    End If
End Sub

Private Sub BorrarIdRep()
    'preguntar antes si MiIdRep es diferente a cero para borrarlo lo anterio
    If MiIdRep <> 0 Then
        'Llamada al procedimiento, de borrado de archivos
        MAdo.Sql = "sp_fdt_del_bancos_proc " & _
        MiIdRep & "," & _
        "'" & GsUid & "'," & MsMedios(0, cboMedios.ListIndex) & ""
        
        MAdo.ExecSQL
            
    End If

End Sub

Private Sub OrdenarDatos()
    Dim i As Integer, j As Integer
    
    If sprDatos.ActiveCol > 1 Then
        With sprDatos
            i = .ActiveRow
            j = .ActiveCol
            .Row = 0
            .Col = j
            
            If Right(.Text, 1) <> " " Then
                MsAscDesc = "ASC"
            Else
                MsAscDesc = "DESC"
            End If
            
            MsOrden = " ORDER BY " & CStr(.ActiveCol) & " "
        End With
        
        RenuevaDatos
                
        With sprDatos
            .Row = 0
            .Col = j
            If MsAscDesc = "DESC" Then
                .Text = .Text & " ^"
            Else
                .Text = .Text & " "
            End If
            .Row = i
            .Action = 0
            On Error Resume Next
            .SetFocus
        End With
    End If
End Sub

Private Sub Procesa()
    On Error GoTo NoPude
    Dim i As Integer
    Dim sNumLiq As String
    Dim sTipoNom As String
    Dim bHaySeleccion As Boolean
    Dim iRetVal As Integer
                
    If cboMedios.ListIndex < 0 Then
        clsMsgbox.Mensaje "Seleccione el archivo a generar", mAceptar, mAdvierte, GsTitMsg
        cboMedios.SetFocus
        Exit Sub
    End If

    'Hallar un id para este proceso
    BorrarIdRep
    
    Randomize
    MiIdRep = Int((32000 * Rnd) + 1)
      
    'Proceso Principal
    Screen.MousePointer = vbHourglass
        
    MAdo.Sql = "DELETE FROM ri_liq_procesar WHERE id_rep = " & MiIdRep & " AND compania = '" & GsCveCia & "'" & _
               " AND usuariow = '" & GsUid & "'"
    If MAdo.ExecSQL = -1 Then Screen.MousePointer = vbDefault: Exit Sub
    bHaySeleccion = False
    With sprDatos
        For i = 1 To .MaxRows
            .Col = 1: .Row = i
            If Val(.Value) = 1 Then
                bHaySeleccion = True
                .Col = 2: sNumLiq = CStr(Val(.Text))
                .Col = 5: sTipoNom = CStr(.Text)
                .Col = 3
                MAdo.Sql = "INSERT INTO ri_liq_procesar (id_rep, usuariow, compania, tipo_nomina, numero_liquidacion, trabajador)" & _
                " VALUES (" & MiIdRep & ",'" & GsUid & "','" & GsCveCia & "','" & sTipoNom & "'," & sNumLiq & ",'" & .Text & "')"
                If MAdo.ExecSQL = -1 Then Screen.MousePointer = vbDefault: Exit Sub
            End If
        Next i
    End With
    
    If Not bHaySeleccion Then
        clsMsgbox.Mensaje "Debe seleccionar al menos un registro para procesar.", mAceptar, mAdvierte, GsTitMsg
        cboMedios.SetFocus
        Exit Sub
    End If
                   
    'Llamada al procedimiento
    MAdo.Sql = "sp_fdt_gen_medios_bancos " & _
    "" & MiIdRep & ",'" & GsUid & "'," & _
    "" & MsMedios(0, cboMedios.ListIndex) & "," & _
    "'" & Format(txtFecha.Text, "yyyymmdd") & "'," & _
    "'" & txtResponsable.Text & "', 2, " & _
    IIf(Me.chkFiltrar.Value = vbChecked, 1, 0)
    
    If MAdo.ExecSQL = -1 Then GoTo NoPude
                    
    MostrarReporte
    If MbError Then GoTo Finaliza
    MostrarMM
    If MbError Then GoTo Finaliza
    
    'Hallar los resultados del proceso
    MAdo.Sql = _
    " SELECT trabajadores, valor_total" & _
    " FROM fdt_bancos_resultados" & _
    " WHERE id_rep = " & MiIdRep & "" & _
    " AND usuariow = '" & GsUid & "'" & _
    " AND banco = " & MsMedios(0, cboMedios.ListIndex)
    If Not MAdo.SendSQL Then GoTo Finaliza
    
    If Not MAdo.EOF Then
        lblNroTrab = "" & MAdo.GetField(1)
        lblValorTotal = Format("" & MAdo.GetField(2), "###,##0.00")
    End If
    
        
    Screen.MousePointer = vbDefault
    
    clsMsgbox.Mensaje "El proceso ha concluido exitosamente", mAceptar, minforma, GsTitMsg
    
    Exit Sub
NoPude:
    BorrarIdRep
    Screen.MousePointer = vbDefault
    clsMsgbox.Mensaje Err & " " & Err.Description, mAceptar, mAdvierte, GsTitMsg
Finaliza:
    Screen.MousePointer = vbDefault
End Sub

Private Sub RecuperaListaMedios()
    cboMedios.Clear
    Erase MsMedios
    MAdo.Sql = "SELECT banco, descripcion, responsable FROM vw_fdt_bancos WHERE compania = '" & GsCveCia & "'"

    If Not MAdo.SendSQL Then Exit Sub
    
    Do Until MAdo.EOF
        cboMedios.AddItem MAdo.GetField(2)  'Descripcion
        ReDim Preserve MsMedios(2, cboMedios.NewIndex)
        MsMedios(0, cboMedios.NewIndex) = MAdo.GetField(1)
        MsMedios(1, cboMedios.NewIndex) = "" & MAdo.GetField(3)
        MAdo.Mnext
    Loop

End Sub

Private Sub RenuevaDatos()
  RenuevaDatosLiq
  RenuevaDatosRut

End Sub

Private Sub RenuevaDatosLiq()
    Screen.MousePointer = vbHourglass
    
    'Se configura el Spread
    With sprDatos
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprDatos
        .ColWidth(1) = 2
        .ColWidth(2) = 6
        .ColWidth(3) = 8
        .ColWidth(4) = 21
        .ColWidth(5) = 4
        .ColWidth(6) = 8
        .ColWidth(7) = 9
        
        .SetText 1, 0, " "
        .SetText 2, 0, "Nro."
        .SetText 3, 0, "Trabajador"
        .SetText 4, 0, "Nombre"
        .SetText 5, 0, "T.N."
        .SetText 6, 0, "Fecha Liq."
        .SetText 7, 0, "Neto"
               
        .Col = -1: .Row = -1: .Lock = True
        .Col = 1: .Row = -1: .CellType = 10: .Lock = False
        .Col = 7: .Row = -1:  .CellType = 2: .TypeFloatSeparator = True:
                  .TypeFloatDecimalPlaces = MiNumDecimales: .TypeFloatMax = "99999999999999999": .TypeFloatMin = "0.00"
        
        ConfiguraSpreadJCL sprDatos
        .UserResizeCol = 2
    End With
    
    MAdo.Sql = MsSql & MsCondicion & MsBusca1 & MsBusca2 & MsBusca3 & MsOrden & MsAscDesc
    If Not MAdo.SendSQL Then Exit Sub
    clsSpread.LlenaSpread 0, sprDatos, MAdo, MAdo.lhDbc, MAdo.lhstmt
    
    GAdam.AjustaSpread sprDatos, 4
    
    Screen.MousePointer = vbDefault
End Sub

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

    With sprRUT
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprRUT
        
        .ColWidth(1) = 2
        .ColWidth(2) = 0
        .ColWidth(3) = 14
        .ColWidth(4) = 45
        .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
    End With
    
    MAdo.Sql = "SELECT 1, tipo, archivo, ruta, tabla, secuencia FROM fdt_rutas " & _
               "WHERE operacion = 'FCO1070' AND codigo = " & MsCodInter & " ORDER BY tipo"
    If Not MAdo.SendSQL Then Exit Sub
    
    clsSpread.LlenaSpread 0, sprRUT, MAdo, MAdo.lhDbc, MAdo.lhstmt

    With sprRUT
        
      For i = 1 To .VirtualMaxRows
          .Col = 2: .Row = i
          If .Text <> "" Then
            nValor = Val(.Value)
          Else
            nValor = 255
          End If
                
          If nValor = 1 Then 'es un reporte, no se puede cambiar
            .Col = 3: .Row = i: .Lock = True
          End If
          .Col = 1: .Row = -1: .CellType = 10
      Next i
    End With

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 Byte

On Error GoTo RutaNoExiste
MbError = False
With sprRUT
    For i = 1 To .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)
          
          'Abriendo el reporte
          With crpReporte
              .WindowShowPrintSetupBtn = True
              .WindowShowSearchBtn = True
              .MarginLeft = 0
              .WindowState = crptNormal
              .WindowTitle = "Reportes Interfases"
              .WindowLeft = 100
              .WindowTop = 100
                      
              .ReportFileName = sRuta & "\" & sArchivo
              .Connect = "DSN = " & UCase(GsDsn) & "; UID = " & GsUid & "; PWD = " & GsPwd
              
              .SQLQuery = " SELECT * FROM " & sTabla & _
                          " WHERE id_rep = " & MiIdRep & " AND usuariow = '" & GsUid & "'" & _
                          " AND banco = " & MsCodInter
        
              .ReplaceSelectionFormula ""
              
              For j = 0 To .GetNSubreports - 1
                  .SubreportToChange = .GetNthSubreportName(j)
                  .Connect = "DSN = " & UCase(GsDsn) & "; UID = " & GsUid & "; PWD = " & GsPwd
                  '.DataFiles(0) = "vw_ri_novint_par"
              Next j
              
              .WindowState = crptNormal
              .Action = 1
              
              For j = 0 To .GetNSubreports - 1
                  .DataFiles(0) = ""
              Next j
              
          End With
                                                            
        End If
    Next i
End With

Exit Sub

RutaNoExiste:
    If Err > 0 Then
        MbError = True
        Screen.MousePointer = vbDefault
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If

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 Byte
Dim iSec As Integer
Dim iRetVal As Long
Dim sFuncSub As String

On Error GoTo RutaNoExiste
MbError = False

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 = " & MiIdRep & " AND usuariow = '" & GsUid & "'" & _
                    " AND banco = " & MsCodInter & " AND sec_archivo = " & iSec & "" & _
                    " ORDER BY secuencia "
          
          If Not MAdo.SendSQL Then GoTo Finaliza
           
          sRuta = sRuta & "\" & sArchivo
          Open sRuta For Output As #1
          Do Until MAdo.EOF
              Print #1, MAdo.GetField(1)
              MAdo.Mnext
          Loop
          Close #1
                      
          iRetVal = Shell("NOTEPAD.EXE " & sRuta, vbNormalFocus)

        End If
    Next i
End With

Exit Sub

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

Finaliza:
    MbError = True
    Screen.MousePointer = vbDefault

End Sub

Private Sub imgListaRut_Click()
Dim Aux As Variant
Dim sRuta As String
Dim nValor As Byte
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



