VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmTipoCambioLista 
   Caption         =   "Relación de Tipo de Cambio"
   ClientHeight    =   3690
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7905
   Icon            =   "frmTipoCambioLista.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3690
   ScaleWidth      =   7905
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      Height          =   3525
      Left            =   90
      TabIndex        =   0
      Top             =   30
      Width           =   7695
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Ver"
         Height          =   375
         Index           =   3
         Left            =   4290
         TabIndex        =   5
         Top             =   2985
         Width           =   1335
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "&Salir"
         Height          =   375
         Left            =   5985
         TabIndex        =   6
         Top             =   2985
         Width           =   1335
      End
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Borrar"
         Height          =   375
         Index           =   2
         Left            =   2955
         TabIndex        =   4
         Top             =   2985
         Width           =   1335
      End
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Editar"
         Height          =   375
         Index           =   1
         Left            =   1620
         TabIndex        =   3
         Top             =   2985
         Width           =   1335
      End
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Nuevo"
         Height          =   375
         Index           =   0
         Left            =   285
         TabIndex        =   2
         Top             =   2985
         Width           =   1335
      End
      Begin MSComctlLib.ListView lvwTipoCambio 
         Height          =   2640
         Left            =   90
         TabIndex        =   1
         Top             =   180
         Width           =   7485
         _ExtentX        =   13203
         _ExtentY        =   4657
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         BeginProperty Font {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
         NumItems        =   0
      End
   End
End
Attribute VB_Name = "frmTipoCambioLista"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
  
Private Sub Form_Load()
  
  On Error GoTo LineaError

  Screen.MousePointer = vbHourglass
  
  Call ConfigurarColumnas
  Call LlenarLista
  Call ManejarControles
  
  Screen.MousePointer = vbDefault
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  Screen.MousePointer = vbDefault
End Sub

Private Sub ConfigurarColumnas()

  'Configura las columnas de la lista lvwUsuario
  
  On Error GoTo LineaError

  Dim aColumnTitle() As String
  Dim aColumnWidth() As Single
  Dim aColumnAlign() As Integer
  
  ReDim aColumnTitle(3) As String
  ReDim aColumnWidth(3) As Single
  ReDim aColumnAlign(2) As Integer

  aColumnTitle(0) = "Fecha"
  aColumnTitle(1) = "Tipo Cambio"
  
  aColumnWidth(0) = 0.35
  aColumnWidth(1) = 0.6
  
  aColumnAlign(0) = lvwColumnLeft
  aColumnAlign(1) = lvwColumnLeft
      
  Call oListAdmin.InicializarLista(lvwTipoCambio, aColumnTitle, _
                                   aColumnWidth, aColumnAlign, lvwReport)
                                   
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

End Sub

Public Sub LlenarLista()
  'Llena la lista
  On Error GoTo LineaError

  Dim sSQL As String
  Dim adors As ADODB.Recordset
  Dim itemX As ListItem
  
  lvwTipoCambio.ListItems.Clear
  
  sSQL = "SELECT dTipoCambFech, nTipoCambMont " + _
         "FROM Tipo_Cambio ORDER BY dTipoCambFech"
  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, adors) Then GoTo salir
  
  Do While Not adors.EOF
    Set itemX = lvwTipoCambio.ListItems.Add(, , Format(CStr(LeerCampo(adors!dTipoCambFech)), "DD/MM/YYYY"))
    itemX.SubItems(1) = Format(CStr(LeerCampo(adors!nTipoCambMont)), "###,###,##0.00")
    adors.MoveNext
  Loop
   
  GoTo salir
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  
salir:
  Set adors = Nothing
         
End Sub

Public Sub ManejarControles()

  'Maneja el uso de los controles
  
  On Error GoTo LineaError

  Call DeshabilitarControl(cmdEditar(kCMD_EDITAR), False)
  Call DeshabilitarControl(cmdEditar(kCMD_BORRAR), False)
  Call DeshabilitarControl(cmdEditar(kCMD_VER), False)
  If lvwTipoCambio.ListItems.Count > 0 Then
  
    lvwTipoCambio.SelectedItem.EnsureVisible
    Call HabilitarControl(cmdEditar(kCMD_EDITAR), False)
    Call HabilitarControl(cmdEditar(kCMD_BORRAR), False)
    Call HabilitarControl(cmdEditar(kCMD_VER), False)
  End If
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  
End Sub

Private Sub lvwCabecera_DblClick()

  'Invoca al evento Click de cmdEditar
  
  On Error GoTo LineaError
  
  If lvwTipoCambio.ListItems.Count > 0 Then
  
    If cmdEditar(kCMD_EDITAR).Enabled Then
      Call cmdEditar_Click(kCMD_EDITAR)
    Else
      Call cmdEditar_Click(kCMD_VER)
    End If
    
  End If

  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  
End Sub

Private Sub cmdEditar_Click(Index As Integer)

  On Error GoTo LineaError
    
  frmTipoCambio.iEditar = Index
  
  frmTipoCambio.Show vbModal
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  
End Sub

Private Sub cmdSalir_Click()

  On Error GoTo LineaError

  Unload Me
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

End Sub
