VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Object = "{B02F3647-766B-11CE-AF28-C3A2FBE76A13}#2.5#0"; "ss32x25.ocx"
Object = "{9FE8BEE1-8569-4532-8518-BB32F08FC1EB}#2.0#0"; "dtF4.ocx"
Begin VB.Form FCO1070T 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Configuración Medios Bancos"
   ClientHeight    =   7575
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8310
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "FCO1070T Bancos Configuracion de Archivos.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   505
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   554
   Begin VB.Frame fraFrame 
      Caption         =   "Archivos y Reportes"
      Height          =   2175
      Index           =   1
      Left            =   240
      TabIndex        =   43
      Top             =   4800
      Width           =   7935
      Begin DataTec_F4.dtF4 dtF4RUT 
         Height          =   255
         Left            =   7560
         TabIndex        =   44
         Top             =   405
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      Begin FPSpread.vaSpread sprRUT 
         Height          =   1860
         Left            =   120
         TabIndex        =   45
         Top             =   240
         Width           =   7305
         _Version        =   131077
         _ExtentX        =   12885
         _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  =   "FCO1070T Bancos Configuracion de Archivos.frx":030A
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Instituciones de Depósito"
      Height          =   2205
      Index           =   4
      Left            =   2775
      TabIndex        =   33
      Top             =   1050
      Width           =   5400
      Begin DataTec_F4.dtF4 dtF4InsDep 
         Height          =   375
         Left            =   5040
         TabIndex        =   40
         Top             =   600
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   661
      End
      Begin FPSpread.vaSpread sprDatos 
         Height          =   1710
         Left            =   90
         TabIndex        =   34
         Top             =   375
         Width           =   4815
         _Version        =   131077
         _ExtentX        =   8493
         _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  =   "FCO1070T Bancos Configuracion de Archivos.frx":0463
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Banco"
      Height          =   870
      Index           =   3
      Left            =   255
      TabIndex        =   23
      Top             =   120
      Width           =   7920
      Begin VB.TextBox txtProcGenera 
         Height          =   285
         Left            =   2040
         MaxLength       =   30
         TabIndex        =   1
         Top             =   525
         Width           =   5415
      End
      Begin VB.TextBox txtDescripcion 
         Height          =   315
         Left            =   2040
         TabIndex        =   0
         Top             =   200
         Width           =   5415
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Proc. Generación"
         Height          =   210
         Index           =   14
         Left            =   120
         TabIndex        =   28
         Top             =   510
         Width           =   1260
      End
      Begin VB.Label lblLabels 
         Caption         =   "Descripción del Archivo"
         Height          =   255
         Index           =   10
         Left            =   120
         TabIndex        =   24
         Top             =   240
         Width           =   1815
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Datos por Compañía"
      Height          =   1320
      Index           =   2
      Left            =   210
      TabIndex        =   18
      Top             =   3360
      Width           =   7935
      Begin VB.TextBox txtAgrTipoCta 
         Height          =   285
         Left            =   6360
         MaxLength       =   10
         TabIndex        =   15
         Top             =   960
         Width           =   1140
      End
      Begin VB.TextBox txtAgrTipoId 
         Height          =   285
         Left            =   3960
         MaxLength       =   10
         TabIndex        =   13
         Top             =   960
         Width           =   1140
      End
      Begin VB.TextBox txtRegFiscal 
         Height          =   285
         Left            =   1425
         MaxLength       =   20
         TabIndex        =   12
         Top             =   945
         Width           =   1335
      End
      Begin VB.TextBox txtResponsable 
         Height          =   315
         Left            =   3960
         MaxLength       =   20
         TabIndex        =   11
         Top             =   615
         Width           =   3540
      End
      Begin VB.TextBox txtSimbMoneda 
         Height          =   285
         Left            =   1440
         MaxLength       =   5
         TabIndex        =   10
         Top             =   600
         Width           =   1335
      End
      Begin VB.ComboBox cboTipoCta 
         Height          =   330
         ItemData        =   "FCO1070T Bancos Configuracion de Archivos.frx":05BC
         Left            =   5820
         List            =   "FCO1070T Bancos Configuracion de Archivos.frx":05C9
         Style           =   2  'Dropdown List
         TabIndex        =   9
         Top             =   240
         Width           =   1695
      End
      Begin VB.TextBox txtOficina 
         Height          =   285
         Left            =   3960
         MaxLength       =   15
         TabIndex        =   8
         Top             =   240
         Width           =   1140
      End
      Begin VB.TextBox txtCuenta 
         Height          =   285
         Left            =   1440
         MaxLength       =   30
         TabIndex        =   7
         Top             =   240
         Width           =   1335
      End
      Begin DataTec_F4.dtF4 dtF4AgrTipoCta 
         Height          =   255
         Left            =   7560
         TabIndex        =   16
         Top             =   960
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      Begin DataTec_F4.dtF4 dtF4AgrTipoId 
         Height          =   255
         Left            =   5160
         TabIndex        =   14
         Top             =   960
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Tipo Cta."
         Height          =   210
         Index           =   1
         Left            =   5640
         TabIndex        =   42
         Top             =   960
         Width           =   630
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Agr. Tipo Id."
         Height          =   210
         Index           =   0
         Left            =   2880
         TabIndex        =   41
         Top             =   960
         Width           =   870
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Registro Fiscal"
         Height          =   210
         Index           =   8
         Left            =   105
         TabIndex        =   27
         Top             =   930
         Width           =   1065
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Responsable"
         Height          =   210
         Index           =   12
         Left            =   2880
         TabIndex        =   26
         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        =   25
         Top             =   615
         Width           =   1170
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Cod. Oficina"
         Height          =   210
         Index           =   6
         Left            =   2880
         TabIndex        =   21
         Top             =   240
         Width           =   885
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Tipo"
         Height          =   210
         Index           =   5
         Left            =   5280
         TabIndex        =   20
         Top             =   240
         Width           =   300
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Número Cuenta"
         Height          =   210
         Index           =   4
         Left            =   120
         TabIndex        =   19
         Top             =   240
         Width           =   1110
      End
   End
   Begin VB.Frame fraFrame 
      Caption         =   "Valor de los Conceptos"
      Height          =   2205
      Index           =   0
      Left            =   225
      TabIndex        =   17
      Top             =   1050
      Width           =   2520
      Begin DataTec_F4.dtF4 dtF4Cnc 
         Height          =   255
         Index           =   0
         Left            =   2040
         TabIndex        =   35
         Top             =   360
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      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 DataTec_F4.dtF4 dtF4Cnc 
         Height          =   255
         Index           =   1
         Left            =   2040
         TabIndex        =   36
         Top             =   720
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      Begin DataTec_F4.dtF4 dtF4Cnc 
         Height          =   255
         Index           =   2
         Left            =   2040
         TabIndex        =   37
         Top             =   1080
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      Begin DataTec_F4.dtF4 dtF4Cnc 
         Height          =   255
         Index           =   3
         Left            =   2040
         TabIndex        =   38
         Top             =   1440
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      Begin DataTec_F4.dtF4 dtF4Cnc 
         Height          =   255
         Index           =   4
         Left            =   2040
         TabIndex        =   39
         Top             =   1800
         Width           =   255
         _ExtentX        =   450
         _ExtentY        =   450
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 5"
         Height          =   210
         Index           =   17
         Left            =   135
         TabIndex        =   32
         Top             =   1785
         Width           =   825
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 4"
         Height          =   210
         Index           =   16
         Left            =   135
         TabIndex        =   31
         Top             =   1425
         Width           =   825
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 3"
         Height          =   210
         Index           =   15
         Left            =   150
         TabIndex        =   30
         Top             =   1095
         Width           =   825
      End
      Begin VB.Label lblLabels 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Concepto 2"
         Height          =   210
         Index           =   13
         Left            =   150
         TabIndex        =   29
         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        =   22
         Top             =   390
         Width           =   825
      End
   End
   Begin MSComDlg.CommonDialog dlgRuta 
      Left            =   195
      Top             =   6675
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   720
      Top             =   7080
      _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           =   "FCO1070T Bancos Configuracion de Archivos.frx":05EA
   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
    Agrupacion1 'Agregado JCL Ene-12/06
    Agrupacion2 'Agregado JCL Ene-12/06
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

