VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmBusquedaArticulos 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Listado de Artículos"
   ClientHeight    =   6825
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8910
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   9.75
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6825
   ScaleWidth      =   8910
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdSalir 
      Cancel          =   -1  'True
      Caption         =   "C&ancelar"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   525
      Left            =   4575
      TabIndex        =   5
      Top             =   6210
      Width           =   1500
   End
   Begin VB.CommandButton cmdSeleccionar 
      Caption         =   "&Seleccionar"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   525
      Left            =   2460
      TabIndex        =   4
      Top             =   6210
      Width           =   1500
   End
   Begin VB.Frame Frame1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   6045
      Left            =   60
      TabIndex        =   0
      Top             =   30
      Width           =   8820
      Begin VB.CommandButton cmdPaginado 
         Caption         =   "<<"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   0
         Left            =   105
         TabIndex        =   11
         Top             =   5550
         Width           =   510
      End
      Begin VB.CommandButton cmdPaginado 
         Caption         =   "<"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   1
         Left            =   675
         TabIndex        =   10
         Top             =   5550
         Width           =   510
      End
      Begin VB.CommandButton cmdPaginado 
         Caption         =   ">"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   2
         Left            =   1965
         TabIndex        =   9
         Top             =   5535
         Width           =   510
      End
      Begin VB.CommandButton cmdPaginado 
         Caption         =   ">>"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   3
         Left            =   2535
         TabIndex        =   8
         Top             =   5535
         Width           =   510
      End
      Begin VB.TextBox txtNroPagina 
         BackColor       =   &H00E0E0E0&
         Height          =   345
         Left            =   1275
         Locked          =   -1  'True
         TabIndex        =   7
         Top             =   5550
         Width           =   600
      End
      Begin VB.CommandButton cmdBuscar 
         Caption         =   "&Buscar"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   405
         Left            =   5160
         TabIndex        =   2
         Top             =   195
         Width           =   1020
      End
      Begin VB.TextBox txtBuscar 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   675
         TabIndex        =   1
         Top             =   240
         Width           =   4410
      End
      Begin MSComctlLib.ListView lvwListado 
         Height          =   4815
         Left            =   60
         TabIndex        =   3
         Top             =   660
         Width           =   8640
         _ExtentX        =   15240
         _ExtentY        =   8493
         View            =   3
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   0   'False
         FullRowSelect   =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   0
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Texto:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   150
         TabIndex        =   6
         Top             =   285
         Width           =   450
      End
   End
End
Attribute VB_Name = "frmBusquedaArticulos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public frmPadre As String
Public pOpcion As String
Dim nOrder As Integer
Dim nAscDesc As Boolean

Dim iNroPagina As Integer
Dim iTotalPagina As Integer
Dim iTotalRegistro As Long

Private iFormaBusquedaProducto As Integer

Public Sub inicio()
  Screen.MousePointer = vbHourglass
  If frmPadre = "frmCajaRegistradoraFull" Then
    If pOpcion = "PagoAdelantado" And (frmCajaRegistradoraFull.iTipoVenta = 6 Or _
       frmCajaRegistradoraFull.iTipoVenta = 7) Then
      cmdSeleccionar.Enabled = False
    End If
  End If
  
  If pOpcion = "Cliente" Then
    If bolExistenProblemasConexionBDCliente = False Then
      ConectarBDCliente
    End If
    'If Not oDBAdmin.EjecutarConsulta(ADOCnn2, sSQL, ADORS) Then error = True
  End If
  
  iNroPagina = 1
  iFormaBusquedaProducto = 0
  ConfiguraColumnas
  
  If pOpcion <> "Cliente" Then
    RecuperaDatos iFormaBusquedaProducto
  End If
  
  VerificaBotonesPaginado
  Screen.MousePointer = vbDefault
