VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmCabeceraImpresionLista 
   Caption         =   "Relación de Cabecera de Impresión"
   ClientHeight    =   3810
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7905
   Icon            =   "frmCabeceraImpresionLista.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3810
   ScaleWidth      =   7905
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      Caption         =   " Cabecera de Impresión "
      Height          =   3660
      Left            =   45
      TabIndex        =   0
      Top             =   75
      Width           =   7785
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Nuevo"
         Height          =   375
         Index           =   0
         Left            =   345
         TabIndex        =   6
         Top             =   3105
         Width           =   1335
      End
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Editar"
         Height          =   375
         Index           =   1
         Left            =   1680
         TabIndex        =   5
         Top             =   3105
         Width           =   1335
      End
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Borrar"
         Height          =   375
         Index           =   2
         Left            =   3015
         TabIndex        =   4
         Top             =   3105
         Width           =   1335
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "&Salir"
         Height          =   375
         Left            =   6045
         TabIndex        =   3
         Top             =   3105
         Width           =   1335
      End
      Begin VB.CommandButton cmdEditar 
         Caption         =   "&Ver"
         Height          =   375
         Index           =   3
         Left            =   4350
         TabIndex        =   2
         Top             =   3105
         Width           =   1335
      End
      Begin MSComctlLib.ListView lvwCabecera 
         Height          =   2640
         Left            =   150
         TabIndex        =   1
         Top             =   300
         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            =   "Courier New"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   0
      End
   End
End
Attribute VB_Name = "frmCabeceraImpresionLista"
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) = "Linea"
  aColumnTitle(1) = "Descripcion"
  
  aColumnWidth(0) = 0.25
  aColumnWidth(1) = 0.7
  
  aColumnAlign(0) = lvwColumnLeft
  aColumnAlign(1) = lvwColumnLeft
      
  Call oListAdmin.InicializarLista(lvwCabecera, 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
  
  lvwCabecera.ListItems.Clear
  
  sSQL = "SELECT cCabeLinea, sCabeDescripcion " + _
         "FROM Cabecera_Impresion ORDER BY cCabeLinea"
  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, adors) Then GoTo salir
  
  Do While Not adors.EOF
    Set itemX = lvwCabecera.ListItems.Add(, , LeerCampo(adors!cCabeLinea))
    itemX.SubItems(1) = LeerCampo(adors!sCabeDescripcion)
    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 lvwCabecera.ListItems.Count > 0 Then
  
    lvwCabecera.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 lvwCabecera.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)

  'Invoca al formulario Usuario
  
  On Error GoTo LineaError
    
  frmCabeceraImpresion.iEditar = Index
  
  frmCabeceraImpresion.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



