VERSION 5.00
Object = "{B02F3647-766B-11CE-AF28-C3A2FBE76A13}#2.5#0"; "ss32x25.ocx"
Object = "{AB3877A8-B7B2-11CF-9097-444553540000}#1.0#0"; "gtdate32.ocx"
Object = "{A830FC0E-AD2F-47FF-AB06-F1ED5FC1FC18}#1.0#0"; "Calendario.ocx"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Begin VB.Form FCO3050 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Archivos para Bancos"
   ClientHeight    =   7335
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6945
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Medios Bancos.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7335
   ScaleWidth      =   6945
   Begin FPSpread.vaSpread sprDatos 
      Height          =   2520
      Left            =   3480
      OleObjectBlob   =   "Medios Bancos.frx":030A
      TabIndex        =   21
      Top             =   990
      Width           =   3255
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Rutas (Lectura/Escritura)"
      Height          =   1725
      Index           =   1
      Left            =   135
      TabIndex        =   25
      Top             =   3570
      Width           =   6600
      Begin FPSpread.vaSpread sprRUT 
         Height          =   1305
         Left            =   150
         OleObjectBlob   =   "Medios Bancos.frx":04E3
         TabIndex        =   26
         Top             =   285
         Width           =   6045
      End
      Begin VB.Image imgListaRUT 
         Height          =   480
         Left            =   6225
         Picture         =   "Medios Bancos.frx":06BC
         Top             =   300
         Width           =   480
      End
   End
   Begin VB.CheckBox chkFiltrar 
      Caption         =   "Filtrar trabajadores con cuenta del banco"
      Height          =   285
      Left            =   90
      TabIndex        =   9
      Top             =   6090
      Value           =   1  'Checked
      Width           =   3450
   End
   Begin VB.CommandButton cmdVerGrupos 
      Height          =   285
      Left            =   2880
      Picture         =   "Medios Bancos.frx":09C6
      Style           =   1  'Graphical
      TabIndex        =   24
      ToolTipText     =   "Ver Detalle Grupos"
      Top             =   1035
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.TextBox txtGrupoNom 
      Height          =   315
      Left            =   1560
      MaxLength       =   6
      TabIndex        =   2
      Top             =   1035
      Visible         =   0   'False
      Width           =   675
   End
   Begin VB.TextBox txtResponsable 
      Height          =   285
      Left            =   1110
      MaxLength       =   20
      TabIndex        =   8
      Top             =   5775
      Width           =   2865
   End
   Begin VB.CommandButton cmdAgregar 
      Height          =   375
      Left            =   2865
      Picture         =   "Medios Bancos.frx":1090
      Style           =   1  'Graphical
      TabIndex        =   5
      ToolTipText     =   "Agregar"
      Top             =   1650
      Width           =   495
   End
   Begin VB.CommandButton cmdQuitar 
      Height          =   375
      Left            =   2865
      Picture         =   "Medios Bancos.frx":139A
      Style           =   1  'Graphical
      TabIndex        =   6
      ToolTipText     =   "Eliminar"
      Top             =   2085
      Width           =   495
   End
   Begin VB.TextBox txtCompanias 
      Height          =   315
      Left            =   1560
      MaxLength       =   4
      TabIndex        =   1
      Top             =   1395
      Width           =   675
   End
   Begin Crystal.CrystalReport crpReporte 
      Left            =   2865
      Top             =   2640
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
   Begin VB.PictureBox picCancela 
      BorderStyle     =   0  'None
      Height          =   495
      Left            =   5370
      Picture         =   "Medios Bancos.frx":16A4
      ScaleHeight     =   495
      ScaleWidth      =   615
      TabIndex        =   11
      Top             =   6540
      Width           =   615
   End
   Begin VB.PictureBox picAcepta 
      BorderStyle     =   0  'None
      Height          =   495
      Left            =   5985
      Picture         =   "Medios Bancos.frx":19AE
      ScaleHeight     =   495
      ScaleWidth      =   615
      TabIndex        =   10
      Top             =   6540
      Width           =   615
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Resultados del proceso"
      Height          =   1080
      Index           =   2
      Left            =   4125
      TabIndex        =   16
      Top             =   5370
      Width           =   2595
      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            =   1050
         TabIndex        =   13
         Top             =   660
         Width           =   1455
      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            =   1050
         TabIndex        =   12
         Top             =   330
         Width           =   495
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Valor Total"
         Height          =   210
         Index           =   2
         Left            =   90
         TabIndex        =   18
         Top             =   660
         Width           =   780
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Trabajadores"
         Height          =   210
         Index           =   1
         Left            =   60
         TabIndex        =   17
         Top             =   315
         Width           =   960
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Medio a Generar"
      Height          =   720
      Index           =   0
      Left            =   120
      TabIndex        =   15
      Top             =   120
      Width           =   6615
      Begin VB.ComboBox cboMedios 
         Height          =   330
         Left            =   105
         Style           =   2  'Dropdown List
         TabIndex        =   0
         Top             =   240
         Width           =   6255
      End
   End
   Begin VB.TextBox txtClsNom 
      Height          =   315
      Left            =   1560
      MaxLength       =   2
      TabIndex        =   3
      Top             =   1755
      Width           =   675
   End
   Begin Calen.Calendario Calendario 
      Height          =   1455
      Left            =   165
      TabIndex        =   4
      Top             =   2100
      Width           =   2595
      _ExtentX        =   4577
      _ExtentY        =   2566
      Compañia        =   ""
      Año             =   ""
      TipoNomina      =   ""
      Periodo         =   ""
      Caption         =   "Calendario"
      CaptionTipoNomina=   "Tipo Nómina"
      CaptionAño      =   "Año"
      CaptionPeriodo  =   "Período"
      Enabled         =   -1  'True
   End
   Begin GTMaskDate.GTMaskDate txtFecha 
      Height          =   315
      HelpContextID   =   722
      Left            =   1125
      TabIndex        =   7
      ToolTipText     =   "Fecha de Envio"
      Top             =   5430
      Width           =   1215
      _Version        =   65537
      _ExtentX        =   2143
      _ExtentY        =   556
      _StockProps     =   77
      BackColor       =   -2147483643
      KeepFocusOnError=   -1  'True
      CaretPicture    =   "Medios Bancos.frx":1CB8
      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 
      BackStyle       =   0  'Transparent
      Caption         =   "Grupo de Nomina"
      Height          =   315
      Index           =   5
      Left            =   240
      TabIndex        =   23
      Top             =   1050
      Visible         =   0   'False
      Width           =   1275
   End
   Begin VB.Image imgGN 
      Height          =   480
      Left            =   2280
      Picture         =   "Medios Bancos.frx":1CD4
      Top             =   1020
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Responsable"
      Height          =   210
      Index           =   12
      Left            =   90
      TabIndex        =   22
      Top             =   5790
      Width           =   945
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "Compañia"
      Height          =   315
      Index           =   4
      Left            =   225
      TabIndex        =   20
      Top             =   1410
      Width           =   1170
   End
   Begin VB.Image imgCia 
      Height          =   480
      Left            =   2250
      Picture         =   "Medios Bancos.frx":1FDE
      Top             =   1365
      Width           =   480
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Fecha"
      Height          =   210
      Index           =   3
      Left            =   120
      TabIndex        =   19
      Top             =   5430
      Width           =   450
   End
   Begin VB.Image imgAceptaActivo 
      Height          =   480
      Left            =   4665
      Picture         =   "Medios Bancos.frx":22E8
      Top             =   6660
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image imgCancelActivo 
      Height          =   480
      Left            =   3600
      Picture         =   "Medios Bancos.frx":25F2
      Top             =   6645
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image imgCancelInactivo 
      Height          =   480
      Left            =   3135
      Picture         =   "Medios Bancos.frx":28FC
      Top             =   6645
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image imgListaCN 
      Height          =   480
      Left            =   2280
      Picture         =   "Medios Bancos.frx":2C06
      Top             =   1725
      Width           =   480
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "Clase de Nómina"
      Height          =   315
      Index           =   0
      Left            =   210
      TabIndex        =   14
      Top             =   1755
      Width           =   1335
   End
   Begin VB.Image imgAceptaProceso 
      Height          =   480
      Left            =   4440
      Picture         =   "Medios Bancos.frx":2F10
      Top             =   6660
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image imgAceptaInactivo 
      Height          =   480
      Left            =   4095
      Picture         =   "Medios Bancos.frx":321A
      Top             =   6660
      Visible         =   0   'False
      Width           =   480
   End
