VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{B02F3647-766B-11CE-AF28-C3A2FBE76A13}#2.5#0"; "ss32x25.ocx"
Begin VB.Form FCO1070 
   Caption         =   "Definición de Medios Magnéticos para Bancos"
   ClientHeight    =   4470
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5190
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Medios Bancos Definicion.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   4470
   ScaleWidth      =   5190
   Begin VB.CheckBox chkTodos 
      Caption         =   "Todos"
      Height          =   210
      Left            =   240
      TabIndex        =   1
      Top             =   120
      Width           =   1215
   End
   Begin FPSpread.vaSpread sprDatos 
      Height          =   3120
      Left            =   240
      TabIndex        =   0
      Top             =   450
      Width           =   4695
      _Version        =   131077
      _ExtentX        =   8281
      _ExtentY        =   5503
      _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 Definicion.frx":030A
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   240
      Top             =   3600
      _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 Definicion.frx":0463
   End
End
Attribute VB_Name = "FCO1070"
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 MsSql As String
Private MsSql2 As String
Private MsSqlAux As String
Private MsOrden As String
Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
Private MoBita As New ADAMBitacora.Bitacora

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

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

Private Sub chkTodos_Click()
    If chkTodos.Value = vbUnchecked Then
        MsSqlAux = ""
    Else
        MsSqlAux = MsSql2
    End If
    RenuevaDatos
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF5: RenuevaDatos
        Case vbKeyF6: Altas
        Case vbKeyF11: GuardaCambios
        Case vbKeyF12: abToolbar.Bands(1).TrackPopup -1, -1
    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
    Me.Icon = LoadPicture(sIconoForma)
    
    'Checa nivel de seguridad
    Gven(Val(Me.Tag)).iNivSeguridad = iObtenNivSeguridad(GsOper, GsUid, MiCx)
    If Gven(Val(Me.Tag)).iNivSeguridad = 0 Then
        Screen.MousePointer = vbDefault
        Me.Top = -10000
        GbAError = True
        Exit Sub
    End If
        
    GAdam.ObtieneColores
    Set clsSpread = New NSpread
    AsignaIconos abToolbar, 3, LALTA, LBAJA, LTRABAJA, LRENUEVA, LGUARDA, LSALIDA
    ToolInicioGrupo abToolbar, 3, True, 2, 3, 4
    CreaBitacora
    
    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 = 5310
        MiY = 4980
        Me.Width = MiX
        Me.Height = MiY
    End If
    Caption = GsDsn & " / " & GsAbreviaturaCia & " - Definición Archivos para Bancos"
    
    MsSql = _
    " SELECT 1, a.banco, a.descripcion FROM fdt_bancos a, fdt_bancos_cias b" & _
    " WHERE a.banco = b.banco AND b.compania = '" & GsCveCia & "'"
    MsSql2 = _
    " UNION SELECT 0, banco, descripcion FROM fdt_bancos " & _
    " WHERE banco NOT IN (SELECT banco FROM fdt_bancos_cias WHERE compania = '" & GsCveCia & "')"
    MsOrden = " ORDER BY 2"
    RenuevaDatos
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 FCO1070 = Nothing
    Set clsSpread = Nothing
    Set MoBita = Nothing
    Gtc(MiCx).ihijas = Gtc(MiCx).ihijas - 1
    If GbExterno Then End
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)
    If Col = 1 Then MoBita.mCambia
End Sub

Private Sub sprDatos_DblClick(ByVal Col As Long, ByVal Row As Long)
    If Col = 2 Then TrabajarCon
End Sub

Private Sub Altas()
Dim sCodRep As String
    MoBita.mAgrega
    
    'buscando el maximo codigo de reporte, para orientar al usuario.
    If UCase(Left(GsDsn, 3)) = "ORA" Then
      MAdo.Sql = "SELECT NVL(MAX(banco),0)+1 FROM fdt_bancos"
    Else
      MAdo.Sql = "SELECT ISNULL(MAX(banco),0)+1 FROM fdt_bancos"
    End If
    MAdo.SendSQL
    
    If Not MAdo.EOF Then
       sCodRep = MAdo.GetField(1)
    End If
    
    With sprDatos
        .Row = .ActiveRow
        .Col = 1: .Text = 1
        .Col = 2: .CellType = 3: .Text = sCodRep
        On Error Resume Next
        .SetFocus
        .Col = 2: .Action = 0
    End With
End Sub

Private Sub Bajas()
    If sprDatos.VirtualMaxRows <> 0 Then MoBita.mBorra
End Sub

Private Sub ConfiguraSpread()
    With sprDatos
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprDatos
        .ColWidth(1) = 2
        .ColWidth(2) = 5
        .SetText 1, 0, " "
        .SetText 2, 0, "Código"
        .SetText 3, 0, "Descripción"
        ConfiguraSpreadJCL sprDatos
    End With
End Sub

Private Sub CreaBitacora()
    MoBita.mCreaBitacora sprDatos, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
    MoBita.mTablaSPInfo 0, "sp_fdt_upd_bancos", "'" & GsCveCia & "'", 1, 2, 3, "1"
    MoBita.mTablaSPInfo 1, "sp_fdt_del_bancos", "'" & GsCveCia & "'", 2
    MoBita.mTablaSPInfo 2, "sp_fdt_upd_bancos", "'" & GsCveCia & "'", 1, 2, 3, "2"
    MoBita.mColNoNulls 1
End Sub

Private Sub GuardaCambios()
    Screen.MousePointer = vbHourglass
    If sprDatos.VirtualMaxRows > 0 Then GbRen = MoBita.mActualizaBD
    MoBita.mVaciaBuffer
    Screen.MousePointer = vbDefault
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
              GuardaCambios
              If GbRen = False Then iDeseaGuardar = 2
           Case vbNo
              MoBita.mVaciaBuffer
        End Select
    Else
        iDeseaGuardar = 1
    End If
End Function

Private Sub RenuevaDatos()
    On Error GoTo MostrarError
    If iDeseaGuardar = 2 Then Exit Sub
    Screen.MousePointer = vbHourglass
    ConfiguraSpread
    MAdo.Sql = MsSql & MsSqlAux & MsOrden
    If Not MAdo.SendSQL Then GoTo MostrarError
    clsSpread.LlenaSpread 0, sprDatos, MAdo, MAdo.lhDbc, MAdo.lhstmt
    With sprDatos
        .Col = 1: .Row = -1: .CellType = 10
        .Col = 2: .Row = -1: .TypeEditLen = 3: .Lock = True
        .Col = 3: .Row = -1: .Lock = True
    End With
    GAdam.AjustaSpread sprDatos, 3
MostrarError:
    Screen.MousePointer = vbDefault
    If Err > 0 Then
        clsMsgbox.Mensaje Err.Description, mAceptar, mAdvierte, GsTitMsg
    End If
End Sub

Private Sub TrabajarCon()
    Dim Aux As Variant
    
    If sprDatos.ActiveRow < 0 Then Exit Sub
    sprDatos.GetText 1, sprDatos.ActiveRow, Aux
    If Val(Aux) = 0 Then Exit Sub
    
    Screen.MousePointer = vbHourglass
    sprDatos.GetText 2, sprDatos.ActiveRow, Aux
    GsDatoAux = CStr(Aux)
    sprDatos.GetText 3, sprDatos.ActiveRow, Aux
    
    NuevaVentana 2
    Dim FFCO1070T As New FCO1070T
    FFCO1070T.Caption = GsDsn & " / " & GsAbreviaturaCia & " - Configura " & CStr(Aux)
    FFCO1070T.Show 1
End Sub

