VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{0D6234D1-DBA2-11D1-B5DF-0060976089D0}#6.0#0"; "todg6.ocx"
Begin VB.Form frmCajaRegistradoraFull 
   BorderStyle     =   1  'Fixed Single
   Caption         =   " Caja Registradora - Versión FULL "
   ClientHeight    =   8595
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   11850
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmCajaRegistradoraFull.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   8595
   ScaleWidth      =   11850
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame2 
      Caption         =   " Datos de la Caja "
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1650
      Left            =   5400
      TabIndex        =   89
      Top             =   0
      Width           =   3000
      Begin VB.TextBox txtCajero 
         Alignment       =   2  'Center
         BackColor       =   &H80000018&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   315
         Left            =   900
         Locked          =   -1  'True
         MaxLength       =   8
         TabIndex        =   92
         TabStop         =   0   'False
         Top             =   285
         Width           =   1830
      End
      Begin VB.TextBox txtCaja 
         Alignment       =   2  'Center
         BackColor       =   &H80000018&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   315
         Left            =   900
         Locked          =   -1  'True
         MaxLength       =   8
         TabIndex        =   91
         TabStop         =   0   'False
         Top             =   660
         Width           =   1830
      End
      Begin VB.TextBox txtTurno 
         Alignment       =   2  'Center
         BackColor       =   &H80000018&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   315
         Left            =   900
         Locked          =   -1  'True
         MaxLength       =   8
         TabIndex        =   90
         TabStop         =   0   'False
         Top             =   1065
         Width           =   1830
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "Cajero:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   180
         TabIndex        =   95
         Top             =   330
         Width           =   705
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "Caja:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   180
         TabIndex        =   94
         Top             =   720
         Width           =   510
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "Turno:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   180
         TabIndex        =   93
         Top             =   1125
         Width           =   660
      End
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "&Imprimir Tickets"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   675
      Index           =   4
      Left            =   6480
      Picture         =   "frmCajaRegistradoraFull.frx":08CA
      TabIndex        =   88
      Top             =   7380
      Visible         =   0   'False
      Width           =   1680
   End
   Begin VB.TextBox txtLiq 
      Height          =   315
      Left            =   4470
      TabIndex        =   84
      Top             =   8595
      Visible         =   0   'False
      Width           =   720
   End
   Begin VB.TextBox txtliqpade 
      Height          =   465
      Left            =   3615
      TabIndex        =   83
      Top             =   8445
      Visible         =   0   'False
      Width           =   2100
   End
   Begin VB.TextBox ttxliqvueltodolares 
      Height          =   315
      Left            =   2760
      TabIndex        =   82
      Top             =   8595
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.TextBox txtliqvueltosoles 
      Height          =   315
      Left            =   1860
      TabIndex        =   81
      Top             =   8595
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.TextBox Txtliqefectivodolares 
      Height          =   315
      Left            =   960
      TabIndex        =   80
      Top             =   8595
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.TextBox txtliqefectivosoles 
      Height          =   315
      Left            =   105
      TabIndex        =   79
      Top             =   8595
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.TextBox txtsupervisor 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   360
      Left            =   6255
      MaxLength       =   6
      TabIndex        =   78
      Top             =   7515
      Visible         =   0   'False
      Width           =   1230
   End
   Begin VB.CommandButton cmdTecla 
      Caption         =   "&AC/TC"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   15.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   690
      Index           =   2
      Left            =   4320
      TabIndex        =   73
      Top             =   7380
      Width           =   1800
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   3840
      Left            =   120
      TabIndex        =   12
      Top             =   1800
      Width           =   11760
      _ExtentX        =   20743
      _ExtentY        =   6773
      _Version        =   393216
      TabHeight       =   529
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      TabCaption(0)   =   " Artículos "
      TabPicture(0)   =   "frmCajaRegistradoraFull.frx":0C54
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "TDBGrid1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "CmdAddArt(2)"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "CmdDelArt(2)"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).ControlCount=   3
      TabCaption(1)   =   "Pago Adelantado"
      TabPicture(1)   =   "frmCajaRegistradoraFull.frx":0C70
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "cmdPagoAdelantado"
      Tab(1).Control(1)=   "txtTX"
      Tab(1).Control(2)=   "Text2"
      Tab(1).Control(2).Enabled=   0   'False
      Tab(1).Control(3)=   "txtGlosa"
      Tab(1).Control(4)=   "Label16"
      Tab(1).Control(5)=   "Label15"
      Tab(1).Control(6)=   "Label14"
      Tab(1).ControlCount=   7
      TabCaption(2)   =   " Liquidación de Pago - N/C"
      TabPicture(2)   =   "frmCajaRegistradoraFull.frx":0C8C
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "Frame6"
      Tab(2).Control(1)=   "Frame4"
      Tab(2).ControlCount=   2
      Begin VB.CommandButton CmdDelArt 
         Caption         =   "E&liminar"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   2
         Left            =   1800
         TabIndex        =   22
         Top             =   3480
         Width           =   1455
      End
      Begin VB.CommandButton CmdAddArt 
         Caption         =   "A&dicionar"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   2
         Left            =   240
         TabIndex        =   21
         Top             =   3480
         Width           =   1455
      End
      Begin VB.Frame Frame6 
         Height          =   3510
         Left            =   -69200
         TabIndex        =   39
         Top             =   375
         Width           =   5850
         Begin VB.TextBox txtTotalNC 
            Alignment       =   1  'Right Justify
            BackColor       =   &H80000018&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   11.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   360
            Left            =   3720
            Locked          =   -1  'True
            TabIndex        =   47
            TabStop         =   0   'False
            Text            =   "0.00"
            Top             =   3090
            Width           =   1980
         End
         Begin VB.CommandButton CmdDel 
            Caption         =   "-"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Index           =   1
            Left            =   5400
            TabIndex        =   44
            Top             =   200
            Width           =   330
         End
         Begin VB.CommandButton CmdAdd 
            Caption         =   "+"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Index           =   1
            Left            =   4920
            TabIndex        =   43
            Top             =   200
            Visible         =   0   'False
            Width           =   330
         End
         Begin VB.CommandButton cmdTXL 
            Caption         =   "..."
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Index           =   1
            Left            =   1965
            TabIndex        =   42
            Top             =   200
            Width           =   330
         End
         Begin VB.TextBox txtTXL 
            Alignment       =   2  'Center
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   1
            Left            =   705
            TabIndex        =   41
            Top             =   200
            Width           =   1215
         End
         Begin MSComctlLib.ListView lvwTX 
            Height          =   2445
            Index           =   1
            Left            =   105
            TabIndex        =   45
            Top             =   600
            Width           =   5625
            _ExtentX        =   9922
            _ExtentY        =   4313
            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            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            NumItems        =   0
         End
         Begin VB.Label Label22 
            AutoSize        =   -1  'True
            Caption         =   "Total N/C (S/.):"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   11.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   270
            Left            =   1200
            TabIndex        =   46
            Top             =   3135
            Width           =   1800
         End
         Begin VB.Label Label20 
            AutoSize        =   -1  'True
            Caption         =   "N/C:"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   240
            Left            =   255
            TabIndex        =   40
            Top             =   240
            Width           =   390
         End
      End
      Begin VB.Frame Frame4 
         Height          =   3510
         Left            =   -74880
         TabIndex        =   30
         Top             =   375
         Width           =   5610
         Begin VB.TextBox txtTotalPA 
            Alignment       =   1  'Right Justify
            BackColor       =   &H80000018&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   11.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   360
            Left            =   3480
            Locked          =   -1  'True
            TabIndex        =   38
            TabStop         =   0   'False
            Text            =   "0.00"
            Top             =   3120
            Width           =   1980
         End
         Begin VB.CommandButton CmdDel 
            Caption         =   "-"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Index           =   0
            Left            =   5160
            TabIndex        =   35
            Top             =   200
            Width           =   330
         End
         Begin VB.CommandButton CmdAdd 
            Caption         =   "+"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Index           =   0
            Left            =   4680
            TabIndex        =   34
            Top             =   200
            Visible         =   0   'False
            Width           =   330
         End
         Begin MSComctlLib.ListView lvwTX 
            Height          =   2445
            Index           =   0
            Left            =   90
            TabIndex        =   36
            Top             =   600
            Width           =   5385
            _ExtentX        =   9499
            _ExtentY        =   4313
            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            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            NumItems        =   0
         End
         Begin VB.CommandButton cmdTXL 
            Caption         =   "..."
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Index           =   0
            Left            =   2565
            TabIndex        =   33
            Top             =   200
            Width           =   330
         End
         Begin VB.TextBox txtTXL 
            Alignment       =   2  'Center
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   0
            Left            =   1320
            TabIndex        =   32
            Top             =   200
            Width           =   1215
         End
         Begin VB.Label Label21 
            AutoSize        =   -1  'True
            Caption         =   "Total PADE/PADV (S/.):"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   11.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   270
            Left            =   240
            TabIndex        =   37
            Top             =   3135
            Width           =   2685
         End
         Begin VB.Label Label19 
            AutoSize        =   -1  'True
            Caption         =   "PADE/PADV:"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   240
            Left            =   165
            TabIndex        =   31
            Top             =   240
            Width           =   1065
         End
      End
      Begin VB.CommandButton cmdPagoAdelantado 
         Caption         =   "..."
         Height          =   315
         Left            =   -72000
         TabIndex        =   25
         Top             =   600
         Width           =   330
      End
      Begin VB.TextBox txtTX 
         Alignment       =   2  'Center
         BackColor       =   &H80000018&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         Left            =   -73650
         Locked          =   -1  'True
         TabIndex        =   24
         Top             =   600
         Width           =   1545
      End
      Begin VB.TextBox Text2 
         Alignment       =   2  'Center
         BackColor       =   &H00000000&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   330
         Left            =   -73650
         Locked          =   -1  'True
         TabIndex        =   27
         TabStop         =   0   'False
         Text            =   "INGRESADO"
         Top             =   1095
         Width           =   2940
      End
      Begin VB.TextBox txtGlosa 
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   2175
         Left            =   -73650
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   29
         Top             =   1605
         Width           =   9015
      End
      Begin TrueOleDBGrid60.TDBGrid TDBGrid1 
         Height          =   3000
         Left            =   120
         OleObjectBlob   =   "frmCajaRegistradoraFull.frx":0CA8
         TabIndex        =   86
         Top             =   480
         Width           =   11535
      End
      Begin VB.Label Label16 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Ver Pago Adelantado:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   480
         Left            =   -74775
         TabIndex        =   23
         Top             =   525
         Width           =   1065
         WordWrap        =   -1  'True
      End
      Begin VB.Label Label15 
         AutoSize        =   -1  'True
         Caption         =   "Estado:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   -74325
         TabIndex        =   26
         Top             =   1155
         Width           =   645
      End
      Begin VB.Label Label14 
         AutoSize        =   -1  'True
         Caption         =   "Glosa:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   -74190
         TabIndex        =   28
         Top             =   1665
         Width           =   540
      End
   End
   Begin VB.Frame Frame5 
      Caption         =   " Datos de la Venta "
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1650
      Left            =   8460
      TabIndex        =   7
      Top             =   30
      Width           =   3360
      Begin VB.TextBox txtRuc 
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   705
         MaxLength       =   11
         TabIndex        =   77
         Top             =   1050
         Width           =   1680
      End
      Begin VB.ComboBox cboTipoVenta 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   360
         ItemData        =   "frmCajaRegistradoraFull.frx":8F89
         Left            =   705
         List            =   "frmCajaRegistradoraFull.frx":8F8B
         Style           =   2  'Dropdown List
         TabIndex        =   9
         Top             =   270
         Width           =   2595
      End
      Begin VB.TextBox txtTC 
         Alignment       =   2  'Center
         BackColor       =   &H80000018&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   315
         Left            =   690
         Locked          =   -1  'True
         MaxLength       =   8
         TabIndex        =   11
         TabStop         =   0   'False
         Top             =   660
         Width           =   735
      End
      Begin VB.Label Label23 
         Caption         =   "&RUC:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   195
         TabIndex        =   76
         Top             =   1080
         Width           =   480
      End
      Begin VB.Label lblFecha 
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   120
         TabIndex        =   62
         Top             =   1125
         Width           =   3075
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "Tip&o:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   180
         TabIndex        =   8
         Top             =   330
         Width           =   465
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "T.C.:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   195
         TabIndex        =   10
         Top             =   720
         Width           =   435
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   " Datos del Cliente "
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1650
      Left            =   120
      TabIndex        =   0
      Top             =   30
      Width           =   5205
      Begin VB.TextBox txtLocal 
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   405
         Left            =   3360
         MaxLength       =   1
         TabIndex        =   3
         Top             =   225
         Width           =   375
      End
      Begin MSDataListLib.DataCombo dcbLocal 
         Height          =   315
         Left            =   1440
         TabIndex        =   97
         Top             =   1200
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   556
         _Version        =   393216
         Enabled         =   0   'False
         Style           =   2
         Text            =   "DataCombo1"
      End
      Begin VB.CommandButton txtBuscaCliente 
         Caption         =   ".F2."
         Height          =   315
         Left            =   3840
         TabIndex        =   4
         Top             =   240
         Width           =   690
      End
      Begin VB.TextBox txtNombres 
         BackColor       =   &H80000009&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   420
         Left            =   1440
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   6
         Top             =   720
         Width           =   3615
      End
      Begin VB.TextBox txtTarjeta 
         Alignment       =   2  'Center
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   405
         Left            =   1440
         MaxLength       =   8
         TabIndex        =   2
         Top             =   225
         Width           =   1710
      End
      Begin VB.Label Label28 
         Alignment       =   2  'Center
         Caption         =   "_"
         Height          =   375
         Left            =   3120
         TabIndex        =   98
         Top             =   240
         Width           =   255
      End
      Begin VB.Label lblLocal 
         AutoSize        =   -1  'True
         Caption         =   "&Local:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   240
         TabIndex        =   96
         Top             =   1260
         Width           =   555
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "&Nombres:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   11.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   180
         TabIndex        =   5
         Top             =   780
         Width           =   960
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Nro. &Tarjeta:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   120
         TabIndex        =   1
         Top             =   285
         Width           =   1230
      End
   End
   Begin VB.Frame Frame3 
      BorderStyle     =   0  'None
      Height          =   1305
      Left            =   240
      TabIndex        =   65
      Top             =   7080
      Width           =   11685
      Begin VB.CommandButton cmdVoucher 
         Caption         =   "&VOUCHER"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   690
         Left            =   2160
         TabIndex        =   85
         ToolTipText     =   "Emitir voucher al liquidar"
         Top             =   255
         Visible         =   0   'False
         Width           =   1680
      End
      Begin VB.CommandButton cmdCambio 
         BackColor       =   &H00E0E0E0&
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   8520
         Picture         =   "frmCajaRegistradoraFull.frx":8F8D
         Style           =   1  'Graphical
         TabIndex        =   71
         ToolTipText     =   "Ir a Caja Registradora"
         Top             =   240
         Width           =   1035
      End
      Begin VB.CommandButton cmdTecla 
         Caption         =   "&Cancelar "
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   690
         Index           =   0
         Left            =   45
         TabIndex        =   75
         Top             =   240
         Width           =   1680
      End
      Begin VB.CommandButton cmdTecla 
         Caption         =   "Caja &Registradora"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   690
         Index           =   1
         Left            =   2670
         TabIndex        =   54
         Top             =   255
         Visible         =   0   'False
         Width           =   2385
      End
      Begin VB.CommandButton cmdTecla 
         Caption         =   "&Salir"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   690
         Index           =   3
         Left            =   9840
         TabIndex        =   56
         Top             =   240
         Width           =   1680
      End
      Begin VB.Label lblTecla 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "SPACE"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   240
         Index           =   49
         Left            =   9000
         TabIndex        =   74
         Top             =   1080
         Width           =   525
      End
      Begin VB.Label lblTecla 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "CTRL+ENTER"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   240
         Index           =   43
         Left            =   4680
         TabIndex        =   72
         Top             =   960
         Width           =   1050
      End
   End
   Begin VB.Frame frapade 
      Caption         =   "Datos de Pago Adelantado"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   1545
      Left            =   120
      TabIndex        =   13
      Top             =   5640
      Width           =   6930
      Begin VB.TextBox txtimportepago 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   14.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   4560
         Locked          =   -1  'True
         TabIndex        =   18
         Text            =   "0.00"
         Top             =   345
         Width           =   2070
      End
      Begin VB.TextBox txtGlosa1 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   570
         Left            =   990
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   20
         Top             =   885
         Width           =   5670
      End
      Begin VB.TextBox txtPADE 
         Alignment       =   2  'Center
         BackColor       =   &H80000018&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   975
         Locked          =   -1  'True
         TabIndex        =   15
         Top             =   390
         Width           =   1365
      End
      Begin VB.CommandButton cmdBuscaPago 
         Caption         =   "ALT+&P"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   405
         Left            =   2355
         MaskColor       =   &H00800000&
         Style           =   1  'Graphical
         TabIndex        =   16
         Top             =   390
         UseMaskColor    =   -1  'True
         Width           =   930
      End
      Begin VB.Label Label26 
         Caption         =   " S/."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   3915
         TabIndex        =   17
         Top             =   480
         Width           =   540
      End
      Begin VB.Label Label25 
         Caption         =   "GLOSA"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   165
         TabIndex        =   19
         Top             =   1065
         Width           =   765
      End
      Begin VB.Label Label24 
         Caption         =   "PAGO"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   255
         TabIndex        =   14
         Top             =   450
         Width           =   675
      End
   End
   Begin VB.Frame frmVuelto 
      Height          =   1605
      Left            =   120
      TabIndex        =   48
      Top             =   5640
      Visible         =   0   'False
      Width           =   6945
      Begin VB.TextBox txtEfectivoDolares 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   14.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   4065
         Locked          =   -1  'True
         TabIndex        =   53
         Text            =   "0.00"
         Top             =   540
         Width           =   2415
      End
      Begin VB.TextBox txtVueltoDolares 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   14.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   4065
         TabIndex        =   55
         Text            =   "0.00"
         Top             =   1050
         Width           =   2415
      End
      Begin VB.TextBox txtVueltoSoles 
         Alignment       =   1  'Right Justify
         BackColor       =   &H80000018&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   14.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   1620
         Locked          =   -1  'True
         TabIndex        =   52
         TabStop         =   0   'False
         Text            =   "0.00"
         Top             =   1065
         Width           =   2415
      End
      Begin VB.TextBox txtEfectivoSoles 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   14.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   1650
         Locked          =   -1  'True
         TabIndex        =   50
         Text            =   "0.00"
         Top             =   555
         Width           =   2415
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "(U$)"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   5220
         TabIndex        =   64
         Top             =   165
         Width           =   540
      End
      Begin VB.Label Label12 
         AutoSize        =   -1  'True
         Caption         =   "(S/.)"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   2730
         TabIndex        =   63
         Top             =   180
         Width           =   570
      End
      Begin VB.Label Label11 
         AutoSize        =   -1  'True
         Caption         =   "Vuelto:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   14.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Left            =   480
         TabIndex        =   51
         Top             =   1050
         Width           =   885
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "&Efectivo:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   14.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Left            =   495
         TabIndex        =   49
         Top             =   510
         Width           =   1080
      End
   End
   Begin VB.Frame fraTotal 
      Height          =   1575
      Left            =   6840
      TabIndex        =   57
      Top             =   5640
      Width           =   4695
      Begin VB.TextBox txtSoles 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H8000000F&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   1080
         Locked          =   -1  'True
         TabIndex        =   58
         TabStop         =   0   'False
         Text            =   "0.00"
         Top             =   165
         Width           =   3375
      End
      Begin VB.TextBox txtDolares 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H8000000F&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   1065
         Locked          =   -1  'True
         TabIndex        =   59
         TabStop         =   0   'False
         Text            =   "0.00"
         Top             =   870
         Width           =   3375
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "S/."
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   360
         TabIndex        =   61
         Top             =   225
         Width           =   615
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "U$"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   360
         TabIndex        =   60
         Top             =   915
         Width           =   555
      End
   End
   Begin VB.Frame fraPagoAdelantado 
      Height          =   1612
      Left            =   1440
      TabIndex        =   66
      Top             =   5640
      Width           =   8400
      Begin VB.TextBox txtPADEDolares 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   5160
         TabIndex        =   69
         Text            =   "0.00"
         Top             =   880
         Width           =   3135
      End
      Begin VB.TextBox txtPagoAdelantado 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   5145
         TabIndex        =   68
         Text            =   "0.00"
         Top             =   210
         Width           =   3135
      End
      Begin VB.Label Label27 
         AutoSize        =   -1  'True
         Caption         =   "US$"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4200
         TabIndex        =   87
         Top             =   920
         Width           =   810
      End
      Begin VB.Label Label18 
         AutoSize        =   -1  'True
         Caption         =   "S/."
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4200
         TabIndex        =   70
         Top             =   270
         Width           =   615
      End
      Begin VB.Label Label17 
         AutoSize        =   -1  'True
         Caption         =   "&PAGO ADELANTADO:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   18
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   435
         Left            =   240
         TabIndex        =   67
         Top             =   270
         Width           =   3735
      End
   End
End
Attribute VB_Name = "frmCajaRegistradoraFull"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim TeclaRapida(50) As Long
Dim TeclaProducto(50) As Long
Public iTipoVenta As Integer '1:Normal 2:Voucher 3:Dolares 4:Transaccion Anulada
Dim bProducto As Boolean 'Establece si se estan registrando ventas o no
Dim Producto() As tProducto 'Almacena los datos de cada producto que se va registrando

Dim igvf As Double
Public nProducto As Long 'Cantidad de productos por transaccion
Public iTotalVenta As Double
Public iEfectivo As Double
Public iVuelto As Double
Public iVueltoDolares As Double
Public bVuelto As Boolean
Dim i As Integer
Dim prin_1(5) As String
Dim prin_2 As String
Public lcProdCode As String
Public lnProdPrecUnit As String
Public lsProdDescCrta As String
Public lsProdDesc As String
Public lsCodCatalogo As String
Public lsCanje As String
Public lsPtos As String
Public lsServ As String
Dim iTotal1 As Double
Dim slpt As String
Dim tPrinter As printer
Public gfax As New XArrayDB
Public piEmitevoucher As Integer

'Estado para el acceso a operaciones
Public bAcceso As Boolean

Public bSincronizaPantalla As Boolean
Public bLiquidaNC As Boolean
Public nIdClienteLocal As Integer