End
Attribute VB_Name = "FCO3050"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MAdo As ODBC.ODBCDirecto
Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
Private MiCx As Integer
Private MsMedios() As String
Private MiX As Integer 'Ancho de la forma
Private MiY As Integer 'Alta de la forma

Private Enum Datos
    GrupoNomina
    Compania
    ClaseNomina
    TipoNomina
End Enum

Private MbCompania_OK As Boolean
Private MbClsNom_OK As Boolean
Private MbTpoNom_OK As Boolean
Private MbGrupoNom_OK As Boolean

Private GIdProc As Integer
Private MsCodInter As String
Private MinPeriodo As Integer
Private MbError As Boolean

Private Sub Calendario_Change(TextBox As Integer)
    lblNroTrab = ""
    lblValorTotal = ""
    MbTpoNom_OK = False
    If Calendario.TipoNomina <> "" And Val(Calendario.Año) > 2000 And Val(Calendario.Periodo) > 0 Then
        Screen.MousePointer = vbHourglass
        MAdo.Sql = _
        " SELECT a.fecha_pago FROM calendario_procesos a, cal_proc_cias b" & _
        " WHERE a.id_calendario = b.id_calendario" & _
        " AND a.tipo_nomina = '" & Calendario.TipoNomina & "'" & _
        " AND a.anio = " & Calendario.Año & _
        " AND a.periodo = " & Calendario.Periodo
        MAdo.SendSQL
        If MAdo.EOF Then
            clsMsgbox.Mensaje "No existe ese período o ese calendario no está relacionado con esta compañia", mAceptar, mAdvierte, GsTitMsg
            Calendario.SetFocus
            'Calendario.Periodo = 0
        Else
            txtFecha.Text = MAdo.GetFieldDate(1)
        End If
        Screen.MousePointer = vbDefault
    End If