End Sub
Private Sub RecuperaDatos(Optional intFormaBusquedaProducto As Integer = 0)
  Dim ADORS As ADODB.Recordset
  Dim ADORS2 As ADODB.Recordset
  Dim sSQL As String
  Dim sSql2 As String
  Dim itm As ListItem
  Dim sCadena As String
  Dim iContRegistro As Integer
  
  Screen.MousePointer = vbHourglass
  
  nOrder = 1
  nAscDesc = False
  
  lvwListado.ListItems.Clear
  iTotalPagina = 0
  
  sCadena = UCase(Trim(txtBuscar.Text))
  
  Select Case pOpcion
  
    Case "Producto"
      Me.Caption = "Listado de Articulos"
      sSQL = " SELECT cProdCode, sProdDesc, sProdDescCrta, nProdPrecUnit, cProdEstd, vDescProv," & _
             " cFlagCanje, nPuntos, cFlagServicio, cCodCatalogo, sDescLinea" & _
             " FROM Producto WHERE cProdEstd = 1 AND nActivo = 1"
      
      If sCadena <> "" Then
        If intFormaBusquedaProducto = 0 Then
          sSQL = sSQL + " AND (sProdDesc like '%" & sCadena & "%'"
          sSQL = sSQL + " OR sProdDescCrta like '%" & sCadena & "%'"
          If IsNumeric(sCadena) Then
            sSQL = sSQL + " OR cCodCatalogo like '%" & sCadena & "%'"
          End If
          sSQL = sSQL + " OR vDescProv like '%" & sCadena & "%')"
        Else
          sSQL = sSQL + " AND (sProdDesc like '" & sCadena & "%'"
          sSQL = sSQL + " OR sProdDescCrta like '" & sCadena & "%'"
          If IsNumeric(sCadena) Then
            sSQL = sSQL + " OR cCodCatalogo like '" & sCadena & "%'"
          End If
          sSQL = sSQL + " OR vDescProv like '" & sCadena & "%')"
        End If
      End If
    
      sSQL = sSQL & " ORDER BY sProdDesc"
    
    Case "Cliente"
             
      'sw To SQL Server era >>> nIdLocal, Date()
      sSQL = " SELECT nTarjNumb, a.cClieCode, sClieApel , sClieName , dNacmDate, c.IdLocal, " & _
             " nPuntCant , nTickCant, dUltTDate" & _
             " FROM Cliente a, Tarjeta c" & _
             " WHERE   (c.cTarjActi=1 and Convert(Char(10), dcadudate,112)>=Convert(Char(10), getdate(),112)) and a.cClieCode = c.cClieCode and a.IdLocal=c.IdLocal "
                          
      If sCadena <> "" Then
        sSQL = sSQL + " AND (sClieApel  LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR nTarjNumb LIKE '%" & sCadena & "%')"
      End If
      Me.Caption = "Listado de Clientes"
      
    Case "PagoAdelantado"
      Me.Caption = "Seleccione Pago Adelantado"
      sSQL = " SELECT b.cOperCode, b.nTarjNumb, C.cClieCode, c.sName, b.nMoneda, b.nMontoDolares," & _
             " b.dOperFech, b.nMontoSoles, b.cOperTipo, b.sGlosa, b.cDocSerie, b.cDocCodigo" & _
             " FROM OperacionParalela b LEFT JOIN" & _
             " (SELECT Cliente.cClieCode, Tarjeta.nTarjNumb, sClieApel + ' ' + sClieName as sName" & _
             " FROM CLIENTE inner join Tarjeta" & _
             " ON Cliente.cClieCode = Tarjeta.cClieCode) c" & _
             " ON b.nTarjNumb = c.nTarjNumb" & _
             " WHERE b.cOperTipo IN (22, 23) and b.cEstado = '1'"
       
      If sCadena <> "" Then
        sSQL = sSQL + " AND (sName LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR c.nTarjNumb LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR ((b.cDocSerie + '-' + cstr(b.cDocCodigo) )LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR cstr(b.cDocCodigo) LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR (b.cDocSerie) LIKE '%" & sCadena & "%')"
        sSQL = sSQL + " OR b.sglosa LIKE '%" & sCadena & "%'"
        If IsNumeric(sCadena) Then
          sSQL = sSQL + " OR b.cOperCode LIKE '%" & sCadena & "%')"
        Else
          sSQL = sSQL + " )"
        End If
      End If
      
    Case "Liquidacion0", "Liquidacion1"
      sSQL = " SELECT b.cOperCode, b.nTarjNumb, C.cClieCode, c.sName, b.nMoneda, b.nMontoDolares," & _
             " b.dOperFech, b.nMontoSoles, b.cOperTipo, b.sGlosa, b.cDocSerie, b.cDocCodigo" & _
             " FROM OperacionParalela b LEFT JOIN" & _
             " (SELECT Cliente.cClieCode, Tarjeta.nTarjNumb, sClieApel + ' ' + sClieName as sName" & _
             " FROM CLIENTE inner join Tarjeta" & _
             " ON Cliente.cClieCode = Tarjeta.cClieCode) c" & _
             " ON b.nTarjNumb = c.nTarjNumb" & _
             " where b.cEstado = '1'"
             
      If pOpcion = "Liquidacion0" Then sSQL = sSQL + " AND b.cOperTipo IN (22, 23)"
      If pOpcion = "Liquidacion1" Then sSQL = sSQL + " AND b.cOperTipo = 21" ' and cOperCodeRela = 0"
      If sCadena <> "" Then
        sSQL = sSQL + " AND (sName LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR c.nTarjNumb LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR ((b.cDocSerie + '-' + cstr(b.cDocCodigo) )LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR cstr(b.cDocCodigo) LIKE '%" & sCadena & "%'"
        sSQL = sSQL + " OR (b.cDocSerie) LIKE '%" & sCadena & "%')"
        sSQL = sSQL + " OR b.sglosa LIKE '%" & sCadena & "%'"
        If IsNumeric(sCadena) Then
          sSQL = sSQL + " OR b.cOperCode LIKE '%" & sCadena & "%')"
        Else
          sSQL = sSQL + " )"
        End If
      End If
      Me.Caption = "Liquidación"
  End Select
  
  Dim error As Boolean
  error = False
  
  If pOpcion = "Cliente" Then
    'ConectarBDCliente
    If bolExisteConexionBDCliente = True Then
      If Not oDBAdmin.EjecutarConsulta(ADOCnn2, sSQL, ADORS) Then error = True
    Else
      error = True
    End If
  End If
  
  'sw ¿FALTA idLocal?
  If pOpcion <> "Cliente" Or error = True Then
    If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo LineaError
  End If
  
  If Not ADORS.EOF Then
  
    ADORS.PageSize = 17
    ADORS.AbsolutePage = iNroPagina
    iTotalPagina = ADORS.PageCount
    iTotalRegistro = ADORS.RecordCount
    iContRegistro = ADORS.PageSize
          
    Do While Not ADORS.EOF And iContRegistro > 0
      Select Case pOpcion
        Case "Producto"
          Set itm = lvwListado.ListItems.Add(, , CStr(LeerCampo(ADORS("cProdCode"))))
          itm.SubItems(1) = LeerCampo(ADORS("cCodCatalogo"))
          itm.SubItems(2) = LeerCampo(ADORS("sProdDesc"))
          itm.SubItems(3) = LeerCampo(ADORS("sProdDescCrta"))
          'itm.SubItems(4) = Format(LeerCampo(adoRS("nProdPrecUnit")), "0.00")
          itm.SubItems(4) = Format(LeerCampo(ADORS("nProdPrecUnit")), "0.00")
          itm.SubItems(5) = LeerCampo(ADORS("sDescLinea"))
          itm.SubItems(6) = IIf(LeerCampo(ADORS("cProdEstd")) = 1, "Activo", "Inactivo")
          itm.SubItems(7) = IIf(LeerCampo(ADORS("cFlagCanje")) = 0, "NO", IIf(LeerCampo(ADORS("cFlagCanje")) = 1, "VNTA", "PTOS"))
          itm.SubItems(8) = LeerCampo(ADORS("nPuntos"))
          itm.SubItems(9) = IIf(LeerCampo(ADORS("cFlagServicio")) = 1, "SI", "NO")
          itm.SubItems(10) = LeerCampo(ADORS("vDescProv"))
        
        Case "Cliente"
          'Set itm = lvwListado.ListItems.Add(, , CStr(LeerCampo(ADORS("nTarjNumb"))))
          'itm.SubItems(1) = LeerCampo(ADORS("sClieApel")) + " " + LeerCampo(ADORS("sClieName"))
          'itm.SubItems(2) = Format(LeerCampo(ADORS("dNacmDate")), "dd/mm/yyyy")
          'itm.SubItems(3) = Format(LeerCampo(ADORS("nPuntCant")), "0.00")
          'itm.SubItems(4) = Format(LeerCampo(ADORS("nTickCant")), "0.00")
          'itm.SubItems(5) = Format(LeerCampo(ADORS("dUltTDate")), "dd/mm/yyyy")
          'itm.SubItems(6) = LeerCampo(ADORS("nIdLocal"))
          
          'sw To SQL Server era >>> nIdLocal
          Set itm = lvwListado.ListItems.Add(, , CStr(LeerCampo(ADORS("nTarjNumb"))))
          itm.SubItems(1) = LeerCampo(ADORS("IdLocal"))
          itm.SubItems(2) = LeerCampo(ADORS("sClieApel")) + " " + LeerCampo(ADORS("sClieName"))
          itm.SubItems(3) = Format(LeerCampo(ADORS("dNacmDate")), "dd/mm/yyyy")
          itm.SubItems(4) = Format(LeerCampo(ADORS("nPuntCant")), "0.00")
          itm.SubItems(5) = Format(LeerCampo(ADORS("nTickCant")), "0.00")
          itm.SubItems(6) = Format(LeerCampo(ADORS("dUltTDate")), "dd/mm/yyyy")
          
        Case "PagoAdelantado"
          Dim mon As Integer
          mon = LeerCampo(ADORS("nMoneda"))
          Set itm = lvwListado.ListItems.Add(, , CStr(LeerCampo(ADORS("cOperCode"))))
          itm.SubItems(1) = IIf(LeerCampo(ADORS("cOperTipo")) = 22, "PADE", "PADV")
          itm.SubItems(2) = LeerCampo(ADORS("nTarjNumb"))
          itm.SubItems(3) = LeerCampo(ADORS("cDocSerie")) + "-" + CStr(val("0" & (ADORS!cDocCodigo)))
          itm.SubItems(4) = LeerCampo(ADORS("sName")) + " " + LeerCampo(ADORS("sGlosa"))
          
          itm.SubItems(6) = Format(LeerCampo(ADORS("dOperFech")), "dd/mm/yyyy")
          
          If mon = 2 Then
            'itm.SubItems(5) = "US$ " + Format(LeerCampo(adoRS("nMontoDolares")), "###,##0.00")
            'itm.SubItems(7) = Format(LeerCampo(adoRS("nMontoDolares")), "###,##0.00")
            itm.SubItems(5) = "US$ " + Format(LeerCampo(ADORS("nMontoDolares")), "0.00")
            itm.SubItems(7) = Format(LeerCampo(ADORS("nMontoDolares")), "0.00")
          Else
            'itm.SubItems(5) = "S/. " + Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
            'itm.SubItems(7) = Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
            itm.SubItems(5) = "S/. " + Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
            itm.SubItems(7) = Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
          End If
          itm.SubItems(8) = mon
          
        Case "Liquidacion0", "Liquidacion1"
          mon = LeerCampo(ADORS("nMoneda"))
          Set itm = lvwListado.ListItems.Add(, , CStr(LeerCampo(ADORS("cOperCode"))))
          itm.SubItems(1) = IIf(LeerCampo(ADORS("cOperTipo")) = 22, "PADE", IIf(LeerCampo(ADORS("cOperTipo")) = 23, "PADV", "N/C"))
          itm.SubItems(2) = LeerCampo(ADORS("nTarjNumb"))
          itm.SubItems(3) = LeerCampo(ADORS("cDocSerie")) + "-" + CStr(val("0" & (ADORS!cDocCodigo)))
          itm.SubItems(4) = LeerCampo(ADORS("sName")) + " " + LeerCampo(ADORS("sGlosa"))
          'itm.SubItems(5) = Format(LeerCampo(ADORS("nMontoSoles")), "###,##0.00")
          itm.SubItems(6) = Format(LeerCampo(ADORS("dOperFech")), "dd/mm/yyyy")
          
          If mon = 2 Then
            itm.SubItems(5) = "US$ " + Format(LeerCampo(ADORS("nMontoDolares")), "0.00")
            itm.SubItems(7) = Format(LeerCampo(ADORS("nMontoDolares")), "0.00")
            'itm.SubItems(5) = "US$ " + Format(LeerCampo(adoRS("nMontoDolares")), "###,##0.00")
            'itm.SubItems(7) = Format(LeerCampo(adoRS("nMontoDolares")), "###,##0.00")
          Else
            itm.SubItems(5) = "S/. " + Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
            itm.SubItems(7) = Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
            'itm.SubItems(5) = "S/. " + Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
            'itm.SubItems(7) = Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
          End If
          itm.SubItems(8) = mon
          
      End Select
      
      iContRegistro = iContRegistro - 1
      ADORS.MoveNext
    Loop
    
  End If
  
  'oDBAdmin.CerrarBD ADOCnn2     'Cerramos conexion
  GoTo Salir
  
