VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Object = "{B02F3647-766B-11CE-AF28-C3A2FBE76A13}#2.5#0"; "ss32x25.ocx"
Begin VB.Form FCO1070T 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Configuración Medios Bancos"
   ClientHeight    =   7320
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6855
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Medios Bancos Mantenimiento.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   488
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   457
   Begin VB.Frame fraFrame 
      Caption         =   "Instituciones de Depósito"
      Height          =   2205
      Index           =   4
      Left            =   2775
      TabIndex        =   29
      Top             =   1050
      Width           =   3720
      Begin FPSpread.vaSpread sprDatos 
         Height          =   1710
         Left            =   90
         TabIndex        =   30
         Top             =   375
         Width           =   3135
         _Version        =   131077
         _ExtentX        =   5530
         _ExtentY        =   3016
         _StockProps     =   64
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MaxCols         =   1
         MaxRows         =   1
         SpreadDesigner  =   "Medios Bancos Mantenimiento.frx":030A
      End
      Begin VB.Image imgF4InsDep 
         Height          =   480
         Left            =   3270
         Picture         =   "Medios Bancos Mantenimiento.frx":0463
         Top             =   375
         Width           =   480
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Banco"
      Height          =   870
      Index           =   3
      Left            =   255
      TabIndex        =   19
      Top             =   120
      Width           =   6240
      Begin VB.TextBox txtProcGenera 
         Height          =   285
         Left            =   1920
         MaxLength       =   30
         TabIndex        =   1
         Top             =   525
         Width           =   4215
      End
      Begin VB.TextBox txtDescripcion 
         Height          =   315
         Left            =   1920
         TabIndex        =   0
         Top             =   200
         Width           =   4215
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Proc. Generación"
         Height          =   210
         Index           =   14
         Left            =   120
         TabIndex        =   24
         Top             =   510
         Width           =   1260
      End
      Begin VB.Label lblLabels 
         Caption         =   "Descripción del Archivo"
         Height          =   255
         Index           =   10
         Left            =   120
         TabIndex        =   20
         Top             =   240
         Width           =   1815
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Datos por Compañía"
      Height          =   1320
      Index           =   2
      Left            =   210
      TabIndex        =   14
      Top             =   3360
      Width           =   6255
      Begin VB.TextBox txtRegFiscal 
         Height          =   285
         Left            =   1425
         MaxLength       =   20
         TabIndex        =   12
         Top             =   945
         Width           =   1335
      End
      Begin VB.TextBox txtResponsable 
         Height          =   285
         Left            =   3240
         MaxLength       =   20
         TabIndex        =   11
         Top             =   615
         Width           =   2880
      End
      Begin VB.TextBox txtSimbMoneda 
         Height          =   285
         Left            =   1440
         MaxLength       =   5
         TabIndex        =   10
         Top             =   600
         Width           =   615
      End
      Begin VB.ComboBox cboTipoCta 
         Height          =   330
         ItemData        =   "Medios Bancos Mantenimiento.frx":076D
         Left            =   4800
         List            =   "Medios Bancos Mantenimiento.frx":077A
         Style           =   2  'Dropdown List
         TabIndex        =   9
         Top             =   240
         Width           =   1335
      End
      Begin VB.TextBox txtOficina 
         Height          =   285
         Left            =   3240
         MaxLength       =   15
         TabIndex        =   8
         Top             =   240
         Width           =   1020
      End
      Begin VB.TextBox txtCuenta 
         Height          =   285
         Left            =   720
         MaxLength       =   30
         TabIndex        =   7
         Top             =   240
         Width           =   1335
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Registro Fiscal"
         Height          =   210
         Index           =   8
         Left            =   105
         TabIndex        =   23
         Top             =   930
         Width           =   1065
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Responsable"
         Height          =   210
         Index           =   12
         Left            =   2220
         TabIndex        =   22
         Top             =   630
         Width           =   945
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Símbolo Moneda"
         Height          =   210
         Index           =   11
         Left            =   105
         TabIndex        =   21
         Top             =   615
         Width           =   1170
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Cod. Oficina"
         Height          =   210
         Index           =   6
         Left            =   2250
         TabIndex        =   17
         Top             =   240
         Width           =   885
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Tipo"
         Height          =   210
         Index           =   5
         Left            =   4320
         TabIndex        =   16
         Top             =   240
         Width           =   300
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Número"
         Height          =   210
         Index           =   4
         Left            =   120
         TabIndex        =   15
         Top             =   240
         Width           =   555
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Valor de los Conceptos"
      Height          =   2205
      Index           =   0
      Left            =   225
      TabIndex        =   13
      Top             =   1050
      Width           =   2520
      Begin VB.TextBox txtConcepto 
         Height          =   315
         Index           =   4
         Left            =   1110
         MaxLength       =   5
         TabIndex        =   6
         Top             =   1755
         Width           =   855
      End
      Begin VB.TextBox txtConcepto 
         Height          =   315
         Index           =   3
         Left            =   1110
         MaxLength       =   5
         TabIndex        =   5
         Top             =   1395
         Width           =   855
      End
      Begin VB.TextBox txtConcepto 
         Height          =   315
         Index           =   2
         Left            =   1110
         MaxLength       =   5
         TabIndex        =   4
         Top             =   1065
         Width           =   855
      End
      Begin VB.TextBox txtConcepto 
         Height          =   315
         Index           =   1
         Left            =   1110
         MaxLength       =   5
         TabIndex        =   3
         Top             =   705
         Width           =   855
      End
      Begin VB.TextBox txtConcepto 
         Height          =   315
         Index           =   0
         Left            =   1110
         MaxLength       =   5
         TabIndex        =   2
         Top             =   345
         Width           =   855
      End
      Begin VB.Image imgF4Concepto 
         Height          =   480
         Index           =   4
         Left            =   2025
         Picture         =   "Medios Bancos Mantenimiento.frx":079B
         Top             =   1755
         Width           =   480
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 5"
         Height          =   210
         Index           =   17
         Left            =   135
         TabIndex        =   28
         Top             =   1785
         Width           =   825
      End
      Begin VB.Image imgF4Concepto 
         Height          =   480
         Index           =   3
         Left            =   2025
         Picture         =   "Medios Bancos Mantenimiento.frx":0AA5
         Top             =   1395
         Width           =   480
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 4"
         Height          =   210
         Index           =   16
         Left            =   135
         TabIndex        =   27
         Top             =   1425
         Width           =   825
      End
      Begin VB.Image imgF4Concepto 
         Height          =   480
         Index           =   2
         Left            =   2025
         Picture         =   "Medios Bancos Mantenimiento.frx":0DAF
         Top             =   1065
         Width           =   480
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 3"
         Height          =   210
         Index           =   15
         Left            =   150
         TabIndex        =   26
         Top             =   1095
         Width           =   825
      End
      Begin VB.Image imgF4Concepto 
         Height          =   480
         Index           =   1
         Left            =   2025
         Picture         =   "Medios Bancos Mantenimiento.frx":10B9
         Top             =   705
         Width           =   480
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 2"
         Height          =   210
         Index           =   13
         Left            =   150
         TabIndex        =   25
         Top             =   735
         Width           =   825
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 1"
         Height          =   210
         Index           =   7
         Left            =   165
         TabIndex        =   18
         Top             =   390
         Width           =   825
      End
      Begin VB.Image imgF4Concepto 
         Height          =   480
         Index           =   0
         Left            =   2025
         Picture         =   "Medios Bancos Mantenimiento.frx":13C3
         Top             =   360
         Width           =   480
      End
   End
   Begin FPSpread.vaSpread sprRUT 
      Height          =   1860
      Left            =   225
      TabIndex        =   31
      Top             =   4755
      Width           =   6225
      _Version        =   131077
      _ExtentX        =   10980
      _ExtentY        =   3281
      _StockProps     =   64
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      MaxCols         =   1
      MaxRows         =   1
      SpreadDesigner  =   "Medios Bancos Mantenimiento.frx":16CD
   End
   Begin MSComDlg.CommonDialog dlgRuta 
      Left            =   195
      Top             =   6675
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Image imgListaRUT 
      Height          =   480
      Left            =   6480
      Picture         =   "Medios Bancos Mantenimiento.frx":1826
      Top             =   4800
      Width           =   480
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   15
      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 Mantenimiento.frx":1B30
   End