End Sub

Private Sub Calendario_F4(Boton As Integer)
    Select Case Boton
        Case 0
            Screen.MousePointer = vbHourglass
            GsParamIN(0) = "SELECT tipo_nomina, descripcion" & _
            " FROM tipos_nomina WHERE 1=1"
            GsParamIN(1) = "tipo_nomina"
            GsParamIN(2) = "descripcion"
            GsParamIN(3) = "Tipo de Nómina"
            GsParamIN(4) = "Descripcion"
            GsParamIN(5) = "Tipos de Nómina"
            GsParamIN(6) = ""
            frmLista.Show 1
            Calendario.TipoNomina = GsParamOUT(0)
        Case 1, 2
            If Trim(Calendario.TipoNomina) = "" Then
                Calendario_F4 0
            Else
                Screen.MousePointer = vbHourglass
                GsParamIN(0) = "SELECT anio, periodo" & _
                " FROM calendario_procesos a, cal_proc_cias b" & _
                " WHERE a.id_calendario = b.id_calendario" & _
                " AND tipo_nomina = '" & Calendario.TipoNomina & "'"
                GsParamIN(1) = "anio"
                GsParamIN(2) = "periodo"
                GsParamIN(3) = "Año"
                GsParamIN(4) = "Período"
                GsParamIN(5) = "Períodos de Nómina"
                GsParamIN(6) = ""
                frmLista.Show 1
                If Trim(GsParamOUT(0)) <> "" Then
                    Calendario.Año = GsParamOUT(0)
                    Calendario.Periodo = GsParamOUT(1)
                    MinPeriodo = GsParamOUT(1)
                End If
            End If
    End Select
End Sub

Private Sub Calendario_GotFocus()
    If Not MbClsNom_OK And Len(Trim(Me.txtClsNom)) > 0 Then
        ValidarExistencia ClaseNomina, MbClsNom_OK
    End If
End Sub

Private Sub Calendario_KeyPress(KeyAscii As Integer, Boton As Integer)
    If KeyAscii = vbKeyReturn Then
        If Boton > 0 Then
            KeyAscii = 0
            SendEnter
            SendEnter
        Else
            ValidarExistencia TipoNomina, MbTpoNom_OK
            If MbTpoNom_OK Then SendEnter: SendEnter
        End If
    End If
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)
    
    Me.txtCompanias.SetFocus
    RenuevaDatosRut
    On Error Resume Next
    txtCompanias.SetFocus
    picAcepta.Picture = imgAceptaActivo.Picture
End Sub

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

Private Sub cmdAgregar_Click()
Dim sGrupoNom As String
Dim sCia As String
Dim sClaseNom As String
Dim sTipoNom As String
Dim sAnio As String
Dim sPeriodo As String
Dim i As Byte
Dim blnExiste As Boolean
Dim sSql As String
Dim sCN As String

If Len(Trim(Me.txtCompanias)) = 0 And Len(Trim(Calendario.TipoNomina)) = 0 And _
    Val(Trim(Calendario.Año)) = 0 And Val(Trim(Calendario.Periodo)) = 0 Then Exit Sub
    