Public Sub Inicio()
  On Error GoTo LineaError
  Screen.MousePointer = vbHourglass
  bLiquidaNC = False
  
  Dim sSQL As String
  Dim ADORS As ADODB.Recordset
  Dim i As Long, j As Long
  Dim iInicio As Long, iFin As Long
  Dim sTecla1 As String, sTecla2 As String, sTecla3 As String
 
  bAcceso = False
  txtsupervisor.Text = ""
  'Limpia los LVW
  lvwTX(0).ListItems.Clear
  lvwTX(1).ListItems.Clear
  sFlag = False
  
  llenacomboventa
  LlenarComboLocal
  
  lblLocal.Visible = True 'False
  dcbLocal.Visible = True 'False
  
  'Muestra el Tipo de Cambio para la fecha
  txtTC.Text = nTipoCambio
  
  TDBGrid1.AllowAddNew = True
  TDBGrid1.AllowDelete = True
  TDBGrid1.AllowUpdate = True
  CmdAddArt(2).Visible = True
  CmdDelArt(2).Visible = True
  cmdVoucher.Visible = (SSTab1.Tab = 2)
  'Limpia algunos
  If bSincronizaPantalla Then
    cboTipoVenta.ListIndex = 1
    Set TDBGrid1.Array = gfax
    TDBGrid1.ReBind
    TDBGrid1.MoveFirst
    TDBGrid1.Update
    TDBGrid1.Refresh
    bSincronizaPantalla = False
  Else
'    IniciaTDBGrid
    txtTarjeta.Text = ""
    txtNombres.Text = ""
    txtEfectivoSoles.Text = "0.00"
    txtEfectivoDolares.Text = "0.00"
    txtVueltoSoles.Text = "0.00"
    txtVueltoDolares.Text = "0.00"
    txtSoles.Text = "0.00"
    txtDolares.Text = "0.00"
    cboTipoVenta.ListIndex = 0
    If Not (iTipoVenta = 1 And piEmitevoucher = 1) Then
      piEmitevoucher = 0
      Set rsPagTar = Nothing
    End If
  End If
  
  txtCajero.Text = psUsuario_Descripcion
  txtCaja.Text = kPAR_CAJA
  txtTurno.Text = kPAR_TURNO
  'txtPagoAdelantado.Text = Format("0", "0.00")
  txtPagoAdelantado.Text = Format("0", "0.00")
  txtPADE.Text = ""
  txtGlosa1.Text = ""
  txtimportepago.Text = "0.00"
  txtGlosa.Text = ""
  txtTX.Text = ""
  txtRUC.Text = ""
  'Valores por default
  bProducto = False
    
  txtLocal = ""
  dcbLocal.BoundText = -1
    
  'Reglas por punto e importe
  If bolExistenProblemasConexionBDCliente = False Then
    ConectarBDCliente     'Abrimos conexion
  End If
  
  If bolExisteConexionBDCliente = True Then
    sSQL = "SELECT * FROM Regla_Punto"
    If Not oDBAdmin.EjecutarConsulta(ADOCnn2, sSQL, ADORS) Then GoTo Salir
    
    If ADORS.EOF Then
      MsgBox "Reglas en relación a los puntos no han sido establecidos", vbOKOnly + vbInformation
      GoTo Salir
    End If
    lReglaImporteMaximo = LeerCampo(ADORS!nImpoMaxi)
    lReglaPuntoImporte = CLng(LeerCampo(ADORS!nPuntImpo))
    lReglaPuntoCantidad = CLng(LeerCampo(ADORS!nPuntCant))
    oDBAdmin.CerrarBD ADOCnn2     'Cerramos conexion
    bolExisteConexionBDCliente = False
    
    'Actualizamos estos parametros en la BD Local
    sSQL = " UPDATE Regla_Punto " & _
           "    SET nImpoMaxi = " & lReglaImporteMaximo & "," & _
           "        nPuntImpo = " & lReglaPuntoImporte & "," & _
           "        nPuntCant = " & lReglaPuntoCantidad
    If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
    
  Else
    sSQL = "SELECT * FROM Regla_Punto"
    If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
    
    If ADORS.EOF Then
      MsgBox "Reglas en relación a los puntos no han sido establecidos", vbOKOnly + vbInformation
      GoTo Salir
    End If
    lReglaImporteMaximo = LeerCampo(ADORS!nImpoMaxi)
    lReglaPuntoImporte = CLng(LeerCampo(ADORS!nPuntImpo))
    lReglaPuntoCantidad = CLng(LeerCampo(ADORS!nPuntCant))
  End If
    
  GoTo Salir
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

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

Private Sub cboTipoVenta_Click()
  iTipoVenta = cboTipoVenta.ListIndex + 1
  If bLiquidaNC = True And iTipoVenta = 2 Then
    iTipoVenta = 3
  End If
    
  'If iTipoVenta = 3 Then iTipoVenta = 1
  If iTipoVenta >= 3 Then iTipoVenta = iTipoVenta + 1
  
  If bLiquidaNC Then Exit Sub
  
  txtEfectivoSoles = "0.00"
  txtEfectivoDolares = "0.00"
  txtVueltoSoles = "0.00"
  txtVueltoDolares = "0.00"
  'TDBGrid1.Columns(6).DefaultValue = "1.00"
  'TDBGrid1.Columns(7).DefaultValue = "0.00"
  'TDBGrid1.Columns(8).DefaultValue = "-"
  'TDBGrid1.Columns(9).DefaultValue = "0.00"
  'TDBGrid1.Columns(10).DefaultValue = "0.00"
  
  SSTab1.TabVisible(0) = True
  SSTab1.TabVisible(1) = False
  SSTab1.TabVisible(2) = False
  SSTab1.TabEnabled(0) = True
  SSTab1.TabEnabled(1) = False
  SSTab1.TabEnabled(2) = False
  fraPagoAdelantado.Visible = False
  txtPADE.Text = ""
  txtimportepago.Text = "0.00"
  txtGlosa1.Text = ""
  txtTX.Text = ""
  txtGlosa.Text = ""
  frapade.Visible = False
  fraTotal.Visible = True
  SSTab1.Tab = 0
    
  'Manejo de RUC
  Select Case iTipoVenta
    Case 1, 2, 3
      Me.txtRUC.BackColor = &H80000005
      Me.txtRUC.Enabled = True
    Case Else
      Me.txtRUC.BackColor = &H8000000F
      Me.txtRUC.Text = ""
      Me.txtRUC.Enabled = False
  End Select
  
  cmdVoucher.Visible = False
  Select Case iTipoVenta
    Case 1, 4, 5 'Normal
      frmVuelto.Visible = True
      txtEfectivoSoles.Locked = False
      txtEfectivoDolares.Locked = True
      txtEfectivoSoles.BackColor = &HFFFFFF
      txtEfectivoDolares.BackColor = &H80000018
      txtEfectivoSoles.TabStop = True
      txtEfectivoDolares.TabStop = True
      If iTipoVenta = 5 Then frapade.Visible = True
      
      If iTipoVenta <> 4 Then
        'vd 05-09-07
        '>For i = gfax.LowerBound(1) To gfax.UpperBound(1)
          '> gfax(i, 9) = "0.00"
        '>Next
        CalculaTotales
        Set TDBGrid1.Array = gfax
        TDBGrid1.Update
        TDBGrid1.Refresh
      End If
      
      If iTipoVenta = 5 Then
        'SSTab1.TabVisible(1) = True
        'SSTab1.TabEnabled(1) = True
        frmVuelto.Visible = False
      End If
      
      If iTipoVenta = 1 Or iTipoVenta = 4 Then
        txtEfectivoDolares.Locked = False
        txtEfectivoDolares.BackColor = &HFFFFFF
        txtEfectivoDolares.TabStop = True
      End If
      
    Case 2 'Voucher
      frmVuelto.Visible = False
    Case 3 'dolares
      frmVuelto.Visible = True
      txtEfectivoSoles.Locked = True
      txtEfectivoDolares.Locked = False
      txtEfectivoSoles.BackColor = &H80000018
      txtEfectivoDolares.BackColor = &HFFFFFF
      txtEfectivoSoles.TabStop = True
      txtEfectivoDolares.TabStop = True
    Case 6, 7
      frmVuelto.Visible = False
      fraPagoAdelantado.Visible = True
      txtTX.Text = ""
      txtGlosa.Text = ""
      Me.txtPagoAdelantado.Text = "0.00"
      Me.txtPADEDolares.Text = "0.00"
      SSTab1.TabVisible(0) = False
      SSTab1.TabVisible(1) = True
      SSTab1.TabVisible(2) = False
      SSTab1.TabEnabled(0) = False
      SSTab1.TabEnabled(1) = True
      SSTab1.TabEnabled(2) = False
      fraTotal.Visible = False
      SSTab1.Tab = 1
    Case 8
      frmVuelto.Visible = True
      fraPagoAdelantado.Visible = False
      txtTX.Text = ""
      txtGlosa.Text = ""
      txtPagoAdelantado.Text = "0.00"
      txtPADEDolares.Text = "0.00"
      cmdVoucher.Visible = True
      SSTab1.TabVisible(0) = False
      SSTab1.TabVisible(1) = False
      SSTab1.TabVisible(2) = True
      SSTab1.TabEnabled(0) = False
      SSTab1.TabEnabled(1) = False
      SSTab1.TabEnabled(2) = True
      fraTotal.Visible = True
      SSTab1.Tab = 2
      
      txtEfectivoDolares.Locked = False
      txtEfectivoDolares.BackColor = &HFFFFFF
      txtEfectivoDolares.TabStop = True
      
    Case 9
      frmAnulaTransaccion.Show vbModal
      cboTipoVenta.ListIndex = 0
    Case 10
      frmPago.Show vbModal
      cboTipoVenta.ListIndex = 0
  End Select
  
  Me.TDBGrid1.Enabled = SSTab1.TabVisible(0)
  
End Sub

Public Sub CmdAdd_Click(Index As Integer)
  Dim i As Long
  Dim iOper As Long
  Dim itm As ListItem
  Dim ADORS As ADODB.Recordset
  Dim sSQL As String
  Dim bControl As Boolean
  
  bControl = False
  
  If Trim(txtTXL(Index)) = "" Then
    MsgBox "Debe ingresar el código de transacción."
    txtTXL(Index).SetFocus
    Exit Sub
  End If
  
  iOper = val(txtTXL(Index))
  
  'Verifica si el numero de TX ya existe 'es correcto
  For i = 1 To lvwTX(Index).ListItems.Count
    If lvwTX(Index).ListItems(i).Text = iOper Then
      MsgBox "El código de transacciòn ya existe."
      Exit Sub
    End If
  Next
  
  'Verifica si el numero de TX es correcto
  sSQL = " SELECT b.cOperCode, b.nTarjNumb, C.cClieCode, c.sName, b.nMoneda, b.nMontoDolares," & _
         " b.dOperFech, b.nMontoSoles, b.cOperTipo, b.sGlosa, cOpercodeRela, cdocserie, 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 cOperCode = " + CStr(iOper) & _
         " AND b.cEstado = '1'"
  
  If oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then
    Do While Not ADORS.EOF
      If Index = 0 Then
        Dim mon As Integer
        mon = LeerCampo(ADORS("nMoneda"))
        Set itm = lvwTX(Index).ListItems.Add(, , CStr(LeerCampo(ADORS("cOperCode"))))
        itm.SubItems(1) = IIf(LeerCampo(ADORS("cOperTipo")) = 12, "PADE", IIf(LeerCampo(ADORS("cOperTipo")) = 13, "PADV", "N/C"))
        itm.SubItems(2) = LeerCampo(ADORS("cdocserie")) & "-" & LeerCampo(ADORS("cdoccodigo"))
        itm.SubItems(3) = LeerCampo(ADORS("nTarjNumb"))
        'itm.SubItems(4) = Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
        itm.SubItems(4) = Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
        itm.SubItems(5) = Format(LeerCampo(ADORS("dOperFech")), "dd/mm/yyyy")
        If mon = 2 Then
          'itm.SubItems(6) = "US$ " + Format(LeerCampo(adoRS("nMontoDolares")), "###,##0.00")
          itm.SubItems(6) = "US$ " + Format(LeerCampo(ADORS("nMontoDolares")), "0.00")
        Else
          'itm.SubItems(6) = "S/. " + Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
          itm.SubItems(6) = "S/. " + Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
        End If
        itm.SubItems(7) = LeerCampo(ADORS("sName")) + " - " + LeerCampo(ADORS("sGlosa"))
      End If
      If Index = 1 Then
        Set itm = lvwTX(Index).ListItems.Add(, , CStr(LeerCampo(ADORS("cOperCode"))))
        itm.SubItems(1) = IIf(LeerCampo(ADORS("cOperTipo")) = 12, "PADE", IIf(LeerCampo(ADORS("cOperTipo")) = 13, "PADV", "N/C"))
        itm.SubItems(2) = LeerCampo(ADORS("cdocserie")) & "-" & LeerCampo(ADORS("cdoccodigo"))
        itm.SubItems(3) = LeerCampo(ADORS("nTarjNumb"))
        'itm.SubItems(4) = Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
        itm.SubItems(4) = Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
        itm.SubItems(5) = Format(LeerCampo(ADORS("dOperFech")), "dd/mm/yyyy")
        itm.SubItems(6) = LeerCampo(ADORS("cOpercodeRela"))
      End If
      ADORS.MoveNext
      bControl = True
    Loop
  End If
  
  If bControl Then
    If Index = 0 Then
      sSQL = " SELECT b.cOperCode, c.nTarjNumb, C.cClieCode, c.sName," & _
             " b.dOperFech, b.nMontoSoles, b.cOperTipo, b.sGlosa, b.cOpercodeRela, cdocserie, 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 cOperCodeRela = " + CStr(iOper) & _
             " AND b.cEstado = '1'"
      If oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then
        Do While Not ADORS.EOF
          Dim numoper As Long
          Dim exist As Boolean
          exist = False
          numoper = LeerCampo(ADORS("cOperCode"))
          
          'Verifica si el numero de TX ya existe
          For i = 1 To lvwTX(1).ListItems.Count
            If lvwTX(1).ListItems(i).Text = numoper Then
              exist = True
            End If
          Next
          
          If Not exist Then
            Set itm = lvwTX(1).ListItems.Add(, , CStr(numoper))
            itm.SubItems(1) = IIf(LeerCampo(ADORS("cOperTipo")) = 12, "PADE", IIf(LeerCampo(ADORS("cOperTipo")) = 13, "PADV", "N/C"))
            itm.SubItems(2) = LeerCampo(ADORS("cdocserie")) & "-" & LeerCampo(ADORS("cdoccodigo"))
            itm.SubItems(3) = LeerCampo(ADORS("nTarjNumb"))
            'itm.SubItems(4) = Format(LeerCampo(adoRS("nMontoSoles")), "###,##0.00")
            itm.SubItems(4) = Format(LeerCampo(ADORS("nMontoSoles")), "0.00")
            itm.SubItems(5) = Format(LeerCampo(ADORS("dOperFech")), "dd/mm/yyyy")
            itm.SubItems(6) = LeerCampo(ADORS("cOpercodeRela"))
          End If
          ADORS.MoveNext
        Loop
      End If
    End If
  End If
  
  TotalLiquidadas
  
End Sub

Private Sub CmdAddArt_Click(Index As Integer)
  If Me.TDBGrid1.Row >= 0 And Trim(TDBGrid1.Columns(1).Text) <> "" Then
    Me.TDBGrid1.Row = gfax.UpperBound(1) + 1
  End If
  
  Me.TDBGrid1.Col = 1
  Me.TDBGrid1.SetFocus
End Sub

Private Sub cmdBuscaPago_Click()
  frmBusquedaArticulos.frmPadre = "frmCajaRegistradoraFull"
  frmBusquedaArticulos.pOpcion = "PagoAdelantado"
  frmBusquedaArticulos.Inicio
  
  frmBusquedaArticulos.Show vbModal
End Sub

Private Sub cmdCambio_Click()
  If cmdCambio.Enabled = True Then
    Unload Me
    frmCajaRegistradora.Show vbModal
  End If
End Sub

Private Sub CMDdel_Click(Index As Integer)
  Dim iOperRela As Long, i As Long
  
  If lvwTX(Index).ListItems.Count < 1 Then Exit Sub
  If Index = 0 Then iOperRela = lvwTX(0).SelectedItem.Text
  
  lvwTX(Index).ListItems.Remove (lvwTX(Index).SelectedItem.Index)
  
  If Index = 0 Then
    For i = lvwTX(1).ListItems.Count To 1 Step -1
      If val(lvwTX(1).ListItems(i).SubItems(6)) = iOperRela Then
        lvwTX(1).ListItems.Remove i
      End If
    Next
  End If
  
  TotalLiquidadas
  
End Sub

Private Sub CmdDelArt_Click(Index As Integer)
  Dim i As Integer
  
  If TDBGrid1.Row <> -1 Then
    TDBGrid1.Delete
    TDBGrid1.Update
    TDBGrid1.Refresh
  End If
  
  TDBGrid1.Col = 1
  
  CalculaTotales
  CalculoVuelto
  Me.TDBGrid1.SetFocus
End Sub

Private Sub cmdPagoAdelantado_Click()
  frmBusquedaArticulos.frmPadre = "frmCajaRegistradoraFull"
  frmBusquedaArticulos.pOpcion = "PagoAdelantado"
  frmBusquedaArticulos.Inicio
  frmBusquedaArticulos.Show vbModal
End Sub

Private Sub cmdTecla_Click(Index As Integer)
  If VerificarFechaSistema = False Then
    MsgBox "La fecha del sistema no puede ser posterior a al ultima operacion realizada...Verifique!!" & vbCrLf & "El sistema se cerrara!!!", vbInformation + vbOKOnly, "Mensaje"
    End
  End If
  
  Select Case Index
    Case 0 'CANCELAR
      If bLiquidaNC = True Then
        If MsgBox("Debe Emitir un documento de venta para la Liquidación" + Chr(13) + _
        "Se emitirá una Boleta de Venta " + Chr(13) + "Desea continuar?" _
        , vbQuestion + vbYesNo + vbDefaultButton1, "Liquidación") = vbYes Then
          cboTipoVenta.ListIndex = 0
          RegistraVenta
        End If
        Exit Sub
      End If
      gfax.Clear
      'gfax.ReDim 0, 0, 0, 14
      gfax.ReDim 0, 0, 0, 15
      TDBGrid1.ReBind
      TDBGrid1.MoveFirst
      TDBGrid1.Update
      TDBGrid1.Refresh
      Inicio
    Case 1 'VOLVER A CAJA REGISTRADORA
      Unload Me
      frmCajaRegistradora.Show vbModal
    Case 2 'AC/TC
       sFlag = False
       If ((iTipoVenta = 7 Or iTipoVenta = 2) And sFlag = False) And (piEmitevoucher <> 1) Then
       
       
         FrmCajaVoucher.Show vbModal
       Else
         sFlag = True
       End If
       
       If sFlag = True Then
         If Validaitems = True Then
           RegistraVenta
           piEmitevoucher = 0
           Set rsPagTar = Nothing
           sFlag = False
         End If
       End If
    Case 3
      If bLiquidaNC = True Then
        If MsgBox("Debe Emitir un documento de venta para la Liquidación" + Chr(13) + _
        "Se emitirá una Boleta de Venta " + Chr(13) + "Desea continuar?" _
        , vbQuestion + vbYesNo + vbDefaultButton1, "Liquidación") = vbYes Then
          cboTipoVenta.ListIndex = 0
          cmdTecla_Click (2)
        End If
        Exit Sub
      End If
      Unload Me
    Case 4
      'sw Add 19/06/2009
      frmReimpresion.idLocal = Trim(CStr(Me.txtLocal.Text))
      
      frmReimpresion.Show vbModal
  End Select
  txtEfectivoSoles.Tag = ""
  
End Sub

Private Sub cmdTXL_Click(Index As Integer)
  frmBusquedaArticulos.frmPadre = "frmCajaRegistradoraFull"
  frmBusquedaArticulos.pOpcion = "Liquidacion" + CStr(Index)
  frmBusquedaArticulos.Inicio
  frmBusquedaArticulos.Show vbModal
End Sub

Private Sub cmdVoucher_Click()
  sFlag = True
  piEmitevoucher = 0
  FrmCajaVoucher.Show vbModal
  If sFlag = True Then
    If Validaitems = True Then
      RegistraVenta
    End If
  End If
End Sub

Private Sub dcbLocal_Change()
  nIdClienteLocal = val(dcbLocal.BoundText)
  SeleccionarClienteLocal CLng(val(dcbLocal.BoundText))
End Sub

Private Sub Form_Load()
  Dim cont As Integer
  
  If VerificarFechaSistema = False Then
    MsgBox "La fecha del sistema no puede ser posterior a al ultima operacion realizada...Verifique!!", vbInformation + vbOKOnly, "Mensaje"
    End
  End If
    
  ConfiguraColumnas
  If Not bSincronizaPantalla Then
    'gfax.ReDim 0, 0, 0, 14
    gfax.ReDim 0, 0, 0, 15
    gfax.Clear
    TDBGrid1.ReBind
    cont = gfax.LowerBound(1)
    
    Set TDBGrid1.Array = gfax
    TDBGrid1.Update
    TDBGrid1.Refresh
    TDBGrid1.MoveFirst
  End If
  
  If UCase(kDSCTOFLAG) = "S" Then
    TDBGrid1.Columns(9).Locked = True
  Else
    TDBGrid1.Columns(9).Locked = False
  End If
  
End Sub