LineaError:
  MsgBox ("No se pudo recuperar los datos")

Salir:
  'adors.Close
  Set ADORS = Nothing
  Screen.MousePointer = vbDefault
End Sub

Private Sub ConfiguraColumnas()
  Dim i As Integer
  Dim clmX As ColumnHeader
  Dim aColumnTitle() As String
  Dim aColumnWidth() As Single
  Dim aColumnAlign() As Integer
     
  Select Case pOpcion
  Case "Producto"
    ReDim aColumnTitle(11) As String
    ReDim aColumnWidth(11) As Single
    ReDim aColumnAlign(11) As Integer
    
    aColumnTitle(0) = "Cod."
    aColumnTitle(1) = "Cod. Catálogo"
    aColumnTitle(2) = "Descripción"
    aColumnTitle(3) = "Descripción Corta"
    aColumnTitle(4) = "Precio Unitario"
    aColumnTitle(5) = "Linea"
    aColumnTitle(6) = "Estado"
    aColumnTitle(7) = "Canje"
    aColumnTitle(8) = "Puntos"
    aColumnTitle(9) = "(%)Serv"
    aColumnTitle(10) = "Proveedor"
    
    aColumnWidth(0) = 0.07
    aColumnWidth(1) = 0.14
    aColumnWidth(2) = 0.4
    aColumnWidth(3) = 0.1
    aColumnWidth(4) = 0.1
    aColumnWidth(5) = 0.2
    aColumnWidth(7) = 0.1
    aColumnWidth(8) = 0.1
    aColumnWidth(9) = 0.1
    aColumnWidth(10) = 0.25
    
    aColumnAlign(0) = lvwColumnLeft
    aColumnAlign(1) = lvwColumnLeft
    aColumnAlign(2) = lvwColumnLeft
    aColumnAlign(3) = lvwColumnLeft
    aColumnAlign(4) = lvwColumnRight
    aColumnAlign(5) = lvwColumnLeft
    aColumnAlign(7) = lvwColumnCenter
    aColumnAlign(8) = lvwColumnRight
    aColumnAlign(9) = lvwColumnCenter
    aColumnWidth(10) = lvwColumnLeft
    
 Case "Cliente"
    ReDim aColumnTitle(7) As String
    ReDim aColumnWidth(7) As Single
    ReDim aColumnAlign(7) As Integer
    
    'aColumnTitle(0) = "Tarjeta"
    'aColumnTitle(1) = "Cliente"
    'aColumnTitle(2) = "Fecha Nacimiento"
    'aColumnTitle(3) = "Puntos"
    'aColumnTitle(4) = "Tickets"
    'aColumnTitle(5) = "Ult.Transacción"
    'aColumnTitle(6) = "Id Local"
  
    aColumnTitle(0) = "Tarjeta"
    aColumnTitle(1) = "Id Local"
    aColumnTitle(2) = "Cliente"
    aColumnTitle(3) = "Fecha Nacimiento"
    aColumnTitle(4) = "Puntos"
    aColumnTitle(5) = "Tickets"
    aColumnTitle(6) = "Ult.Transacción"
    
    'aColumnWidth(0) = 0.1
    'aColumnWidth(1) = 0.4
    'aColumnWidth(2) = 0.13
    'aColumnWidth(3) = 0.13
    'aColumnWidth(4) = 0.13
    'aColumnWidth(5) = 0.13
    'aColumnWidth(6) = 0.4
    
    aColumnWidth(0) = 0.13
    aColumnWidth(1) = 0.13
    aColumnWidth(2) = 0.4
    aColumnWidth(3) = 0.13
    aColumnWidth(4) = 0.13
    aColumnWidth(5) = 0.13
    aColumnWidth(6) = 0.13
    
    'aColumnAlign(0) = lvwColumnLeft
    'aColumnAlign(1) = lvwColumnLeft
    'aColumnAlign(2) = lvwColumnCenter
    'aColumnAlign(3) = lvwColumnRight
    'aColumnAlign(4) = lvwColumnRight
    'aColumnAlign(5) = lvwColumnCenter
    'aColumnAlign(6) = lvwColumnLeft
    
    aColumnAlign(0) = lvwColumnLeft
    aColumnAlign(1) = lvwColumnLeft
    aColumnAlign(2) = lvwColumnCenter
    aColumnAlign(3) = lvwColumnRight
    aColumnAlign(4) = lvwColumnRight
    aColumnAlign(5) = lvwColumnCenter
    aColumnAlign(6) = lvwColumnLeft
    
  Case "PagoAdelantado", "Liquidacion0", "Liquidacion1"
    ReDim aColumnTitle(9) As String
    ReDim aColumnWidth(9) As Single
    ReDim aColumnAlign(9) As Integer
    
    aColumnTitle(0) = "Operacion"
    aColumnTitle(1) = "Tipo Venta"
    aColumnTitle(2) = "Nº Tarjeta"
    aColumnTitle(3) = "Documento"
    aColumnTitle(4) = "Cliente - Glosa"
    aColumnTitle(5) = "Monto"
    aColumnTitle(6) = "Fecha"
    aColumnTitle(7) = "MontoVal"
    aColumnTitle(8) = "Moneda"
  
    aColumnWidth(0) = 0.1
    aColumnWidth(1) = 0.1
    aColumnWidth(2) = 0.1
    aColumnWidth(3) = 0.13
    aColumnWidth(4) = 0.28
    aColumnWidth(5) = 0.15
    aColumnWidth(6) = 0.15
    aColumnWidth(7) = 0
    aColumnWidth(8) = 0
        
    aColumnAlign(0) = lvwColumnLeft
    aColumnAlign(1) = lvwColumnLeft
    aColumnAlign(2) = lvwColumnCenter
    aColumnAlign(3) = lvwColumnLeft
    aColumnAlign(4) = lvwColumnLeft
    aColumnAlign(5) = lvwColumnRight
    aColumnAlign(6) = lvwColumnCenter
    aColumnAlign(7) = lvwColumnCenter
    aColumnAlign(8) = lvwColumnCenter
 End Select
 
 For i = 0 To (UBound(aColumnTitle) - 1)
    Set clmX = lvwListado.ColumnHeaders.Add(, , aColumnTitle(i), _
                                          lvwListado.Width * aColumnWidth(i), _
                                          aColumnAlign(i))
 Next
 