If Val(Trim(Calendario.Año)) = 0 And Val(Trim(Calendario.Periodo)) = 0 Then Exit Sub

'verifica clase de nomina, solo si se ha llenado
If Not MbClsNom_OK And Len(Trim(Me.txtClsNom)) > 0 Then
    ValidarExistencia ClaseNomina, MbClsNom_OK
    If Not MbClsNom_OK Then Exit Sub
End If
If Not MbTpoNom_OK Then
    ValidarExistencia TipoNomina, MbTpoNom_OK
    If Not MbTpoNom_OK Then Exit Sub
End If
If Not MbCompania_OK Then
    ValidarExistencia Compania, MbCompania_OK
    If Not MbCompania_OK Then Exit Sub
End If
'por defecto el grupo de nomina queda validado
MbGrupoNom_OK = True
If Not MbGrupoNom_OK Then
    ValidarExistencia GrupoNomina, MbGrupoNom_OK
    If Not MbGrupoNom_OK Then Exit Sub
End If

If Len(Trim(Me.txtClsNom)) > 0 Then
  sSql = "SELECT a.clase_nomina" & _
    " FROM clases_nomina a, rel_usu_clase_nom b" & _
    " WHERE a.clase_nomina = b.clase_nomina" & _
    " AND b.usuario = '" & GsUid & "'" & _
    " AND a.clase_nomina = '" & txtClsNom & "'"
Else
'se quiere insertar varias clases de nomina
  sSql = "SELECT a.clase_nomina" & _
    " FROM clases_nomina a, rel_usu_clase_nom b" & _
    " WHERE a.clase_nomina = b.clase_nomina" & _
    " AND b.usuario = '" & GsUid & "'"
End If

MAdo.Sql = sSql
MAdo.SendSQL

While Not MAdo.EOF
  sCN = MAdo.GetField(1)
  blnExiste = False

  With sprDatos
      'revisando que no se este insertando algo ya registrado
      For i = 1 To .MaxRows
          .Row = i
          .Col = 1: sGrupoNom = Trim(.Text)
          .Col = 2: sCia = Trim(.Text)
          .Col = 3: sClaseNom = Trim(.Text)
          .Col = 4: sTipoNom = Trim(.Text)
          .Col = 5: sAnio = Trim(.Text)
          .Col = 6: sPeriodo = Trim(.Text)
          
          
          If (UCase(Trim(sClaseNom)) = UCase(Trim(sCN))) And _
              (UCase(Trim(sTipoNom)) = UCase(Trim(Calendario.TipoNomina))) And _
              (UCase(Trim(sAnio)) = UCase(Trim(Calendario.Año))) And _
              (UCase(Trim(sPeriodo)) = UCase(Trim(Calendario.Periodo))) Then
          
              If (UCase(Trim(sCia)) = UCase(Trim(txtCompanias))) And _
                  (UCase(Trim(sGrupoNom)) = UCase(Trim(txtGrupoNom))) Then
                 blnExiste = True
                 'GoTo Continua
              End If
              
              If (UCase(Trim(sCia)) = "") And _
                 (UCase(Trim(sGrupoNom)) = "") And _
                 (UCase(Trim(txtGrupoNom)) = "") And _
                 (UCase(Trim(txtCompanias)) <> "") Then
                 blnExiste = True
                 'GoTo Continua
              End If
              
              If (UCase(Trim(sCia)) <> "") And _
                 (UCase(Trim(sGrupoNom)) = "") And _
                 (UCase(Trim(txtGrupoNom)) = "") And _
                 (UCase(Trim(txtCompanias)) = "") Then
                 blnExiste = True
                 'GoTo Continua
              End If
                              
          End If
                                                          
      Next i
    
'Continua:
    If Not blnExiste Then
        'agregando una fila al spread
        .Row = .VirtualMaxRows + 1: .Action = 7
        .VirtualMaxRows = .VirtualMaxRows + 1
        .Row = .VirtualMaxRows
        .Col = -1:
        sprDatos.SetText 1, .Row, Trim(txtGrupoNom)
        sprDatos.SetText 2, .Row, Trim(txtCompanias)
        sprDatos.SetText 3, .Row, Trim(sCN)
        sprDatos.SetText 4, .Row, Trim(Calendario.TipoNomina)
        sprDatos.SetText 5, .Row, Trim(Calendario.Año)
        If Trim(Calendario.Periodo) <> 0 Then
          sprDatos.SetText 6, .Row, Trim(Calendario.Periodo)
        Else
          sprDatos.SetText 6, .Row, Trim(MinPeriodo)
        End If
        
        .Col = 1: .ColHidden = True
 '   Else
 '       clsMsgbox.Mensaje "El grupo de nomina, compañia, clase de nomina, tipo de nomina, año y periodo ya los agregó a la lista", mAceptar, mAdvierte, GsTitMsg
    End If
    
    'Me.txtGrupoNom.SetFocus