Private Sub ConfiguraColumnas()
  Dim i As Integer, x As Integer
  Dim clmX As ColumnHeader
  Dim aColumnTitle() As String
  Dim aColumnWidth() As Single
  Dim aColumnAlign() As Integer
     
  ReDim aColumnTitle(15) As String
  ReDim aColumnWidth(15) As Single
  ReDim aColumnAlign(15) As Integer
    
  aColumnTitle(0) = "TX"
  aColumnTitle(1) = "Tipo"
  aColumnTitle(2) = "Doc"
  aColumnTitle(3) = "Tarjeta"
  aColumnTitle(4) = "Total(S/.)"
  aColumnTitle(5) = "Fecha"
  aColumnTitle(6) = "Monto Orig."
  aColumnTitle(7) = "Cliente - Glosa"
  'aColumnTitle(2) = "Tarjeta"
  'aColumnTitle(3) = "Cliente"
 
  aColumnWidth(0) = 0
  aColumnWidth(1) = 0
  aColumnWidth(2) = 0.15
  aColumnWidth(3) = 0.15
  aColumnWidth(4) = 0.2
  aColumnWidth(5) = 0.23
  aColumnWidth(6) = 0.25
  aColumnWidth(7) = 0.5
        
  aColumnAlign(0) = lvwColumnLeft
  aColumnAlign(1) = lvwColumnLeft
  aColumnAlign(2) = lvwColumnCenter
  aColumnAlign(3) = lvwColumnLeft
  aColumnAlign(4) = lvwColumnRight
  aColumnAlign(5) = lvwColumnCenter
  aColumnAlign(6) = lvwColumnCenter
    
  For i = 0 To (UBound(aColumnTitle) - 1)
    Set clmX = lvwTX(0).ColumnHeaders.Add(, , aColumnTitle(i), _
                                            lvwTX(0).Width * aColumnWidth(i), _
                                            aColumnAlign(i))
  Next
  
  ReDim aColumnTitle(15) As String
  ReDim aColumnWidth(15) As Single
  ReDim aColumnAlign(15) As Integer
    
  aColumnTitle(0) = "TX"
  aColumnTitle(1) = "Tipo"
  aColumnTitle(2) = "Doc"
  aColumnTitle(3) = "Tarjeta"
  'aColumnTitle(2) = "Tarjeta"
  'aColumnTitle(3) = "Cliente"
  aColumnTitle(4) = "Total(S/.)"
  aColumnTitle(5) = "Fecha"
  aColumnTitle(6) = "PADE/PADV"
    
  aColumnWidth(0) = 0
  aColumnWidth(1) = 0
  aColumnWidth(2) = 0.15
  aColumnWidth(3) = 0.15
  aColumnWidth(4) = 0.2
  aColumnWidth(5) = 0.23
  aColumnWidth(6) = 0.22
        
  aColumnAlign(0) = lvwColumnLeft
  aColumnAlign(1) = lvwColumnLeft
  aColumnAlign(2) = lvwColumnCenter
  aColumnAlign(3) = lvwColumnLeft
  aColumnAlign(4) = lvwColumnRight
  aColumnAlign(5) = lvwColumnCenter
    
  For i = 0 To (UBound(aColumnTitle) - 1)
    Set clmX = lvwTX(1).ColumnHeaders.Add(, , aColumnTitle(i), _
                                            lvwTX(1).Width * aColumnWidth(i), _
                                            aColumnAlign(i))
  Next
  
End Sub

Private Sub TDBGrid1_AfterColEdit(ByVal ColIndex As Integer)
  CalculaTotales
  TDBGrid1.Update
  TDBGrid1.Refresh
End Sub

Private Sub TDBGrid1_AfterDelete()
  CalculaTotales
  TDBGrid1.Update
  TDBGrid1.Refresh
End Sub

Private Sub TDBGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
  'Select Case TDBGrid1.Col
  '  Case 9
  '  TDBGrid1.Columns(9).Locked = True
  '
  'End Select
End Sub

Private Sub txtBuscaCliente_Click()
  frmBusquedaArticulos.frmPadre = "frmCajaRegistradoraFull"
  frmBusquedaArticulos.pOpcion = "Cliente"
  frmBusquedaArticulos.Inicio
  frmBusquedaArticulos.txtBuscar.Text = txtTarjeta.Text
  frmBusquedaArticulos.cmdBuscar_Click
  frmBusquedaArticulos.Show vbModal
  txtNombres.Enabled = (Trim(txtTarjeta.Text) = "")
  txtNombres.Locked = Not (Trim(txtTarjeta.Text) = "")
End Sub

Private Sub txtEfectivoDolares_GotFocus()
  CalculaTotales
  txtEfectivoDolares.SelStart = 0
  txtEfectivoDolares.SelLength = Len(Me.txtEfectivoDolares.Text)
End Sub

Private Sub txtEfectivoDolares_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
    txtEfectivoDolares_LostFocus
  End If
End Sub

Private Sub txtEfectivoSoles_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
    txtEfectivoSoles_LostFocus
  End If
End Sub
Private Sub txtEfectivoSoles_GotFocus()
  'If Trim(Me.txtEfectivoSoles.Text) = "" Then Me.txtEfectivoSoles.Text = "0.00"
  CalculoVuelto
  '  CalculaTotales
  txtEfectivoSoles.SelStart = 0
  txtEfectivoSoles.SelLength = Len(Me.txtEfectivoSoles.Text)
End Sub

Private Sub txtEfectivoSoles_KeyPress(KeyAscii As Integer)
  On Error GoTo LineaError
  
  Call ValidKeyPress(KeyAscii, kVKP_NUMERIC_ONLY)
  txtEfectivoSoles.Tag = "1"
  Exit Sub
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
End Sub
Private Sub txtEfectivoDolares_KeyPress(KeyAscii As Integer)
  On Error GoTo LineaError
  
  Call ValidKeyPress(KeyAscii, kVKP_NUMERIC_ONLY)
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
End Sub

Private Sub txtEfectivoSoles_LostFocus()
  'txtEfectivoSoles = Format(txtEfectivoSoles, "0.00")
  txtEfectivoSoles = Format(txtEfectivoSoles, "0.00")
  EfectivoSolesCambia
  CalculoVuelto
End Sub

Private Sub txtEfectivoDolares_LostFocus()
  txtEfectivoDolares = Format(txtEfectivoDolares, "0.00")
  'txtEfectivoDolares = Format(txtEfectivoDolares, "0.00")
  CalculoVuelto
End Sub

Private Sub txtGlosa_GotFocus()
  cmdCambio.Enabled = False
End Sub

Private Sub txtGlosa_LostFocus()
  cmdCambio.Enabled = True
End Sub

Private Sub txtGlosa1_Change()
  txtGlosa.Text = txtGlosa1.Text
End Sub

Private Sub txtGlosa1_GotFocus()
  cmdCambio.Enabled = False
End Sub

Private Sub txtGlosa1_LostFocus()
  cmdCambio.Enabled = True
End Sub

Private Sub txtLocal_KeyDown(KeyCode As Integer, Shift As Integer)
  Select Case KeyCode
    Case 13
      If IsNumeric(txtLocal.Text) And (val(txtLocal.Text) = 1 Or val(txtLocal.Text) = 2) Then
        'Call txtTarjeta_LostFocus
        Call LlamarCliente
      End If
  End Select
End Sub

Private Sub txtLocal_KeyPress(KeyAscii As Integer)
  'KeyAscii = IIf( _
    (KeyAscii >= 49 And KeyAscii <= 57) Or _
    (KeyAscii = 8 Or KeyAscii = 32), _
    KeyAscii, 0)
          
  KeyAscii = IIf( _
    (KeyAscii = 49 Or KeyAscii = 50) Or _
    (KeyAscii = 8 Or KeyAscii = 32), _
    KeyAscii, 0)

End Sub

Private Sub txtNombres_GotFocus()
  cmdCambio.Enabled = False
End Sub

Private Sub txtNombres_LostFocus()
  cmdCambio.Enabled = True
End Sub

Private Sub txtPADEDolares_GotFocus()
  txtPADEDolares.SelStart = 0
  txtPADEDolares.SelLength = Len(txtPagoAdelantado.Text)
  txtPagoAdelantado.Text = "0.00"
End Sub

Private Sub txtPADEDolares_LostFocus()
  txtPADEDolares = Format(txtPADEDolares, "0.00")
  'txtPADEDolares = Format(txtPADEDolares, "0.00")
End Sub

Private Sub txtPagoAdelantado_GotFocus()
  txtPagoAdelantado.SelStart = 0
  txtPagoAdelantado.SelLength = Len(txtPagoAdelantado.Text)
  txtPADEDolares.Text = "0.00"
End Sub

Private Sub txtPagoAdelantado_LostFocus()
  'txtPagoAdelantado = Format(txtPagoAdelantado, "####,####,####,###0.00")
  txtPagoAdelantado = Format(txtPagoAdelantado, "0.00")
End Sub

Private Sub txtRuc_KeyPress(KeyAscii As Integer)
  'Valida q solo se ingresen números (valores enteros)
  On Error GoTo LineaError
  
  Call ValidKeyPress(KeyAscii, kVKP_NUMERIC_INTEGER_ONLY)
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
End Sub

Private Sub txtSoles_Change()
  TotalCambia
End Sub

Private Sub txtTarjeta_KeyDown(KeyCode As Integer, Shift As Integer)
  Select Case KeyCode
    Case vbKeyF5
      'txtBuscaCliente_Click
    Case 13
      'Call txtTarjeta_LostFocus
      Call LlamarCliente
  End Select
End Sub

Private Sub txtTarjeta_KeyPress(KeyAscii As Integer)
  'Valida q solo se ingresen números (valores enteros)
  On Error GoTo LineaError
  
  Call ValidKeyPress(KeyAscii, kVKP_NUMERIC_INTEGER_ONLY)
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
End Sub

Private Sub LlamarCliente()
  On Error GoTo LineaError
  
  If frmBusquedaArticulos.Visible Then Exit Sub
  
  Dim sSQL As String
  Dim ADORS As ADODB.Recordset
  Dim i As Long, j As Long
  Dim sTarjeta As String
  'sw To SQL Server era >>> nIdLocal
  Dim idLocal As Integer
  
  If Trim(txtTarjeta.Text) = "" Then
    txtNombres = ""
    dcbLocal.BoundText = -1
    GoTo Salir
  End If
  
  sTarjeta = Right("00000000" + Trim(txtTarjeta.Text), 8)
  'sw To SQL Server era >>> nIdLocal
  idLocal = val(txtLocal.Text)
  
  txtTarjeta.Text = sTarjeta
  
'  sSQL = "SELECT a.cClieCode, sClieApel + ' ' + sClieName AS sName, dNacmDate, " + _
'         "nPuntCant, nTickCant, dUltTDate, sTranDesc " + _
'         "FROM Cliente a, Transaccion b, Tarjeta c " + _
'         "WHERE a.cTranCode = b.cTranCode AND " + _
'         "a.cClieCode = c.cClieCode AND " + _
'         "nTarjNumb = '$'"
         
  'sw To SQL Server era >>> nIdLocal >>> Date()
  sSQL = " SELECT a.cClieCode, sClieApel , sClieName , dNacmDate, a.IdLocal, " + _
         "        nPuntCant, nTickCant, dUltTDate" + _
         "   FROM Cliente a, Tarjeta c " + _
         "  WHERE a.cClieCode = c.cClieCode and a.IdLocal=c.IdLocal and (c.cTarjActi=1 and Convert(Char(10), dcadudate,112)>=Convert(Char(10), getdate(),112)) " + _
         "    AND nTarjNumb = '$'"
         
  'sw To SQL Server era >>> nIdLocal
  If idLocal = 1 Or idLocal = 2 Then
    sSQL = sSQL + "    AND a.IdLocal = $ "
  End If
  
  'sw To SQL Server era >>> nIdLocal
  sSQL = VBsprintf(sSQL, sTarjeta, CInt(idLocal))
  
  If bolExistenProblemasConexionBDCliente = False Then
    ConectarBDCliente     'Abrimos conexion
  End If
  
  If Not oDBAdmin.EjecutarConsulta(ADOCnn2, sSQL, ADORS) Then GoTo Salir
  
  If ADORS.RecordCount = 0 Then
    txtTarjeta.Text = ""
    txtNombres.Text = ""
    dcbLocal.BoundText = -1
    txtLocal.Text = ""
    MsgBox "El Código de cliente no existe o la tarjeta se encuentra inactiva"
    txtTarjeta.SetFocus
  ElseIf ADORS.RecordCount = 1 Then
    'lblLocal.Visible = False
    'dcbLocal.Visible = False
    txtNombres.Text = LeerCampo(ADORS("sClieApel")) + " " + LeerCampo(ADORS("sClieName"))
    'lblLocal.Visible = True: dcbLocal.Visible = True
    'sw To SQL Server eran >>> nIdLocal
    dcbLocal.BoundText = ADORS("IdLocal")
    txtLocal.Text = ADORS("IdLocal")
  ElseIf ADORS.RecordCount = 2 Then
    txtNombres.Text = ""
    lblLocal.Visible = True: dcbLocal.Visible = True
    'MsgBox "Seleccione local al cual pertenece!!", vbInformation + vbOKOnly, "Mensaje"
    dcbLocal.BoundText = -1
    'dcbLocal.SetFocus
    txtBuscaCliente_Click
  End If
  
  GoTo Salir
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  Screen.MousePointer = vbDefault

Salir:
  Set ADORS = Nothing
End Sub

Private Sub TDBGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
  Dim sSQL As String
  Dim ADORS As ADODB.Recordset
  Dim Texto As String
  Dim flag_1 As Integer
  Texto = TDBGrid1.Text
  If TDBGrid1.Columns(1) = "" And (ColIndex <> 2 And ColIndex <> 1) Then
    Beep
    Cancel = True
    Exit Sub
  End If
  
  Select Case ColIndex
    Case 0
    Case 1
      TDBGrid1.Columns(1) = Right("000000" + Trim(Texto), 6)
      'Captura la descripción y precio unitario del articulo
      sSQL = " SELECT sProdDescCrta, nProdPrecUnit, cProdEstd, cFlagCanje, nPuntos, cFlagServicio, nActivo, ccodcatalogo FROM Producto" & _
             " WHERE cAlmaCode = '" & kPAR_ALMACEN & "' AND cProdCode = " + CStr(Texto)
        
      If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo LineaError
      If ADORS.RecordCount = 1 Then
        If LeerCampo(ADORS("cProdEstd")) <> 1 Or LeerCampo(ADORS("nActivo")) <> 1 Then
          MsgBox "El Producto no se encuentra activo."
          GoTo Salir
        End If
        TDBGrid1.Columns(2) = LeerCampo(ADORS("ccodcatalogo"))
        TDBGrid1.Columns(3) = LeerCampo(ADORS("sProdDescCrta"))
        TDBGrid1.Columns(6) = "1.00"
        TDBGrid1.Columns(7) = Format(LeerCampo(ADORS("nProdPrecUnit")), "0.00")
        TDBGrid1.Columns(11) = IIf(LeerCampo(ADORS("cFlagCanje")) = 0, "NO", IIf(LeerCampo(ADORS("cFlagCanje")) = 1, "VNTA", "PTOS"))
        TDBGrid1.Columns(12) = LeerCampo(ADORS("nPuntos"))
        TDBGrid1.Columns(13) = IIf(LeerCampo(ADORS("cFlagServicio")) = 1, "SI", "NO")
        TDBGrid1.Columns(8) = "-"
        TDBGrid1.Columns(9) = "0.00"
        CalculaTotales
      End If
    
    Case 2
      sSQL = " SELECT  cProdCode, sProdDescCrta, nProdPrecUnit, cProdEstd, cFlagCanje, nPuntos, cFlagServicio, nActivo, ccodcatalogo FROM Producto" & _
             " WHERE cAlmaCode = '" & kPAR_ALMACEN & "' and nactivo=1" & _
             " AND ccodcatalogo like  '%" & Trim(Texto) & "' "
      
      If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo LineaError
      If Not ADORS.EOF Then
        TDBGrid1.Columns(1) = Right("000000" + Trim(LeerCampo(ADORS("cProdCode"))), 6)
        TDBGrid1.Columns(2) = LeerCampo(ADORS("ccodcatalogo"))
        TDBGrid1.Columns(3) = LeerCampo(ADORS("sProdDescCrta"))
        TDBGrid1.Columns(6) = "1.00"
        TDBGrid1.Columns(7) = Format(LeerCampo(ADORS("nProdPrecUnit")), "0.00")
        TDBGrid1.Columns(11) = IIf(LeerCampo(ADORS("cFlagCanje")) = 0, "NO", IIf(LeerCampo(ADORS("cFlagCanje")) = 1, "VNTA", "PTOS"))
        TDBGrid1.Columns(12) = LeerCampo(ADORS("nPuntos"))
        TDBGrid1.Columns(13) = IIf(LeerCampo(ADORS("cFlagServicio")) = 1, "SI", "NO")
        TDBGrid1.Columns(8) = "-"
        TDBGrid1.Columns(9) = "0.00"
        CalculaTotales
        Exit Sub
      End If
      
      '---------Buscando intensamente ---------------
      Texto = Replace(Texto, ".", "")
      
      If Not IsNumeric(Texto) Then
        Beep
        MsgBox "Articulo No Existe...!!!"
        Cancel = True
        flag_1 = 0
      Else
        'Captura la descripción y precio unitario del articulo
        flag_1 = 1
        sSQL = " SELECT cProdCode, sProdDescCrta, nProdPrecUnit, cProdEstd, cFlagCanje, nPuntos, cFlagServicio, nActivo, ccodcatalogo FROM Producto" & _
               " WHERE cAlmaCode = '" & kPAR_ALMACEN & "' and nactivo=1"
        
        If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo LineaError
        
        Texto = CDbl(Replace(Texto, ".", ""))
        
        Dim Buscar As Boolean
        Dim icatalogo As Long
        Dim sCatalogo As String
        Buscar = True
        If ADORS.RecordCount > 0 Then
          ADORS.MoveFirst
          Do While (Not ADORS.EOF)
            If Buscar = False Then
              Exit Do
            End If
            
            icatalogo = val(Replace(LeerCampo(ADORS("ccodcatalogo")), ".", ""))
            
            If icatalogo = val(Texto) Then
              Buscar = False
              Exit Do
              If LeerCampo(ADORS("cProdEstd")) <> 1 Or LeerCampo(ADORS("nActivo")) <> 1 Then
                MsgBox "El Producto no se encuentra activo."
                GoTo Salir
              End If
            End If
            ADORS.MoveNext
          Loop
        End If
      End If
      If Buscar = False Then
        If flag_1 = 1 Then
          TDBGrid1.Columns(1) = Right("000000" + Trim(LeerCampo(ADORS("cProdCode"))), 6)
          TDBGrid1.Columns(2) = LeerCampo(ADORS("ccodcatalogo"))
          TDBGrid1.Columns(3) = LeerCampo(ADORS("sProdDescCrta"))
          TDBGrid1.Columns(6) = "1.00"
          TDBGrid1.Columns(7) = Format(LeerCampo(ADORS("nProdPrecUnit")), "0.00")
          
          TDBGrid1.Columns(11) = IIf(LeerCampo(ADORS("cFlagCanje")) = 0, "NO", IIf(LeerCampo(ADORS("cFlagCanje")) = 1, "VNTA", "PTOS"))
          TDBGrid1.Columns(12) = LeerCampo(ADORS("nPuntos"))
          TDBGrid1.Columns(13) = IIf(LeerCampo(ADORS("cFlagServicio")) = 1, "SI", "NO")
          CalculaTotales
        End If
      Else
        TDBGrid1.Columns(3) = ""
      End If
      If icatalogo <> val(Texto) Then
        MsgBox "Articulo No Existe...!!!"
        Beep
        Cancel = True
        Exit Sub
      End If
    
    Case 7, 9, 10
      If Not IsNumeric(Texto) Or val(Texto) < 0 Then
        Beep
        Cancel = True
      Else
        If ColIndex = 9 And (val(Texto) > 100 Or val(Texto) < 0) Then
          Beep
          MsgBox "Porcentaje Recargo/ Descuento incorrecto "
          Cancel = True
        Else
          TDBGrid1.Text = Format(Texto, "0.00")
          CalculaTotales
        End If
      End If
      
    Case 6
      
      If Not IsNumeric(Texto) Or val(Texto) <= 0 Then
        Beep
        Cancel = True
      Else
        If Trim(TDBGrid1.Text) <> "-" And val(Replace(TDBGrid1.Columns(6), ",", "")) * val(Replace(TDBGrid1.Columns(7), ",", "")) Then
          TDBGrid1.Columns(9) = "0.00"
          CalculaTotales
        End If
        TDBGrid1.Text = Format(Round(Texto, 0), "0.00")
        CalculaTotales
      End If
      
    Case 8
      If Trim(TDBGrid1.Text) <> "-" And Trim(TDBGrid1.Text) <> "+" Then
        TDBGrid1.Text = "-"
        CalculaTotales
      Else
        If Trim(TDBGrid1.Text) <> "-" And val(Replace(TDBGrid1.Columns(6), ",", "")) * val(Replace(TDBGrid1.Columns(7), ",", "")) Then
          TDBGrid1.Columns(9) = "0.00"
          CalculaTotales
        End If
      End If
  End Select
  
  GoTo Salir
  
LineaError:
  MsgBox ("No se pudo seleccionar el artìculo")
Salir:
  Set ADORS = Nothing
  Me.TDBGrid1.Update
  Me.TDBGrid1.Refresh
  
End Sub

Private Sub TDBGrid1_ButtonClick(ByVal ColIndex As Integer)
  On Error Resume Next
  Select Case ColIndex
    Case 4
      TDBGrid1_LostFocus
      lcProdCode = ""
      frmBusquedaArticulos.frmPadre = "frmCajaRegistradoraFull"
      frmBusquedaArticulos.pOpcion = "Producto"
      frmBusquedaArticulos.Inicio
      frmBusquedaArticulos.Show vbModal
      If Trim(lcProdCode) <> "" Then
        TDBGrid1.Columns(1) = lcProdCode
        TDBGrid1.Columns(2) = lsCodCatalogo
        TDBGrid1.Columns(6) = "1.00"
        TDBGrid1.Columns(7) = lnProdPrecUnit
        TDBGrid1.Columns(3) = lsProdDescCrta
        TDBGrid1.Columns(11) = Me.lsCanje
        TDBGrid1.Columns(12) = Me.lsPtos
        TDBGrid1.Columns(13) = Me.lsServ
        TDBGrid1.Columns(8) = "-"
        TDBGrid1.Columns(9) = "0.00"
        TDBGrid1.Columns(10) = "0.00"
        TDBGrid1.Col = 6
        CalculaTotales
      End If
  End Select
  
  Me.TDBGrid1.Update
  Me.TDBGrid1.Refresh
  
End Sub

Private Sub TDBGrid1_HeadClick(ByVal ColIndex As Integer)
  'Ascending sort
  Select Case ColIndex
    Case 0, 1
      gfax.QuickSort gfax.LowerBound(1), gfax.UpperBound(1), ColIndex, XORDER_ASCEND, XTYPE_STRING
    Case Else
      gfax.QuickSort gfax.LowerBound(1), gfax.UpperBound(1), ColIndex, XORDER_ASCEND, XTYPE_INTEGER
  End Select
  Me.TDBGrid1.Update
  Me.TDBGrid1.Refresh
  '  TDBGrid1.Refresh
End Sub