End Sub

Public Sub cmdBuscar_Click()
  iNroPagina = 1
  iFormaBusquedaProducto = 0
  RecuperaDatos iFormaBusquedaProducto
  VerificaBotonesPaginado
End Sub

Private Sub cmdPaginado_Click(Index As Integer)
    Select Case Index
        Case 0
            iNroPagina = 1
            RecuperaDatos iFormaBusquedaProducto
            VerificaBotonesPaginado
        Case 1
            iNroPagina = iNroPagina - 1
            RecuperaDatos iFormaBusquedaProducto
            VerificaBotonesPaginado
        Case 2
            iNroPagina = iNroPagina + 1
            RecuperaDatos iFormaBusquedaProducto
            VerificaBotonesPaginado
        Case 3
            iNroPagina = iTotalPagina
            RecuperaDatos iFormaBusquedaProducto
            VerificaBotonesPaginado
    End Select
End Sub

Private Sub VerificaBotonesPaginado()
    If iTotalPagina <= 0 Then
        cmdPaginado(0).Enabled = False
        cmdPaginado(1).Enabled = False
        cmdPaginado(2).Enabled = False
        cmdPaginado(3).Enabled = False
        Me.txtNroPagina = 0
    Else
        If iNroPagina > 1 Then
          cmdPaginado(0).Enabled = True
          cmdPaginado(1).Enabled = True
        Else
          cmdPaginado(0).Enabled = False
          cmdPaginado(1).Enabled = False
        End If
        
        If iNroPagina < iTotalPagina Then
          cmdPaginado(2).Enabled = True
          cmdPaginado(3).Enabled = True
        Else
          cmdPaginado(2).Enabled = False
          cmdPaginado(3).Enabled = False
        End If
        Me.txtNroPagina = iNroPagina
    End If