'Agregado JCL Ene-12/06
Private MbAgr1_OK As Boolean
Private MbAgr2_OK 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 dtF4AgrTipoCta_Click()
    Dim Lista As New cdtLista
    
    Screen.MousePointer = vbHourglass
    Lista.Sql = "SELECT a.agrupacion, a.descripcion" & _
    " FROM agrupaciones_trab a, rel_agr_companias b" & _
    " WHERE a.agrupacion = b.agrupacion" & _
    " AND b.compania = '" & GsCveCia & "'"
    Lista.Campo1 = "a.agrupacion"
    Lista.Campo2 = "a.descripcion"
    Lista.Titulo1 = "Agrupación"
    Lista.Titulo2 = "Descripción"
    Lista.TituloVentana = "Agrupaciones"
    Lista.Orden = ""
    Lista.MostrarLista
    If Lista.Valor1 <> "" Then
        txtAgrTipoCta = Lista.Valor1
        MbAgr2_OK = True
    End If
    
    Set Lista = Nothing
    Screen.MousePointer = vbDefault
End Sub

Private Sub dtF4AgrTipoId_Click()
    Dim Lista As New cdtLista
    
    Screen.MousePointer = vbHourglass
    Lista.Sql = "SELECT a.agrupacion, a.descripcion" & _
    " FROM agrupaciones_trab a, rel_agr_companias b" & _
    " WHERE a.agrupacion = b.agrupacion" & _
    " AND b.compania = '" & GsCveCia & "'"
    Lista.Campo1 = "a.agrupacion"
    Lista.Campo2 = "a.descripcion"
    Lista.Titulo1 = "Agrupación"
    Lista.Titulo2 = "Descripción"
    Lista.TituloVentana = "Agrupaciones"
    Lista.Orden = ""
    Lista.MostrarLista
    If Lista.Valor1 <> "" Then
        txtAgrTipoId = Lista.Valor1
        MbAgr1_OK = True
    End If
    
    Set Lista = Nothing
    Screen.MousePointer = vbDefault