End
Attribute VB_Name = "FCO1070T"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Mado As ODBC.ODBCDirecto
Private Micx As Integer 'Conexión
Private MiX As Integer 'Ancho de la forma
Private MiY As Integer 'Alta de la forma
Private MsBanco As String
Private Enum Datos
    Concepto1
    Concepto2
    Concepto3
    Concepto4
    Concepto5
End Enum

Private MbConcepto1_OK As Boolean
Private MbConcepto2_OK As Boolean
Private MbConcepto3_OK As Boolean
Private MbConcepto4_OK As Boolean
Private MbConcepto5_OK As Boolean

Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
Private MoBita As New ADAMBitacora.Bitacora
Private MoBitaRUT As New ADAMBitacora.Bitacora

Private MbE1 As Boolean
Private MbE2 As Boolean

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

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


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF5: RecuperarDatos
        Case vbKeyF6: Altas
        Case vbKeyF7: Bajas
        Case vbKeyF11: GuardarCambios
        Case vbKeyF12: abToolbar.Bands(1).TrackPopup -1, -1
    End Select
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then
        Select Case LCase(ActiveControl.Name)
            Case "txtconcepto":
                Select Case ActiveControl.Index
                  Case 0: imgF4Concepto_Click (0)
                  Case 1: imgF4Concepto_Click (1)
                  Case 2: imgF4Concepto_Click (2)
                  Case 3: imgF4Concepto_Click (3)
                  Case 4: imgF4Concepto_Click (4)
                End Select
        End Select
    End If