End Sub

Private Sub cmdsalir_Click()
  Unload Me
End Sub

Private Sub cmdSeleccionar_Click()
  If lvwListado.ListItems.Count < 1 Then Exit Sub

  If frmPadre = "frmCajaRegistradoraFull" Then
        If pOpcion = "Producto" Then
          frmCajaRegistradoraFull.lcProdCode = Right("000000" + lvwListado.SelectedItem.Text, 6)
          frmCajaRegistradoraFull.lsCodCatalogo = lvwListado.SelectedItem.SubItems(1)
          frmCajaRegistradoraFull.lsProdDescCrta = lvwListado.SelectedItem.SubItems(3)
          frmCajaRegistradoraFull.lnProdPrecUnit = lvwListado.SelectedItem.SubItems(4)
          frmCajaRegistradoraFull.lsCanje = lvwListado.SelectedItem.SubItems(6)
          frmCajaRegistradoraFull.lsPtos = lvwListado.SelectedItem.SubItems(8)
          frmCajaRegistradoraFull.lsServ = lvwListado.SelectedItem.SubItems(9)
    
        ElseIf pOpcion = "Cliente" Then
          frmCajaRegistradoraFull.txtTarjeta = lvwListado.SelectedItem.Text
          frmCajaRegistradoraFull.txtNombres = lvwListado.SelectedItem.SubItems(2)
          frmCajaRegistradoraFull.txtLocal = lvwListado.SelectedItem.SubItems(1)
          frmCajaRegistradoraFull.dcbLocal.BoundText = lvwListado.SelectedItem.SubItems(1)
    
        ElseIf pOpcion = "PagoAdelantado" Then
          frmCajaRegistradoraFull.txtTX = lvwListado.SelectedItem.Text
          frmCajaRegistradoraFull.txtPADE = lvwListado.SelectedItem.Text
          frmCajaRegistradoraFull.txtGlosa1 = lvwListado.SelectedItem.SubItems(4)
          frmCajaRegistradoraFull.txtimportepago = lvwListado.SelectedItem.SubItems(7)
          If lvwListado.SelectedItem.SubItems(8) = 1 Then
            frmCajaRegistradoraFull.Label26.Caption = "S/."
          Else
            frmCajaRegistradoraFull.Label26.Caption = "US$"
          End If
        ElseIf pOpcion = "Liquidacion0" Then
          frmCajaRegistradoraFull.txtTXL(0) = Right("000000" + lvwListado.SelectedItem.Text, 6)
          frmCajaRegistradoraFull.CmdAdd_Click (0)
        ElseIf pOpcion = "Liquidacion1" Then
          frmCajaRegistradoraFull.txtTXL(1) = Right("000000" + lvwListado.SelectedItem.Text, 6)
          frmCajaRegistradoraFull.CmdAdd_Click (1)
        End If
  
  ElseIf frmPadre = "frmCajaFacturacionPagos" Then
        If pOpcion = "Cliente" Then
          frmCajaFacturacionPagos.txtTarjeta = lvwListado.SelectedItem.Text
          frmCajaFacturacionPagos.txtNombres = lvwListado.SelectedItem.SubItems(2)
          frmCajaFacturacionPagos.txtLocal = lvwListado.SelectedItem.SubItems(1)
          frmCajaFacturacionPagos.dcbLocal.BoundText = lvwListado.SelectedItem.SubItems(1)
        ElseIf pOpcion = "Producto" Then
          frmCajaFacturacionPagos.lcProdCode = Right("000000" + lvwListado.SelectedItem.Text, 6)
          frmCajaFacturacionPagos.lsCodCatalogo = lvwListado.SelectedItem.SubItems(1)
          frmCajaFacturacionPagos.lsProdDescCrta = lvwListado.SelectedItem.SubItems(3)
          frmCajaFacturacionPagos.lnProdPrecUnit = lvwListado.SelectedItem.SubItems(4)
          frmCajaFacturacionPagos.lsCanje = lvwListado.SelectedItem.SubItems(6)
          frmCajaFacturacionPagos.lsPtos = lvwListado.SelectedItem.SubItems(8)
          frmCajaFacturacionPagos.lsServ = lvwListado.SelectedItem.SubItems(9)
        
        End If
  ElseIf frmPadre = "frmConsultaCtaCteCliente" Then
        If pOpcion = "Cliente" Then
          frmConsultaCtaCteCliente.txtTarjeta = lvwListado.SelectedItem.Text
          frmConsultaCtaCteCliente.txtNombres = lvwListado.SelectedItem.SubItems(2)
          frmConsultaCtaCteCliente.txtLocal = lvwListado.SelectedItem.SubItems(1)
          frmConsultaCtaCteCliente.dcbLocal.BoundText = lvwListado.SelectedItem.SubItems(1)
        End If
  
  ElseIf frmPadre = "frmCajaRegistradora" Then
        If pOpcion = "Cliente" Then
          frmCajaRegistradora.txtTarjeta = lvwListado.SelectedItem.Text
          frmCajaRegistradora.txtCliente = lvwListado.SelectedItem.SubItems(2)
          frmCajaRegistradora.txtLocal = lvwListado.SelectedItem.SubItems(1)
          frmCajaRegistradora.dcbLocal.BoundText = lvwListado.SelectedItem.SubItems(1)
        End If
    
  ElseIf frmPadre = "frmConfiguraBotonProducto" Then
        frmConfiguraBotonProducto.txtCodigoProducto = lvwListado.SelectedItem.Text
        frmConfiguraBotonProducto.txtNombreProducto = lvwListado.SelectedItem.SubItems(2)
  End If
  
  cmdsalir_Click