End With

    MAdo.Mnext
Wend

  txtGrupoNom.Text = ""
  MbGrupoNom_OK = True
  txtCompanias.Text = ""
  MbCompania_OK = True
  
  txtClsNom.Text = ""
  MbClsNom_OK = True
  Calendario.TipoNomina = ""
  Calendario.Año = 0
  Calendario.Periodo = 0
  MinPeriodo = 0
  MbTpoNom_OK = True

End Sub

Private Sub cmdQuitar_Click()
If sprDatos.VirtualMaxRows = 0 Then Exit Sub
With sprDatos
    .Row = .ActiveRow
    .Action = 5
    .VirtualMaxRows = .VirtualMaxRows - 1
    .Row = .VirtualMaxRows
    
End With
End Sub

'Private Sub cmdVerGrupos_Click()
'
'    GsLlave = "VDG"  'Ver Detalle Grupo
'    FDT1020.Caption = GsDsn & " / " & GsAbreviaturaCia & " - Grupos de Nomina"
'    FDT1020.Show
'
'End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: GbRen = False: Unload Me
        Case vbKeyF11: Procesa
        Case vbKeyF4
            If LCase(ActiveControl.Name) = "txtclsnom" Then imgListaCn_Click
            If LCase(ActiveControl.Name) = "txtcompanias" Then imgCia_Click
            If LCase(ActiveControl.Name) = "txtgruponom" Then imgGN_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
        
    Caption = GsDsn & "/" & GsCveCia & " - Archivos para Bancos"
    'GAdam.ConfiguraGtDate txtFecha
    GAdam.ConfiguraFecha txtFecha, True
    
    txtFecha.Text = Date
        
    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 = 7035
        MiY = 7710
        Me.Width = MiX
        Me.Height = MiY
    End If
        
    GAdam.ObtieneColores
    Set clsSpread = New NSpread
    ConfiguraSpread
    
    Me.txtCompanias = GsCveCia
    MbClsNom_OK = False
    MbTpoNom_OK = False
    MbCompania_OK = False
    MbGrupoNom_OK = False
    MsCodInter = "0"
    MinPeriodo = 0
    
    RecuperaListaMedios
    VerificarClasesNomina
    RenuevaDatosRut
    
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If picCancela.Picture = imgCancelActivo.Picture Then picCancela.Picture = imgCancelInactivo.Picture
    If picAcepta.Picture = imgAceptaActivo.Picture Then picAcepta.Picture = imgAceptaInactivo.Picture
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 FCO3050 = Nothing
End Sub

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

Private Sub imgCia_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT c.compania, c.nombre_cia " & _
            " FROM companias c, aut_companias ac " & _
            " WHERE c.compania = ac.compania AND " & _
            " ac.usuario = '" & GsUid & "'"
    GsParamIN(1) = "c.compania"
    GsParamIN(2) = "c.nombre_cia"
    GsParamIN(3) = "Compania"
    GsParamIN(4) = "Nombre"
    GsParamIN(5) = "Companias"
    GsParamIN(6) = ""
    frmLista.Show 1
    txtCompanias = GsParamOUT(0)
    MbCompania_OK = True

End Sub

Private Sub imgGN_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT grupo, descripcion" & _
    " FROM fdt_grupos_nomina " & _
    " WHERE ISNULL(agrupacion,'') <> '' " & _
    " AND ISNULL(compania,'') = '' " & _
    " AND ISNULL(clase_nomina,'') = '' " & _
    " AND ISNULL(tipo_nomina,'') = '' "
    GsParamIN(1) = "grupo"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Grupo de Nómina"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Grupos de Nómina"
    GsParamIN(6) = ""
    frmLista.Show 1
    txtGrupoNom = GsParamOUT(0)
    MbGrupoNom_OK = True

End Sub

Private Sub imgListaCn_Click()
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT a.clase_nomina, a.descripcion" & _
    " FROM clases_nomina a, rel_usu_clase_nom b" & _
    " WHERE a.clase_nomina = b.clase_nomina" & _
    " AND b.usuario = '" & GsUid & "' "
    GsParamIN(1) = "a.clase_nomina"
    GsParamIN(2) = "a.descripcion"
    GsParamIN(3) = "Clase de Nómina"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Clases de Nómina"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
        txtClsNom = GsParamOUT(0)
        MbClsNom_OK = True
    End If