End Sub

Private Sub Form_Load()
    GbAError = False
    Me.Tag = GiVenMax%
    Gven(Val(Me.Tag)).icx = Gicx%
    Micx = Gven(Val(Me.Tag)).icx
    Set Mado = Gtc(Micx).Ado
    Me.Icon = LoadPicture(sIconoForma)
    
    Caption = GsDsn & " / " & GsAbreviaturaCia & " - Configuración Archivos para Bancos"
    AsignaIconos abToolbar, 3, LALTA, LBAJA, LRENUEVA, LGUARDA, LSALIDA
    GAdam.ObtieneColores
    Set clsSpread = New NSpread
    
    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 = 6945
        MiY = 7695
        Me.Width = MiX
        Me.Height = MiY
    End If
    
    MsBanco = GsDatoAux
    CreaBitacora
    RecuperarDatos
    Screen.MousePointer = vbDefault
End Sub

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

Private Sub Form_Unload(Cancel As Integer)
    Set Mado = Nothing
    Set FCO1070T = Nothing
    Set clsSpread = Nothing
    Set MoBita = Nothing
    Gtc(Micx).ihijas = Gtc(Micx).ihijas - 1
End Sub

Private Sub imgF4Concepto_Click(Index As Integer)
    Screen.MousePointer = vbHourglass
    GsParamIN(0) = "SELECT concepto, descripcion" & _
    " FROM conceptos_ns" & _
    " WHERE compania = '" & GsCveCia & "'"
    GsParamIN(1) = "concepto"
    GsParamIN(2) = "descripcion"
    GsParamIN(3) = "Concepto"
    GsParamIN(4) = "Descripcion"
    GsParamIN(5) = "Conceptos de Nómina"
    GsParamIN(6) = ""
    frmLista.Show 1
    If GsParamOUT(0) <> "" Then
      Select Case Index
        Case 0: txtConcepto(0) = GsParamOUT(0)
                MbConcepto1_OK = True
        Case 1: txtConcepto(1) = GsParamOUT(0)
                MbConcepto2_OK = True
        Case 2: txtConcepto(2) = GsParamOUT(0)
                MbConcepto3_OK = True
        Case 3: txtConcepto(3) = GsParamOUT(0)
                MbConcepto4_OK = True
        Case 4: txtConcepto(4) = GsParamOUT(0)
                MbConcepto5_OK = True
      End Select
    End If
    Screen.MousePointer = vbDefault

End Sub

Private Sub imgF4InsDep_Click()
Dim i As Integer
If sprDatos.VirtualMaxRows > 0 Then
  With sprDatos
      If .ActiveCol = 1 Then
          Screen.MousePointer = vbHourglass
          GsParamIN(0) = "SELECT institucion_deposito, descripcion" & _
          " FROM ins_depositos" & _
          " WHERE 1=1"
          GsParamIN(1) = "institucion_deposito"
          GsParamIN(2) = "descripcion"
          GsParamIN(3) = "Código"
          GsParamIN(4) = "Descripcion"
          GsParamIN(5) = "Instituciones de Depósito"
          GsParamIN(6) = ""
          frmLista.Show 1
          If GsParamOUT(0) <> "" Then
              With sprDatos
                  'revisando que el dato escogido ya no exita en el grid
                  For i = 1 To .MaxRows
                      .Col = 1: .Row = i
                      If .Value = GsParamOUT(0) Then
                          clsMsgbox.Mensaje "El dato escogido ya esta grabado. Escoja otro por favor", mAceptar, mAdvierte, GsTitMsg
                          Exit Sub
                      End If
                  Next i
                  .Col = 1: .Row = .ActiveRow: .Text = GsParamOUT(0)
                  .Col = 2: .Row = .ActiveRow: .Text = GsParamOUT(0)
                  .Col = 3: .Row = .ActiveRow: .Text = GsParamOUT(1)
              End With
              MoBita.mCambia
          End If
          Screen.MousePointer = vbDefault
      End If
  End With