End Sub

Private Sub dtF4Cnc_Click(Index As Integer)
    Dim Lista As New cdtLista
    
    Screen.MousePointer = vbHourglass
    Lista.Sql = "SELECT concepto, descripcion" & _
    " FROM conceptos_ns" & _
    " WHERE compania = '" & GsCveCia & "'"
    Lista.Campo1 = "concepto"
    Lista.Campo2 = "descripcion"
    Lista.Titulo1 = "Concepto"
    Lista.Titulo2 = "Descripcion"
    Lista.TituloVentana = "Conceptos de Nómina"
    Lista.Orden = ""
    Lista.MostrarLista
    If Lista.Valor1 <> "" Then
      Select Case Index
        Case 0: txtConcepto(0) = Lista.Valor1
                MbConcepto1_OK = True
        Case 1: txtConcepto(1) = Lista.Valor1
                MbConcepto2_OK = True
        Case 2: txtConcepto(2) = Lista.Valor1
                MbConcepto3_OK = True
        Case 3: txtConcepto(3) = Lista.Valor1
                MbConcepto4_OK = True
        Case 4: txtConcepto(4) = Lista.Valor1
                MbConcepto5_OK = True
      End Select
    End If
    
    Set Lista = Nothing
    Screen.MousePointer = vbDefault
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": dtF4Cnc_Click ActiveControl.Index
            Case "txtagrtipoid": dtF4AgrTipoId_Click
            Case "txtagrtipocta": dtF4AgrTipoCta_Click
        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 = 8400
        MiY = 8055
        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 dtF4InsDep_Click()
Dim i As Integer
Dim Lista As New cdtLista

If sprDatos.VirtualMaxRows > 0 Then
  With sprDatos
      If .ActiveCol = 1 Then
          Screen.MousePointer = vbHourglass
          Lista.Sql = "SELECT institucion_deposito, descripcion" & _
          " FROM ins_depositos" & _
          " WHERE 1=1"
          Lista.Campo1 = "institucion_deposito"
          Lista.Campo2 = "descripcion"
          Lista.Titulo1 = "Código"
          Lista.Titulo2 = "Descripcion"
          Lista.TituloVentana = "Instituciones de Depósito"
          Lista.Orden = ""
          Lista.MostrarLista
          If Lista.Valor1 <> "" 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 = Lista.Valor1 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 = Lista.Valor1
                  .Col = 2: .Row = .ActiveRow: .Text = Lista.Valor1
                  .Col = 3: .Row = .ActiveRow: .Text = Lista.Valor2
              End With
              MoBita.mCambia
          End If
          Screen.MousePointer = vbDefault
      End If
  End With
End If

Set Lista = Nothing
End Sub