End Sub

Private Sub picAcepta_Click()
    Procesa
End Sub

Private Sub picAcepta_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    picAcepta.Picture = imgAceptaActivo.Picture
    picCancela.Picture = imgCancelInactivo.Picture
End Sub

Private Sub picCancela_Click()
    Unload Me
End Sub

Private Sub picCancela_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    picCancela.Picture = imgCancelActivo.Picture
    picAcepta.Picture = imgAceptaInactivo.Picture
End Sub

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

Private Sub txtClsNom_Change()
    lblNroTrab = ""
    lblValorTotal = ""
    MbClsNom_OK = False
End Sub

Private Sub txtClsNom_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        KeyAscii = 0
        If Len(Trim(Me.txtClsNom)) > 0 Then
           ValidarExistencia ClaseNomina, MbClsNom_OK
        Else
           MbClsNom_OK = True
        End If
        If MbClsNom_OK Then SendEnter
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii)))
    End If
End Sub

Private Function HallarFechaTermino() As String
    MAdo.Sql = _
    " SELECT fecha_termino FROM calendario_procesos" & _
    " WHERE tipo_nomina = '" & Calendario.TipoNomina & "'" & _
    " AND anio = " & Calendario.Año & _
    " AND periodo = " & Calendario.Periodo
    MAdo.SendSQL
    If Not MAdo.EOF Then
        HallarFechaTermino = sRellenar(Month(MAdo.GetField(1)), "0", 0, 2) & sRellenar(Day(MAdo.GetField(1)), "0", 0, 2)
    Else
        HallarFechaTermino = "0000"
    End If
End Function

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 Procesa()
    On Error GoTo NoPude
    Dim sFuncSub As String
    Dim iRetVal As Integer
    Dim iIdProc As Integer
    Dim sGrupoNom As String
    Dim sCia As String
    Dim sClaseNom As String
    Dim sTipoNom As String
    Dim sAnio As String
    Dim sPeriodo As String
    Dim i As Integer
            
    'Zona de validaciones
    If Not MbClsNom_OK Then
        ValidarExistencia ClaseNomina, MbClsNom_OK
        If Not MbClsNom_OK Then Exit Sub
    End If
    If Not MbTpoNom_OK Then
        ValidarExistencia TipoNomina, MbTpoNom_OK
        If Not MbTpoNom_OK Then Exit Sub
    End If
    If Not MbCompania_OK Then
        ValidarExistencia Compania, MbCompania_OK
        If Not MbCompania_OK Then Exit Sub
    End If
    'como por ahora no utilizamos grupo de nomina, le mandamos la verificacion de una
    MbGrupoNom_OK = True
    If Not MbGrupoNom_OK Then
        ValidarExistencia GrupoNomina, MbGrupoNom_OK
        If Not MbGrupoNom_OK Then Exit Sub
    End If
    If cboMedios.ListIndex < 0 Then
        clsMsgbox.Mensaje "Seleccione el archivo a generar", mAceptar, mAdvierte, GsTitMsg
        cboMedios.SetFocus
        Exit Sub
    End If

    If sprDatos.VirtualMaxRows = 0 Then
        clsMsgbox.Mensaje "Debe seleccionar al menos grupo de nomina o una compañia", mAceptar, mAdvierte, GsTitMsg
        Exit Sub
    End If

    BorrarIdRep
    'Hallar un id para este proceso
    Randomize
    iIdProc = Int((32000 * Rnd) + 1)
    GIdProc = iIdProc
      
    'Proceso Principal
    Screen.MousePointer = vbHourglass
    
    MAdo.Sql = "DELETE FROM ri_procesar WHERE id_rep = " & iIdProc & " AND usuariow = '" & GsUid & "'"
    If MAdo.ExecSQL = -1 Then GoTo NoPude
    With sprDatos
        For i = 1 To .MaxRows
            .Row = i
            .Col = 1: sGrupoNom = Trim(.Text)
            .Col = 2: sCia = Trim(.Text)
            .Col = 3: sClaseNom = Trim(.Text)
            .Col = 4: sTipoNom = Trim(.Text)
            .Col = 5: sAnio = Trim(.Text)
            .Col = 6: sPeriodo = Trim(.Text)
            
                
            MAdo.Sql = "INSERT INTO ri_procesar (id_rep, usuariow, grupo_nom, compania, clase_nomina, tipo_nomina, anio, periodo)" & _
            " VALUES (" & iIdProc & ",'" & GsUid & "','" & sGrupoNom & "','" & sCia & "','" & sClaseNom & "','" & sTipoNom & "'," & sAnio & "," & sPeriodo & ")"
            If MAdo.ExecSQL = -1 Then GoTo NoPude
        Next i
    End With
    
    'Mostrar icono de Procesando
    picAcepta.Picture = imgAceptaProceso.Picture
    DoEvents
            
    'Llamada al procedimiento
    MAdo.Sql = "sp_fdt_gen_medios_bancos " & _
    "" & iIdProc & ",'" & GsUid & "'," & _
    "" & MsMedios(0, cboMedios.ListIndex) & "," & _
    "'" & Format(txtFecha.Text, "yyyymmdd") & "'," & _
    "'" & txtResponsable.Text & "', 1, " & _
    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 = " & iIdProc & "" & _
    " 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
            
    picAcepta.Picture = imgAceptaActivo.Picture
    
    Screen.MousePointer = vbDefault
    
    clsMsgbox.Mensaje "El proceso ha concluido exitosamente", mAceptar, minforma, GsTitMsg
        
    Exit Sub