End If
End Sub

Private Sub GuardarCambios()
  
  Screen.MousePointer = vbHourglass
  If MbE1 Then
    If sprDatos.MaxRows = 0 Then Exit Sub
    GbRen = MoBita.mActualizaBD
    If GbRen Then RenuevaDatosBco
    MbE1 = False
    MoBita.mVaciaBuffer
  End If
  
  If MbE2 Then
      If sprRUT.MaxRows = 0 Then Exit Sub
      GbRen = MoBitaRUT.mActualizaBD
      MoBitaRUT.mVaciaBuffer
      MbE2 = False
      If GbRen = True Then RenuevaDatosRut
  End If

    If cboTipoCta.ListIndex = -1 Then
        clsMsgbox.Mensaje "Debe seleccionar el tipo de cuenta", mAceptar, mAdvierte, GsTitMsg
        Exit Sub
    End If
    
    'Zona de validaciones
    If Not MbConcepto1_OK Then
        ValidarExistencia Concepto1, MbConcepto1_OK
        If Not MbConcepto1_OK Then Exit Sub
    End If
    
    If Not MbConcepto2_OK Then
        ValidarExistencia Concepto2, MbConcepto2_OK
        If Not MbConcepto2_OK Then Exit Sub
    End If
    
    If Not MbConcepto3_OK Then
        ValidarExistencia Concepto3, MbConcepto3_OK
        If Not MbConcepto3_OK Then Exit Sub
    End If
    
    If Not MbConcepto4_OK Then
        ValidarExistencia Concepto4, MbConcepto4_OK
        If Not MbConcepto4_OK Then Exit Sub
    End If
    
    If Not MbConcepto5_OK Then
        ValidarExistencia Concepto5, MbConcepto5_OK
        If Not MbConcepto5_OK Then Exit Sub
    End If
                    
    Screen.MousePointer = vbHourglass
    
    Mado.SQL = _
    "sp_fdt_upd_bancos_detalle " & _
    "'" & GsCveCia & "'," & _
    MsBanco & "," & _
    "'" & txtDescripcion & "'," & _
    "'" & txtCuenta & "'," & _
    cboTipoCta.ItemData(cboTipoCta.ListIndex) & "," & _
    "'" & txtOficina & "'," & _
    Val(txtConcepto(0)) & "," & _
    IIf(Trim(txtConcepto(1)) <> "", Val(txtConcepto(1)), "NULL") & "," & _
    IIf(Trim(txtConcepto(2)) <> "", Val(txtConcepto(2)), "NULL") & "," & _
    IIf(Trim(txtConcepto(3)) <> "", Val(txtConcepto(3)), "NULL") & "," & _
    IIf(Trim(txtConcepto(4)) <> "", Val(txtConcepto(4)), "NULL") & "," & _
    "'" & txtSimbMoneda & "'," & _
    "'" & txtResponsable & "'," & _
    "'" & txtRegFiscal & "'," & _
    "'FCO1070'," & _
    "'TODOS'," & _
    "'" & txtProcGenera & "'"
        
    '"'" & GsUid & "',"
    If Mado.ExecSQL = -1 Then GoTo NoPude
    
    Screen.MousePointer = vbDefault
    Exit Sub
    

NoPude:
    Screen.MousePointer = vbDefault
    If Err > 0 Then
        clsMsgbox.Mensaje Err & " " & Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
    
End Sub