Private Sub TDBGrid1_FootClick(ByVal ColIndex As Integer)
  'Descending sort
  Select Case ColIndex
    Case 0, 1
      gfax.QuickSort gfax.LowerBound(1), gfax.UpperBound(1), ColIndex, XORDER_DESCEND, XTYPE_STRING
    Case Else
      gfax.QuickSort gfax.LowerBound(1), gfax.UpperBound(1), ColIndex, XORDER_DESCEND, XTYPE_INTEGER
  End Select
  Me.TDBGrid1.Update
  Me.TDBGrid1.Refresh
  'Me.TDBGrid1.Refresh
End Sub

Private Sub TDBGrid1_LostFocus()
  On Error Resume Next

  Dim i As Long
  CalculaTotales
  
  'TDBGrid1.ReBind
  TDBGrid1.Refresh
  Set TDBGrid1.Array = gfax
  TDBGrid1.Update
  
'  TDBGrid1.Array = gfax
'  TDBGrid1.Update
End Sub

Private Sub TDBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
  On Error Resume Next
  Dim a, b, c As Double
  'TDBGrid1.Update
  'TDBGrid1.Refresh
  If IsNull(LastRow) Or IsNull(LastCol) Then Exit Sub
  
  If IsNull(gfax(LastRow, 6)) Or gfax(LastRow, 6) = "" Then gfax(LastRow, 6) = "1.00"
  If IsNull(gfax(LastRow, 7)) Or gfax(LastRow, 7) = "" Then gfax(LastRow, 7) = "0.00"
  If IsNull(gfax(LastRow, 9)) Or gfax(LastRow, 9) = "" Then gfax(LastRow, 9) = "0.00"
  If IsNull(gfax(LastRow, 10)) Or gfax(LastRow, 10) = "" Then gfax(LastRow, 10) = "0.00"
  If IsNull(gfax(LastRow, 0)) Or gfax(LastRow, 0) = "" Then gfax(LastRow, 0) = CStr(LastRow + 1)
  
  If IsNull(gfax(LastRow, 6)) Or gfax(LastRow, 6) = "" Then
    a = 0
  Else
    a = val(Replace(gfax(LastRow, 6), ",", ""))
  End If
  If IsNull(gfax(LastRow, 7)) Or gfax(LastRow, 7) = "" Then
    b = 0
  Else
    b = val(Replace(gfax(LastRow, 7), ",", ""))
  End If
  
  If IsNull(gfax(LastRow, 9)) Or gfax(LastRow, 9) = "" Then
    c = 0
  Else
    c = val(Replace(gfax(LastRow, 9), ",", ""))
  End If
  gfax(LastRow, 10) = Format(a * b * (100 - c) / 100, "0.00")
  'gfax(LastRow, 10) = Format(a * b * (100 - c) / 100, "###,###,###,###,##0.00")
    
  CalculaTotales
  Me.TDBGrid1.Update
  Me.TDBGrid1.Refresh
  
End Sub

Public Sub CalculaTotales()
  On Error Resume Next
  Dim i As Long
  Dim lTotal, lSubtotal, lCant, lPrec, lDscto, lservicio As Double
  Dim sCant, sPrec, sDscto, sFlagServicio As String
  Dim iEfectivoSoles As Double
  
  iEfectivoSoles = 0
  If iTipoVenta = 8 Then
    'txtDolares.Text = Format((lTotal / nTipoCambio), "###,###,###,###,###.00")
  Else
    'TDBGrid1.Update
    'TDBGrid1.Refresh
    lTotal = 0
    For i = gfax.LowerBound(1) To gfax.UpperBound(1)
      sCant = IIf(IsEmpty(gfax(i, 6)), "1.00", gfax(i, 6))
      sPrec = IIf(IsEmpty(gfax(i, 7)), "0.00", gfax(i, 7))
      sDscto = IIf(IsEmpty(gfax(i, 9)), "0.00", gfax(i, 9))
      sFlagServicio = IIf(gfax(i, 13) = "SI", "1", "0")
    
      sCant = IIf(sCant = "", "0.00", sCant)
      sPrec = IIf(sPrec = "", "0.00", sPrec)
      sDscto = IIf(sDscto = "", "0.00", sDscto)
    
      sCant = Replace(sCant, ",", "")
      sPrec = Replace(sPrec, ",", "")
      sDscto = Replace(sDscto, ",", "")
    
      If IsNumeric(sCant) And IsNumeric(sPrec) Then
        lCant = val(sCant)
        lPrec = val(sPrec)
        lDscto = (val(sDscto) / 100 * lCant * lPrec)
        If iTipoVenta = 1 Or iTipoVenta = 2 Or iTipoVenta = 3 Or iTipoVenta = 5 Or iTipoVenta = 4 Then
          lservicio = val(sFlagServicio) * kPAR_PORCSERV / 100
        Else
          lservicio = 0
        End If
                
        lSubtotal = lCant * lPrec
        If gfax(i, 8) = "+" Then
          lSubtotal = lSubtotal + lDscto
        Else
          lSubtotal = lSubtotal - lDscto
        End If
      
        gfax(i, 10) = Format(lSubtotal, "0.00")
        Dim Serv As Double
        Dim Igv As Double
        
        Serv = ((lSubtotal / (kIGV + lservicio + 1))) * lservicio
        Igv = ((lSubtotal / (kIGV + lservicio + 1))) * kIGV
               
        gfax(i, 14) = Format(Serv, "0.00")
        gfax(i, 15) = Format(Igv, "0.00")
        
        lTotal = lTotal + lSubtotal
      End If
    Next
    
     txtSoles.Text = Format(Abs(lTotal), "0.00")
     txtDolares.Text = Format(Abs(lTotal / nTipoCambio), "0.00")
  End If
  
  CalculoVuelto
  
  ' vd 05-09-07
  'TDBGrid1.Update
  'TDBGrid1.Refresh
End Sub


Private Sub CalculoVuelto()

  If Trim(txtEfectivoSoles.Text) = "" Then txtEfectivoSoles.Text = "0.00"
  If Trim(txtEfectivoDolares.Text) = "" Then txtEfectivoDolares.Text = "0.00"
  If Trim(txtVueltoDolares.Text) = "" Then txtVueltoDolares.Text = "0.00"
  'txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "0.00")
  txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "0.00")
  If val(Replace(txtEfectivoDolares, ",", "")) <= val(Replace(txtVueltoDolares, ",", "")) Then
    txtVueltoDolares.Text = "0.00"
  End If
  
  If ((val(Replace(txtEfectivoDolares, ",", "")) - val(Replace(txtVueltoDolares, ",", ""))) * nTipoCambio) >= val(Replace(txtSoles, ",", "")) Then
    txtEfectivoSoles.Text = "0.00"
  End If
      
  If (iTipoVenta = 1 Or iTipoVenta = 4 Or iTipoVenta = 8) And (Trim(txtEfectivoSoles.Tag) = "") Then
    
    txtEfectivoSoles.Text = Format(val(Replace(txtSoles, ",", "")) - _
                            val(Replace(txtEfectivoDolares, ",", "")) * nTipoCambio + _
                            val(Replace(txtVueltoDolares, ",", "")) * nTipoCambio + _
                            val(Replace(txtVueltoSoles, ",", "")), "0.00")
                            'Val(Replace(txtVueltoSoles, ",", "")), "0.00")
      
    If val(Replace(txtEfectivoSoles.Text, ",", "")) < 0 Then
      'txtVueltoSoles.Text = Format(-Val(Replace(txtEfectivoSoles.Text, ",", "")), "0.00")
      txtVueltoSoles.Text = Format(-val(Replace(txtEfectivoSoles.Text, ",", "")), "0.00")
      txtEfectivoSoles.Text = "0.00"
    End If
    
  End If
  
  EfectivoSolesCambia
  
End Sub

Private Sub TotalCambia()
  If Trim(txtEfectivoSoles.Text) = "" Then txtEfectivoSoles.Text = "0.00"
  If Trim(txtEfectivoDolares.Text) = "" Then txtEfectivoDolares.Text = "0.00"
  If Trim(txtVueltoDolares.Text) = "" Then txtVueltoDolares.Text = "0.00"
  'txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "0.00")
  txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "0.00")
      
  If iTipoVenta = 1 Or iTipoVenta = 4 Or iTipoVenta = 8 Then
           
    txtEfectivoSoles.Text = Format(val(Replace(txtSoles, ",", "")) - _
                            val(Replace(txtEfectivoDolares, ",", "")) * nTipoCambio + _
                            val(Replace(txtVueltoDolares, ",", "")) * nTipoCambio, "0.00")
                            
    txtVueltoSoles = "0.00"
    'Val(Replace(txtVueltoDolares, ",", "")) * nTipoCambio, "0.00")
  End If
  
End Sub

Private Sub EfectivoSolesCambia()
  If Trim(txtEfectivoSoles.Text) = "" Then txtEfectivoSoles.Text = "0.00"
  If Trim(txtEfectivoDolares.Text) = "" Then txtEfectivoDolares.Text = "0.00"
  If Trim(txtVueltoDolares.Text) = "" Then txtVueltoDolares.Text = "0.00"
  'txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "0.00")
  txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "0.00")
      
  If iTipoVenta = 1 Or iTipoVenta = 4 Or iTipoVenta = 8 Then
           
    txtVueltoSoles = Format(val(Replace(txtEfectivoSoles, ",", "")) + _
                     val(Replace(txtEfectivoDolares, ",", "")) * nTipoCambio - _
                     val(Replace(txtVueltoDolares, ",", "")) * nTipoCambio - _
                     val(Replace(txtSoles, ",", "")), "0.00")
                                                                           
  End If
  'Val(Replace(txtSoles, ",", "")), "0.00")
End Sub

Private Sub RegistraVenta()
  'GoTo prueba
  On Error GoTo LineaError
  
  Dim sSQL As String
  Dim ADORS As ADODB.Recordset
  Dim i As Long, j As Long, iCodOper As Long, iCodOperRela As Long
  Dim iTotal, iTotalVenta As Double, iSubTotal As Double, iSubTotalDscto As Double
  Dim iTotalDscto As Double, iTotItems As Double
  Dim sFecha As String
  Dim sTexto As String
  Dim iSigno As Integer
  Dim iFlagTipo As Integer
  Dim sTarjeta As String
  Dim ivuelto_1 As Double
  Dim iMontoDolares As Double
  Dim iMontoSoles As Double
  Dim iDolaresEfectivo As Double
  Dim iSolesEfectivo As Double
  Dim rs1 As Recordset
  Dim p_1 As Integer
  Dim impr_1 As String
  Dim impr_2 As String
  Dim nImporte As Double, iServicio, nPuntos As Double, nPtosImp As Double
  Dim iPtoVta, iPtoItm As Double, iPagoAdelantado As Double
  Dim blLiquidaVenta As Boolean
  Dim Texto_imprimir As String
  Dim iPuntos As Long
  Dim sssql As String
  Dim blnfactura As Boolean
  Dim intPuntosAcumulados As Long
  Dim x As printer
  
  Dim cEmisor As String
  Dim cDocCodigofull As Long
  Dim cDocSerie As String
  Dim cdocTipo As String
  Dim cRuc As String
  Dim IGV_1 As Double
  blLiquidaVenta = False
  blnfactura = False
  Dim KSERIE_PARALELO As String
  
  'sw To SQL Server add
  Dim idLocal As String
  
  TDBGrid1.Update
  If piEmitevoucher <> 1 Then
    CalculaTotales
    CalculoVuelto
  End If
  cDocCodigofull = 0
  p_1 = 0
  
  ConectarBDCliente
  'Verifica si es Factura
  If Not Trim(Me.txtRUC.Text) = "" Then
    blnfactura = True
    cRuc = Trim(Me.txtRUC.Text)
    cdocTipo = "01"
    cDocSerie = kSERIE_FACTURA
  Else
    cRuc = ""
    cdocTipo = "02"
    cDocSerie = kSERIE
  End If
  
  '--------------------
  '-- Registra Venta --
  '--------------------

   'SE OBTIENE FECHA DEL SISTEMA DE LA BASE DE DATOS DE SQL - version 2.0.5
   
   Dim cnFECHASQL As ADODB.Connection
   Dim sqlFECHASIS As String
   Dim rsFEchaSis As ADODB.Recordset
      
   If oDBAdmin.AbrirBD(cnFECHASQL, psConnectString, False) = True Then
     
     sqlFECHASIS = "select convert(varchar,getdate(),120) as fechasis"
     If oDBAdmin.EjecutarConsulta(cnFECHASQL, sqlFECHASIS, rsFEchaSis) = True Then
         
         If rsFEchaSis!fechasis <> "" Then
             sFecha = rsFEchaSis!fechasis
         End If

     Else
         'no pudo abrir el rs: que consulte al access
         'MsgBox "No se pudo obtener la fecha, hay problemas de conexión de la red con la Base de Datos Principal", vbOKOnly + vbExclamation, "Aviso"
         sFecha = Format(Now(), "DD/MM/YYYY hh:mm")
         'Unload Me
     End If

     Set cnFECHASQL = Nothing

   Else
     'no pudo conectarse al sql: que consulte al access
      'MsgBox "No se pudo obtener la fecha, hay problemas de conexión de la red con la Base de Datos Principal", vbOKOnly + vbExclamation, "Aviso"
      sFecha = Format(Now(), "DD/MM/YYYY hh:mm")
      'Unload Me
   End If
   
   'obtencion fecha version 2.0.4
   'sFecha = Format(Now(), "DD/MM/YYYY hh:mm")

  Set ADORS = Nothing
  
  iFlagTipo = iTipoVenta
  If iTipoVenta = 4 Then
    iSigno = -1
    iFlagTipo = 1
  Else
    iSigno = 1
    iFlagTipo = iTipoVenta
  End If
  If iTipoVenta = 5 Then
    iFlagTipo = 1
  End If
  
  iCodOperRela = 0
  
  'vd 05/08/07 TDBGrid1.Update
      
  'Verifica si es un tipo de operaciòn que necesita password: Anulación o Descuento
  For i = gfax.LowerBound(1) To gfax.UpperBound(1)
    sTexto = IIf(Replace(gfax(i, 9), ",", "") = "", "0", Replace(gfax(i, 9), ",", ""))
    If val(sTexto) <> 0 Then
      bAcceso = True
      Exit For
    End If
  Next
  
  If bAcceso Then
    bAcceso = False
    Load frmAutorizarOperacion
    Set frmAutorizarOperacion.frmPadre = Me
    frmAutorizarOperacion.Show vbModal
    If Not bAcceso Then Exit Sub
    'bAcceso = False
  End If
  
  '--------Abre la gaveta de dinero automaticamente al aceptar la venta ----
  Dim opc_gaveta As String
  opc_gaveta = LeerCfg("PARAMETROS", "GAVETA", psArchivoCfg)
  If Trim(UCase(opc_gaveta)) = "S" Then
    Abre_Gaveta_Dinero (LeerCfg("PARAMETROS", "PRINTER", psArchivoCfg))
  End If
  '-------------------------------------------------------------------------
  If iTipoVenta = 6 Or iTipoVenta = 7 Then
    If Not IsNumeric(Replace(IIf(txtPagoAdelantado = "", "0.00", txtPagoAdelantado), ",", "")) Then Exit Sub
    If Not IsNumeric(Replace(IIf(txtPADEDolares = "", "0.00", txtPADEDolares), ",", "")) Then Exit Sub
    If val(Replace(IIf(txtPagoAdelantado = "", "0.00", txtPagoAdelantado), ",", "")) = 0 And _
       val(Replace(IIf(txtPADEDolares = "", "0.00", txtPADEDolares), ",", "")) = 0 Then
      MsgBox "Debe registar una cantidad mayor que cero."
      txtPagoAdelantado.SetFocus
      Exit Sub
    End If
  End If
 
  'Calculo de vueltos
  Dim iVueltoSoles As Double
  
  If iTipoVenta = 1 Or iTipoVenta = 4 Then   'Or iTipoVenta = 8
    If Trim(Me.txtEfectivoDolares.Text) = "" Then Me.txtEfectivoDolares.Text = "0.00"
    If Trim(Me.txtEfectivoSoles.Text) = "" Then Me.txtEfectivoSoles.Text = "0.00"
    
    If val(Replace(Me.txtEfectivoDolares.Text, ",", "")) = 0 And _
      val(Replace(Me.txtEfectivoSoles.Text, ",", "")) = 0 Then
      Me.txtEfectivoSoles.Text = Me.txtSoles
    End If
  End If

  'Configura la Impresora por default
  'sw 1 = Efectivo
  'sw 2 = VOUCHER
  'sw 3 = O/C
  'sw 4 = N/C
  'sw 5 = PADE
  'sw 6 = PADV
  'sw 7 = LIQPAD
  'sw 8 = ANULAR TRANSACCION
  'sw 9 = RECAUDACION
  
  Select Case iTipoVenta
    Case 4, 5, 6, 7, 8
      If iTipoVenta = 4 Then iTipoVenta = 20 ' O/C
      If iTipoVenta = 5 Then iTipoVenta = 21 ' N/C
      If iTipoVenta = 6 Then iTipoVenta = 22 ' PADE
      If iTipoVenta = 7 Then iTipoVenta = 23 ' PADV
      If iTipoVenta = 8 Then iTipoVenta = 24 ' LIQPAD
      ConfiguraImpresora kPAR_IMPRESORA_ALTERNA
    Case Else
      ConfiguraImpresora kPAR_IMPRESORA
  End Select
  
  Select Case iTipoVenta
    Case 20, 21, 22, 23, 24
      sSQL = "SELECT MAX(cOperCode) AS maximo FROM OperacionParalela"
    Case Else
      sSQL = "SELECT MAX(cOperCode) AS maximo FROM Operacion"
  End Select
  
  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir

  If ADORS.RecordCount = 1 Then
    If IsNull(ADORS("maximo")) Then
      iCodOper = 1
    Else
      iCodOper = LeerCampo(ADORS("maximo")) + 1
      'EscribirCfg "PARAMETROS", "cOpeB", psArchivoCfg, Str(iCodOper + 1)
    End If
  End If
  
  'Inicializa Recorset
  If iTipoVenta <> 2 And piEmitevoucher <> 1 Then
    Set rsPagTar = New Recordset
  End If

  If iCodOper = 1 Then