End Sub

Private Sub Form_Unload(Cancel As Integer)
    'sw Se comento el 19/06/2009, pues pone a la ADOCnn2 en Nothing y en pruebas
    'sw causo poblemas
    'sw oDBAdmin.CerrarBD ADOCnn2     'Cerramos conexion
End Sub

Private Sub lvwListado_DblClick()
  If frmPadre = "frmCajaRegistradoraFull" Then
    If pOpcion = "PagoAdelantado" And (frmCajaRegistradoraFull.iTipoVenta = 6 Or _
       frmCajaRegistradoraFull.iTipoVenta = 7) Then
      Exit Sub
    End If
  End If
  cmdSeleccionar_Click
End Sub

Private Sub lvwListado_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
  'Ordena los registos según la columna seleccionada
  On Error GoTo LineaError
  Call APISort(lvwListado, ColumnHeader.Index, gbytLVW_SORT_DEFAULT)
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
End Sub

Private Sub lvwListado_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyReturn Then
    cmdSeleccionar_Click
  End If
End Sub

'Private Sub Timer1_Timer()
'    If pgb1.Value = pgb1.Max Then
'        pgb1.Value = pgb1.Min
'    End If
'    pgb1.Value = pgb1.Value + 1
'End Sub
'
'Private Sub ActivaBarra()
'    pgb1.Min = 0
'    pgb1.Max = 100
'    pgb1.Value = 0
'    pgb1.Visible = True
'    Timer1.Enabled = True
'
'End Sub
'
'Private Sub DesactivaBarra()
'    Timer1.Enabled = False
'    pgb1.Visible = False
'End Sub

Private Sub txtBuscar_Change()
'    If pOpcion = "Cliente" Then
'        If Len(Trim(Me.txtBuscar.Text)) < 2 Then Exit Sub
'    End If
'
    iNroPagina = 1
    If pOpcion = "Producto" Then
        iFormaBusquedaProducto = 1
        RecuperaDatos iFormaBusquedaProducto
    End If
    
    VerificaBotonesPaginado
End Sub

Private Sub txtBuscar_KeyDown(KeyCode As Integer, Shift As Integer)
      
    If KeyCode = vbKeyReturn Then
        cmdBuscar_Click
       ' cmdBuscar.SetFocus
    End If
End Sub