Private Sub RecuperarDatos()
'limpiamos primero los controles
    txtDescripcion = ""
    txtCuenta = ""
    txtOficina = ""
    txtConcepto(0) = ""
    txtConcepto(1) = ""
    txtConcepto(2) = ""
    txtConcepto(3) = ""
    txtConcepto(4) = ""
    txtSimbMoneda = ""
    txtResponsable = ""
    txtRegFiscal = ""
    cboTipoCta.ListIndex = -1
    txtProcGenera = ""
    
    Mado.SQL = _
    " SELECT * FROM vw_fdt_bancos" & _
    " WHERE compania = '" & GsCveCia & "'" & _
    " AND banco = " & MsBanco '& _

    If Not Mado.SendSQL Then Exit Sub
                
    If Not Mado.EOF Then
        txtDescripcion = "" & Mado.GetField(3)
        txtCuenta = "" & Mado.GetField(4)
        txtOficina = "" & Mado.GetField(6)
        txtConcepto(0) = "" & Mado.GetField(7)
        txtConcepto(1) = "" & Mado.GetField(8)
        txtConcepto(2) = "" & Mado.GetField(9)
        txtConcepto(3) = "" & Mado.GetField(10)
        txtConcepto(4) = "" & Mado.GetField(11)
        txtSimbMoneda = "" & Mado.GetField(12)
        txtResponsable = "" & Mado.GetField(13)
        txtRegFiscal = "" & Mado.GetField(14)
        Select Case Mado.GetFieldInt(5)
            Case 1: cboTipoCta.ListIndex = 0
            Case 2: cboTipoCta.ListIndex = 1
            Case 3: cboTipoCta.ListIndex = 2
        End Select
        
        txtProcGenera = "" & Mado.GetField(15)
    Else
        Mado.SQL = "SELECT descripcion, proc_generacion FROM fdt_bancos WHERE banco = " & MsBanco & ""
        If Not Mado.SendSQL Then Exit Sub
        If Not Mado.EOF Then
            txtDescripcion = "" & Mado.GetField(1)
            txtProcGenera = "" & Mado.GetField(2)
        End If
    End If
    
    RenuevaDatos
End Sub

Private Sub ValidarExistencia(Dato As Datos, Variable As Boolean)
    Variable = True
    Select Case Dato
        Case Concepto1
            'If Trim(Me.txtConcepto(0)) = "" Then Exit Sub
            Mado.SQL = "SELECT descripcion FROM conceptos_ns WHERE compania = '" & GsCveCia & "'" & _
                        " AND concepto = " & CStr(Val(txtConcepto(0)))
        Case Concepto2
            If Trim(Me.txtConcepto(1)) = "" Then Exit Sub
            Mado.SQL = "SELECT descripcion FROM conceptos_ns WHERE compania = '" & GsCveCia & "'" & _
                        " AND concepto = " & CStr(Val(txtConcepto(1)))
        Case Concepto3
            If Trim(Me.txtConcepto(2)) = "" Then Exit Sub
            Mado.SQL = "SELECT descripcion FROM conceptos_ns WHERE compania = '" & GsCveCia & "'" & _
                        " AND concepto = " & CStr(Val(txtConcepto(2)))
        Case Concepto4
            If Trim(Me.txtConcepto(3)) = "" Then Exit Sub
            Mado.SQL = "SELECT descripcion FROM conceptos_ns WHERE compania = '" & GsCveCia & "'" & _
                        " AND concepto = " & CStr(Val(txtConcepto(3)))
        Case Concepto5
            If Trim(Me.txtConcepto(4)) = "" Then Exit Sub
            Mado.SQL = "SELECT descripcion FROM conceptos_ns WHERE compania = '" & GsCveCia & "'" & _
                        " AND concepto = " & CStr(Val(txtConcepto(4)))
    End Select
    Screen.MousePointer = vbHourglass
    Mado.SendSQL
    If Mado.EOF Then
        Variable = False
        Select Case Dato
            Case Concepto1: MostrarError "El concepto no existe", txtConcepto(0)
            Case Concepto2: MostrarError "El concepto no existe", txtConcepto(1)
            Case Concepto3: MostrarError "El concepto no existe", txtConcepto(2)
            Case Concepto4: MostrarError "El concepto no existe", txtConcepto(3)
            Case Concepto5: MostrarError "El concepto no existe", txtConcepto(4)
        End Select
    End If
    Screen.MousePointer = vbDefault
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 sprDatos_Change(ByVal Col As Long, ByVal Row As Long)
  MoBita.mCambia
End Sub

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

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

End Sub

Private Sub sprDatos_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 Then imgF4InsDep_Click
End Sub

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

End Sub

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


With sprRUT

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

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

  End If
End With
  
  MoBitaRUT.mCambia

End Sub

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

End Sub

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

End Sub

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

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

End Sub

Private Sub txtConcepto_Change(Index As Integer)
  Select Case Index
    Case 0: MbConcepto1_OK = False
    Case 1: MbConcepto2_OK = False
    Case 2: MbConcepto3_OK = False
    Case 3: MbConcepto4_OK = False
    Case 4: MbConcepto5_OK = False
  End Select
End Sub