'    kOPERACION = LeerCfg("PARAMETROS", "cOpeB", psArchivoCfg)
'    iCodOper = Val(kOPERACION)
  End If
  
  'Si hay vuelto se convierte en iTipo = 5
  If iTipoVenta = 1 And (val(Replace(txtVueltoSoles, ",", "")) <> 0 Or val(Replace(txtVueltoDolares, ",", "")) <> 0) Then
    iTipoVenta = 5
  End If
  
  'Asigna valor para liquidar NC
  If iTipoVenta = 24 Then blLiquidaVenta = True
    
  'Registra los datos del producto
  If iTipoVenta = 22 Or iTipoVenta = 23 Or iTipoVenta = 24 Then
    nProducto = -1
  Else
    ReDim Producto(gfax.UpperBound(1))
    
    For i = gfax.LowerBound(1) To gfax.UpperBound(1)
      Producto(i).Almacen = kPAR_ALMACEN
      Producto(i).Cant = Replace(gfax(i, 6), ",", "")
      Producto(i).PUnit = Replace(gfax(i, 7), ",", "")
      Producto(i).Codigo = gfax(i, 1)
      Producto(i).nombre = gfax(i, 3)
      If gfax(i, 8) = "+" Then
        Producto(i).Dscto = Replace(IIf(gfax(i, 9) = "", 0, gfax(i, 9)), ",", "")
      Else
        Producto(i).Dscto = -1 * Replace(IIf(gfax(i, 9) = "", 0, gfax(i, 9)), ",", "")
      End If
      
      Producto(i).Canje = gfax(i, 11)
      Producto(i).Ptos = val(Replace(gfax(i, 12), ",", ""))
      Producto(i).Serv = gfax(i, 13)
    Next
    nProducto = gfax.UpperBound(1)
  End If
  
  
    
  If Trim(txtTarjeta.Text) <> "" Then
    sTarjeta = Right("00000000" + Trim(txtTarjeta.Text), 8)
  Else
    sTarjeta = ""
  End If
  
  'sw To SQL Server add
  idLocal = IIf(Trim(Me.txtLocal.Text) = "", "NULL", Trim(Me.txtLocal.Text))
  
  'Calcula el total de las ventas
  iTotalVenta = Replace(txtSoles, ",", "")
  'lblTotal.Caption = "TOT:" + Right("               " + Format(CStr(iTotalVenta), "0.00"), 14)
  
  'Captura Serie y Codigo del Documento
  
  Select Case iTipoVenta
    Case 20
      cdocTipo = "10"
    Case 21
      cdocTipo = "11"
   Case 22
      cdocTipo = "12"
   Case 23
      cdocTipo = "13"
   Case 24
      cdocTipo = "14"
  End Select
  

  
  Dim dbCalculado As Boolean
  Dim ddtotefectivo, ddtotvuelto As Double
  Dim mon As Integer
  Dim ierroritm As Integer
  ierroritm = 0
  dbCalculado = False
  
  Do While dbCalculado = False And ierroritm < 3
    Select Case iTipoVenta
      Case 20, 21, 22, 23, 24
        If iTipoVenta = 22 Or iTipoVenta = 23 Then 'PADE o PADV
          iDolaresEfectivo = val(Replace(txtPADEDolares, ",", ""))
          iEfectivo = val(Replace(txtPagoAdelantado, ",", ""))
          If iEfectivo > 0 Then
            mon = 1
          End If
          If iDolaresEfectivo > 0 Then
            mon = 2
          End If
          If mon = 1 Then 'Soles
            iTotal = val(Replace(txtPagoAdelantado, ",", ""))
            iMontoDolares = CDbl(Format(CStr(iTotal / nTipoCambio), "0.00"))
            'iMontoDolares = CDbl(Format(CStr(iTotal / nTipoCambio), "0.00"))
          End If
          If mon = 2 Then 'Dolares
            iMontoDolares = val(Replace(txtPADEDolares, ",", ""))
            iTotal = CDbl(Format(CStr(iMontoDolares * nTipoCambio), "0.00"))
            'iTotal = CDbl(Format(CStr(iMontoDolares * nTipoCambio), "0.00"))
          End If
          
          iSolesEfectivo = iEfectivo
          iVuelto = 0
          iVueltoDolares = 0
        Else
          
          iTotal = val(Replace(txtSoles, ",", ""))
          iMontoDolares = val(Replace(txtDolares, ",", ""))
          If piEmitevoucher = 1 And blLiquidaVenta = True Then
            iDolaresEfectivo = val(Replace(txtliqefectivodolares, ",", ""))
            iSolesEfectivo = val(Replace(txtliqefectivosoles, ",", ""))
            iEfectivo = val(Replace(txtliqefectivosoles, ",", ""))
            iVuelto = val(Replace(txtliqvueltosoles, ",", ""))
            iVueltoDolares = val(Replace(ttxliqvueltodolares, ",", ""))
          Else
            iDolaresEfectivo = val(Replace(txtEfectivoDolares, ",", ""))
            iSolesEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
            iEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
            iVuelto = val(Replace(txtVueltoSoles, ",", ""))
            iVueltoDolares = val(Replace(txtVueltoDolares, ",", ""))
          End If
          If iVuelto < 0 Then iVuelto = 0
          If iDolaresEfectivo < 0 Then iDolaresEfectivo = 0
          If iVueltoDolares < 0 Then iVueltoDolares = 0
          If iTipoVenta = 21 Then iCodOperRela = val(txtTX.Text)
          If iTipoVenta = 20 And Trim(txtLiq.Text) <> "" Then iCodOperRela = val(txtLiq.Text)
        End If
      Case Else
        iVuelto = val(Replace(txtVueltoSoles, ",", ""))
        iTotal = val(Replace(txtSoles, ",", ""))
        If iVuelto < 0 Then iVuelto = 0
        If piEmitevoucher = 1 And bLiquidaNC Then
          iEfectivo = val(Replace(txtliqefectivosoles, ",", ""))
          iDolaresEfectivo = val(Replace(txtliqefectivodolares, ",", ""))
          iVueltoDolares = val(Replace(ttxliqvueltodolares, ",", ""))
          iVuelto = val(Replace(Me.txtliqvueltosoles, ",", ""))
        Else
          iEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
          iDolaresEfectivo = val(Replace(txtEfectivoDolares, ",", ""))
          iSolesEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
          iVueltoDolares = val(Replace(txtVueltoDolares, ",", ""))
        End If
        If iVueltoDolares < 0 Then iVueltoDolares = 0
    End Select
    
    ddtotefectivo = Round(iSolesEfectivo + (iDolaresEfectivo * nTipoCambio), 2)
    ddtotvuelto = Round(iVuelto + (iVueltoDolares * nTipoCambio), 2)
    
    If (iTipoVenta <> 2 And iTipoVenta <> 22 And iTipoVenta <> 23 And iTipoVenta <> 21 And iTipoVenta <> 24) And (Round(ddtotefectivo - ddtotvuelto, 2) <> Round(iTotal, 2)) Then
      MsgBox "Ocurrio un error de Cálculo"
      dbCalculado = False
      ierroritm = ierroritm + 1
    Else
      dbCalculado = True
      ierroritm = 0
    End If
  Loop
  '------------------------
  '-- Captura Parámetros --
  '------------------------
  Texto_imprimir = ""
  Call CabeceraImpresion
  sTexto = ""
  
  sssql = "SELECT sImpresora, sImpresoraAlterna from Configuracion"
  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sssql, rs1) Then GoTo Salir
  impr_1 = rs1.Fields("sImpresora")
  impr_2 = rs1.Fields("sImpresoraAlterna")
  
  'Pregunta si x.Devicename tiene el mismo nombre que el nombre de la impresora por donde necesitas sacar la impresion.
  If iTipoVenta = 1 Or iTipoVenta = 2 Or iTipoVenta = 5 Then
    p_1 = 1
  Else
    p_1 = 2
  End If
  
  printer.FontSize = 8 '11
  printer.FontName = "Courier New"
  
  Select Case iTipoVenta
    Case 20, 21, 22, 23, 24
    Case Else
      For i = 0 To UBound(sCabecera) - 1
        If Not Trim(sCabecera(i)) = "" Then
          sTexto = sTexto + Right(Space(60) + sCabecera(i), Int(Len(Space(40) + sCabecera(i)) / 2)) + vbCrLf
        End If
      Next
  End Select
  
  'Linea de Datos del Socio
  If Not sTarjeta = "" Then
    sTexto = sTexto + vbCrLf + " COD.TARJ.: " + sTarjeta + " "
    If Not blnfactura = True Then
      sTexto = sTexto + vbCrLf + " NOMBRE: " + txtNombres.Text + vbCrLf
    End If
  Else
    If Not blnfactura = True And Not Trim(txtNombres.Text) = "" Then
      sTexto = sTexto + vbCrLf + " NOMBRE: " + UCase(Trim(txtNombres.Text)) + vbCrLf
    End If
  End If
  
  If blnfactura = True Then
    sTexto = sTexto + vbCrLf + " NOMBRE: " & "____________________________"
    sTexto = sTexto + vbCrLf + vbCrLf + "         " & "____________________________" + vbCrLf
    sTexto = sTexto + vbCrLf + " RUC Cliente: " & Trim(Me.txtRUC.Text) + vbCrLf
  End If
  
  ' Obteniendo Nro de documento
  sSQL = "SELECT  * FROM Config_Documento WHERE cTipoDoc='" & IIf(cdocTipo = "01", "02", cdocTipo) & "'"
  '
  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
     
     

  If blnfactura = True Then
    If ADORS.EOF Then
      'kSERIE_FACTURA = "F01"
      kSERIE_FACTURA = Right("000" & Right(kPAR_CAJA, 2), 3)
      sSQL = "INSERT INTO Config_Documento (cTipoDoc,cOperCode,nDocCodigo,cSerieDoc,cUserDesc,dUltAct,observacion) " & _
             " VALUES ('01',0, 0, 'F01','',#" & Date & "#,'Primer Registro') "
             
             
      If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
      cDocCodigofull = 1
    Else
      kSERIE_FACTURA = LeerCampo(ADORS!cSerieDoc)
      cDocCodigofull = LeerCampo(ADORS!nDocCodigo) + 1
    End If
    cDocSerie = kSERIE_FACTURA
  Else
    Select Case cdocTipo
      Case "10"
        If ADORS.EOF Then
          KSERIE_PARALELO = "OC1"
          sSQL = "INSERT INTO Config_Documento (cTipoDoc,cOperCode,nDocCodigo,cSerieDoc,cUserDesc,dUltAct,observacion) " & _
                 " VALUES ('10',0, 0, 'OC1','',#" & Date & "#,'Primer Registro') "
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
          cDocCodigofull = 1
        Else
          KSERIE_PARALELO = LeerCampo(ADORS!cSerieDoc)
          cDocCodigofull = LeerCampo(ADORS!nDocCodigo) + 1
        End If
        cDocSerie = KSERIE_PARALELO
            
      Case "11"
        If ADORS.EOF Then
          KSERIE_PARALELO = "NC1"
          sSQL = "INSERT INTO Config_Documento (cTipoDoc,cOperCode,nDocCodigo,cSerieDoc,cUserDesc,dUltAct,observacion) " & _
                 " VALUES ('11',0, 0, 'NC1','',#" & Date & "#,'Primer Registro') "
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
          cDocCodigofull = 1
        Else
          KSERIE_PARALELO = LeerCampo(ADORS!cSerieDoc)
          cDocCodigofull = LeerCampo(ADORS!nDocCodigo) + 1
        End If
        cDocSerie = KSERIE_PARALELO
            
      Case "12"
        If ADORS.EOF Then
          KSERIE_PARALELO = "PA1"
          sSQL = "INSERT INTO Config_Documento (cTipoDoc,cOperCode,nDocCodigo,cSerieDoc,cUserDesc,dUltAct,observacion) " & _
                 " VALUES ('12',0, 0, 'PA1','',#" & Date & "#,'Primer Registro') "
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
          cDocCodigofull = 1
        Else
          KSERIE_PARALELO = LeerCampo(ADORS!cSerieDoc)
          cDocCodigofull = LeerCampo(ADORS!nDocCodigo) + 1
        End If
        cDocSerie = KSERIE_PARALELO
            
      Case "13"
        If ADORS.EOF Then
          KSERIE_PARALELO = "PV1"
          sSQL = "INSERT INTO Config_Documento (cTipoDoc,cOperCode,nDocCodigo,cSerieDoc,cUserDesc,dUltAct,observacion) " & _
                 " VALUES ('13',0, 0, 'PV1','',#" & Date & "#,'Primer Registro') "
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
          cDocCodigofull = 1
        Else
          KSERIE_PARALELO = LeerCampo(ADORS!cSerieDoc)
          cDocCodigofull = LeerCampo(ADORS!nDocCodigo) + 1
        End If
        cDocSerie = KSERIE_PARALELO
          
      Case "14"
        If ADORS.EOF Then
          KSERIE_PARALELO = "LQ1"
          sSQL = "INSERT INTO Config_Documento (cTipoDoc,cOperCode,nDocCodigo,cSerieDoc,cUserDesc,dUltAct,observacion) " & _
                 " VALUES ('14',0, 0, 'LQ1','',#" & Date & "#,'Primer Registro') "
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
          cDocCodigofull = 1
        Else
          KSERIE_PARALELO = LeerCampo(ADORS!cSerieDoc)
          cDocCodigofull = LeerCampo(ADORS!nDocCodigo) + 1
        End If
        cDocSerie = KSERIE_PARALELO
          
      Case Else
        If ADORS.EOF Then
          'kSERIE = "B01"
          kSERIE = Right("00" & Right(kPAR_CAJA, 2), 3)
          sSQL = "INSERT INTO Config_Documento (cTipoDoc,cOperCode,nDocCodigo,cSerieDoc,cUserDesc,dUltAct,observacion)" & _
                 " VALUES ('02',0, 0, 'B01', '', #" & Date & "#,'Primer Registro') "
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
          cDocCodigofull = 1
        Else
          kSERIE = LeerCampo(ADORS!cSerieDoc)
          cDocCodigofull = LeerCampo(ADORS!nDocCodigo) + 1
        End If
        cDocSerie = kSERIE
    End Select
  End If
  
  '------------------Validacion de Numeración Correlativa ----------------------------
    Dim NameArchivo As String
    Dim archivo
    Dim Texto As String
    Dim fso, MyFile
    
  If cdocTipo = "01" Or cdocTipo = "02" Then
    ' ES OPERACION
    'tendria que preguntar primero si hay valor en venta01 del sql para la caja
      Dim cnSQL As ADODB.Connection
      Dim rsVenta01 As ADODB.Recordset
      Dim bValorSQL As Boolean
      Dim nValorSQL As Long
      bValorSQL = False
      
      
      If oDBAdmin.AbrirBD(cnSQL, psConnectString, False) = True Then
        'sSQL = "select isnull(max(cast(NroDoc as int)),0) as maximo from venta01  WHERE cCodCaja='" & kPAR_CAJA & "' AND TipoDoc = '" & cdocTipo & "'"
        sSQL = "select isnull(max(cast(NroDoc as int)),0) as maximo from venta01  WHERE cCodCaja='" & kPAR_CAJA & "' AND TipoDoc in ('01','02')"
        If oDBAdmin.EjecutarConsulta(cnSQL, sSQL, rsVenta01) = True Then
            If rsVenta01!Maximo = 0 Then
                'no hay nada para la caja y el tipo de documento en sql
            Else
                'si hay, y el valor a actualizar en ndoccodigo de configdocumento deberia ser el valor retornado
                bValorSQL = True
                nValorSQL = rsVenta01!Maximo
            End If
        Else
            'no pudo abrir el rs: que consulte al access nomas
            
        End If

        Set cnSQL = Nothing
      Else
        'no pudo conectarse al sql: que consulte al access nomas
        
      End If
  
      
      If bValorSQL = True Then
      
         'aca tendria que preguntar si el codigo del access es mayor, si es asi manda el del access
        'sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo = '" & cdocTipo & "'"

        'sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo IN ('01','02') "
         sSQL = "SELECT IIf(MAX(cDocCodigo) Is Null, 0, MAX(cDocCodigo)) as Maximo FROM Operacion WHERE cDocTipo IN ('01','02') "
        If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
        Dim nValorAccess As Long
        nValorAccess = val(ADORS!Maximo)
        If nValorAccess > nValorSQL Then
            nValorSQL = nValorAccess
        End If
        
        If val(cDocCodigofull) <> val("0" & (nValorSQL) + 1) And val("0" & nValorSQL) > 0 Then
'          Dim NameArchivo As String
'          Dim archivo
'          Dim Texto As String
'          Dim fso, MyFile
          
          cDocCodigofull = nValorSQL + 1
          
          Set fso = CreateObject("Scripting.FileSystemObject")
          archivo = "Error_Full_1" & cdocTipo & cDocCodigofull
          If Trim(archivo) = "" Then
              archivo = "textfile"
          End If
          Texto = Texto + "Codigo generado " & cDocCodigofull & Chr(13)
          
          NameArchivo = "C:\Temp\" + Trim(archivo) + ".log"
          Set MyFile = fso.CreateTextFile(NameArchivo, True)
          cDocCodigofull = ("0" & (rsVenta01!Maximo)) + 1
          Texto = Texto + "Nuevo Codigo " & cDocCodigofull & Chr(13)
          Texto = Texto + CStr(Now)
          MyFile.WriteLine (Texto)
          MsgBox "Ocurrio un error en la numeración, se asignará el " & cDocCodigofull & " al documento "
          MyFile.Close
        End If
      
      Else
        'sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo = '" & cdocTipo & "'"
        sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo IN ('01','02')"
        If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
        If val(cDocCodigofull) <> val("0" & (ADORS!Maximo) + 1) And val("0" & ADORS!Maximo) > 0 Then