NoPude:
    BorrarIdRep
    picAcepta.Picture = imgAceptaInactivo.Picture
    Screen.MousePointer = vbDefault
    clsMsgbox.Mensaje Err & " " & Err.Description, mAceptar, mAdvierte, GsTitMsg

Finaliza:
    picAcepta.Picture = imgAceptaInactivo.Picture
    Screen.MousePointer = vbDefault
End Sub

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

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 ValidarExistencia(Dato As Datos, Variable As Boolean)
    Screen.MousePointer = vbHourglass
    Variable = True
    Select Case Dato
        Case GrupoNomina
            MAdo.Sql = "SELECT 1 FROM fdt_grupos_nomina" & _
            " WHERE ISNULL(agrupacion,'') <> '' " & _
            " AND ISNULL(compania,'') = '' " & _
            " AND ISNULL(clase_nomina,'') = '' " & _
            " AND ISNULL(tipo_nomina,'') = '' " & _
            " AND grupo = '" & txtGrupoNom & "'"
        Case Compania
            MAdo.Sql = "SELECT 1 " & _
            " FROM companias c, aut_companias ac " & _
            " WHERE c.compania = ac.compania AND " & _
            " ac.usuario = '" & GsUid & "' AND " & _
            " c.compania = '" & txtCompanias & "'"
        Case ClaseNomina
            MAdo.Sql = "SELECT 1 FROM clases_nomina a, rel_usu_clase_nom b" & _
            " WHERE a.clase_nomina = b.clase_nomina AND a.clase_nomina = '" & txtClsNom & "'" & _
            " AND b.usuario = '" & GsUid & "'"
        Case TipoNomina
            MAdo.Sql = "SELECT 1 FROM tipos_nomina WHERE tipo_nomina = '" & Calendario.TipoNomina & "'"
    End Select
    MAdo.SendSQL
    If MAdo.EOF Then
        Variable = False
        Select Case Dato
            Case GrupoNomina: MostrarError "No existe el grupo de nómina", txtGrupoNom
            Case Compania: MostrarError "No existe la compañia no no tiene permisos sobre ella", txtCompanias
            Case ClaseNomina: MostrarError "No existe la clase de nómina o el usuario no tiene permisos", txtClsNom
            Case TipoNomina: MostrarError "No existe el tipo de nómina", Calendario
        End Select
    End If
    Screen.MousePointer = vbDefault
End Sub

Private Sub VerificarClasesNomina()
    MAdo.Sql = "SELECT COUNT(*) FROM rel_usu_clase_nom WHERE usuario = '" & GsUid & "'"
    MAdo.SendSQL
    If MAdo.EOF Then
        clsMsgbox.Mensaje "No tiene permiso sobre ninguna clase de nómina, no puede generar ningún archivo.", mAceptar, mAdvierte, GsTitMsg
    Else
        If MAdo.GetFieldInt(1) = 1 Then
            MAdo.Sql = "SELECT clase_nomina FROM rel_usu_clase_nom WHERE usuario = '" & GsUid & "'"
            MAdo.SendSQL
            txtClsNom = MAdo.GetField(1)
        End If
    End If
End Sub