Private Sub dtF4RUT_Click()
Dim Aux As Variant
Dim sRuta As String
Dim nValor As Byte
'Dim Carpeta As New cdtCarpeta

With sprRUT
  If .ActiveCol = 5 Then
      .GetText .ActiveCol, .ActiveRow, Aux
      sRuta = Aux
      sRuta = sCambiarSlash(sRuta, 2)
  
      'GsDatoAux = Carpeta.PedirCarpeta(sRuta)
      GsDatoAux = BrowseForFolder(sRuta, Me.hwnd, "&Seleccione una carpeta:")
      
      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

'Set Carpeta = Nothing
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 dtF4InsDep_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 dtF4RUT_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 txtAgrTipoCta_Change()
    MbAgr2_OK = False
End Sub

Private Sub txtAgrTipoId_Change()
    MbAgr1_OK = False
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 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 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 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
    
    If Not MbAgr1_OK Then
        ValidarExistencia Agrupacion1, MbAgr1_OK
        If Not MbAgr1_OK Then Exit Sub
    End If
                    
    If Not MbAgr2_OK Then
        ValidarExistencia Agrupacion2, MbAgr2_OK
        If Not MbAgr2_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 & "'," & _
    "'FEC1030'," & _
    "'TODOS'," & _
    "'" & txtProcGenera & "'," & _
    "'" & txtAgrTipoId & "'," & _
    "'" & txtAgrTipoCta & "'"
        
    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 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 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 RecuperarDatos()
'limpiamos primero los controles
    txtDescripcion = ""
    txtCuenta = ""
    txtOficina = ""
    txtConcepto(0) = ""
    txtConcepto(1) = ""
    txtConcepto(2) = ""
    txtConcepto(3) = ""
    txtConcepto(4) = ""
    txtAgrTipoId = ""
    txtAgrTipoCta = ""
    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)
        txtAgrTipoId = "" & MAdo.GetField(16)
        txtAgrTipoCta = "" & MAdo.GetField(17)
    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 RenuevaDatos()
    If iDeseaGuardar = 2 Then Exit Sub 'Cancelar
    RenuevaDatosBco
    RenuevaDatosRut
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, 3
End Sub

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

    With sprRUT
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprRUT
        .ColWidth(1) = 6
        .ColWidth(2) = 0
        .ColWidth(3) = 12
        .ColWidth(4) = 20
        .ColWidth(5) = 40
        .ColWidth(6) = 20
        
        .SetText 1, 0, "Secuencia"
        .SetText 2, 0, "Tipo Oculto": .Col = 2: .ColHidden = True
        .SetText 3, 0, "Tipo"
        .SetText 4, 0, "Archivo"
        .SetText 5, 0, "Ruta (Lectura/Escritura)"
        .SetText 6, 0, "Tabla/Vista"
                
        .Col = 1: .TypeEditLen = 3
        .Col = 4: .TypeEditLen = 50
        .Col = 5: .TypeEditLen = 500
        .Col = 6: .TypeEditLen = 30
                                
        .ScrollBars = ScrollBarsBoth
        ConfiguraSpreadJCL sprRUT
    End With
    
    MAdo.Sql = "SELECT secuencia, tipo, '' tipo_dato, archivo, ruta, tabla FROM fdt_rutas " & _
               "WHERE operacion = '" & GsOper & "' AND codigo = " & 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 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)))
                        
        Case Agrupacion1
            MAdo.Sql = "SELECT 1 FROM agrupaciones_trab a, rel_agr_companias b" & _
            " WHERE a.agrupacion = b.agrupacion AND b.compania = '" & GsCveCia & "'" & _
            " AND a.agrupacion = '" & txtAgrTipoId & "'"
            
        Case Agrupacion2
            MAdo.Sql = "SELECT 1 FROM agrupaciones_trab a, rel_agr_companias b" & _
            " WHERE a.agrupacion = b.agrupacion AND b.compania = '" & GsCveCia & "'" & _
            " AND a.agrupacion = '" & txtAgrTipoCta & "'"
        
    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)
            Case Agrupacion1: MostrarError "La agrupación específicada para Tipo de Identificación no existe", txtAgrTipoId
            Case Agrupacion2: MostrarError "La agrupación específicada para Tipo de Cuenta no existe", txtAgrTipoCta
        End Select
    End If
    Screen.MousePointer = vbDefault
End Sub