'          Dim NameArchivo As String
'          Dim archivo
'          Dim Texto As String
'          Dim fso, MyFile
          
          
          Set fso = CreateObject("Scripting.FileSystemObject")
          archivo = "Error_Full_1" & cdocTipo & cDocCodigofull
          If Trim(archivo) = "" Then
              archivo = "textfile"
          End If
          Texto = Texto + "Codigo generado " & cDocCodigofull & Chr(13)
          
          NameArchivo = "C:\Temp\" + Trim(archivo) + ".log"
          Set MyFile = fso.CreateTextFile(NameArchivo, True)
          cDocCodigofull = ("0" & (ADORS!Maximo)) + 1
          Texto = Texto + "Nuevo Codigo " & cDocCodigofull & Chr(13)
          Texto = Texto + CStr(Now)
          MyFile.WriteLine (Texto)
          MsgBox "Ocurrio un error en la numeración, se asignará el " & cDocCodigofull & " al documento "
          MyFile.Close
        End If
  
  
      End If
    
  Else
    'ES OPERACION PARALELA
        sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM OperacionParalela WHERE cDocTipo = '" & cdocTipo & "'"
  
  
        If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
        If val(cDocCodigofull) <> val("0" & (ADORS!Maximo) + 1) And val("0" & ADORS!Maximo) > 0 Then

          Set fso = CreateObject("Scripting.FileSystemObject")
          archivo = "Error_Full_1" & cdocTipo & cDocCodigofull
          If Trim(archivo) = "" Then
            archivo = "textfile"
          End If
          Texto = Texto + "Codigo generado " & cDocCodigofull & Chr(13)
          
          NameArchivo = "C:\Temp\" + Trim(archivo) + ".log"
          Set MyFile = fso.CreateTextFile(NameArchivo, True)
          cDocCodigofull = ("0" & (ADORS!Maximo)) + 1
          Texto = Texto + "Nuevo Codigo " & cDocCodigofull & Chr(13)
          Texto = Texto + CStr(Now)
          MyFile.WriteLine (Texto)
          MsgBox "Ocurrio un error en la numeración, se asignará el " & cDocCodigofull & " al documento "
          MyFile.Close
        End If
  
  
  End If
  '---------------Actualizando el valor de la numeración ----------------
  sSQL = "UPDATE Config_Documento " & _
         " SET cSerieDoc='" & cDocSerie & "'," & _
         " nDocCodigo=" & cDocCodigofull & " " & _
         " WHERE cTipodoc='" & IIf(cdocTipo = "01", "02", cdocTipo) & "'"
  If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
  '------------------Impresión de Ticket----------------------------
  
  
  If blnfactura = True Then
    sTexto = sTexto + vbCrLf + " TK NRO: " & kSERIE_FACTURA & "-" & Right("000000" & CStr(cDocCodigofull), 6) & " NS:" & kSERIE_DISCO_DURO
  Else
    Select Case iTipoVenta
      Case 20, 22, 23, 24, 21
        sTexto = sTexto + vbCrLf + " TK NRO: " & KSERIE_PARALELO & "-" & Right("000000" & CStr(cDocCodigofull), 6) & " NS:" & kSERIE_DISCO_DURO1
      Case Else
        sTexto = sTexto + vbCrLf + " TK NRO: " & kSERIE & "-" & Right("000000" & CStr(cDocCodigofull), 6) & " NS:" & kSERIE_DISCO_DURO
    End Select
  End If
  
  'Printer.Print sTexto
  Texto_imprimir = Texto_imprimir + vbCrLf + sTexto
  sTexto = ""
  
  'Cabecera segun tipo de venta
  Select Case iTipoVenta
    Case 2 'Voucher
      sTexto = "VOUCHER"
      sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
    Case 1, 5 ' EFECTIVO EX Dolares
      If iDolaresEfectivo > 0 Then
        sTexto = "U$(TC: " + Format(CStr(nTipoCambio), "###,##0.00") + ")"
        sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
      End If
    Case 4 'Anula Productos
      sTexto = "ANULA PROD"
      sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
    Case 20 'O/C
      sTexto = "O/C"
      sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
    Case 21 'NC
      sTexto = "N/C"
      sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
    Case 22 'PADE
      sTexto = "PADE"
      sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
    Case 23 'PADV
      sTexto = "PADV"
      sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
    Case 24 'LIQ
      sTexto = "LIQPAD"
      sTexto = Right(Space(60) + sTexto, Int(Len(Space(40) + sTexto) / 2)) + vbCrLf
  End Select
  'Printer.Print sTexto
  Texto_imprimir = Texto_imprimir + vbCrLf + sTexto + vbCrLf
  sTexto = ""
  
  'Ancho de linea = 27
  
  iSubTotal = 0
  If iTipoVenta <> 22 And iTipoVenta <> 23 Then
    iTotal = 0
  End If
  iTotItems = 0
  iTotalDscto = 0
  iServicio = 0
  iPtoItm = 0
  iPtoVta = 0
    
    
  '<<<<<<<<<<<<<<<<<<<<<<<<<-------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>
  
  If iTipoVenta = 22 Or iTipoVenta = 23 Or iTipoVenta = 24 Then
    If iTipoVenta = 24 Then
      iTotal = val(Replace(txtPagoAdelantado, ",", ""))
    End If
    
    'Detalle de los N/C relacionados
    Dim iOperNC As Long
    Dim nSubtotal As Double
    Dim nItems As Long
    Dim nPrecUnit As Long
    'Dim nItems As Long
    Dim sProdDescCrta As String
    Dim sProdDesc As String
    Dim nDscto As Double
    Dim sTeclDesc As String
    Dim toti As Double
    Dim isubtotal_1 As Double
    Dim PUnit As Double
    
    If iTipoVenta = 24 Then
      iTotal = 0
      iTotItems = 0
      
      sTexto = sTexto + "Producto         Cant Precio  SubTotal " + vbCrLf
      sTexto = sTexto + "---------------------------------------" + vbCrLf
      
      For i = 1 To lvwTX(1).ListItems.Count
        iOperNC = lvwTX(1).ListItems(i).Text
        sSQL = " SELECT O.cOperCode, O.cProdCode, O.nProdCant, O.nProdPrecUnit, O.nDscto,P.sProdDesc, P.sProdDescCrta," & _
               " O.nProdCant * O.nProdPrecUnit As TotalMonto," & _
               " c.cTeclCode , c.sTeclDesc FROM OperacionParalelaProducto O INNER JOIN" & _
               " (Producto P LEFT JOIN ConfiguracionTeclado AS C ON P.cProdCode = C.cProdCode)" & _
               " ON O.cProdCode = P.cProdCode AND O.cAlmaCode = P.cAlmaCode" & _
               " Where cOperCode = " + CStr(iOperNC)
                'O.nProdCant * O.nProdPrecUnit * (100 - O.nDscto) / 100 As TotalMonto,
        If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
  
        nSubtotal = 0
        sTexto = sTexto + "TX" + CStr(iOperNC) + vbCrLf
        Do While Not ADORS.EOF
          nItems = LeerCampo(ADORS("nProdCant"))
          PUnit = LeerCampo(ADORS("nProdPrecUnit"))
          sProdDescCrta = LeerCampo(ADORS("sProdDescCrta"))
          sProdDesc = LeerCampo(ADORS("sProdDesc"))
          
          nDscto = LeerCampo(ADORS("nDscto"))
          If nDscto > 0 Then
            PUnit = PUnit * nDscto / 100 + PUnit
          End If
                    
          sTexto = sTexto + Left(sProdDescCrta + Space(16), 16) & _
                    " " + Right(Space(4) & CStr(nItems), 4) & _
                    " " + Right(Space(6) & Format(CStr(PUnit), "0.00"), 6) & _
                    " " + Right(Space(9) & Format(CStr(PUnit * nItems), "0.00"), 9) + vbCrLf
          If nDscto < 0 Then
             sTexto = sTexto + Left("*Dscto " + CStr(Abs(nDscto)) + " %" + Space(16), 16) & _
                      " " + Space(11) & _
                      " " + Right(Space(9) & Format(CStr(PUnit * nItems * nDscto / 100), "0.00"), 9) + vbCrLf
             PUnit = PUnit * nDscto / 100 + PUnit
                     
          End If
          nSubtotal = nSubtotal + (PUnit * nItems)
          
          ADORS.MoveNext
          iTotItems = iTotItems + nItems
        Loop
        sTexto = sTexto + Chr(13) + Left(" AV./ITEM" & Space(23), 23) + Right(Space(15) & Format(CStr(nItems), "0.00"), 15) + vbCrLf
        iTotal = iTotal + nSubtotal
      Next
    End If
    '----------------------------
  Else
    
    sTexto = sTexto + "Producto         Cant Precio  SubTotal " + vbCrLf
    sTexto = sTexto + "---------------------------------------" + vbCrLf
    iServicio = 0
    igvf = 0
    For i = 0 To gfax.UpperBound(1)
      If blnfactura = True Then
            
        If (Trim(gfax(i, 13)) = "SI") Then
          iSubTotal = (val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", "")) + (val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", "")) * Producto(i).Dscto / 100)) / (1 + kIGV + kPAR_PORCSERV * (IIf(gfax(i, 13) = "SI", 1, 0)) / 100)
          isubtotal_1 = val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", ""))
          toti = (kPAR_PORCSERV * iSubTotal * IIf(gfax(i, 13) = "SI", 1, 0)) / 100
          IGV_1 = val(Replace(gfax(i, 15), ",", ""))
          iServicio = iServicio + val(Replace(gfax(i, 14), ",", ""))
          PUnit = val(Replace(gfax(i, 7), ",", "")) / (1 + kIGV + kPAR_PORCSERV * (IIf(gfax(i, 13) = "SI", 1, 0)) / 100)
        Else
          iSubTotal = val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", ""))
          PUnit = val(Replace(gfax(i, 7), ",", ""))
          IGV_1 = val(Replace(gfax(i, 15), ",", ""))
        End If
            
        nDscto = Producto(i).Dscto
                        
        PUnit = val(Replace(gfax(i, 7), ",", ""))
        If nDscto > 0 Then
          PUnit = PUnit * nDscto / 100 + PUnit
        End If
        
        sTexto = sTexto + Left(Producto(i).nombre + Space(16), 16) & _
               " " + Right(Space(4) & CStr(val(Replace(gfax(i, 6), ",", ""))), 4) & _
               " " + Right(Space(6) & Format(CStr(PUnit), "0.00"), 6) & _
               " " + Right(Space(9) & Format(CStr(PUnit * val(Replace(gfax(i, 6), ",", ""))), "0.00"), 9) + vbCrLf
                         
        iTotal = iTotal + iSubTotal
        igvf = igvf + IGV_1
        iTotItems = iTotItems + val(Replace(gfax(i, 6), ",", ""))
        
      Else ' tk boleta de venta
                                                         
        If (Trim(gfax(i, 13)) = "SI") Then
          iSubTotal = (val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", "")) + (val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", "")) * Producto(i).Dscto / 100)) / (1 + kIGV + kPAR_PORCSERV * (IIf(gfax(i, 13) = "SI", 1, 0)) / 100)
          isubtotal_1 = val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", ""))
          toti = (kPAR_PORCSERV * iSubTotal * IIf(gfax(i, 13) = "SI", 1, 0)) / 100
          IGV_1 = isubtotal_1 - iSubTotal - toti
          PUnit = val(Replace(gfax(i, 7), ",", "")) / (1 + kIGV + kPAR_PORCSERV * (IIf(gfax(i, 13) = "SI", 1, 0)) / 100)
        Else
          iSubTotal = val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", ""))
          PUnit = val(Replace(gfax(i, 7), ",", ""))
          IGV_1 = 0
        End If
            
        nDscto = Producto(i).Dscto
        PUnit = val(Replace(gfax(i, 7), ",", ""))
        If nDscto > 0 Then
          PUnit = PUnit * nDscto / 100 + PUnit
        End If
        
        sTexto = sTexto + Left(Producto(i).nombre + Space(16), 16) & _
               " " + Right(Space(4) & CStr(val(Replace(gfax(i, 6), ",", ""))), 4) & _
               " " + Right(Space(6) & Format(CStr(PUnit), "0.00"), 6) & _
               " " + Right(Space(9) & Format(CStr(PUnit * val(Replace(gfax(i, 6), ",", ""))), "0.00"), 9) + vbCrLf
        
        iServicio = iServicio + val(Replace(gfax(i, 14), ",", ""))
        iTotal = iTotal + iSubTotal
        iTotItems = iTotItems + val(Replace(gfax(i, 6), ",", ""))
      End If
      'Controla el total de puntos por item y por venta
      iPtoItm = 0
      iPtoVta = 0
      IGV_1 = 0
      
      'Descuentos
      nDscto = (Producto(i).Dscto * val(Replace(gfax(i, 7), ",", "")) / 100)
      
      iSubTotalDscto = val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", "")) + (nDscto / 100 * (val(Replace(gfax(i, 6), ",", "")) * val(Replace(gfax(i, 7), ",", ""))))
      Dim Serv As Double
       
      If Producto(i).Dscto < 0 Then
        sTexto = sTexto + Left("*Dscto " + CStr(Abs(Producto(i).Dscto)) + " %" + Space(16), 16) & _
               " " + Space(11) & _
               " " + Right(Space(9) & Format(CStr(PUnit * val(Replace(gfax(i, 6), ",", "")) * Producto(i).Dscto / 100), "0.00"), 9) + vbCrLf
      End If
            
      iTotalDscto = iTotalDscto + nDscto
        
    Next
  End If
 

  'Añade el % de servicio al total
    
  sTexto = sTexto + "---------------------------------------"
  Texto_imprimir = Texto_imprimir + vbCrLf + sTexto
  sTexto = ""
  
  'Total segun tipo de venta
  
  Select Case iTipoVenta
    Case 2 'Normal, Voucher
    
        If blnfactura = True Then
            sTexto = Left(" VALOR VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", "")) - igvf - iServicio), "0.00"), 15) + vbCrLf
                       
            sTexto = sTexto + Left(" IGV" + Space(23), 23) + Right(Space(15) + Format(CStr(igvf), "0.00"), 15) + vbCrLf
            If iServicio > 0 Then
                sTexto = sTexto + Left(" SERVICIO" + "(" + kPAR_PORCSERV + " %)" + Space(23), 23) + Right(Space(15) + Format(CStr(iServicio), "0.00"), 15) + vbCrLf
            End If
            sTexto = sTexto + Left(" TOTAL VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", ""))), "0.00"), 15) + vbCrLf + vbCrLf
                        
            toti = val(Replace(txtSoles, ",", ""))
            iTotal = 0
            If rsPagTar.RecordCount > 0 Then
                rsPagTar.MoveFirst
                Do While Not rsPagTar.EOF
                    sTexto = sTexto + Left(" " + rsPagTar.Fields("descrip") + Space(23), 23) + Right(Space(15) + Format(CStr(rsPagTar.Fields("pago")), "0.00"), 15) + vbCrLf
                    toti = toti - rsPagTar.Fields("pago")
                    iTotal = iTotal + rsPagTar.Fields("pago")
                    rsPagTar.MoveNext
                Loop
            End If
            If val(Replace(txtSoles, ",", "")) > iTotal Then
                ivuelto_1 = 0
            Else
                ivuelto_1 = toti - iTotal
            End If
        
        Else
            IGV_1 = (val(Replace(txtSoles.Text, ",", "")) - val(CStr(iTotal)))
            'Validacion
            If Round(IGV_1 + iTotal, 2) <> val(Replace(txtSoles.Text, ",", "")) Then
               MsgBox "Inconsistencia de Datos"
               iTotal = val(Replace(txtSoles.Text, ",", "")) - IGV_1
            End If
                        
            'sTexto = Left(" VALOR VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", ""))), "0.00"), 15) + vbCrLf
            sTexto = Left(" TOTAL VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", ""))), "0.00"), 15) + vbCrLf
            
            If iServicio > 0 Then
                sTexto = sTexto + Left(" SERVICIO" + "(" + kPAR_PORCSERV + " %)" + Space(23), 23) + Right(Space(15) + Format(CStr(iServicio), "0.00"), 15) + vbCrLf
            End If
            
            toti = val(Replace(txtSoles.Text, ",", ""))
            
            If rsPagTar.RecordCount > 0 Then
                rsPagTar.MoveFirst
                Do While Not rsPagTar.EOF
                    sTexto = sTexto + Left(" " + rsPagTar.Fields("descrip") + Space(23), 23) + Right(Space(15) + Format(CStr(rsPagTar.Fields("pago")), "0.00"), 15) + vbCrLf
                    toti = toti - rsPagTar.Fields("pago")
                    iTotal = iTotal + rsPagTar.Fields("pago")
                    rsPagTar.MoveNext
                Loop
            End If
            
           
            iTotal = 0
            If val(Replace(txtSoles, ",", "")) > iTotal Then
                ivuelto_1 = 0
            Else
                ivuelto_1 = toti - iTotal
            End If
            
                        
        End If
        If bLiquidaNC = False Then
            If toti > 0 Then
               sTexto = sTexto + Left(" EFECTIVO S/." + Space(23), 23) + Right(Space(15) + Format(CStr(toti), "0.00"), 15) + vbCrLf
            End If
            If ivuelto_1 > 0 Then
               sTexto = sTexto + Left(" VUELTO" + Space(23), 23) + Right(Space(15) + Format(CStr(ivuelto_1), "0.00"), 15) + vbCrLf
            End If
        Else
         If Trim(txtliqefectivosoles.Text) = "" Then txtliqefectivosoles.Text = "0.00"
         If Trim(txtliqefectivodolares.Text) = "" Then txtliqefectivodolares.Text = "0.00"
         If Trim(txtliqpade.Text) = "" Then txtliqpade.Text = "0.00"
         If Trim(txtliqvueltosoles.Text) = "" Then txtliqvueltosoles.Text = "0.00"
         If Trim(ttxliqvueltodolares.Text) = "" Then ttxliqvueltodolares.Text = "0.00"
         
         If CDbl(txtliqefectivosoles.Text) > 0 Then
            sTexto = sTexto + Left(" EFECTIVO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqefectivosoles.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqefectivodolares.Text) > 0 Then
            sTexto = sTexto + Left(" EFECTIVO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqefectivodolares.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqpade.Text) > 0 Then
           sTexto = sTexto + Left(" PADE/PADV" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqpade.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqvueltosoles.Text) <> 0 Then
            sTexto = sTexto + Left(" VUELTO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqvueltosoles.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(ttxliqvueltodolares.Text) <> 0 Then
            sTexto = sTexto + Left(" VUELTO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(ttxliqvueltodolares.Text), "0.00"), 15)
         End If
        End If
       ' Set rsPagTar = Nothing
      
   Case 4 'Anula Productos
      sTexto = Left(" CASH/TL" + Space(23), 23) + Right(Space(15) + Format(CStr(iTotal), "0.00"), 15)
    Case 5, 1 'Efectivo
       If blnfactura = True Then
          sTexto = Left(" VALOR VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", "")) - igvf - iServicio), "0.00"), 15) + vbCrLf
          sTexto = sTexto + Left(" IGV" + Space(23), 23) + Right(Space(15) + Format(CStr(igvf), "0.00"), 15) + vbCrLf
          If iServicio > 0 Then
            sTexto = sTexto + Left(" SERVICIO" + "(" + kPAR_PORCSERV + " %)" + Space(23), 23) + Right(Space(15) + Format(CStr(iServicio), "0.00"), 15) + vbCrLf
          End If
          sTexto = sTexto + Left(" TOTAL VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", ""))), "0.00"), 15) + vbCrLf + vbCrLf
      Else 'adicionado
            'sTexto = Left(" VALOR VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", ""))), "0.00"), 15) + vbCrLf
            sTexto = Left(" TOTAL VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(val(Replace(txtSoles.Text, ",", ""))), "0.00"), 15) + vbCrLf
            If iServicio > 0 Then
               sTexto = sTexto + Left(" SERVICIO" + "(" + kPAR_PORCSERV + " %)" + Space(23), 23) + Right(Space(15) + Format(CStr(iServicio), "0.00"), 15) + vbCrLf
            End If
      End If
     If bLiquidaNC = False Then
        If iEfectivo > 0 Then
           sTexto = sTexto + Left(" EFECTIVO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(iEfectivo), "0.00"), 15) + vbCrLf
        End If
        If iDolaresEfectivo > 0 Then
           sTexto = sTexto + Left(" EFECTIVO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(iDolaresEfectivo), "0.00"), 15) + vbCrLf
        End If
        If iVuelto <> 0 Then
           sTexto = sTexto + Left(" VUELTO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(iVuelto), "0.00"), 15) + vbCrLf
        End If
        If iVueltoDolares <> 0 Then
           sTexto = sTexto + Right(" VUELTO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(iVueltoDolares), "0.00"), 15)
        End If
      Else
         If Trim(txtliqefectivosoles.Text) = "" Then txtliqefectivosoles.Text = "0.00"
         If Trim(txtliqefectivodolares.Text) = "" Then txtliqefectivodolares.Text = "0.00"
         If Trim(txtliqpade.Text) = "" Then txtliqpade.Text = "0.00"
         If Trim(txtliqvueltosoles.Text) = "" Then txtliqvueltosoles.Text = "0.00"
         If Trim(ttxliqvueltodolares.Text) = "" Then ttxliqvueltodolares.Text = "0.00"
         
         If piEmitevoucher = 1 Then
            If rsPagTar.RecordCount > 0 Then
                rsPagTar.MoveFirst
               
                Do While Not rsPagTar.EOF
                    sTexto = sTexto + Left(" " + rsPagTar.Fields("descrip") + Space(23), 23) + Right(Space(15) + Format(CStr(rsPagTar.Fields("pago")), "0.00"), 15) + vbCrLf
                    toti = toti - rsPagTar.Fields("pago")
                    iTotal = iTotal + rsPagTar.Fields("pago")
                    rsPagTar.MoveNext
                Loop
            End If
         End If
         
         If CDbl(txtliqefectivosoles.Text) > 0 Then
            sTexto = sTexto + Left(" EFECTIVO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqefectivosoles.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqefectivodolares.Text) > 0 Then
            sTexto = sTexto + Left(" EFECTIVO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqefectivodolares.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqpade.Text) > 0 Then
             sTexto = sTexto + Left(" PADE/PADV" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqpade.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqvueltosoles.Text) <> 0 Then
             sTexto = sTexto + Left(" VUELTO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqvueltosoles.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(ttxliqvueltodolares.Text) <> 0 Then
             sTexto = sTexto + Left(" VUELTO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(ttxliqvueltodolares.Text), "0.00"), 15)
         End If
        End If
    Case 20 'O/C
          
    If bLiquidaNC = False Then
         sTexto = Left(" VALOR VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(txtSoles.Text), "0.00"), 15) + vbCrLf
         If iServicio > 0 Then
             sTexto = sTexto + Left(" SERVICIO" + "(" + kPAR_PORCSERV + " %)" + Space(23), 23) + Right(Space(15) + Format(CStr(iServicio), "0.00"), 15) + vbCrLf
         End If
       
         If iEfectivo > 0 Then
            sTexto = sTexto + Left(" EFECTIVO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtEfectivoSoles.Text), "0.00"), 15) + vbCrLf
         End If
         If iDolaresEfectivo > 0 Then
             sTexto = sTexto + Left(" EFECTIVO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtEfectivoDolares.Text), "0.00"), 15) + vbCrLf
         End If
         If iVuelto <> 0 Then
              sTexto = sTexto + Left(" VUELTO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(iVuelto), "0.00"), 15) + vbCrLf
         End If
         If iVueltoDolares <> 0 Then
             sTexto = sTexto + Left(" VUELTO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(iVueltoDolares), "0.00"), 15)
         End If
     Else
         sTexto = Left(" VALOR VTA" + Space(23), 23) + Right(Space(15) + Format(CStr(txtSoles.Text), "0.00"), 15) + vbCrLf
         If iServicio > 0 Then
             sTexto = sTexto + Left(" SERVICIO" + "(" + kPAR_PORCSERV + " %)" + Space(23), 23) + Right(Space(15) + Format(CStr(iServicio), "0.00"), 15) + vbCrLf
         End If
       
         If CDbl(txtliqefectivosoles.Text) > 0 Then
             sTexto = sTexto + Left(" EFECTIVO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqefectivosoles.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqefectivodolares.Text) > 0 Then
              sTexto = sTexto + Left(" EFECTIVO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqefectivodolares.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqpade.Text) > 0 Then
              sTexto = sTexto + Left(" PADE/PADV" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqpade.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(txtliqvueltosoles.Text) <> 0 Then
             sTexto = sTexto + Left(" VUELTO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(txtliqvueltosoles.Text), "0.00"), 15) + vbCrLf
         End If
         If CDbl(ttxliqvueltodolares.Text) <> 0 Then
              sTexto = sTexto + Left(" VUELTO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(ttxliqvueltodolares.Text), "0.00"), 15)
         End If
     
     End If
    Case 21 'N/C
         sTexto = Left(" TOTAL S/." + Space(23), 23) + Right(Space(15) + Format(CStr(txtSoles), "0.00"), 15)
    Case 22 'PADE
      Select Case mon
       Case 2
          sTexto = Left(" CASH/TL" + Space(19), 19) + Right(Space(19) + "US$ " + Format(CStr(iMontoDolares), "0.00"), 19)
       Case Else
          sTexto = Left(" CASH/TL" + Space(19), 19) + Right(Space(19) + "S/. " + Format(CStr(iTotal), "0.00"), 19)
      End Select
      
    Case 23 'PADV
    'jpcb270710
      Select Case mon
       Case 2
        If iTipoVenta = 23 Then
            sTexto = Left(" TARJETA" + Space(19), 19) + Right(Space(19) + "US$ " + Format(CStr(iMontoDolares), "0.00"), 19)
        Else
           sTexto = Left(" CASH/TL" + Space(19), 19) + Right(Space(19) + "US$ " + Format(CStr(iMontoDolares), "0.00"), 19)
        End If
           
       Case Else
        If iTipoVenta = 23 Then
            sTexto = Left(" TARJETA" + Space(19), 19) + Right(Space(19) + "S/. " + Format(CStr(iTotal), "0.00"), 19)
        Else
            sTexto = Left(" CASH/TL" + Space(19), 19) + Right(Space(19) + "S/. " + Format(CStr(iTotal), "0.00"), 19)
        End If
      End Select
      
    Case 24 'LIQPAD
          sTexto = Left(" SUB/TOTL" + Space(23), 23) + Right(Space(15) + Format(CStr(iTotal), "0.00"), 15) + vbCrLf
          sTexto = sTexto + Left(" PADE/PADV" + Space(23), 23) + Right(Space(15) + txtTotalPA.Text, 15) + vbCrLf
          sTexto = sTexto + Left(" TOT-PAGAR" + Space(23), 23) + Right(Space(15) + txtSoles.Text, 15) + vbCrLf
         If iEfectivo > 0 Then
            sTexto = sTexto + Left(" EFECTIVO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(iEfectivo), "0.00"), 15) + vbCrLf
         End If
        If iDolaresEfectivo > 0 Then
           sTexto = sTexto + Left(" EFECTIVO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(iDolaresEfectivo), "0.00"), 15) + vbCrLf
        End If
           
      If piEmitevoucher = 1 Then
         If rsPagTar.RecordCount > 0 Then
            rsPagTar.MoveFirst
               
            Do While Not rsPagTar.EOF
               'sTexto = sTexto + Left(" " + rsPagTar.Fields("descrip") + Space(23), 23) + Right(Space(15) + Format(CStr(rsPagTar.Fields("pago")), "0.00"), 15) + vbCrLf
               sTexto = sTexto + Left(" " + rsPagTar.Fields("descrip") + Space(23), 23) + Right(Space(15) + Format(CStr(rsPagTar.Fields("pago")), "0.00"), 15) + vbCrLf
               toti = toti - rsPagTar.Fields("pago")
               iTotal = iTotal + rsPagTar.Fields("pago")
              rsPagTar.MoveNext
            Loop
         End If
       End If
      If iVuelto <> 0 Then
          sTexto = sTexto + Left(" VUELTO(S/)" + Space(23), 23) + Right(Space(15) + Format(CStr(iVuelto), "0.00"), 15) + vbCrLf
      End If
      If iVueltoDolares <> 0 Then
          sTexto = sTexto + Left(" VUELTO(U$)" + Space(23), 23) + Right(Space(15) + Format(CStr(iVueltoDolares), "0.00"), 15)
      End If
           
  End Select

  
  printer.FontSize = 9 '12
  printer.FontBold = True
  Texto_imprimir = Texto_imprimir + vbCrLf + sTexto
  sTexto = ""
  If iTotItems > 0 Then
     sTexto = Left(" ITEM" + Space(23), 23) + Right(Space(15) + Format(CStr(iTotItems), "0.00"), 15)
 End If
  Select Case iTipoVenta
    Case 4 'Anula Productos
      sTexto = sTexto + vbCrLf + "VO-POSTN"
  End Select
  
  Texto_imprimir = Texto_imprimir + vbCrLf + sTexto + vbCrLf
  'Printer.Print sTexto
    
  'Printer.Print " "
  
  sTexto = ""
'
'  sTexto = sTexto + "---------------------------------------" + vbCrLf
'  sTexto = sTexto + Left(" TRANSACCION" + Space(23), 23) + Right(Space(15) + CStr(iCodOper), 15) + vbCrLf
'  sTexto = sTexto + "---------------------------------------" + vbCrLf

 '---Puntos----------
 nImporte = CDbl(Me.txtSoles.Text)
 If nImporte > 0 And sTarjeta <> "" Then
   iPuntos = Int(nImporte / lReglaPuntoImporte) * lReglaPuntoCantidad
 End If
 
 
  If sTarjeta <> "" Then
     'sw 'sw Add 19/06/2009, era solo >>> intPuntosAcumulados = ObtenerPuntosAcumulados(sTarjeta)
     intPuntosAcumulados = ObtenerPuntosAcumulados(sTarjeta, Trim(Me.txtLocal.Text))
     If (intPuntosAcumulados + iPuntos) >= 0 And iPuntos > 0 And intPuntosAcumulados <> -1 Then
         sTexto = sTexto & " UD. ACUMULO: " & iPuntos & " PUNTOS" & vbCrLf
         sTexto = sTexto & " TIENE ACUMULADO: " & IIf(intPuntosAcumulados + iPuntos < 0, "**", intPuntosAcumulados + iPuntos) & " PUNTOS" & vbCrLf & vbCrLf
     End If
  End If
  
 '---Fin Puntos------
  
  sTexto = sTexto + Space(9) + Format(CStr(Now()), "(DDD) DD/MM/YYYY ") + Format(CStr(Now()), "hh:mm") + vbCrLf 'Hora: 6 + 1
  If bAcceso = True Then
    sTexto = sTexto + "       SUPERVISOR: " + txtsupervisor + vbCrLf
  End If
  sTexto = sTexto + Space(3) + Left(psUsuario_Descripcion, 10) + " " 'Usuario: 10 + 1
  sTexto = sTexto + Space(1) + "Cj:" + kPAR_CAJA + " T:" + kPAR_TURNO
  sTexto = sTexto + Space(1) + "v" & App.Major & "." & App.Minor & "." & App.Revision
  sTexto = sTexto + vbCrLf & "         Correlativo: " & ObtenerCorrelativo(p_1)

  Select Case iTipoVenta
 Case 20, 22, 23, 21
 Case 24
     If piEmitevoucher <> 1 Then
        txtliqefectivodolares.Text = IIf(Trim(txtEfectivoDolares.Text) = "", "0.00", txtEfectivoDolares.Text)
        txtliqefectivosoles.Text = IIf(Trim(txtEfectivoSoles.Text) = "", "0.00", txtEfectivoSoles.Text)
        txtliqvueltosoles.Text = IIf(Trim(txtVueltoSoles.Text) = "", "0.00", txtVueltoSoles.Text)
        ttxliqvueltodolares.Text = IIf(Trim(txtVueltoDolares.Text) = "", "0.00", txtVueltoDolares.Text)
     End If
     txtliqpade.Text = IIf(Trim(txtTotalPA.Text) = "", "0.00", txtTotalPA.Text)
     txtLiq.Text = iCodOper
 Case Else
    sTexto = sTexto + vbCrLf + vbCrLf + "   " + kPIE_TICKET
 End Select
  
  printer.FontSize = 8 '11
  printer.FontBold = False
  '-------------segun impresora seleccionada --------
  Texto_imprimir = Texto_imprimir + vbCrLf + sTexto
  
If p_1 = 1 Then
  ConfiguraImpresora kPAR_IMPRESORA
  Select Case KImpresora
     Case 1
         Call CortePapel(Texto_imprimir, p_1, CStr(iCodOper))
     Case 0
         printer.Print Texto_imprimir
         printer.Print " "
         printer.Print " "
         printer.EndDoc
   End Select
Else
   ConfiguraImpresora kPAR_IMPRESORA_ALTERNA
  Select Case KImpresoraALT
     Case 1
          Call CortePapel(Texto_imprimir, p_1)
      Case 0
          printer.Print Texto_imprimir
          printer.Print " "
          printer.Print " "
          printer.EndDoc
    End Select
End If
  

  '-------------------Graba operacion -------------------------
   Select Case iTipoVenta
    Case 20, 21, 22, 23, 24
      If iTipoVenta = 22 Or iTipoVenta = 23 Or iTipoVenta = 24 Then
      Else
        
        iDolaresEfectivo = val(Replace(txtEfectivoDolares, ",", ""))
        iSolesEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
        iTotal = val(Replace(txtSoles, ",", ""))
        iMontoDolares = val(Replace(txtDolares, ",", ""))
        iEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
        iVuelto = val(Replace(Me.txtVueltoSoles, ",", ""))
        If iVuelto < 0 Then iVuelto = 0
        iVueltoDolares = val(Replace(Me.txtVueltoDolares, ",", ""))
        If iVueltoDolares < 0 Then iVueltoDolares = 0
        If iTipoVenta = 21 Then
            iCodOperRela = val(txtTX.Text)
        Else
            'jpcb 17/12/2008
            If iTipoVenta = 20 And Trim(txtLiq.Text) <> "" Then
            Else
                iCodOperRela = 0
            End If
        End If
      End If
          
      
'      '------------------Validacion de Numeración Correlativa -------------------------//
'      If cdocTipo = "01" Or cdocTipo = "02" Then
'         sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo = '" & cdocTipo & "'"
'      Else
'         sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM OperacionParalela WHERE cDocTipo = '" & cdocTipo & "'"
'      End If
'      If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
'    If cDocCodigofull <> ((ADORS!Maximo) + 1) And val("0" & ADORS!Maximo) > 0 Then
'      Set fso = CreateObject("Scripting.FileSystemObject")
'      archivo = "Error_Full2" & cdocTipo & cDocCodigofull
'      If Trim(archivo) = "" Then
'          archivo = "textfile"
'      End If
'      Texto = Texto + "Codigo generado " & cDocCodigofull & Chr(13)
'
'      NameArchivo = "C:\Temp\" + Trim(archivo) + ".log"
'      Set MyFile = fso.CreateTextFile(NameArchivo, True)
'      cDocCodigofull = ("0" & (ADORS!Maximo)) + 1
'      Texto = Texto + "Nuevo Codigo " & cDocCodigofull & Chr(13)
'      Texto = Texto + CStr(Now)
'      MyFile.WriteLine (Texto)
'      MsgBox "Ocurrio un error en la numeración, se asignará el " & cDocCodigofull & " al documento "
'      MyFile.Close
'    End If
    
    '---------------Actualizando el valor de la numeración --------------------------------//
    sSQL = "UPDATE Config_Documento " & _
          " SET cOperCode=" & CStr(iCodOper) & "," & _
          " nDocCodigo=" & cDocCodigofull & ", " & _
          " cUserDesc='" & psUsuario_Descripcion & "' " & _
          " WHERE cTipodoc='" & cdocTipo & "'"
    If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
    
    '------------------fin Validacion de Numeración Correlativa -----------------------
      
     If iTipoVenta = 23 Then
     '170810 VALIDA EL ERROR DE DUPLICIDAD DE PADV  (por error se graba otro registro inmediatamente e igual que el anterior)
             
            sSQL = "SELECT dOperFech,nTarjNumb,nMoneda,nMontoSoles,nMontoDolares,nEfectivoSoles,sGlosa FROM OPERACIONPARALELA WHERE cOperCode=" & iCodOper - 1 & ""
            
            If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
            
            If Format(ADORS!dOperFech, "DD/MM/YYYY hh:mm") = sFecha And ADORS!nTarjNumb = sTarjeta And ADORS!nMoneda = CStr(mon) And _
                ADORS!nMontoSoles = iTotal And ADORS!nMontoDolares = iMontoDolares And _
                 ADORS!nEfectivoSoles = iEfectivo And ADORS!sGlosa = txtGlosa Then
                
                
                sSQL = "UPDATE Config_Documento " & _
                      " SET cOperCode=" & CStr(iCodOper - 1) & "," & _
                      " nDocCodigo=" & cDocCodigofull - 1 & ", " & _
                      " cUserDesc='" & psUsuario_Descripcion & "' " & _
                      " WHERE cTipodoc='" & cdocTipo & "'"
                If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
                
                GoTo Salir
                
            Else
      
                    sSQL = " INSERT INTO OPERACIONPARALELA (cOperCode, cOperTipo, dOperFech, nTarjNumb," & _
                           " nMoneda, nMontoSoles, nMontoDolares, nEfectivoSoles, nVueltoSoles, sGlosa," & _
                           " cEstado, cCajaCodi, cFlagSincronizacion, cTurnoCodi, cUserDesc, cOpercodeRela, " & _
                           " nEfectivoDolares, nVueltoDolares, cDocSerie, cDocCodigo, cDocTipo ) " & _
                           " VALUES" + _
                           " ($, $, '$', '$', $, $, $, $, $, '$', '$', '$', '$', '$', '$', $ ,$ ,$,'$',$,'$')"
                    sSQL = VBsprintf(sSQL, CStr(iCodOper), CStr(iTipoVenta), sFecha, sTarjeta, CStr(mon), CStr(iTotal), _
                                           CStr(iMontoDolares), CStr(iEfectivo), CStr(iVuelto), txtGlosa, CStr(1), _
                                           kPAR_CAJA, CStr(0), kPAR_TURNO, psUsuario_Descripcion, CStr(iCodOperRela), _
                                           CStr(iDolaresEfectivo), CStr(iVueltoDolares), KSERIE_PARALELO, cDocCodigofull, cdocTipo)
                    If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
                    
            End If
        
     Else
              If cdocTipo = "10" Then
                txtGlosa = txtNombres
              End If
            sSQL = " INSERT INTO OPERACIONPARALELA (cOperCode, cOperTipo, dOperFech, nTarjNumb," & _
                   " nMoneda, nMontoSoles, nMontoDolares, nEfectivoSoles, nVueltoSoles, sGlosa," & _
                   " cEstado, cCajaCodi, cFlagSincronizacion, cTurnoCodi, cUserDesc, cOpercodeRela, " & _
                   " nEfectivoDolares, nVueltoDolares, cDocSerie, cDocCodigo, cDocTipo ) " & _
                   " VALUES" + _
                   " ($, $, '$', '$', $, $, $, $, $, '$', '$', '$', '$', '$', '$', $ ,$ ,$,'$',$,'$')"
            sSQL = VBsprintf(sSQL, CStr(iCodOper), CStr(iTipoVenta), sFecha, sTarjeta, CStr(mon), CStr(iTotal), _
                                   CStr(iMontoDolares), CStr(iEfectivo), CStr(iVuelto), txtGlosa, CStr(1), _
                                   kPAR_CAJA, CStr(0), kPAR_TURNO, psUsuario_Descripcion, CStr(iCodOperRela), _
                                   CStr(iDolaresEfectivo), CStr(iVueltoDolares), KSERIE_PARALELO, cDocCodigofull, cdocTipo)
            If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
      End If
               
               
'      sSql = " INSERT INTO OPERACIONPARALELA (cOperCode, cOperTipo, dOperFech, nTarjNumb," & _
'             " nMoneda, nMontoSoles, nMontoDolares, nEfectivoSoles, nVueltoSoles, sGlosa," & _
'             " cEstado, cCajaCodi, cFlagSincronizacion, cTurnoCodi, cUserDesc, cOpercodeRela, " & _
'             " nEfectivoDolares, nVueltoDolares, cDocSerie, cDocCodigo, cDocTipo ) " & _
'             " VALUES" + _
'             " ($, $, '$', '$', $, $, $, $, $, '$', '$', '$', '$', '$', '$', $ ,$ ,$,'$',$,'$')"
'      sSql = VBsprintf(sSql, CStr(iCodOper), CStr(iTipoVenta), sFecha, sTarjeta, CStr(mon), CStr(iTotal), _
'                             CStr(iMontoDolares), CStr(iEfectivo), CStr(iVuelto), txtGlosa, CStr(1), _
'                             kPAR_CAJA, CStr(0), kPAR_TURNO, psUsuario_Descripcion, CStr(iCodOperRela), _
'                             CStr(iDolaresEfectivo), CStr(iVueltoDolares), KSERIE_PARALELO, cDocCodigofull, cdocTipo)
'      If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSql) Then GoTo Salir
      
      
      nImporte = 0
      nPtosImp = 0
      nPuntos = 0
      
'      For i = 0 To gfax.UpperBound(1)
      For i = 0 To nProducto
        'TDBGrid1.Row = i
        sSQL = " INSERT INTO OPERACIONPARALELAPRODUCTO (cAlmaCode, cOperCode, cProdCode, nProdCant," & _
               " nProdPrecUnit, nDscto, nServicio,cSupervisor)" & _
               " VALUES" + _
               " ('$', $, $, $, $, $,$,'$')"
        sSQL = VBsprintf(sSQL, kPAR_ALMACEN, CStr(iCodOper), CStr(Producto(i).Codigo), CStr(Abs(val(Replace(gfax(i, 6), ",", "")))), _
                         CStr(val(Replace(gfax(i, 7), ",", ""))), CStr(Producto(i).Dscto), IIf(gfax(i, 13) = "SI", kPAR_PORCSERV, "0"), IIf(CStr(Producto(i).Dscto) = "0", "", txtsupervisor.Text))
        If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
        
  
        'CONTABILIZA PUNTOS
        '------------------
'        nImporte = nImporte + _
'                   Producto(i).Cant * val(TDBGrid1.Columns(7).Text) * (100 - Producto(i).Dscto) * _
'                   IIf(Producto(i).Canje = "VNTA", 1, 0) / 100
'        nPtosImp = nPtosImp + _
'                   Producto(i).Cant * Producto(i).PUnit * (100 - Producto(i).Dscto) * _
'                   IIf(Producto(i).Canje = "PTOS", 1, 0) / 100
'        nPuntos = nPuntos + IIf(Producto(i).Canje = "PTOS", 1, 0) * Producto(i).Ptos * Producto(i).Cant
      Next
      Dim CodLiq As Long
      If iTipoVenta = 1 Or _
         iTipoVenta = 20 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Or _
         iTipoVenta = 5 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Or _
         iTipoVenta = 24 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Then
         Dim iCodTipo As Long
         If iTipoVenta = 24 Then
         txtLiq.Text = iCodOper
         End If
         
         If bLiquidaNC = False Then
            If piEmitevoucher = 1 And iEfectivo = 0 Then
              iCodTipo = 2
            Else
              iCodTipo = 1
            End If
            CodLiq = 0
            
         Else
            iCodTipo = 3
            CodLiq = val(txtLiq.Text)
         End If
        '---primera
           If iDolaresEfectivo <= 0 And iEfectivo <= 0 Then iEfectivo = Replace(txtSoles, ",", "")
           
           sSQL = " INSERT INTO OPERACION (cOperCode, cUserDesc, nTarjNumb, cProdCode, nProdCant, nProdPrecUnit," & _
               " nMontoDolares, dOperFech, cOperTipo, cCajaCodi, cTurnoCodi, nmontosoles, nVueltoDolares,  cDocSerie, cDoccodigo, cdocTipo, cOpercodeAnula, IdLocal) " + _
               " VALUES" + _
               " ($, '$', '$', $, $, $, $, '$', $, '$', '$',$ ,$, '$', $, '$', $, $)"
           sSQL = VBsprintf(sSQL, CStr(iCodOper), psUsuario_Descripcion, sTarjeta, CStr(0), CStr(1), _
                           CStr(-1 * iVuelto), CStr(iDolaresEfectivo), sFecha, CStr(iCodTipo), kPAR_CAJA, kPAR_TURNO, CStr(iEfectivo), CStr(iVueltoDolares), cDocSerie, cDocCodigofull, cdocTipo, CodLiq, idLocal)

        If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
        iVuelto = val(Replace(txtVueltoSoles, ",", ""))
        If iVuelto < 0 Then iVuelto = 0
      End If
      
      
      nImporte = CDbl(Me.txtSoles.Text)
      nPuntos = 0
      '--------------------------Inserta linea voucher liq------------------------------------
      Dim importevoucher As Double
      
      If piEmitevoucher = 1 Then
         importevoucher = nImporte - iEfectivo + iVuelto
         sSQL = " INSERT INTO OPERACION (cOperCode, cUserDesc, nTarjNumb, cProdCode, nProdCant, nProdPrecUnit," & _
               " nMontoDolares, dOperFech, cOperTipo, cCajaCodi, cTurnoCodi, nmontosoles, nVueltoDolares,  cDocSerie, cDoccodigo, cdocTipo, cOpercodeAnula, cemisor, IdLocal) " + _
               " VALUES" + _
               " ($, '$', '$', $, $, $, $, '$', $, '$', '$',$ ,$, '$', $, '$', $, '$', $)"
         sSQL = VBsprintf(sSQL, CStr(iCodOper), psUsuario_Descripcion, sTarjeta, CStr(0), CStr(1), _
                           0, 0, sFecha, 2, kPAR_CAJA, kPAR_TURNO, CStr(importevoucher), 0, cDocSerie, cDocCodigofull, cdocTipo, CodLiq, cEmisor, idLocal)
         If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
                          
      End If
      
      '-----------------------------------------------------------------------------
       
      'ACTUALIZA PUNTOS
      '----------------
      If nImporte > 0 And sTarjeta <> "" Then
        Call Guarda_Puntos(sTarjeta, "VNTA", cdocTipo, cDocSerie, cDocCodigofull, nImporte, , nIdClienteLocal)
        iPuntos = Int(nImporte / lReglaPuntoImporte) * lReglaPuntoCantidad
      End If
      If nPuntos > 0 And sTarjeta <> "" Then
        Call Guarda_Puntos(sTarjeta, "PTOS", cdocTipo, cDocSerie, cDocCodigofull, nPuntos, nPtosImp, nIdClienteLocal)
      End If
      '----------------
      
      If iTipoVenta = 24 Then
        sSQL = " UPDATE OPERACIONPARALELA" & _
               " SET cEstado = 2" + _
               " WHERE cOperCode = $"
        sSQL = VBsprintf(sSQL, CStr(iCodOper))
        If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
                
        For i = 1 To lvwTX(0).ListItems.Count
          iCodOperRela = val(lvwTX(0).ListItems(i).Text)
          sSQL = " UPDATE OPERACIONPARALELA" & _
                 " SET cOpercodeRela = $," & _
                 " cEstado = 2" + _
                 " WHERE cOperCode = $"
          sSQL = VBsprintf(sSQL, CStr(iCodOper), CStr(iCodOperRela))
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
        Next
        
        For i = 1 To lvwTX(1).ListItems.Count
          iCodOperRela = val(lvwTX(1).ListItems(i).Text)
          sSQL = " UPDATE OPERACIONPARALELA" & _
                 " SET cOpercodeRela = $," & _
                 " cEstado = 2" + _
                 " WHERE cOperCode = $" ' AND cOperCodeRela = 0"
          sSQL = VBsprintf(sSQL, CStr(iCodOper), CStr(iCodOperRela))
          If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
        Next
      End If
  
      
    Case Else
      
      nImporte = 0
      nPtosImp = 0
      nPuntos = 0
      If rsPagTar.state = adStateOpen Then
      If rsPagTar.RecordCount > 0 Then
        rsPagTar.MoveFirst
        Do While Not rsPagTar.EOF
            cEmisor = cEmisor + "," + rsPagTar.Fields("cod_tar")
            rsPagTar.MoveNext
        Loop
      End If
      End If
      
  '------------------Validacion de Numeración Correlativa -------------------------//
  
  
'  sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo = '" & cdocTipo & "'"
'         If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
'
'  If cDocCodigofull <> ((ADORS!Maximo) + 1) And val("0" & ADORS!Maximo) > 0 Then
'    Set fso = CreateObject("Scripting.FileSystemObject")
'    archivo = "Error_Full2" & cdocTipo & cDocCodigofull
'    If Trim(archivo) = "" Then
'        archivo = "textfile"
'    End If
'    Texto = Texto + "Codigo generado " & cDocCodigofull & Chr(13)
'
'    NameArchivo = "C:\Temp\" + Trim(archivo) + ".log"
'    Set MyFile = fso.CreateTextFile(NameArchivo, True)
'    cDocCodigofull = ("0" & (ADORS!Maximo)) + 1
'    Texto = Texto + "Nuevo Codigo " & cDocCodigofull & Chr(13)
'    Texto = Texto + CStr(Now)
'    MyFile.WriteLine (Texto)
'    MsgBox "Ocurrio un error en la numeración, se asignará el " & cDocCodigofull & " al documento "
'  End If

If cdocTipo = "01" Or cdocTipo = "02" Then
    'tendria que preguntar primero si hay valor en venta01 del sql para la caja
      Dim cnSQL_ As ADODB.Connection
      Dim rsVenta01_ As ADODB.Recordset
      Dim bValorSQL_ As Boolean
      Dim nValorSQL_ As Long
      bValorSQL_ = False
      
      If oDBAdmin.AbrirBD(cnSQL_, psConnectString, False) = True Then
        'sSQL = "select isnull(max(cast(NroDoc as int)),0) as maximo from venta01  WHERE cCodCaja='" & kPAR_CAJA & "' AND TipoDoc = '" & cdocTipo & "'"
        sSQL = "select isnull(max(cast(NroDoc as int)),0) as maximo from venta01  WHERE cCodCaja='" & kPAR_CAJA & "' AND TipoDoc in ('01','02') "
        If oDBAdmin.EjecutarConsulta(cnSQL_, sSQL, rsVenta01_) = True Then
                If rsVenta01_!Maximo = 0 Then
                    'no hay nada para la caja y el tipo de documento en sql
                Else
                    'si hay, y el valor a actualizar en ndoccodigo de configdocumento deberia ser el valor retornado
                    bValorSQL_ = True
                    nValorSQL_ = rsVenta01_!Maximo
                End If
        Else
            'no pudo abrir el rs: que consulte al access nomas
            
        End If

        Set cnSQL_ = Nothing
      Else
        'no pudo conectarse al sql: que consulte al access nomas
        
      End If
    If bValorSQL_ = True Then
         'aca tendria que preguntar si el codigo del access es mayor, si es asi manda el del access
        'sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo = '" & cdocTipo & "'"
        sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo IN ('01','02')"
        If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
        Dim nValorAccess_ As Long
        nValorAccess_ = ADORS!Maximo
        If nValorAccess_ > nValorSQL_ Then
            nValorSQL_ = nValorAccess_
        End If
    
        If val(cDocCodigofull) <> val("0" & (nValorSQL_) + 1) And val("0" & nValorSQL_) > 0 Then
'          Dim NameArchivo As String
'          Dim archivo
'          Dim Texto As String
'          Dim fso, MyFile
          
          cDocCodigofull = nValorSQL_ + 1
          
          Set fso = CreateObject("Scripting.FileSystemObject")
          archivo = "Error_Full_1" & cdocTipo & cDocCodigofull
          If Trim(archivo) = "" Then
              archivo = "textfile"
          End If
          Texto = Texto + "Codigo generado " & cDocCodigofull & Chr(13)
          
          NameArchivo = "C:\Temp\" + Trim(archivo) + ".log"
          Set MyFile = fso.CreateTextFile(NameArchivo, True)
          cDocCodigofull = ("0" & (rsVenta01_!Maximo)) + 1
          Texto = Texto + "Nuevo Codigo " & cDocCodigofull & Chr(13)
          Texto = Texto + CStr(Now)
          MyFile.WriteLine (Texto)
          MsgBox "Ocurrio un error en la numeración, se asignará el " & cDocCodigofull & " al documento "
          MyFile.Close
        End If
    
    
    Else
        'sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo = '" & cdocTipo & "'"
        sSQL = "SELECT MAX(cDocCodigo) AS maximo FROM Operacion WHERE cDocTipo IN ('01','02')"
        
        If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
        If val(cDocCodigofull) <> val("0" & (ADORS!Maximo) + 1) And val("0" & ADORS!Maximo) > 0 Then
'          Dim NameArchivo As String
'          Dim archivo
'          Dim Texto As String
'          Dim fso, MyFile
          
          
          Set fso = CreateObject("Scripting.FileSystemObject")
          archivo = "Error_Full_1" & cdocTipo & cDocCodigofull
          If Trim(archivo) = "" Then
              archivo = "textfile"
          End If
          Texto = Texto + "Codigo generado " & cDocCodigofull & Chr(13)
          
          NameArchivo = "C:\Temp\" + Trim(archivo) + ".log"
          Set MyFile = fso.CreateTextFile(NameArchivo, True)
          cDocCodigofull = ("0" & (ADORS!Maximo)) + 1
          Texto = Texto + "Nuevo Codigo " & cDocCodigofull & Chr(13)
          Texto = Texto + CStr(Now)
          MyFile.WriteLine (Texto)
          MsgBox "Ocurrio un error en la numeración, se asignará el " & cDocCodigofull & " al documento "
          MyFile.Close
        End If
        
    End If
      
End If
  
  '---------------Actualizando el valor de la numeración --------------------------------//
  sSQL = "UPDATE Config_Documento " & _
        " SET cOperCode=" & CStr(iCodOper) & "," & _
        " cUserDesc='" & psUsuario_Descripcion & "' " & _
        " WHERE cTipodoc='" & cdocTipo & "'"
  If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
  
  '------------------fin Validacion de Numeración Correlativa ---------------------------//
          
      For i = 0 To gfax.UpperBound(1)
         'TDBGrid1.Row = i
         If bLiquidaNC Then iFlagTipo = 3
         
         If iFlagTipo = 3 Then
            CodLiq = val(txtLiq.Text)
         Else
            CodLiq = 0
         End If
         sSQL = " INSERT INTO OPERACION (cOperCode, cUserDesc, nTarjNumb, cAlmaCode, cProdCode, nProdCant, nProdPrecUnit," & _
                " nMontoDolares, dOperFech, cOperTipo, cCajaCodi, cTurnoCodi, nDscto, nServicio, cDocCodigo, cRuc, cDocSerie, cDocTipo, cEmisor, cOpercodeanula, idLocal,cSupervisor) " + _
                " VALUES" + _
                " ($, '$', '$', '$', $, $, $, $, '$', $, '$', '$', $, $, $, '$', '$', '$', '$', $, $,'$')"
         
         sSQL = VBsprintf(sSQL, CStr(iCodOper), psUsuario_Descripcion, sTarjeta, kPAR_ALMACEN, CStr(Producto(i).Codigo), CStr(val(Replace(gfax(i, 6), ",", "") * iSigno)), _
                CStr(val(Replace(gfax(i, 7), ",", ""))), CStr(0), sFecha, CStr(iFlagTipo), kPAR_CAJA, kPAR_TURNO, CStr(Producto(i).Dscto), IIf(gfax(i, 13) = "SI", kPAR_PORCSERV, "0"), cDocCodigofull, cRuc, cDocSerie, cdocTipo, cEmisor, CodLiq, idLocal, IIf(CStr(Producto(i).Dscto) = "0", "", txtsupervisor.Text))
               
         If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
         iEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
         iVuelto = val(Replace(txtVueltoSoles, ",", ""))
         If iVuelto < 0 Then iVuelto = 0
    
      Next
       
      nImporte = CDbl(Me.txtSoles.Text)
      nPuntos = 0
         
      iVuelto = val(Replace(txtVueltoSoles, ",", ""))
      iDolaresEfectivo = val(Replace(txtEfectivoDolares, ",", ""))
      iSolesEfectivo = val(Replace(txtEfectivoSoles, ",", ""))
      iVueltoDolares = val(Replace(Me.txtVueltoDolares, ",", ""))
      If iVuelto < 0 Then iVuelto = 0
      If iVueltoDolares < 0 Then iVueltoDolares = 0
      'ACTUALIZA PUNTOS
      '----------------
      If Not blLiquidaVenta Then
        If nImporte > 0 And sTarjeta <> "" Then
          Call Guarda_Puntos(sTarjeta, "VNTA", cdocTipo, cDocSerie, cDocCodigofull, nImporte, , nIdClienteLocal)
          iPuntos = Int(nImporte / lReglaPuntoImporte) * lReglaPuntoCantidad
        End If
        If nPuntos > 0 And sTarjeta <> "" Then
          Call Guarda_Puntos(sTarjeta, "PTOS", cdocTipo, cDocSerie, cDocCodigofull, nPuntos, nPtosImp, nIdClienteLocal)
        End If
    
      End If
      '---------------
      
      If iTipoVenta = 1 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Or _
         iTipoVenta = 20 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Or _
         iTipoVenta = 5 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Or _
         iTipoVenta = 3 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Or _
         iTipoVenta = 24 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0) Or _
         (iTipoVenta = 2 And (iDolaresEfectivo > 0 Or iSolesEfectivo > 0)) Then
        '-----segunda
         If bLiquidaNC = False Then
            iCodTipo = 1
            CodLiq = 0
         Else
            iCodTipo = 3
            CodLiq = val(txtLiq.Text)
         End If
        
            sSQL = " INSERT INTO OPERACION (cOperCode, cUserDesc, nTarjNumb, cProdCode, nProdCant, nProdPrecUnit," & _
                   " nMontoDolares, dOperFech, cOperTipo, cCajaCodi, cTurnoCodi,nmontosoles, nVueltoDolares, cDocCodigo, cRuc, cDocSerie, cDocTipo,cEmisor, cOpercodeAnula, IdLocal) " + _
                   " VALUES" + _
                   " ($, '$', '$', $, $, $, $, '$', $, '$', '$',$ ,$, $, '$', '$', '$', '$', $, $)"
            sSQL = VBsprintf(sSQL, CStr(iCodOper), psUsuario_Descripcion, sTarjeta, CStr(0), CStr(1), _
                               CStr(-1 * iVuelto), CStr(iDolaresEfectivo), sFecha, CStr(iCodTipo), kPAR_CAJA, kPAR_TURNO, CStr(iSolesEfectivo), CStr(iVueltoDolares), CStr(cDocCodigofull), cRuc, cDocSerie, cdocTipo, cEmisor, CodLiq, idLocal)
'        Else
'             ssql = " INSERT INTO OPERACION (cOperCode, cUserDesc, nTarjNumb, cProdCode, nProdCant, nProdPrecUnit," & _
'               " nMontoDolares, dOperFech, cOperTipo, cCajaCodi, cTurnoCodi, nmontosoles, nVueltoDolares,  cDocSerie, cDoccodigo, cdocTipo) " + _
'               " VALUES" + _
'               " ($, '$', '$', $, $, $, $, '$', $, '$', '$',$ ,$, '$', $, '$')"
'            ssql = VBsprintf(ssql, CStr(iCodOper), psUsuario_Descripcion, sTarjeta, CStr(0), CStr(1), _
'                           CStr(0), CStr(0), sFecha, CStr(iCodTipo), kPAR_CAJA, kPAR_TURNO, CStr(-1 * (Replace(txtSoles.Text, ",", ""))), CStr(0), cDocSerie, cDocCodigofull, cdocTipo)
            
       ' End If
    
     If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then GoTo Salir
        'iEfectivo = Val(Replace(txtEfectivoDolares, ",", ""))
        iVuelto = val(Replace(txtVueltoSoles, ",", ""))
        If iVuelto < 0 Then iVuelto = 0
    End If
            
  End Select
   
  
  bLiquidaNC = False
  '-------------------Fin Graba operacion -------------------------
  
  '----------------------
  '-- Blanquea la Caja --
  '----------------------
  bProducto = False
  iTotalVenta = 0
  'cmdTecla_Click (0)
  
  'SINCRONIZAR
  'Sincronizar
  
  'Inicializa variables y controles
  gfax.Clear
  'gfax.ReDim 0, 0, 0, 14
  gfax.ReDim 0, 0, 0, 15
  TDBGrid1.ReBind
  TDBGrid1.MoveFirst
  TDBGrid1.Update
  cmdTecla_Click (0)
    
  Inicio
  txtTarjeta.SetFocus
  If blLiquidaVenta Then
     Call LiquidaNC(iCodOper)
  End If
  
 
  GoTo Salir
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  Screen.MousePointer = vbDefault

Salir:
  Set ADORS = Nothing
  If piEmitevoucher <> 1 Then
    Set rsPagTar = Nothing
  End If
   
End Sub

Private Sub LiquidaNC(aCodigo As Long)
  Dim sSQL As String
  Dim i As Long
  Dim ADORS As ADODB.Recordset, ADORS1 As ADODB.Recordset
  
  sSQL = " SELECT cAlmaCode, cProdCode, nProdCant as Cant," & _
         " nProdPrecUnit as Precio, nDscto As Dscto, nServicio as Servicio" & _
         " From OperacionParalelaProducto WHERE cOperCode IN(" & _
         " Select cOpercode From Operacionparalela Where cOperTipo= 21 and cOperflagAbierto=1 and cOpercodeRela = " & CStr(aCodigo) & ")"
  '       " GROUP BY cOperCode, cAlmaCode, cProdCode, "
  If Not oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS) Then GoTo Salir
  
  gfax.ReDim 0, ADORS.RecordCount - 1, 0, 15
  For i = 0 To ADORS.RecordCount - 1
    sSQL = " SELECT cCodCatalogo, sProdDescCrta, nProdPrecUnit, cProdEstd, cFlagCanje, nPuntos, cFlagServicio FROM Producto" & _
           " WHERE cAlmaCode = '" & kPAR_ALMACEN & "' AND cProdCode = " + LeerCampo(ADORS("cProdCode"))
    Call oDBAdmin.EjecutarConsulta(ADOCnn, sSQL, ADORS1)
    If ADORS1.RecordCount = 1 Then
      gfax(i, 1) = Right("000000" + LeerCampo(ADORS("cProdCode")), 6)
      gfax(i, 2) = LeerCampo(ADORS1("cCodCatalogo"))
      gfax(i, 3) = LeerCampo(ADORS1("sProdDescCrta"))
      gfax(i, 5) = ""
      gfax(i, 6) = LeerCampo(ADORS("Cant"))
      gfax(i, 7) = Format(LeerCampo(ADORS1("nProdPrecUnit")), "0.00")
      gfax(i, 8) = IIf((ADORS("Dscto")) > 0, "+", "-")
      gfax(i, 9) = Format(Abs(val(ADORS("Dscto"))), "##0.00")
      gfax(i, 10) = val(gfax(i, 6)) * val(gfax(i, 7)) + (val(gfax(i, 6)) * val(gfax(i, 7)) * (val(ADORS!Dscto) / 100))
      gfax(i, 11) = IIf(LeerCampo(ADORS1("cFlagCanje")) = 0, "NO", IIf(LeerCampo(ADORS1("cFlagCanje")) = 1, "VNTA", "PTOS"))
      gfax(i, 12) = LeerCampo(ADORS1("nPuntos"))
      gfax(i, 13) = IIf(LeerCampo(ADORS1("cFlagServicio")) = 1, "SI", "NO")
      CalculaTotales
    End If
    ADORS.MoveNext
  Next
  
   
  bSincronizaPantalla = True
  frmCajaRegistradoraFull.Inicio
  CmdAddArt(2).Visible = False
  CmdDelArt(2).Visible = False
  If piEmitevoucher <> 1 Then
    CalculaTotales
  End If
  Call TDBGrid1_LostFocus
  TDBGrid1.AllowAddNew = False
  TDBGrid1.AllowDelete = False
  TDBGrid1.AllowUpdate = False
  
  'Llena el combo de Tipo de Venta
  cboTipoVenta.Clear
 
  
  
  If piEmitevoucher <> 1 Then
     cboTipoVenta.AddItem "EFECTIVO", 0
     cboTipoVenta.AddItem "O/C", 1
  Else
     cboTipoVenta.AddItem "EFECTIVO", 0
     cboTipoVenta.AddItem "VOUCHER", 1
     cboTipoVenta.AddItem "O/C", 2
  End If
  cboTipoVenta.ListIndex = IIf(piEmitevoucher = 1, 1, 0)
  cboTipoVenta.Enabled = (piEmitevoucher <> 1)
  frmVuelto.Visible = False
  
  bLiquidaNC = True
  
Salir:
End Sub

Private Sub txtTarjeta_LostFocus()
txtTarjeta = Format(txtTarjeta, "00000000")
End Sub

Private Sub txtTXL_LostFocus(Index As Integer)
  If Trim(txtTXL(Index).Text) = "" Then Exit Sub
  txtTXL(Index) = Right("000000" + Trim(txtTXL(Index)), 6)
End Sub

Private Sub TotalLiquidadas()
  Dim i As Long
  Dim iTotal1 As Double, iTotal2 As Double, iEfectivoSoles As Double
  iTotal1 = 0
  iTotal2 = 0
       
  For i = 1 To lvwTX(0).ListItems.Count
    iTotal1 = iTotal1 + val(Replace(lvwTX(0).ListItems(i).SubItems(4), ",", ""))
  Next
  For i = 1 To lvwTX(1).ListItems.Count
    iTotal2 = iTotal2 + val(Replace(lvwTX(1).ListItems(i).SubItems(4), ",", ""))
  Next
  'txtTotalPA = Format(iTotal1, "0.00")
  'txtTotalNC = Format(iTotal2, "0.00")
  'txtSoles = Format((iTotal2 - iTotal1), "0.00")
 'txtDolares = Format((iTotal2 - iTotal1) / nTipoCambio, "0.00")
  txtTotalPA = Format(iTotal1, "0.00")
  txtTotalNC = Format(iTotal2, "0.00")
  txtSoles = Format((iTotal2 - iTotal1), "0.00")
  txtDolares = Format((iTotal2 - iTotal1) / nTipoCambio, "0.00")
  txtEfectivoSoles = "0.00"
  txtEfectivoDolares = "0.00"
  txtVueltoDolares = "0.00"
  txtVueltoSoles = "0.00"
  
  If txtSoles = "0.00" Then
    txtEfectivoSoles = "0.00"
     txtEfectivoSoles.BackColor = &H80000018
     txtEfectivoSoles.Locked = True
   Else
     txtEfectivoSoles.BackColor = &HFFFFFF
     txtEfectivoSoles.Locked = False
   End If
   CalculoVuelto
End Sub

Private Sub SeleccionarClienteLocal(nIdLocal As Integer)
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim STRSQL As String

If val(txtTarjeta) <> 0 And nIdLocal <> 0 Then
  'sw To SQL Server era
  'sw cn.ConnectionString = kCONNECT_STRING + psRutaMDB
  cn.ConnectionString = psCadenaConexionSQLServer
  cn.Open
  
  'sw To SQL Server era >>> nIdLocal
  rs.Open "SELECT * FROM cliente WHERE cClieCode=" & CLng(txtTarjeta) & " AND IdLocal=" & nIdLocal & "", cn, adOpenStatic, adLockReadOnly
  
  If Not rs.EOF Then
    txtNombres = LeerCampo(rs("sClieApel")) + " " + LeerCampo(rs("sClieName"))
  Else
    txtNombres = ""
  End If
    
  Set cn = Nothing
End If


End Sub
Private Sub LlenarComboLocal()
Dim cnSQL As ADODB.Connection
Dim sSQL As String
Dim ADORS As ADODB.Recordset
  
  'sw To SQL Server era
  'sw cn.ConnectionString = kCONNECT_STRING + psRutaMDB
  'cn.ConnectionString = psCadenaConexionSQLServer
  'cn.Open
  If Not oDBAdmin.AbrirBD(cnSQL, psCadenaConexionSQLServer, False) Then GoTo Salir

  sSQL = "SELECT idlocal,dsclocal FROM local"

  If Not oDBAdmin.EjecutarConsulta(cnSQL, sSQL, ADORS) Then GoTo Salir
  
  With dcbLocal
    Set dcbLocal.RowSource = ADORS
    dcbLocal.BoundColumn = "idlocal"
    dcbLocal.ListField = "dsclocal"
  End With
  
  
Set cnSQL = Nothing
Exit Sub
Salir:
Set cnSQL = Nothing
  
End Sub


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

  On Error Resume Next

'SHIFT
'-----
'1, se está pulsando la tecla Shift (mayúsculas)
'2, se está pulsando Control
'4, se está pulsando Alt
'3, se están pulsando Shift y Ctrl,
'5, se están pulsando Shift y Alt,
'6, se están pulsando Ctrl y Alt,
'7, se están pulsando las tres teclas.
  
  Select Case Shift
  
    Case 0
      Select Case KeyCode
        Case vbKeyF1, vbKeyF4, vbKeyF6, vbKeyF7, vbKeyF8, _
             vbKeyF9, vbKeyF10, vbKeyF11, vbKeyF12 '112 To 123 ---- 01 - 12
'          Call cmdTecla_Click(KeyCode - 111)
           
        Case vbKeySpace
            If Not iTipoVenta = 6 And Not iTipoVenta = 7 Then
                Call cmdCambio_Click
            End If
          
        Case vbKeyF5
          'Me.TDBGrid1.Row = gfax.UpperBound(1) + 1
          'Me.CalculaTotales
          'TDBGrid1.MoveLast
          Call CmdAddArt_Click(2)
          Call TDBGrid1_ButtonClick(4)
          
        Case vbKeyF2
          Call txtBuscaCliente_Click
        Case vbKeyF3
          If TDBGrid1.Columns(8).Caption = "Dscto(S/.)" Then
             TDBGrid1.Columns(8).Caption = "Recar(S/.)"
          Else
             TDBGrid1.Columns(8).Caption = "Dscto(S/.)"
          End If
       
      End Select
    Case 1
        Select Case KeyCode
          Case vbKeyF1, vbKeyF2, vbKeyF3, vbKeyF4, vbKeyF5, vbKeyF6, vbKeyF7, vbKeyF8, _
             vbKeyF9, vbKeyF10, vbKeyF11, vbKeyF12 '112 To 123 ---- 13 - 24
'          Call cmdTecla_Click(KeyCode - 99)
        End Select
    Case 2
        Select Case KeyCode
         Case 13
          cmdTecla(2).SetFocus
          Call cmdTecla_Click(2) 'AC/TC
         'Case 17
'          If frapade.Visible = True Then
'           Call cmdBuscaPago_Click
'          End If
        End Select
    Case 4
      Select Case KeyCode
'        Case vbKeyU
'           Me.txtVueltoDolares.SetFocus
        Case vbKeyV
          Me.txtVueltoDolares.SetFocus
        Case 82
            Me.txtRUC.SetFocus
        Case vbKeyF4
          Unload Me
        Case vbKeyE
          Me.txtEfectivoSoles.SetFocus
        Case vbKeyT
          Me.txtTarjeta.SetFocus
        Case vbKey1
          Me.SSTab1.Tab = 0
        Case vbKey2
          Me.SSTab1.Tab = 1
        Case vbKey3
          Me.SSTab1.Tab = 2
        Case vbKeyX
          Me.txtTX.SetFocus
        
      End Select
    End Select
    
  Exit Sub
End Sub

Private Function Validaitems() As Boolean
On Error Resume Next

Dim i As Long
Validaitems = False
CalculoVuelto

If frapade.Visible Then
   If txtPADE.Text = "" Then
      cmdBuscaPago_Click
      Exit Function
   End If
End If

If SSTab1.Tab = 2 Then
   If lvwTX(1).ListItems.Count <= 0 Then
      MsgBox "Debe seleccionar Nota de Consumo a Liquidar"
      Exit Function
   End If
End If

If val(Me.txtVueltoDolares.Text) < 0 Or _
   val(Me.txtVueltoSoles.Text) < 0 And bLiquidaNC = False Then
    MsgBox "No se puede registrar la operacion si el vuelto es negativo"
    Exit Function
End If

If val(Me.txtEfectivoSoles.Text) < 0 Or _
   val(Me.txtEfectivoDolares.Text) < 0 And bLiquidaNC = False Then
    MsgBox "No se puede registrar la operacion si el efectivo es negativo"
    Exit Function
End If
'vd 05/09/07 TDBGrid1.Update
If SSTab1.Tab = 0 Then
  For i = gfax.LowerBound(1) To gfax.UpperBound(1)
    If gfax(i, 1) = "" Then
      gfax(i, 0) = CStr(i + 1)
        If gfax(i, 6) = "" Then gfax(i, 6) = "1.00"
        If gfax(i, 7) = "" Then gfax(i, 7) = "0.00"
        If gfax(i, 8) = "" Then gfax(i, 8) = "0.00"
        If gfax(i, 9) = "" Then gfax(i, 9) = "0.00"
        If gfax(i, 11) = "" Then gfax(i, 9) = "0"
        If gfax(i, 12) = "" Then gfax(i, 9) = "0.00"
        MsgBox "Debe registrar un artìculo."
        Exit Function
           
    End If
  Next
End If
 
 
 If Not Trim(Me.txtRUC.Text) = "" Then
    If Len(Trim(Me.txtRUC.Text)) <> 11 Then
        MsgBox "El RUC debe poseer 11 dígitos"
        Exit Function
    End If
 End If
 
Validaitems = True

 
End Function

Private Function Chequeaitems() As Boolean
Dim i As Long
Chequeaitems = False

If SSTab1.Tab = 0 Then
  For i = gfax.LowerBound(1) To gfax.UpperBound(1)
    If gfax(i, 1) = "" Then
      gfax(i, 0) = CStr(i + 1)
        'If gfax(i, 5) = "" Then gfax(i, 5) = "1.00"
        If gfax(i, 7) = "" Then gfax(i, 7) = "0.00"
        If gfax(i, 9) = "" Then gfax(i, 9) = "0.00"
        If gfax(i, 10) = "" Then gfax(i, 10) = "0.00"
        If gfax(i, 11) = "" Then gfax(i, 9) = "0.00"
        If gfax(i, 12) = "" Then gfax(i, 9) = "0.00"

        Exit Function
    End If
  Next
End If
 Chequeaitems = True
End Function

Private Sub llenacomboventa()
'Llena el combo de Tipo de Venta
  cboTipoVenta.Clear
'  cboTipoVenta.AddItem "-->", 0
  cboTipoVenta.AddItem "EFECTIVO", 0
  cboTipoVenta.AddItem "VOUCHER", 1
  'cboTipoVenta.AddItem "DOLARES", 3
  cboTipoVenta.AddItem "O/C", 2
  cboTipoVenta.AddItem "N/C", 3
  cboTipoVenta.AddItem "PADE", 4
  cboTipoVenta.AddItem "PADV", 5
  cboTipoVenta.AddItem "LIQPAD", 6
  cboTipoVenta.AddItem "ANULAR TRANSACCION", 7
  cboTipoVenta.AddItem "RECAUDACION - PAGO", 8
  cboTipoVenta.Enabled = True
 End Sub
Private Sub txtVueltoDolares_GotFocus()
'    CalculaTotales
    CalculoVuelto
    txtVueltoDolares.SelStart = 0
    txtVueltoDolares.SelLength = Len(Me.txtVueltoDolares.Text)
End Sub
Private Sub txtVueltoDolares_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = 13 Then
        txtVueltoDolares_LostFocus
    End If
End Sub
Private Sub txtVueltoDolares_LostFocus()
    'txtVueltoSoles.Text = "0.00"
    CalculoVuelto
    txtEfectivoSoles.SetFocus
    txtEfectivoSoles.SelStart = 0
    txtEfectivoSoles.SelLength = Len(Me.txtEfectivoSoles.Text)
End Sub