Private Sub txtConcepto_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
    KeyAscii = 0
    Select Case Index
        Case 0:    ValidarExistencia Concepto1, MbConcepto1_OK
                   If MbConcepto1_OK Then SendEnter
        Case 1:    ValidarExistencia Concepto2, MbConcepto2_OK
                   If MbConcepto2_OK Then SendEnter
        Case 2:    ValidarExistencia Concepto3, MbConcepto3_OK
                   If MbConcepto3_OK Then SendEnter
        Case 3:    ValidarExistencia Concepto4, MbConcepto4_OK
                   If MbConcepto4_OK Then SendEnter
        Case 4:    ValidarExistencia Concepto5, MbConcepto5_OK
                   If MbConcepto5_OK Then SendEnter
    End Select
Else
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub

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

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

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

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

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

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

Private Sub RenuevaDatosBco()
    'Se configura el Spread
    With sprDatos
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprDatos
        .ColWidth(1) = 6
        .ColWidth(2) = 6
        .ColWidth(3) = 18
        .SetText 1, 0, "Ins Dep"
        .SetText 2, 0, "Codigo"
        .SetText 3, 0, "Descripcion"
        
        .Col = 1: .TypeEditLen = 3: .TypeEditCharCase = 2
        .Col = 2: .TypeEditLen = 15: .TypeEditCharCase = 2
        .Col = 3: .TypeEditLen = 40: .TypeEditCharCase = 2
        
        .Col = 1: .Row = -1: .Lock = True
        .Col = 3: .Row = -1: .Lock = True
        .ScrollBars = ScrollBarsBoth
        ConfiguraSpreadJCL sprDatos
    End With
    
    Mado.SQL = "SELECT ins_dep, cod_banco, descripcion FROM fdt_bancos_ins_dep a, ins_depositos b " & _
               "WHERE a.ins_dep = b.institucion_deposito AND a.banco = '" & MsBanco & "'"
    If Not Mado.SendSQL Then Exit Sub
    
    clsSpread.LlenaSpread 0, sprDatos, Mado, Mado.lhDbc, Mado.lhstmt
    
    'GAdam.AjustaSpread sprDatos, 2
End Sub

Private Sub CreaBitacora()
  MoBita.mCreaBitacora sprDatos, Mado.lhEnv, Mado.lhDbc, Mado.lhstmt, Mado
  MoBita.mTablaSPInfo 0, "sp_fdt_upd_bancos_ins_dep", "" & MsBanco & "", 1, 2, "1"
  MoBita.mTablaSPInfo 1, "sp_fdt_upd_bancos_ins_dep", "" & MsBanco & "", 1, 2, "2"
  MoBita.mTablaSPInfo 2, "sp_fdt_upd_bancos_ins_dep", "" & MsBanco & "", 1, 2, "3"
  MoBita.mColNoNulls 1
    
  MoBitaRUT.mCreaBitacora sprRUT, Mado.lhEnv, Mado.lhDbc, Mado.lhstmt, Mado
  MoBitaRUT.mTablaSPInfo 0, "sp_fdt_upd_rutas", "'" & GsOper & "'", "" & MsBanco & "", 1, 2, 4, 5, 6
  MoBitaRUT.mTablaSPInfo 1, "sp_fdt_del_rutas", "'" & GsOper & "'", "" & MsBanco & "", 1, 2
  MoBitaRUT.mTablaSPInfo 2, "sp_fdt_upd_rutas", "'" & GsOper & "'", "" & MsBanco & "", 1, 2, 4, 5, 6
  MoBitaRUT.mColNoNulls 1
    
End Sub

Private Sub Altas()
Dim nValor As Byte

If MbE1 Then
  With sprDatos
     .VirtualMode = True
     MoBita.mAgrega
     .VirtualMode = False
     .Col = -1: .Row = -1: .Lock = True
     .Col = 2: .Row = -1: .Lock = False
  End With
End If

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

End Sub

Private Sub Bajas()
  If MbE1 Then
    If sprDatos.VirtualMaxRows <= 0 Then Exit Sub
    MoBita.mBorra
  End If
  
  If MbE2 Then
      If sprRUT.VirtualMaxRows <= 0 Then Exit Sub
      MoBitaRUT.mBorra
  End If
    
End Sub

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

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

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

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

End Sub

Private Sub RenuevaDatos()
    If iDeseaGuardar = 2 Then Exit Sub 'Cancelar
    RenuevaDatosBco
    RenuevaDatosRut
End Sub

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