Private Sub ConfiguraSpread()
    'Se configura el Spread
    With sprDatos
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprDatos
        .ColWidth(1) = 5
        .ColWidth(2) = 5
        .ColWidth(3) = 6
        .ColWidth(4) = 6
        .ColWidth(5) = 4
        .ColWidth(6) = 4
        .SetText 1, 0, "Grupo Nom"
        .SetText 2, 0, "Cia."
        .SetText 3, 0, "C.Nom."
        .SetText 4, 0, "Tipo"
        .SetText 5, 0, "Anio"
        .SetText 6, 0, "Per."
        
        .Col = 1: .TypeEditLen = 6: .TypeEditCharCase = 2
        .Col = 2: .TypeEditLen = 4: .TypeEditCharCase = 2
        .Col = 3: .TypeEditLen = 2: .TypeEditCharCase = 2
        .Col = 4: .TypeEditLen = 2: .TypeEditCharCase = 2
        .Col = 5: .TypeEditLen = 4: .TypeEditCharCase = 2
        .Col = 6: .TypeEditLen = 3: .TypeEditCharCase = 2
        
        .Col = -1: .Row = -1: .Lock = True
        .Col = 1: .ColHidden = True
        .ScrollBars = ScrollBarsBoth
        ConfiguraSpreadJCL sprDatos
    End With
    MAdo.Sql = "SELECT '','','','','','' FROM companias WHERE compania='Z'"
    MAdo.SendSQL
    
    clsSpread.LlenaSpread 0, sprDatos, MAdo, MAdo.lhDbc, MAdo.lhstmt
    
    'GAdam.AjustaSpread sprDatos, 2
End Sub

Private Sub txtCompanias_Change()
    MbCompania_OK = False
End Sub

Private Sub txtCompanias_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Len(Trim(txtCompanias.Text)) > 0 Then
            KeyAscii = 0
            ValidarExistencia Compania, MbCompania_OK
            If MbCompania_OK Then Me.txtClsNom.SetFocus
        Else
            MbCompania_OK = True
            Me.txtClsNom.SetFocus
        End If
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii)))
    End If

End Sub

Private Sub txtGrupoNom_Change()
    MbGrupoNom_OK = False
End Sub

Private Sub txtGrupoNom_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        If Len(Trim(txtGrupoNom.Text)) > 0 Then
            KeyAscii = 0
            ValidarExistencia GrupoNomina, MbGrupoNom_OK
            If MbGrupoNom_OK Then SendEnter
        Else
            MbGrupoNom_OK = True
            SendEnter
        End If
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii)))
    End If

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) = 40
        .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 = " & GIdProc & " AND usuariow = '" & GsUid & "'" & _
                          " AND banco = " & MsCodInter
        
              .ReplaceSelectionFormula ""
              
              For j = 0 To .GetNSubreports - 1
                  .SubreportToChange = .GetNthSubreportName(j)
                  .Connect = "DSN = " & UCase(GsDsn) & "; UID = " & GsUid & "; PWD = " & GsPwd
              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
Dim iIntentos As Integer 'JCL Junio 20/07 Para Pronaca

On Error GoTo RutaNoExiste
MbError = False

iIntentos = 0 'JCL Junio 20/07 Para Pronaca

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 = " & GIdProc & " AND usuariow = '" & GsUid & "'" & _
                    " AND banco = " & MsCodInter & " AND sec_archivo = " & iSec & "" & _
                    " ORDER BY secuencia "
          If Not MAdo.SendSQL Then GoTo Finaliza
           
          sRuta = sRuta & "\" & sArchivo
          
          'JCL Junio 20/07 Para Pronaca
          If Dir(sRuta, vbArchive) <> "" Then 'Si existe se borra
            Shell "Attrib " & sRuta & " -r" 'Para poder borrarlo hay que quitarle la propiedad solo lectura
            Kill sRuta 'Eliminar el archivo
          End If
          
          Open sRuta For Output As #1
          Do Until MAdo.EOF
              Print #1, MAdo.GetField(1) & MAdo.GetField(2)
              MAdo.Mnext
          Loop
          Close #1
                      
          Shell "Attrib " & sRuta & " +r" 'JCL Junio 20/07 Para Pronaca Se establece atributo de solo lectura
                      
          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 'JCL Junio 20/07 Para Pronaca
        If Err = 70 Or Err = 75 Then
            iIntentos = iIntentos + 1
            If iIntentos < 5000 Then
                Resume
            Else
                Screen.MousePointer = vbDefault
                clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
            End If
        Else
            Screen.MousePointer = vbDefault
            clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
        End If
    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

