VERSION 5.00
Object = "{90F3D7B3-92E7-44BA-B444-6A8E2A3BC375}#1.0#0"; "actskin4.ocx"
Object = "{69F9D01E-F1DE-11D4-9536-002018603DA2}#7.0#0"; "MiControl.ocx"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "Crystl32.OCX"
Begin VB.Form f_ventascstore 
   Caption         =   " xx"
   ClientHeight    =   7890
   ClientLeft      =   60
   ClientTop       =   630
   ClientWidth     =   12120
   ClipControls    =   0   'False
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   7890
   ScaleWidth      =   12120
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdDctoItem 
      Caption         =   "Dcto. Item(Ctrl+I)"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   83
      Top             =   4440
      Width           =   1635
   End
   Begin VB.CommandButton cmdDctoAdic 
      Caption         =   "Dcto. Adic(Ctrl+A)"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   82
      Top             =   3960
      Width           =   1635
   End
   Begin VB.Frame Frame2 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1935
      Left            =   120
      TabIndex        =   53
      Top             =   0
      Width           =   11895
      Begin VB.TextBox txt_direccion 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   345
         Left            =   5325
         TabIndex        =   70
         Top             =   1530
         Width           =   3495
      End
      Begin VB.TextBox txt_tipodoc 
         Alignment       =   2  'Center
         BackColor       =   &H80000001&
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   14.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000002&
         Height          =   555
         Left            =   9000
         TabIndex        =   69
         TabStop         =   0   'False
         Top             =   1320
         Width           =   2775
      End
      Begin VB.TextBox txt_tcambio 
         Alignment       =   2  'Center
         DataField       =   "NBRDOCUMENT"
         DataMember      =   "OP_SALES"
         DataSource      =   "DataEnvironment1"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   315
         Left            =   3120
         TabIndex        =   68
         TabStop         =   0   'False
         Top             =   1560
         Width           =   795
      End
      Begin VB.TextBox txt_NBRDOCUMENT 
         Alignment       =   2  'Center
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   360
         Left            =   2420
         Locked          =   -1  'True
         MaxLength       =   10
         TabIndex        =   66
         Top             =   705
         Width           =   1500
      End
      Begin VB.TextBox txt_razonsocial 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   "HH:mm:ss"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   345
         Left            =   5325
         TabIndex        =   57
         Top             =   1110
         Width           =   3495
      End
      Begin VB.TextBox txt_ruc 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   360
         Left            =   5325
         MaxLength       =   11
         TabIndex        =   56
         Top             =   690
         Width           =   1455
      End
      Begin VB.CommandButton cmd_bcliente 
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   335
         Left            =   6800
         Picture         =   "0502000.frx":0000
         TabIndex        =   55
         TabStop         =   0   'False
         Top             =   270
         Width           =   375
      End
      Begin VB.TextBox TXT_IDCLIENTE 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   345
         Left            =   5325
         MaxLength       =   11
         TabIndex        =   54
         Top             =   270
         Width           =   1455
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel11 
         Height          =   255
         Left            =   3030
         OleObjectBlob   =   "0502000.frx":0532
         TabIndex        =   58
         Top             =   1305
         Width           =   975
      End
      Begin ACTIVESKINLibCtl.SkinLabel lbl_tnegocio 
         Height          =   255
         Left            =   8970
         OleObjectBlob   =   "0502000.frx":05A6
         TabIndex        =   59
         Top             =   743
         Width           =   855
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel9 
         Height          =   255
         Left            =   120
         OleObjectBlob   =   "0502000.frx":0614
         TabIndex        =   60
         Top             =   1590
         Width           =   1095
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel8 
         Height          =   255
         Left            =   120
         OleObjectBlob   =   "0502000.frx":0688
         TabIndex        =   61
         Top             =   1185
         Width           =   1455
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel7 
         Height          =   255
         Left            =   4080
         OleObjectBlob   =   "0502000.frx":0702
         TabIndex        =   62
         Top             =   1575
         Width           =   975
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel6 
         Height          =   255
         Left            =   4080
         OleObjectBlob   =   "0502000.frx":0774
         TabIndex        =   63
         Top             =   1155
         Width           =   1215
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel2 
         Height          =   270
         Left            =   120
         OleObjectBlob   =   "0502000.frx":07EE
         TabIndex        =   64
         Top             =   750
         Width           =   1575
      End
      Begin ACTIVESKINLibCtl.SkinLabel lbl_tdocumento 
         Height          =   270
         Left            =   120
         OleObjectBlob   =   "0502000.frx":0868
         TabIndex        =   65
         Top             =   315
         Width           =   1575
      End
      Begin MSComCtl2.DTPicker dtp_fecha 
         Height          =   315
         Left            =   1695
         TabIndex        =   67
         Top             =   1560
         Width           =   1305
         _ExtentX        =   2302
         _ExtentY        =   556
         _Version        =   393216
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         CalendarForeColor=   -2147483635
         CustomFormat    =   "dd/MM/yyyy"
         Format          =   21299203
         CurrentDate     =   37592
      End
      Begin MSDataListLib.DataCombo dtc_serie 
         Height          =   360
         Left            =   1695
         TabIndex        =   71
         Top             =   705
         Width           =   735
         _ExtentX        =   1296
         _ExtentY        =   635
         _Version        =   393216
         Style           =   2
         ForeColor       =   -2147483635
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin MSDataListLib.DataCombo dtc_tdocumento 
         Height          =   315
         Left            =   1695
         TabIndex        =   72
         Top             =   300
         Width           =   2235
         _ExtentX        =   3942
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         ForeColor       =   -2147483635
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin MSComCtl2.DTPicker dtp_fechapro 
         Height          =   315
         Left            =   1695
         TabIndex        =   73
         Top             =   1155
         Width           =   1305
         _ExtentX        =   2302
         _ExtentY        =   556
         _Version        =   393216
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         CalendarForeColor=   -2147483635
         CustomFormat    =   "dd/MM/yyyy"
         Format          =   21299203
         CurrentDate     =   37592
      End
      Begin MSDataListLib.DataCombo dtc_tnegocio 
         Height          =   315
         Left            =   9975
         TabIndex        =   74
         Top             =   713
         Width           =   1800
         _ExtentX        =   3175
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         ForeColor       =   -2147483635
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel4 
         Height          =   255
         Left            =   4080
         OleObjectBlob   =   "0502000.frx":08E4
         TabIndex        =   75
         Top             =   735
         Width           =   495
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel3 
         Height          =   270
         Left            =   4080
         OleObjectBlob   =   "0502000.frx":094A
         TabIndex        =   76
         Top             =   300
         Width           =   1215
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel5 
         Height          =   255
         Left            =   8970
         OleObjectBlob   =   "0502000.frx":09C2
         TabIndex        =   77
         Top             =   315
         Width           =   975
      End
      Begin MSDataListLib.DataCombo dtc_vendedor 
         Height          =   315
         Left            =   9975
         TabIndex        =   78
         Top             =   285
         Width           =   1800
         _ExtentX        =   3175
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         ForeColor       =   -2147483635
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.Label lblversion 
         BorderStyle     =   1  'Fixed Single
         Height          =   300
         Left            =   7560
         TabIndex        =   79
         Top             =   240
         Visible         =   0   'False
         Width           =   855
      End
   End
   Begin VB.CommandButton cmd_salvar 
      Caption         =   "Salva Transacc. (F4)"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   51
      Top             =   5160
      Width           =   1635
   End
   Begin VB.CommandButton cmd_recupera 
      Caption         =   "Recupera Trans.(F5)"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   50
      Top             =   5640
      Width           =   1635
   End
   Begin VB.CommandButton cmd_tarjeta 
      Caption         =   "Tarjeta (F8)"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   48
      Top             =   2520
      Width           =   1635
   End
   Begin VB.CommandButton cmd_vale 
      Caption         =   "Cta. Cte   (F9)"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   47
      Top             =   3000
      Width           =   1635
   End
   Begin VB.CommandButton cmdadelanto 
      Caption         =   "&Adelanto"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   46
      Top             =   3480
      Width           =   1635
   End
   Begin VB.Frame fraDatosItem 
      Appearance      =   0  'Flat
      BackColor       =   &H80000004&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   795
      Left            =   120
      TabIndex        =   28
      Top             =   1920
      Width           =   10215
      Begin VB.PictureBox Picture2 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   2340
         ScaleHeight     =   270
         ScaleWidth      =   4335
         TabIndex        =   80
         Top             =   360
         Width           =   4395
         Begin ACTIVESKINLibCtl.SkinLabel lblDescripcion 
            Height          =   330
            Left            =   0
            OleObjectBlob   =   "0502000.frx":0A32
            TabIndex        =   81
            Top             =   0
            Width           =   4875
         End
      End
      Begin VB.CommandButton cmdBuscaArticulo 
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   335
         Left            =   1860
         Picture         =   "0502000.frx":0A90
         TabIndex        =   33
         TabStop         =   0   'False
         ToolTipText     =   "Buscar Artículo"
         Top             =   358
         Width           =   375
      End
      Begin VB.CommandButton cmdActualizaItem 
         Caption         =   "Actualizar"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   7920
         Picture         =   "0502000.frx":0FC2
         Style           =   1  'Graphical
         TabIndex        =   32
         Top             =   1080
         Visible         =   0   'False
         Width           =   855
      End
      Begin VB.CommandButton cmdEliminarItem 
         Caption         =   "Eliminar"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   6840
         Picture         =   "0502000.frx":14F4
         Style           =   1  'Graphical
         TabIndex        =   31
         Top             =   1080
         Visible         =   0   'False
         Width           =   855
      End
      Begin VB.CommandButton cmdNuevoItem 
         Caption         =   "Nuevo"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   5880
         Picture         =   "0502000.frx":15F6
         Style           =   1  'Graphical
         TabIndex        =   30
         Top             =   1080
         Visible         =   0   'False
         Width           =   855
      End
      Begin VB.TextBox txtArticulo 
         Height          =   330
         Left            =   180
         MaxLength       =   20
         TabIndex        =   29
         Top             =   360
         Width           =   1665
      End
      Begin MiControl.CtrlNumber ctnprecio 
         Height          =   405
         Left            =   6765
         TabIndex        =   34
         TabStop         =   0   'False
         Top             =   360
         Width           =   1080
         _ExtentX        =   1905
         _ExtentY        =   714
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin MiControl.CtrlNumber ctnUnidades 
         Height          =   405
         Left            =   7860
         TabIndex        =   35
         Top             =   360
         Width           =   1080
         _ExtentX        =   1905
         _ExtentY        =   714
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin MiControl.CtrlNumber CTN_SUBTOTAL 
         Height          =   405
         Left            =   8970
         TabIndex        =   36
         Top             =   360
         Width           =   1080
         _ExtentX        =   1905
         _ExtentY        =   714
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel12 
         Height          =   255
         Left            =   180
         OleObjectBlob   =   "0502000.frx":1B28
         TabIndex        =   37
         Top             =   120
         Width           =   735
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel13 
         Height          =   255
         Left            =   6765
         OleObjectBlob   =   "0502000.frx":1B96
         TabIndex        =   38
         Top             =   120
         Width           =   615
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel14 
         Height          =   255
         Left            =   7860
         OleObjectBlob   =   "0502000.frx":1C00
         TabIndex        =   39
         Top             =   120
         Width           =   855
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel15 
         Height          =   255
         Left            =   8970
         OleObjectBlob   =   "0502000.frx":1C6E
         TabIndex        =   40
         Top             =   120
         Width           =   495
      End
      Begin VB.Label lblCosto 
         AutoSize        =   -1  'True
         Caption         =   "Precio:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   6840
         TabIndex        =   45
         Top             =   360
         Width           =   630
      End
      Begin VB.Label lblUnidades 
         AutoSize        =   -1  'True
         Caption         =   "Cantidad"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   7800
         TabIndex        =   44
         Top             =   480
         Visible         =   0   'False
         Width           =   810
      End
      Begin VB.Label lblArticulo 
         AutoSize        =   -1  'True
         Caption         =   "Producto"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   480
         TabIndex        =   43
         Top             =   480
         Width           =   645
      End
      Begin VB.Label lbl_total 
         AutoSize        =   -1  'True
         Caption         =   "Total"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   9120
         TabIndex        =   42
         Top             =   480
         Width           =   465
      End
      Begin VB.Label lblDescripcion_1 
         BackColor       =   &H8000000E&
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1860
         TabIndex        =   41
         Top             =   360
         Visible         =   0   'False
         Width           =   4635
      End
   End
   Begin ACTIVESKINLibCtl.Skin sknVentaCstore 
      Left            =   10440
      OleObjectBlob   =   "0502000.frx":1CD6
      Top             =   6000
   End
   Begin VB.Frame Frame1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2055
      Left            =   120
      TabIndex        =   19
      Top             =   5460
      Width           =   10215
      Begin Crystal.CrystalReport crFacturaMM 
         Left            =   4920
         Top             =   1560
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin VB.PictureBox Picture1 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1335
         Left            =   140
         Picture         =   "0502000.frx":1F0A
         ScaleHeight     =   1275
         ScaleWidth      =   3885
         TabIndex        =   52
         Top             =   405
         Width           =   3945
         Begin VB.Label Label7 
            Alignment       =   2  'Center
            BackColor       =   &H00FFFFFF&
            Caption         =   "TELF: (01) 4622546 /  (01) 98290477"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   375
            Left            =   -120
            TabIndex        =   84
            Top             =   960
            Width           =   4095
         End
      End
      Begin VB.TextBox TXT_NOAFECTO 
         Alignment       =   1  'Right Justify
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   360
         Left            =   8760
         TabIndex        =   6
         TabStop         =   0   'False
         Top             =   660
         Width           =   1335
      End
      Begin VB.TextBox TXT_MONEDATOTAL 
         Alignment       =   1  'Right Justify
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   360
         Left            =   8400
         TabIndex        =   10
         TabStop         =   0   'False
         Top             =   1620
         Width           =   375
      End
      Begin VB.TextBox txt_total 
         Alignment       =   1  'Right Justify
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   360
         Left            =   8760
         TabIndex        =   11
         TabStop         =   0   'False
         Top             =   1620
         Width           =   1335
      End
      Begin VB.TextBox txt_igv 
         Alignment       =   1  'Right Justify
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   360
         Left            =   8760
         TabIndex        =   8
         TabStop         =   0   'False
         Top             =   1140
         Width           =   1335
      End
      Begin VB.TextBox txt_subtotal 
         Alignment       =   1  'Right Justify
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   360
         Left            =   8760
         TabIndex        =   4
         TabStop         =   0   'False
         Top             =   180
         Width           =   1335
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel16 
         Height          =   255
         Left            =   7200
         OleObjectBlob   =   "0502000.frx":1043C
         TabIndex        =   24
         Top             =   240
         Width           =   1095
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel17 
         Height          =   255
         Left            =   7200
         OleObjectBlob   =   "0502000.frx":104AC
         TabIndex        =   25
         Top             =   720
         Width           =   1095
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel18 
         Height          =   255
         Left            =   7200
         OleObjectBlob   =   "0502000.frx":1051C
         TabIndex        =   26
         Top             =   1200
         Width           =   495
      End
      Begin ACTIVESKINLibCtl.SkinLabel SkinLabel19 
         Height          =   255
         Left            =   7200
         OleObjectBlob   =   "0502000.frx":10580
         TabIndex        =   27
         Top             =   1680
         Width           =   615
      End
      Begin VB.Label lbl_noafecto 
         Caption         =   "No Afecto"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   3960
         TabIndex        =   5
         Top             =   840
         Visible         =   0   'False
         Width           =   1215
      End
      Begin VB.Label lbl_totalgen 
         Caption         =   "Total"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   3960
         TabIndex        =   9
         Top             =   1200
         Visible         =   0   'False
         Width           =   615
      End
      Begin VB.Label lbligv 
         Caption         =   "IGV"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   3960
         TabIndex        =   7
         Top             =   1320
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lblsubtotal 
         Caption         =   "Sub Total"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   3960
         TabIndex        =   3
         Top             =   960
         Visible         =   0   'False
         Width           =   1215
      End
   End
   Begin VB.CommandButton cmd_salir 
      Caption         =   "&Salir"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   1
      Top             =   7140
      Width           =   1635
   End
   Begin VB.CommandButton cmd_Cancelar 
      Cancel          =   -1  'True
      Caption         =   "&Cancelar "
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   0
      Top             =   6600
      Width           =   1635
   End
   Begin MSDataGridLib.DataGrid DBDetalle 
      Height          =   2655
      Left            =   120
      TabIndex        =   2
      TabStop         =   0   'False
      Top             =   2760
      Width           =   10215
      _ExtentX        =   18018
      _ExtentY        =   4683
      _Version        =   393216
      AllowUpdate     =   0   'False
      BackColor       =   -2147483624
      Enabled         =   -1  'True
      ForeColor       =   -2147483635
      HeadLines       =   1
      RowHeight       =   19
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "[Enter]_Modificar_         [F2] Consultas     [Escape] Descartar Venta       [F3]_Eliminar Registro"
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.CommandButton cmd_efectivo 
      Caption         =   "Efectivo (F7)"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   10440
      TabIndex        =   49
      Top             =   2040
      Width           =   1635
   End
   Begin VB.Label lbl_tnegocio_1 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Negocio:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   8040
      TabIndex        =   23
      Top             =   3360
      Width           =   825
   End
   Begin VB.Label Label4 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Fecha Proceso:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   3720
      TabIndex        =   22
      Top             =   4440
      Width           =   1425
   End
   Begin VB.Label lbl_tdocumento_1 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Tipo Documento:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   7560
      TabIndex        =   21
      Top             =   4080
      Visible         =   0   'False
      Width           =   1545
   End
   Begin VB.Label lblFieldLabel 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Nro.Documento:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   7560
      TabIndex        =   20
      Top             =   3960
      Visible         =   0   'False
      Width           =   1455
   End
   Begin VB.Label Label11 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Tipo Cambio:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   7800
      TabIndex        =   18
      Top             =   3960
      Width           =   1215
   End
   Begin VB.Label Label8 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Vendedor:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   4080
      TabIndex        =   17
      Top             =   3600
      Width           =   945
   End
   Begin VB.Label Label6 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Ruc:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   9840
      TabIndex        =   16
      Top             =   4200
      Visible         =   0   'False
      Width           =   405
   End
   Begin VB.Label Label5 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Fecha Doc.:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   7920
      TabIndex        =   15
      Top             =   4080
      Width           =   1080
   End
   Begin VB.Label Label3 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Direccion:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   9480
      TabIndex        =   14
      Top             =   3960
      Width           =   900
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Apellido/R.S.:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   9120
      TabIndex        =   13
      Top             =   4080
      Width           =   1230
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      Caption         =   "Codigo Cliente:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   9075
      TabIndex        =   12
      Top             =   3960
      Visible         =   0   'False
      Width           =   1365
   End
   Begin VB.Menu mnu_op 
      Caption         =   "Operaciones"
      Begin VB.Menu mnu_op_buscar 
         Caption         =   "&Buscar/Anular Transaccion"
      End
      Begin VB.Menu guion6 
         Caption         =   "-"
         Index           =   0
      End
      Begin VB.Menu mnu_op_cashdrop 
         Caption         =   "Cash Drop"
         Shortcut        =   {F6}
      End
      Begin VB.Menu guion3 
         Caption         =   "-"
      End
      Begin VB.Menu mnu_op_cierrex 
         Caption         =   "Cierre X"
         Shortcut        =   {F11}
      End
      Begin VB.Menu mnu_op_cierrez 
         Caption         =   "Cierre Z"
         Shortcut        =   {F12}
      End
      Begin VB.Menu guionx 
         Caption         =   "-"
      End
      Begin VB.Menu mnu_op_abrirgaveta 
         Caption         =   "Abrir Gaveta"
      End
      Begin VB.Menu guionx2 
         Caption         =   "-"
      End
      Begin VB.Menu mnu_op_fcaja 
         Caption         =   "Fondo Caja"
      End
   End
   Begin VB.Menu mnu_pagos 
      Caption         =   "Pagos"
      Begin VB.Menu mnu_pagos_efectivo 
         Caption         =   "Efectivo"
         Shortcut        =   {F7}
      End
      Begin VB.Menu mnu_pagos_Tarjeta 
         Caption         =   "Tarjeta"
         Shortcut        =   {F8}
      End
      Begin VB.Menu mnu_pagos_vale 
         Caption         =   "Vale"
         Shortcut        =   {F9}
      End
      Begin VB.Menu mnuAdelanto 
         Caption         =   "Adelanto                                         "
      End
      Begin VB.Menu guion1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuDctoAdic 
         Caption         =   "Dcto. Adic"
         Shortcut        =   ^A
      End
      Begin VB.Menu mnuDctoItem 
         Caption         =   "Dcto. Item"
         Shortcut        =   ^I
      End
      Begin VB.Menu guion20 
         Caption         =   "-"
      End
      Begin VB.Menu mnu_pagos_salvar 
         Caption         =   "Salvar Transaccion"
         Shortcut        =   {F4}
      End
      Begin VB.Menu mnu_pagos_restaurar 
         Caption         =   "Restaurar Transaccion"
         Shortcut        =   {F5}
      End
   End
End
Attribute VB_Name = "f_ventascstore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Se retiraron los Fuentes de la red el 24/04/2003
Option Explicit
Public mobj_cseguridad As DB_SE_MANTENIMIENTOS.c_seguridad
Public MOBJ_CMONEDA As DB_MA_MANTENIMIENTOS.C_MONEDA
Public mobj_cdocumento As DB_MA_MANTENIMIENTOS.C_DOCUMENTO
Public mobj_cventasgen As DB_OP_FACTURACION.C_VENTASGENERAL
Public MOBJ_CVENTASCSTORE As DB_OP_FACTURACION.C_VENTASCSTORE
Public Mobj_Correlativo As DB_CORRELATIVO.C_Correlativos
Private MobjUtilSetup As UTIL_SETUP.C_SETUP

Private MobjMovimientos As DB_INV_MOVIMIENTOS.C_MOVIMIENTOS
Private MrsMesCerrado As ADODB.Recordset

'--------------------------------------------------------------------------
'datos del clientes
Public mstr_monedacliente
Public mint_limitecredito
Public mbln_afectoimpuesto
'--------------------------------------------------------------------------

Public pb_editar As Boolean
Public pb_agregar As Boolean
Public pb_primerregistro As Boolean
Public pb_ultimoregistro As Boolean
Public pbderecho_agregar As Boolean
Public pbderecho_consultar As Boolean
Public pbderecho_editar As Boolean
Public pbderecho_borrar As Boolean
Public pbderecho_imprimir As Boolean
Public pbderecho_EMITIR As Boolean
Public pbderecho_ANULAR As Boolean
Public pb_tiposcreen As String

Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String
Public GrecibeColumnaOpcional2 As String
Public GrecibeColumnaOpcional3 As String

Public grscliente As ADODB.Recordset

Private WithEvents MrsGrilla As ADODB.Recordset
Attribute MrsGrilla.VB_VarHelpID = -1
Public rs_prod As ADODB.Recordset

Public mbln_editandoproducto As Boolean
Public MBLN_INICIO  As Boolean

Public MintCustomer_user9CS As Integer

Public mbln_articuloencontrado As Boolean
Public MintTipoCliente As Integer
Public GstrTipoClienteDescr As String
Public GdblLimiteCredito As Double
Public GdblDeudaVigente As Double
Public GdblSaldoDisponible As Double
Public GstrIddeEstado As String
Public GstrDescrEstado As String
Public GstrTipodeCambio As String
Public gdblMontoTipoCambio  As Double
Public GBlnClienteCargado As Boolean
Public GstrCondiciondePago As String

Public GintDiasdeGracia As Integer
Public GdblMontoExtra As Double
Public GblnconPlacas As Boolean
Public GblnAfecto As Boolean
Public GStrNumeroPlaca As String
Public GintNumeroVale As Double
Public MBlndatosasignados As Boolean
Public mbln_cabezeraprotegida As Boolean

Public LdblTotalBase As Double
Public LdblTotalExt As Double
Public LDblIGVBase As Double
Public LDblIGVExt As Double
Public LDblSubAfectoBase As Double
Public LDblSubAfectoExt As Double
Public LDblNoAfectoBase As Double
Public LDblNoAfectoExt As Double

Public LDblTOTALNOTAFFECTPEN As Double
Public LDblTOTALNOTAFFECTUSD As Double
Public LDblTOTRETURNEDPEN As Double
Public LDblTOTRETURNEDUSD As Double
Public LDblTOTCASHPEN As Double
Public LDblTOTCASHUSD As Double
Public GSTRPLACA As String
Public GLONKILOMETRAJE As Long

Public pdbl_documentobuscado As Double
Public pbln_consulta As Boolean
Public pbln_errorcab As Boolean
Public GINT_TIPOPAGO As Integer
Public prs_productos_tienda As ADODB.Recordset
Public prs_productos_playa As ADODB.Recordset
Public prs_clientes As ADODB.Recordset

Public dblCantidad As Double

Public numDocumentoT As Double  'almacena el numero del documento primro

'Mi Mercado: J. Illescas ------> permite saber si se editara el articulo con salto automatico incluido
Public swEditSaltoAutomatico As Boolean
Public sw_codBarrPeso As Boolean            'Controla si el articulo ingresado es codigo de barra de Peso

Public compactCodBarrPeso As Boolean         'Permite saber si se compacto el codigo de barra de Peso

Public DescuentoItem As Integer
Public descuentoAdicional As Integer
Public TipoDescuento As Integer
Private Sub cmd_bcliente_Click()
  Dim LArrayBusqueda(1 To 4, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "CUSTIDSS"
  LArrayBusqueda(1, 2) = "Id Cliente"
  LArrayBusqueda(1, 3) = 1500
  LArrayBusqueda(2, 1) = "CUSTNAME"
  LArrayBusqueda(2, 2) = "Cliente"
  LArrayBusqueda(2, 3) = 4000
  LArrayBusqueda(3, 1) = "TAXREGNBR"
  LArrayBusqueda(3, 2) = "R.U.C."
  LArrayBusqueda(3, 3) = 1800
  LArrayBusqueda(4, 1) = "ADDR1"
  LArrayBusqueda(4, 2) = "DIRECCION"
  LArrayBusqueda(4, 3) = 2700
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  GrecibeColumnaOpcional2 = Empty
  
  fbusquedasventas.GObtenerRegistros prs_clientes, LArrayBusqueda, 4, 2, 11000, 5970, 700, 700
  fbusquedasventas.Show vbModal
   
If GrecibeUbicacion <> 0 Then
    TXT_IDCLIENTE = GrecibeColumnaID
    'txt_tipodoc.Text = "FACTURA"
    txt_razonsocial.Text = GrecibeColumnaOpcional
    txt_direccion.Text = GrecibeColumnaOpcional3
    If pasar_ruc(GrecibeColumnaOpcional2) Then
        txt_ruc.Text = Trim(GrecibeColumnaOpcional2)
    Else
        txt_ruc.Text = ""
    End If
    Call valida_codigocliente("KD")
    'txt_ruc.SetFocus
End If
End Sub

Private Sub cmd_Cancelar_Click()

If Len(Trim(TXT_IDCLIENTE)) = 0 And Len(Trim(txt_razonsocial.Text)) = 0 And Val(txt_total.Text) = 0 Then
    If MsgBox("Esta Seguro de Salir del Sistema", vbYesNo + vbQuestion, "Precaucion") = vbYes Then
        Call cmd_salir_Click
    End If
Else
    If MsgBox("Esta Seguro de Cancelar la Venta Actual", vbYesNo + vbQuestion, "Precaucion") = vbYes Then
        MBLN_INICIO = True
        Call borrar_valores
        Call inicio
        Call enfoque_inicial
    End If
End If

End Sub
Private Sub cmd_efectivo_Click()
Dim IntPagoAdelantado As Integer

IntPagoAdelantado = 0

If Trim(gstrtipoventas) <> "A" Then
           
   Set MrsMesCerrado = MobjMovimientos.ValidaMesCerrado(GstrSiteProce, dtp_fechapro.Value)

   If MrsMesCerrado!MESCERRADO = 1 Then
      MsgBox " No se pueden Ingresar Documentos de un Mes que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
      Exit Sub
   Else
     If MrsMesCerrado!PDCERRADO = 1 Then
        MsgBox " No se pueden Ingresar Documentos de un Parte Diario que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
        Exit Sub
     End If
   End If
        
   Set MrsMesCerrado = Nothing
         
End If


If MintTipoCliente = 2 And Trim(dtc_tdocumento.BoundText) <> Trim(mobj_cventasgen.obtenertiponc) Then
    If Val(txt_total.Text) > 0 Then
    
          If MsgBox("Desea Facturar Consumo como Adelanto", vbYesNo + vbQuestion, "Pago Adelantado") = vbYes Then
              If Len(Trim(TXT_IDCLIENTE.Text)) > 0 Then
                If grscliente!credito = 2 Then
                   IntPagoAdelantado = 1
                   
                   '********************************************************
                   'Aquí entra la validación del Saldo
                    
                    If MintCustomer_user9CS = 1 Then
                    
                                   Dim Lstrcadenaadel As String
                                   Dim Lutil As UTIL_SETUP.C_SETUP
                                   Dim Lrstemp As ADODB.Recordset
                                   Dim Ldblsaldo As Double
                                       
                                   'Modificado por : Cesar Ospino \ Fecha : 18/03/2006
                                   'Lstrcadenaadel = " OP_Verifica_SaldoAdelantado '" & Trim(TXT_IDCLIENTE.Text) & "','" & GstrSiteProce & "'"
                            
                                    Lstrcadenaadel = " OP_Verifica_SaldoAdelantadoNuevo '" & Trim(TXT_IDCLIENTE.Text) & "'"
                            
                                        Set Lutil = New UTIL_SETUP.C_SETUP
                                        Set Lrstemp = Lutil.Auxiliar3(Lstrcadenaadel)
                                        
                                        If CDbl(Lrstemp!saldo) > 0 Then  ' Verifica si tiene Saldo
                                           If CDbl(txt_total.Text) > CDbl(Lrstemp!saldo) Then  ' Verifica si el Monto Total es superior al Saldo
                                              MsgBox "Monto excede los S/. " & Str(CDbl(Lrstemp!saldo)) & " Soles disponibles a facturar ", vbDefaultButton1 + vbExclamation, "Mensaje"
                                              Set Lutil = Nothing
                                              Set Lrstemp = Nothing
                                              Exit Sub
                                           End If
                                        Else
                                           MsgBox "Cliente no tiene Saldo Disponible", vbDefaultButton1 + vbExclamation, "Mensaje"
                                           Set Lutil = Nothing
                                           Set Lrstemp = Nothing
                                           Exit Sub
                                        End If
                                         
                                         
'                                        Modificado por : Cesar Ospino \ Fecha : 18/03/2006
'                                         If Lrstemp!saldo < 0 Then  ' Aún tiene Saldo
'                                            Ldblsaldo = Lrstemp!saldo * -1
'
'                                            If Val(txt_total.Text) > Ldblsaldo Then
'                                               MsgBox "Monto excede los " & Str(Ldblsaldo) & " Soles disponibles a facturar ", vbDefaultButton1 + vbExclamation, "Mensaje"
'                                               Set Lutil = Nothing
'                                               Set Lrstemp = Nothing
'                                               Exit Sub
'                                            End If
'                                         Else
'                                            MsgBox "Cliente no tiene Saldo Disponible", vbDefaultButton1 + vbExclamation, "Mensaje"
'                                            Exit Sub
'                                         End If
                                        
                                         Set Lutil = Nothing
                                         Set Lrstemp = Nothing
            
            
                               '********************************************************
                               If IntPagoAdelantado = 1 Then
                                  f_ingresovalesadelanto.lblcorrelativo.Caption = pdbl_correlativo
                                  f_ingresovalesadelanto.txtdocumento.Text = dtc_serie.Text & txt_NBRDOCUMENT.Text
                                  f_ingresovalesadelanto.txttotvales.Caption = GFormatodeNumero(CDbl(txt_total.Text), 2)
                                  f_ingresovalesadelanto.txttotvalesacum.Caption = GFormatodeNumero(0, 2)
                                  f_ingresovalesadelanto.RefrescarGrilla
                                  f_ingresovalesadelanto.Show vbModal
                                  If Not gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
                                     Exit Sub
                                  End If
                               Else
                                  f_ingresovales.lblcorrelativo.Caption = pdbl_correlativo
                                  f_ingresovales.Show vbModal
                                  If Not gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
                                     Exit Sub
                                  End If
                               End If
                    Else
                       If IntPagoAdelantado = 1 Then
                          f_ingresovalesadelanto.lblcorrelativo.Caption = pdbl_correlativo
                          f_ingresovalesadelanto.txtdocumento.Text = dtc_serie.Text & txt_NBRDOCUMENT.Text
                          f_ingresovalesadelanto.txttotvales.Caption = GFormatodeNumero(CDbl(txt_total.Text), 2)
                          f_ingresovalesadelanto.txttotvalesacum.Caption = GFormatodeNumero(0, 2)
                          f_ingresovalesadelanto.RefrescarGrilla
                          f_ingresovalesadelanto.Show vbModal
                          If Not gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
                             Exit Sub
                          End If
                       Else
                          f_ingresovales.lblcorrelativo.Caption = pdbl_correlativo
                          f_ingresovales.Show vbModal
                          If Not gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
                             Exit Sub
                          End If
                       End If
                    End If
                Else
                   IntPagoAdelantado = 0
                   MsgBox "Cliente no es de Adelanto", vbExclamation, "Atencion"
                   Exit Sub
                End If
              End If
          Else
            IntPagoAdelantado = 0
          End If
          
          gbln_ventaefectuada = False
          
          fpagoefectivo.LBL_MONEDAT.Caption = TXT_MONEDATOTAL.Text
          fpagoefectivo.LBL_MONEDAV.Caption = TXT_MONEDATOTAL.Text
          fpagoefectivo.LBL_MONTOV.Caption = "0"
          fpagoefectivo.txt_tc.Text = txt_tcambio.Text
          fpagoefectivo.lbl_pen = GstrSimboloMonedaBase
          fpagoefectivo.lbl_usd = GstrSimboloMonedaExt
          
          If GstrMonedaLimiteCredito = GstrCodMonedaBase Then     ' GRABAR EN MONEDA BASE Y CALCULAR MONEDA EXTRANJERA
              fpagoefectivo.txt_esoles.Text = LdblTotalBase
              fpagoefectivo.LBL_MONTOT.Caption = LdblTotalBase
          Else
              fpagoefectivo.txt_edolares.Text = LdblTotalExt
              fpagoefectivo.LBL_MONTOT.Caption = LdblTotalExt
          End If
          
          GINT_TIPOPAGO = 0
          
          fpagoefectivo.Show vbModal
          
          If gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
              
               If IntPagoAdelantado = 0 Then
                 Select Case GINT_TIPOPAGO
                    Case 1
                        Call GRABAR_VENTA(GC_PAGOEFECTIVO)
                    Case 2
                        Call GRABAR_VENTA(GC_TARJETACRED)
                    Case 3
                        Call GRABAR_VENTA(GC_OTROS)
                 End Select
               Else
                 Call GRABAR_VENTA(GC_CONTADOADELANTO, IntPagoAdelantado)
               End If
          End If
   End If
Else
  If Val(txt_total.Text) > 0 Then
  
    ' ****************************************************
    ' Insertar Parte para Grabar Vales en Clientes Contado
    ' ****************************************************
  
      If Len(Trim(TXT_IDCLIENTE.Text)) > 0 Then
         If Not grscliente.EOF Then
          If grscliente!credito = 0 Or IsNull(grscliente!credito) And GblnconPlacas = True Then ' Si el Cliente es Contado
              'IntPagoAdelantado = 1
              f_ingresovales.lblcorrelativo.Caption = pdbl_correlativo
              f_ingresovales.Show vbModal
              If Not gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
                 Exit Sub
              End If
          Else
             'IntPagoAdelantado = 0
             'MsgBox "Cliente no es de Adelanto", vbExclamation, "Atencion"
             'Exit Sub
          End If
         End If
         
      End If
  
    gbln_ventaefectuada = False
    
    ' ****************************************************
    ' Fin de Parte para Grabar Vales en Clientes Contado
    ' ****************************************************
    
    
    fpagoefectivo.LBL_MONEDAT.Caption = TXT_MONEDATOTAL.Text
    fpagoefectivo.LBL_MONEDAV.Caption = TXT_MONEDATOTAL.Text
    fpagoefectivo.LBL_MONTOV.Caption = "0"
    fpagoefectivo.txt_tc.Text = txt_tcambio.Text
    fpagoefectivo.lbl_pen = GstrSimboloMonedaBase
    fpagoefectivo.lbl_usd = GstrSimboloMonedaExt
    
    If GstrMonedaLimiteCredito = GstrCodMonedaBase Then     ' GRABAR EN MONEDA BASE Y CALCULAR MONEDA EXTRANJERA
        fpagoefectivo.txt_esoles.Text = LdblTotalBase
        fpagoefectivo.LBL_MONTOT.Caption = LdblTotalBase
    Else
        fpagoefectivo.txt_edolares.Text = LdblTotalExt
        fpagoefectivo.LBL_MONTOT.Caption = LdblTotalExt
    End If
    GINT_TIPOPAGO = 0
    
    fpagoefectivo.Show vbModal
    
    If gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
        
        Select Case GINT_TIPOPAGO
            Case 1
                Call GRABAR_VENTA(GC_PAGOEFECTIVO)
            Case 2
                Call GRABAR_VENTA(GC_TARJETACRED)
            Case 3
                Call GRABAR_VENTA(GC_OTROS)
        End Select
    End If
  End If
End If

End Sub

Private Sub cmd_recupera_Click()
If GBlnpermitegrabartrans Then
    gdouloadsales = 0
    txtArticulo.SetFocus        'PARA EVITAR QUE VALIDE CODIGO CLIENTE
    frecuperartransaccion.Show vbModal
    If gdouloadsales <> 0 Then  'se eligio restaurar alguna transaccion
        MBLN_INICIO = False
        'NO SE DEBE PODER MODIFICAR LA CABEZERA
        pdbl_correlativo = gdouloadsales
        Call CARGACABEZERALOADSALE(gdouloadsales)
        Call valida_codigocliente("RT")     'obtener moneda, tipo cambio, tipo, etc
        Call valida_RUCcliente("RT")
        Call ESTADO_CABEZERA(False)         ' proteger la cabezera
        Call CARGAGRILLA(gdouloadsales)     'mostrar los datos grabados en la cabezera
        If gstrtipoventas <> "A" Then
            Call FORMATONBRDOCUMENT         'darle formato al numero de documento
        End If
        txt_NBRDOCUMENT.Enabled = False
        txtArticulo.SetFocus
        'MsgBox "Transaccion Recuperada", vbExclamation, "OK"
        ' AL CERRAR TRANSACCION VOLVER A CONSULTAR EL NRO.DE DOCUMENTO
    End If
Else
    MsgBox "No Esta Activada la Grabacion de Transacciones"
End If
End Sub

Private Sub cmd_salir_Click()
If Val(txt_total.Text) > 0 Then
    If MsgBox("Esta Seguro de Salir " + Chr(13) + "Los Cambios hechos se perderan ", vbYesNo + vbQuestion, "Precaución") = vbNo Then
        Exit Sub
    End If
End If
Call cierra_objetos
Unload Me
End Sub

Private Sub cmd_salvar_Click()
Dim dbl_monto As Double
If GBlnpermitegrabartrans Then
    dbl_monto = Val(txt_total.Text)
    If dbl_monto > 0 Then
        mobj_cventasgen.salvartransaccion pdbl_correlativo, dbl_monto
        Call borrar_valores
        Call inicio
        'TXT_IDCLIENTE.SetFocus
        MBLN_INICIO = False
    Else
        MsgBox "No hay Registros para Salvar", vbExclamation, "Atencion"
    End If
Else
    MsgBox "No Esta Activada la Grabacion de Transacciones", vbExclamation, "Atencion"
End If
End Sub
Private Sub cmd_tarjeta_Click()
If Val(txt_total.Text) > 0 Then

   If Trim(gstrtipoventas) <> "A" Then
           
       Set MrsMesCerrado = MobjMovimientos.ValidaMesCerrado(GstrSiteProce, dtp_fechapro.Value)
    
       If MrsMesCerrado!MESCERRADO = 1 Then
          MsgBox " No se pueden Ingresar Documentos de un Mes que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
          Exit Sub
       Else
         If MrsMesCerrado!PDCERRADO = 1 Then
            MsgBox " No se pueden Ingresar Documentos de un Parte Diario que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
            Exit Sub
         End If
       End If
            
       Set MrsMesCerrado = Nothing
         
   End If
 

   fpagotarjetas.lbl_moneda.Caption = TXT_MONEDATOTAL.Text
   fpagotarjetas.lbl_monto.Caption = txt_total.Text
   fpagotarjetas.txt_tcambio.Text = txt_tcambio.Text
   fpagotarjetas.dtc_monedat.BoundText = GstrMonedaLimiteCredito
   fpagotarjetas.Show vbModal
   If gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
       Call GRABAR_VENTA(GC_TARJETACRED)
   End If
End If
End Sub

Public Function VerificarFacturacion() As String
    
  Dim LstrMensaje As String
    
  Dim Lintdocumentosvencidos As Integer
  Dim MrsDocumentoVencido As ADODB.Recordset
  Dim LDblMontoaFacturar As Double
  Dim LDblMontoFree As Double
  
  LstrMensaje = Empty
  
  Lintdocumentosvencidos = 0
  LDblMontoFree = 0
  VerificarFacturacion = ""
    
  'Verificar si el RUC es Válido
   
  'Verificar si existen Documentos Vencidos
  
  Set MrsDocumentoVencido = mobj_cventasgen.ObtenerDocumentosVencidosVG(TXT_IDCLIENTE.Text)
   
  If Not MrsDocumentoVencido.EOF Then
     LDblMontoFree = MrsDocumentoVencido!MontoLibre
     
     If gstrtipoventas = "A" Then
        LDblMontoFree = mobj_cventasgen.ConvertirMoneda(LDblMontoFree, GstrMonedaLimiteCredito, GStrMonedaCaja, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecResultado)
     Else
        LDblMontoFree = mobj_cventasgen.ConvertirMoneda(LDblMontoFree, GstrMonedaLimiteCredito, GStrMonedaCaja, dtp_fechapro.Value, GstrTipodeCambio, GintDecResultado)
     End If
     
     Do While Not MrsDocumentoVencido.EOF
        Lintdocumentosvencidos = Lintdocumentosvencidos + MrsDocumentoVencido!Vencidos
        MrsDocumentoVencido.MoveNext
     Loop
  End If
     
                              
  'LDblMontoaFacturar = mobj_cventasgen.ConvertirMoneda(txt_total.Text, GstrMonedaLimiteCredito, GStrMonedaCaja, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecResultado)
           
  'GdblSaldoDisponible y GdblMontoExtra originalmente están a la moneda del cliente
  'pero llegan convertidos a la moneda de la caja
  
  ' LDblMontoFree : se asume a la moneda del Cliente , entonces se tiene que convertir
  ' a la moneda de la caja
           
  If gstrtipoventas = "A" Then
     LDblMontoaFacturar = mobj_cventasgen.ConvertirMoneda(txt_total.Text, GstrMonedaLimiteCredito, GStrMonedaCaja, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecResultado)
  Else
     LDblMontoaFacturar = mobj_cventasgen.ConvertirMoneda(txt_total.Text, GstrMonedaLimiteCredito, GStrMonedaCaja, dtp_fechapro.Value, GstrTipodeCambio, GintDecResultado)
  End If
  
  If LDblMontoaFacturar > GdblSaldoDisponible + GdblMontoExtra Then
      If LDblMontoFree >= LDblMontoaFacturar Then
         GoTo TERMINAR:
      Else
         LstrMensaje = "Excede el Límite de Crédito"
         VerificarFacturacion = LstrMensaje
         GoTo TERMINAR:
      End If
  End If
    
  If Lintdocumentosvencidos >= 1 Then
     If (LDblMontoFree > LDblMontoaFacturar) And _
         LDblMontoFree <> 0 Then
         GoTo TERMINAR
     Else
        LstrMensaje = "NO SE PUEDE FACTURAR,DOCUMENTOS VENCIDOS"
        VerificarFacturacion = LstrMensaje
     End If
  End If
     
TERMINAR:
    
  Set MrsDocumentoVencido = Nothing
     
End Function

Private Sub cmd_vale_Click()
If Val(txt_total.Text) > 0 Then
    If Len(Trim(TXT_IDCLIENTE.Text)) > 0 Then
          If grscliente!credito = 1 Then
              
            ' Validacion Parte Diario
              
              If Trim(gstrtipoventas) <> "A" Then
           
                Set MrsMesCerrado = MobjMovimientos.ValidaMesCerrado(GstrSiteProce, dtp_fechapro.Value)

                If MrsMesCerrado!MESCERRADO = 1 Then
                   MsgBox " No se pueden Ingresar Documentos de un Mes que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
                   Exit Sub
                Else
                If MrsMesCerrado!PDCERRADO = 1 Then
                   MsgBox " No se pueden Ingresar Documentos de un Parte Diario que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
                   Exit Sub
                End If
               End If
        
             Set MrsMesCerrado = Nothing
         
            End If

            If Trim(dtc_tdocumento.BoundText) <> Trim(mobj_cventasgen.obtenertiponc) Then
              ' Hay que Verificar si no tiene Documentos Vencidos
               Dim LstrMensajeVerificacion As String
               LstrMensajeVerificacion = VerificarFacturacion
               If Trim(LstrMensajeVerificacion) <> "" Then
                  MsgBox LstrMensajeVerificacion, vbDefaultButton1 + vbExclamation, "Advertencia"
                  Exit Sub
               End If
            ' *************************************************
               f_ingresovales.lblcorrelativo.Caption = pdbl_correlativo
               f_ingresovales.Show vbModal
            Else
              ' Si es una Nota de Credito
              gbln_ventaefectuada = True
            End If
            
            If gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
                
                Call GRABAR_VENTA(GC_VALESCRED)
                MsgBox "Documento Fue Grabado", vbDefaultButton1 + vbInformation, "Advertencia"
                
            End If
        Else
               MsgBox "Cliente no es de credito", vbExclamation, "Atencion"
        End If
    End If
End If
End Sub

Private Sub cmdadelanto_Click()
      
  ' Validacion de Parte Diario
      
   If Trim(gstrtipoventas) <> "A" Then
           
       Set MrsMesCerrado = MobjMovimientos.ValidaMesCerrado(GstrSiteProce, dtp_fechapro.Value)
    
       If MrsMesCerrado!MESCERRADO = 1 Then
          MsgBox " No se pueden Ingresar Documentos de un Mes que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
          Exit Sub
       Else
         If MrsMesCerrado!PDCERRADO = 1 Then
            MsgBox " No se pueden Ingresar Documentos de un Parte Diario que ya ha sido Cerrado", vbExclamation + vbDefaultButton1, "Mensaje"
            Exit Sub
         End If
       End If
            
       Set MrsMesCerrado = Nothing
         
  End If
           
      
  ' Fin de Validaicon de Parte Diario
      
      
  If Trim(dtc_tdocumento.BoundText) = Trim(mobj_cventasgen.obtenertiponc) Then
     If MsgBox("Nota de Crédito por Consumo de Adelanto ", vbYesNo + vbQuestion, "Advertencia") = vbNo Then
        Exit Sub
     End If
  Else
      If MsgBox("La factura corresponde a un Pago por Adelanto ", vbYesNo + vbQuestion, "Advertencia") = vbNo Then
         Exit Sub
      End If
  End If
  
  
  If Val(txt_total.Text) > 0 Then
    fpagoefectivo.LBL_MONEDAT.Caption = TXT_MONEDATOTAL.Text
    fpagoefectivo.LBL_MONEDAV.Caption = TXT_MONEDATOTAL.Text
    fpagoefectivo.LBL_MONTOV.Caption = "0"
    fpagoefectivo.txt_tc.Text = txt_tcambio.Text
    fpagoefectivo.lbl_pen = GstrSimboloMonedaBase
    fpagoefectivo.lbl_usd = GstrSimboloMonedaExt
    
    If GstrMonedaLimiteCredito = GstrCodMonedaBase Then     ' GRABAR EN MONEDA BASE Y CALCULAR MONEDA EXTRANJERA
        fpagoefectivo.txt_esoles.Text = LdblTotalBase
        fpagoefectivo.LBL_MONTOT.Caption = LdblTotalBase
    Else
        fpagoefectivo.txt_edolares.Text = LdblTotalExt
        fpagoefectivo.LBL_MONTOT.Caption = LdblTotalExt
    End If
    GINT_TIPOPAGO = 0
    fpagoefectivo.Caption = "Pago Adelantado"
    fpagoefectivo.Show vbModal
    
    If gbln_ventaefectuada Then   ' si se efectuo el pago, grabar y emitir
        
        Select Case GINT_TIPOPAGO
            Case 1
                Call GRABAR_VENTA(GC_PAGOEFECTIVO, 1)
            Case 2
                Call GRABAR_VENTA(GC_TARJETACRED)
            Case 3
                Call GRABAR_VENTA(GC_OTROS)
        End Select
        MsgBox "Documento Fue Grabado", vbDefaultButton1 + vbInformation, "Advertencia"
    End If
  End If
End Sub

Private Sub cmdBuscaArticulo_Click()

If mbln_editandoproducto Then
    Exit Sub
End If
'If ExisteTipoCambio = False Then
'        Exit Sub
'    End If
     GrecibeUbicacion = 0
     GrecibeColumnaID = Empty
     GrecibeColumnaOpcional = Empty
     
     Dim ArrayBusqueda(1 To 5, 1 To 3) As Variant
     Dim blnExiste As Boolean
     ArrayBusqueda(1, 1) = "id"
     ArrayBusqueda(1, 2) = "Codigo"
     ArrayBusqueda(1, 3) = 1000
     ArrayBusqueda(2, 1) = "Descripcion"
     ArrayBusqueda(2, 2) = "Descripción "
     ArrayBusqueda(2, 3) = 4000
     ArrayBusqueda(3, 1) = "stock"
     ArrayBusqueda(3, 2) = "Stock"
     ArrayBusqueda(3, 3) = 1000
     ArrayBusqueda(4, 1) = "descrmoney"
     ArrayBusqueda(4, 2) = "Moneda"
     ArrayBusqueda(4, 3) = 700
     ArrayBusqueda(5, 1) = "precio"
     ArrayBusqueda(5, 2) = "Precio"
     ArrayBusqueda(5, 3) = 1000
      
      
     'Hay que Cargar la lista de Productos
      
     If gstrtipoventas = "A" Then
        Set prs_productos_tienda = mobj_cventasgen.Listarproductosventas(GstrSiteProce, True)
     Else
        Set prs_productos_playa = mobj_cventasgen.Listarproductosventas(GstrSiteProce, False)
        Set prs_productos_tienda = mobj_cventasgen.Listarproductosventas(GstrSiteProce, True)
     End If
 
    
     If gstrtipoventas = "A" Then
        fbusquedaarticulocstore.GObtenerRegistros prs_productos_tienda, ArrayBusqueda, 5, 2, 8600, 5970, 700, 700
     Else
        If dtc_tnegocio.BoundText = 2 Then
            fbusquedaarticulocstore.GObtenerRegistros prs_productos_tienda, ArrayBusqueda, 5, 2, 8600, 5970, 700, 700
         Else
            fbusquedaarticulocstore.GObtenerRegistros prs_productos_playa, ArrayBusqueda, 5, 2, 8600, 5970, 700, 700
         End If
         
     End If
    fbusquedaarticulocstore.Show vbModal
     If GrecibeUbicacion <> 0 Then
         txtArticulo.Text = GrecibeColumnaID
         txtArticulo.SetFocus
         Call validaarticulo
      End If
      
End Sub




Private Sub cmdDctoAdic_Click()
    mbln_editandoproducto = True        'EDITAR
    descuentoAdicional = True           'SE REALIZARA DESCUENTOS POR ITEM
    
    frmDescuentos.Caption = "Descuento Adicional"
    frmDescuentos.lblApliTot = txt_total.Text
    frmDescuentos.Show vbModal
    
    mbln_editandoproducto = False       'REINICIAR
    descuentoAdicional = False
    
End Sub

Private Sub cmdDctoItem_Click()
'cofiguracion ventana descuentos item
    If DBDetalle.Row = -1 Then Exit Sub
    mbln_editandoproducto = True 'EDITAR
    DescuentoItem = True                        'SE REALIZARA DESCUENTOS POR ITEM
    
    frmDescuentos.Caption = "Descuento sobre el Item Nº " & DBDetalle.Columns(0).Text
    frmDescuentos.lblApliTot = DBDetalle.Columns(6).Text
    frmDescuentos.Label3.Visible = False
    frmDescuentos.ctnDes3.Visible = False
    frmDescuentos.Label5.Visible = False
    frmDescuentos.lblTotAct.Visible = False
    frmDescuentos.Show vbModal
    
    mbln_editandoproducto = False 'REINICIAR
    DescuentoItem = False

End Sub




Private Sub Command1_Click()
   MsgBox dtc_tdocumento.BoundText
End Sub

Private Sub CTN_SUBTOTAL_GotFocus()

''If Val(ctnprecio.Text) = 0 Or Len(Trim(txtArticulo.Text)) = 0 Then
''   MsgBox "Debe ingresar un producto con precio", vbCritical, "Error"
''   'txtArticulo.SetFocus
''   'ctnprecio.SetFocus
''End If

If (rs_prod!curyid = GstrCodMonedaBase And rs_prod!stdcostpen > Val(ctnprecio.Text)) Or _
(rs_prod!curyid = GstrMonedaExtranjera And rs_prod!stdcostusd > Val(ctnprecio.Text)) Then
    MsgBox "Relacion Costo/Precio incorrecto", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If

If rs_prod!CLASSID <> GstrCategoriaFuels Then
        
    If rs_prod!stkitem = False Then
       CTN_SUBTOTAL.Enabled = True
       CTN_SUBTOTAL.BackColor = vbCyan
       'CTN_SUBTOTAL.SetFocus
    Else
       CTN_SUBTOTAL.Enabled = False
       MsgBox "El Producto debe ser un combustible", vbExclamation, "Atencion"
       txtArticulo.SetFocus
    End If
    
Else
    CTN_SUBTOTAL.Enabled = True
    CTN_SUBTOTAL.BackColor = vbCyan
End If


End Sub

Private Sub CTN_SUBTOTAL_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Or KeyCode = vbKeyDown Then
 'calcular la cantidad
   Call grabarregistro
End If
If KeyCode = vbKeyUp Then
    ctnUnidades.SetFocus
End If
End Sub

Private Sub CTN_SUBTOTAL_KeyUp(KeyCode As Integer, Shift As Integer)
On Error Resume Next
Dim LDOU_TOT As Double
LDOU_TOT = CDbl(CTN_SUBTOTAL.Text)
ctnUnidades.Text = Str(Round(LDOU_TOT / CDbl(ctnprecio.Text), GintDecStock))
End Sub

Private Sub CTN_SUBTOTAL_LostFocus()
 CTN_SUBTOTAL.BackColor = vbWhite
End Sub

Private Sub ctnprecio_GotFocus()
If Len(Trim(txtArticulo.Text)) = 0 Then
    MsgBox "Ingrese Primero un Articulo", vbExclamation, "Atencion"
    txtArticulo.SetFocus
Else
    If Not mbln_articuloencontrado Then
        MsgBox "Producto Incorrecto", vbExclamation, "Atencion ."
        txtArticulo.SetFocus
    Else
        ctnprecio.BackColor = vbCyan
    End If
End If
End Sub

Private Sub ctnprecio_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If Val(ctnprecio.Text) <= 0 Then
        MsgBox "Debe Ingresar Un Precio", vbExclamation, "Atencion"
        If ctnprecio.Enabled = True Then
           ctnprecio.SetFocus
        End If
        Exit Sub
    End If

    If (rs_prod!curyid = GstrCodMonedaBase And rs_prod!stdcostpen > Val(ctnprecio.Text)) Or _
        (rs_prod!curyid = GstrMonedaExtranjera And rs_prod!stdcostusd > Val(ctnprecio.Text)) Then
            MsgBox "Precio menor al costo del producto", vbExclamation, "Atencion"
            If ctnprecio.Enabled = True Then
               ctnprecio.SetFocus
            End If
            Exit Sub
   Else
      ctnUnidades.SetFocus
    End If
End If

If KeyCode = vbKeyUp Then
    txtArticulo.SetFocus
End If

End Sub

Private Sub ctnprecio_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = "-" Then
    KeyAscii = 0
End If
End Sub

Private Sub ctnprecio_KeyUp(KeyCode As Integer, Shift As Integer)
Dim LDOU_UNI As Double
LDOU_UNI = Val(ctnUnidades.Text)
CTN_SUBTOTAL.Text = Str(Round(LDOU_UNI * Val(ctnprecio.Text), GintDecResultado))
End Sub

Private Sub ctnprecio_LostFocus()
ctnprecio.BackColor = vbWhite
End Sub

Private Sub ctnUnidades_GotFocus()
If Len(Trim(txtArticulo.Text)) = 0 Then
    MsgBox "Ingrese Primero un Articulo", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If

If gstrtipoventas <> "A" Then
    If Val(ctnprecio.Text) <= 0 Then
        MsgBox "Ingrese Precio", vbExclamation, "Atencion"
        If ctnprecio.Enabled = True Then
           ctnprecio.SetFocus
        End If
        Exit Sub
    End If
End If


If (rs_prod!curyid = GstrCodMonedaBase And rs_prod!stdcostpen > Val(ctnprecio.Text)) Or _
(rs_prod!curyid = GstrMonedaExtranjera And rs_prod!stdcostusd > Val(ctnprecio.Text)) Then
    MsgBox "Relacion Costo/Precio incorrecto", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If

If Not mbln_articuloencontrado Then
    MsgBox "Producto Incorrecto", vbExclamation, "Atencion ."
    txtArticulo.SetFocus
Else
    ctnUnidades.BackColor = vbCyan
End If

'AUTOR: JORGE ILLESCAS:------------PARA MI MERCADO---------------------------------------
'APENAS LEE EL CODIGO DE BARRAS, EL ARTICULO PASA A LOS DETALLES DE VENTA----------------
'If ctnUnidades.Text <> 0 Then
'    Call ctnUnidades_KeyDown(13, 0)
'    txtArticulo.SetFocus
'End If
    
End Sub
Private Sub ctnUnidades_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If Val(ctnUnidades.Text) <= 0 Then
        MsgBox "Debe Ingresar Una cantidad", vbExclamation, "Atencion"
        ctnUnidades.SetFocus
        Exit Sub
    End If

    If rs_prod!CLASSID <> GstrCategoriaFuels Then
        If Val(Int(ctnUnidades.Text)) < Val(ctnUnidades.Text) Then
            MsgBox "No Puede Despachar cantidades con Decimales", vbExclamation, "Atencion"
            ctnUnidades.SetFocus
            Exit Sub
        End If
    End If

   If Val(ctnUnidades.Text) > rs_prod!stock And (Not GIntPermiteStkNegativo) And rs_prod!stkitem = True Then
        MsgBox "Cantidad Mayor al stock Disponible", vbExclamation, "Atencion"
        ctnUnidades.SetFocus
        Exit Sub
   Else
        If rs_prod!CLASSID <> GstrCategoriaFuels And rs_prod!stkitem = True Then
             Call grabarregistro
        Else
             CTN_SUBTOTAL.SetFocus
        End If
    End If
End If

If KeyCode = vbKeyUp Then
    If gstrtipoventas = "A" Then
        txtArticulo.SetFocus
    Else
       If ctnprecio.Enabled = True Then
          ctnprecio.SetFocus
       Else
          txtArticulo.SetFocus
       End If
    End If
End If

End Sub
Private Sub ctnUnidades_KeyPress(KeyAscii As Integer)

If Chr(KeyAscii) = "-" Then
    KeyAscii = 0
End If

End Sub

Private Sub ctnUnidades_KeyUp(KeyCode As Integer, Shift As Integer)
Dim LDOU_UNI As Double
LDOU_UNI = Val(ctnUnidades.Text)
CTN_SUBTOTAL.Text = Str(Round(LDOU_UNI * Val(ctnprecio.Text), GintDecResultado))
End Sub

Private Sub ctnUnidades_LostFocus()
ctnUnidades.BackColor = vbWhite
End Sub

Private Sub DBDETALLE_DblClick()
    If Not MrsGrilla.EOF Or MrsGrilla.RecordCount > 0 Then
        Call editar_producto
        Call validaarticulo
        ctnUnidades.SetFocus
    End If
End Sub
Sub editar_producto()
        mbln_articuloencontrado = True
        mbln_editandoproducto = True
        txtArticulo.Text = MrsGrilla!INVTIDSKU
        lblDescripcion.Caption = MrsGrilla!DESCRINVENTORY
        ctnprecio.Text = MrsGrilla!SLSPRICESALE
        ctnUnidades.Text = MrsGrilla!QTY
        txtArticulo.Locked = True
        ctnUnidades.SetFocus
        'Call validaarticulo
End Sub
Sub editar_producto_SaltoAutomatic()
'MMercado: Jorge Illescas-----------------------------------------------------------------------------------------------
'Apuntando al articulo que se modificara automaticamente(no permite duplicar el item, solo la cantidad del mismo articulo)
'Permite editar el articulo y realizar un salto automatico
'-----------------------------------------------------------------------------------------------------------------------
        mbln_articuloencontrado = True
        mbln_editandoproducto = True
        swEditSaltoAutomatico = True   'Controla este evento
        
        'Busca el articulo en el recosrdset temporal q carga todos los articulos de detalle de venta
        MrsGrilla.MoveFirst
        MrsGrilla.Find "INVTIDSKU='" & Trim(txtArticulo.Text) & "'"
        If Not MrsGrilla.EOF Then
            txtArticulo.Text = MrsGrilla!INVTIDSKU
            lblDescripcion.Caption = MrsGrilla!DESCRINVENTORY
            ctnprecio.Text = MrsGrilla!SLSPRICESALE
            ctnUnidades.Text = IIf(sw_codBarrPeso, Round(MrsGrilla!QTY + MrsGrilla!QTY, GintDecResultado), MrsGrilla!QTY + 1)
            compactCodBarrPeso = True
                
            txtArticulo.Locked = True
        Else
            MsgBox "Intenete ingresar nuevamente el el articulo!", vbCritical, "Atencion"
        End If

'        ctnUnidades.SetFocus
'        Call validaarticulo
End Sub
Private Sub DBDETALLE_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then        'MODIFICAR
    If Not MrsGrilla.EOF Or MrsGrilla.RecordCount > 0 Then
        Call editar_producto
        Call validaarticulo
        KeyCode = vbKeyTab
        txtArticulo.SetFocus
    End If
End If
If KeyCode = vbKeyF7 Then
   Call cmd_efectivo_Click
End If

If KeyCode = vbKeyF3 Then   'ELIMINAR
    If Not MrsGrilla.EOF Or MrsGrilla.RecordCount > 0 Then
      If MsgBox("Seguro que desea Eliminar el Registro No." + Str(MrsGrilla.AbsolutePosition), vbYesNo + vbQuestion, "Advertencia") = vbYes Then
          MOBJ_CVENTASCSTORE.eliminarcstoreDetalle pdbl_correlativo, MrsGrilla!lin
          Call CARGAGRILLA(pdbl_correlativo)
          If MrsGrilla.RecordCount = 0 Then ' NO HAY REGISTROS
            ESTADO_CABEZERA (True)  'ACTIVAR CABEZERA
            txtArticulo.SetFocus
          End If
      End If
     End If
End If
If KeyCode = vbKeyF8 Then
    Call cmd_tarjeta_Click
End If

End Sub

Private Sub dtc_serie_Change()
 txt_NBRDOCUMENT.Text = mobj_cventasgen.obtenernrodocumento(dtc_tdocumento.BoundText, dtc_serie.BoundText, GstrSiteProce)
End Sub

Private Sub dtc_serie_GotFocus()
dtc_serie.BackColor = vbCyan
Call valida_cabezera1
End Sub

Private Sub dtc_serie_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Or KeyCode = vbKeyDown Then
    txt_NBRDOCUMENT.Text = mobj_cventasgen.obtenernrodocumento(dtc_tdocumento.BoundText, dtc_serie.BoundText, GstrSiteProce)
    txt_NBRDOCUMENT.SetFocus
End If
If KeyCode = vbKeyUp Then
   If dtc_tdocumento.Enabled = True Then
      dtc_tdocumento.SetFocus
   End If
End If
End Sub

Private Sub dtc_serie_LostFocus()
If dtc_tdocumento.Text <> "" Then
    txt_NBRDOCUMENT.Text = mobj_cventasgen.obtenernrodocumento(dtc_tdocumento.BoundText, dtc_serie.BoundText, GstrSiteProce)
End If
dtc_serie.BackColor = vbWhite
End Sub

Private Sub dtc_tdocumento_Change()
txt_tipodoc.Text = dtc_tdocumento.Text
TXT_IDCLIENTE.Text = ""
txt_ruc.Text = ""
txt_direccion.Text = ""
txt_razonsocial.Text = ""
'buscar numeros de serie para ese tipo de documento
Call CargaDataCombo(dtc_serie, mobj_cventasgen.obtenerseriesdoc(dtc_tdocumento.BoundText, GstrSiteProce), "nbrseries", "nbrseries")
txt_NBRDOCUMENT.Text = mobj_cventasgen.obtenernrodocumento(dtc_tdocumento.BoundText, dtc_serie.BoundText, GstrSiteProce)
End Sub
Private Sub dtc_tdocumento_GotFocus()
dtc_tdocumento.BackColor = vbCyan
End Sub

Private Sub dtc_tdocumento_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Or KeyCode = vbKeyDown Then
   dtc_serie.SetFocus
End If

If KeyCode = 27 Then
   cmd_Cancelar_Click
End If

End Sub

Private Sub dtc_tdocumento_LostFocus()
dtc_tdocumento.BackColor = vbWhite
End Sub

Private Sub dtc_tnegocio_GotFocus()
Call valida_cabezera1
End Sub

Private Sub dtc_tnegocio_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Or KeyCode = vbKeyDown Then
    txtArticulo.SetFocus
End If

If KeyCode = vbKeyUp Then
   If dtp_fecha.Enabled = True Then
      dtp_fecha.SetFocus
   End If
End If
End Sub

Private Sub dtp_fecha_GotFocus()
Call valida_cabezera1
End Sub

Private Sub dtp_fecha_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    dtc_tnegocio.SetFocus
End If
End Sub

Private Sub dtp_fecha_LostFocus()
Call valida_cabezera1
End Sub

Private Sub dtp_fechapro_GotFocus()
Call valida_cabezera1
End Sub

Private Sub dtp_fechapro_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If dtp_fecha.Enabled = True Then
       dtp_fecha.SetFocus
    End If
End If
End Sub

Private Sub dtp_fechapro_LostFocus()
Call valida_cabezera1
End Sub
Private Sub Form_Activate()
Unload F_inicio
If pbderecho_consultar = False Then
    Unload Me
Else
    Call enfoque_inicial
End If
MBLN_INICIO = False
End Sub
Private Sub enfoque_inicial()
If gstrtipoventas = "A" Then
    Me.Caption = Me.Caption + " Emision de Tickets" + Space(45) + GstrPuntodeVenta + " (" + GstrTerminal + ") " + CStr(GDatFechaProcesoVentas)
Else
    Me.Caption = Me.Caption + Space(55) + GstrPuntodeVenta + " (" + GstrTerminal + ") " + CStr(GDatFechaProcesoVentas)
End If
lblversion.Caption = "SIES " & App.Major & "." & App.Minor & "." & App.Revision

If MBLN_INICIO Then
    If gstrtipoventas = "A" Then
       If TXT_IDCLIENTE.Enabled = True Then
          'Permite elegir el enfoque inicial segun sea factura o ticket
          If GstrImprFacPreImpresa Then
             TXT_IDCLIENTE.SetFocus
          Else
             txtArticulo.SetFocus
          End If
       Else
          txtArticulo.SetFocus
       End If
    Else
       If dtc_tdocumento.Enabled = True Then
          dtc_tdocumento.SetFocus
       End If
    End If
    MBLN_INICIO = False
End If

End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
'AUTOR: JORGE ILLESCAS------------------------------------------------------------------------------------
'PARA CALCULAR LA CANTIDAD DEL ARTICULO A VENDER----------------------------------------------------------
If KeyAscii = vbKeyF3 Then
    
End If
End Sub

Private Sub Form_Load()
sknVentaCstore.LoadSkin (App.Path & "\Skins\B-Studio.skn")
sknVentaCstore.ApplySkin (Me.hWnd)

'GstrMonedaLimiteCredito = ""
If gstrtipoventas = "A" Then
    Me.Caption = "Ventas Cstore (05.020.00)"
    cmdadelanto.Enabled = False
    cmdadelanto.Visible = False
Else
    Me.Caption = "Ingreso Documentos Manuales (05.025.00)"
    cmd_salvar.Enabled = False
    cmd_salvar.Visible = False
    cmd_recupera.Enabled = False
    cmd_recupera.Visible = False
End If

Call gseguridad(Me)

If pbderecho_consultar Then
    Call instancia_objetos
    Me.Width = 12270
    Me.Height = 8610
    'dtp_fecha.Value =GDatFechaProceso
    dtp_fechapro.Value = GDatFechaProcesoVentas
    Call ObtenerConfiguracionTicket
    
    CTN_SUBTOTAL.PermitirNegativos = False
    CTN_SUBTOTAL.Enteros = 11
    CTN_SUBTOTAL.Decimales = 2
    CTN_SUBTOTAL.Enabled = False
    ctnUnidades.PermitirNegativos = False
    ctnUnidades.Decimales = GintDecStock
    ctnUnidades.Enteros = 9
    ctnprecio.PermitirNegativos = False
    ctnprecio.Enteros = 9
    ctnprecio.Decimales = GintDecPrecio
    
'    ctnprecio.BackColor = lblDescripcion.BackColor
    'txt_vendedor.Text = mobj_cventasgen.obtenernombrevendedor(GstrCodigoVENDEDOR)
    Call CargaDataCombo(dtc_tdocumento, mobj_cventasgen.ListarDocumentosventas(GstrSiteProce), "DOCTYPEID", "DESCR")
    Call CargaDataCombo(dtc_tnegocio, mobj_cventasgen.ListarTiposNegocio, "businesstype", "DESCRbusiness")
    Call CargaDataCombo(dtc_vendedor, mobj_cventasgen.ListarvendedorAyuda, "SALESPERID", "SALESPERNAME")
    Call inicio
Else
    MsgBox ("No tiene Derechos de Consultar en este formulario")
End If

End Sub

Sub inicio()
    Call ESTADO_CABEZERA(True)
    'GstrTipodeCambio
    pdbl_correlativo = Mobj_Correlativo.ObtenerCorrelativo(GCUSERID)
    GstrTipodeCambio = GstrTipoCambioVentas
    
    If gstrtipoventas = "A" Then
        dtp_fecha.Enabled = False
        dtp_fechapro.Enabled = False
        txt_NBRDOCUMENT.Enabled = False
        txt_NBRDOCUMENT.Text = ""
        dtc_serie.Enabled = False
        'dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipoticket
        txt_tipodoc.Text = "TICKET BOLETA"
        txt_NBRDOCUMENT.Text = CStr(mobj_cventasgen.obtenernroticket(GstrPuntodeVenta, txt_tipodoc.Text))
        

        
        'Añadiendo opciones para Facturacion (Formato Pre-Impreso)-------------------------------------------------
        If GstrImprFacPreImpresa Then
            lbl_tdocumento.Visible = True
            dtc_tdocumento.Visible = True
            dtc_tdocumento.Enabled = True
            dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipofactura  'Factura
            'COCO'
            txt_NBRDOCUMENT.Text = mobj_cventasgen.obtenernrodocumento(dtc_tdocumento.BoundText, dtc_serie.BoundText, GstrSiteProce)
            
            lbl_tnegocio.Visible = True
            dtc_tnegocio.Visible = True

        Else
            dtc_tdocumento.Enabled = False
            dtc_tdocumento.Visible = False
            lbl_tdocumento.Visible = False
            dtc_tnegocio.Visible = False
            lbl_tnegocio.Visible = False
        End If
        '-----------------------------------------------------------------------------------------------------------
        
'        dtc_tdocumento.Enabled = False
'        dtc_tdocumento.Visible = False
'        lbl_tdocumento.Visible = False
        txt_NBRDOCUMENT.MaxLength = 10
        mnu_op_cierrex.Visible = True
        mnu_op_cierrez.Visible = True

        dtc_tnegocio.BoundText = "2"
        ctnprecio.Enabled = False
        dtc_vendedor.Enabled = False
        dtc_vendedor.BoundText = Trim(GstrCodigoVENDEDOR) + Space(20 - Len(Trim(GstrCodigoVENDEDOR)))
    Else
        dtp_fecha.Enabled = True
        dtp_fechapro.Enabled = True
        If gblnsaltarcorrelativo Then
            txt_NBRDOCUMENT.Enabled = True
            txt_NBRDOCUMENT.Locked = True
        Else
            txt_NBRDOCUMENT.Enabled = True
            txt_NBRDOCUMENT.Locked = False
        End If
        lbl_tdocumento.Visible = True
        dtc_tdocumento.Visible = True
        dtc_tdocumento.Enabled = True
        dtc_tdocumento.Text = ""
        dtc_serie.Enabled = True
        txt_NBRDOCUMENT.MaxLength = 7
        dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipoboleta
        dtc_tnegocio.BoundText = "1"
        dtc_vendedor.Enabled = True
        dtc_vendedor.BoundText = Trim(GstrCodigoVENDEDOR) + Space(20 - Len(Trim(GstrCodigoVENDEDOR)))
        mnu_op_cierrex.Visible = False
        mnu_op_cierrez.Visible = False
        dtc_tnegocio.Visible = True
        lbl_tnegocio.Visible = True
        MBLN_INICIO = True
        ctnprecio.Enabled = False
    End If
    'INDICA QUE EL FORMULARIO ACABA DE INCIARSE
    dtp_fecha.Value = Date
    TXT_MONEDATOTAL.Text = GstrSimboloMoneda    'moneda de la caja cuando se inicia
    MBLN_INICIO = True
    mbln_editandoproducto = False
    gbln_ventaefectuada = False
    mbln_articuloencontrado = False
    dtp_fechapro.Value = GDatFechaProcesoVentas
    'dtp_fecha.Value = GDatFechaProceso
    Call Datosclientepordefecto
    txt_tcambio.Text = gdblMontoTipoCambio
    
    If gstrtipoventas = "A" Then
        Set prs_productos_tienda = mobj_cventasgen.Listarproductosventas(GstrSiteProce, True)
    Else
        Set prs_productos_playa = mobj_cventasgen.Listarproductosventas(GstrSiteProce, False)
        Set prs_productos_tienda = mobj_cventasgen.Listarproductosventas(GstrSiteProce, True)
    End If
    
    Set prs_clientes = mobj_cventasgen.ListarClientesAyuda

    Call CARGAGRILLA(pdbl_correlativo)
    
End Sub

Private Sub Form_Unload(Cancel As Integer)
 'End
End Sub

Private Sub mnu_op_abrirgaveta_Click()
'Call abrir_gaveta
End Sub

Private Sub mnu_op_buscar_Click()
Call busquedaventas
End Sub
Private Sub mnu_op_cashdrop_Click()
F_CASHDROP.Show vbModal
End Sub

Private Sub mnu_op_cierrex_Click()
FCierreX_Tienda.Show
End Sub

Private Sub mnu_op_cierrez_Click()
FCierreZ_Tienda.Show
End Sub

Private Sub mnu_op_fcaja_Click()
F_fondocaja.Show
End Sub

Private Sub mnu_pagos_efectivo_Click()
Call cmd_efectivo_Click
End Sub
Private Sub mnu_pagos_restaurar_Click()
Call cmd_recupera_Click
End Sub
Private Sub mnu_pagos_salvar_Click()
Call cmd_salvar_Click
End Sub
Private Sub mnu_pagos_Tarjeta_Click()
Call cmd_tarjeta_Click
End Sub
Sub instancia_objetos()
Set mobj_cseguridad = New DB_SE_MANTENIMIENTOS.c_seguridad
Set MOBJ_CMONEDA = New DB_MA_MANTENIMIENTOS.C_MONEDA
Set mobj_cventasgen = New DB_OP_FACTURACION.C_VENTASGENERAL
Set MOBJ_CVENTASCSTORE = New DB_OP_FACTURACION.C_VENTASCSTORE
Set Mobj_Correlativo = New DB_CORRELATIVO.C_Correlativos
Set mobj_cdocumento = New DB_MA_MANTENIMIENTOS.C_DOCUMENTO
Set MobjUtilSetup = New UTIL_SETUP.C_SETUP
Set MobjMovimientos = New DB_INV_MOVIMIENTOS.C_MOVIMIENTOS

End Sub

Private Sub mnu_pagosanular_Click()
 Call anular_ticket
End Sub

Private Sub mnu_pagoseliminar_Click()
Call eliminar_ticket
End Sub

Private Sub mnu_pagos_vale_Click()
Call cmd_vale_Click
End Sub

Private Sub mnuAdelanto_Click()
  cmdadelanto_Click
End Sub

Private Sub mnuDctoAdic_Click()
    Call cmdDctoAdic_Click
End Sub

Private Sub mnuDctoItem_Click()
   Call cmdDctoItem_Click
End Sub

Private Sub txt_direccion_GotFocus()
  txt_direccion.BackColor = vbCyan
  Call valida_cabezera1
  Call valida_cabezera2
  Call valida_cabezera3
End Sub

Private Sub txt_direccion_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Or KeyCode = 13 Then
    KeyCode = 0
    If gstrtipoventas = "A" Then
        txtArticulo.SetFocus
    Else
        KeyCode = 0
        If dtp_fechapro.Enabled = True Then
           dtp_fechapro.SetFocus
        End If
    End If
End If
If KeyCode = vbKeyUp Then
    txt_razonsocial.SetFocus
End If
End Sub

Private Sub txt_direccion_KeyPress(KeyAscii As Integer)
KeyAscii = GBloqueaCaracter(KeyAscii)
End Sub

Private Sub txt_direccion_LostFocus()
txt_direccion.BackColor = vbWhite
End Sub

Private Sub TXT_IDCLIENTE_Change()
 If GBlnClienteCargado = True Then
    Datosclientepordefecto
    txt_razonsocial.Text = Empty
    txt_direccion.Text = Empty
    txt_ruc.Text = Empty
    cmdadelanto.Enabled = False
    GBlnClienteCargado = False
 End If
End Sub

Private Sub TXT_IDCLIENTE_GotFocus()
 TXT_IDCLIENTE.BackColor = vbCyan
 Call valida_cabezera2
End Sub

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

If KeyCode = 13 Or KeyCode = vbKeyDown Then
    Call valida_codigocliente("KD")
End If
If KeyCode = vbKeyUp And gstrtipoventas = "M" Then
    txt_NBRDOCUMENT.SetFocus
End If
If KeyCode = vbKeyF2 Then
    Call cmd_bcliente_Click
End If

End Sub

Private Sub TXT_IDCLIENTE_KeyPress(KeyAscii As Integer)
 KeyAscii = GBloqueaCaracter(KeyAscii)
End Sub

Private Sub TXT_IDCLIENTE_LostFocus()
'Call valida_codigocliente("LF")
TXT_IDCLIENTE.BackColor = vbWhite

End Sub

Private Sub txt_NBRDOCUMENT_Change()
'    numDocumentoT = txt_NBRDOCUMENT.Text
End Sub

Private Sub txt_NBRDOCUMENT_GotFocus()
txt_NBRDOCUMENT.BackColor = vbCyan
Call valida_cabezera1
End Sub

Private Sub txt_NBRDOCUMENT_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Or KeyCode = 13 Then
    Call valida_NUMERODOCUMENTO("KD")
End If
If KeyCode = vbKeyUp Then
    dtc_serie.SetFocus
End If

If KeyCode = vbKeyEscape Then
    cmd_Cancelar.SetFocus
End If

End Sub

Private Sub txt_NBRDOCUMENT_KeyPress(KeyAscii As Integer)
KeyAscii = GBloqueanonumeros(KeyAscii)
End Sub

Private Sub txt_NBRDOCUMENT_LostFocus()
txt_NBRDOCUMENT.BackColor = vbWhite
Call FORMATONBRDOCUMENT
End Sub
Private Sub txt_razonsocial_GotFocus()
txt_razonsocial.BackColor = vbCyan
Call valida_cabezera1
Call valida_cabezera2
Call valida_cabezera3
End Sub

Private Sub txt_razonsocial_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Or KeyCode = 13 Then
    If gstrtipoventas = "A" Then
        If txt_tipodoc.Text = "TICKET FACTURA" And Len(txt_razonsocial.Text) = 0 Then
            MsgBox "Debe Ingresar una Razon social", vbExclamation, "Atencion"
        Else
            txt_direccion.SetFocus
        End If
    Else
        If dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipofactura And Len(txt_razonsocial.Text) = 0 Then
            MsgBox "Debe Ingresar una Razon social", vbExclamation, "Atencion"
        Else
            txt_direccion.SetFocus
        End If
    End If
End If
If KeyCode = vbKeyUp Then
    If Len(Trim(txt_ruc.Text)) > 0 Then
        txt_ruc.SetFocus
    Else
       If TXT_IDCLIENTE.Enabled = True Then
          TXT_IDCLIENTE.SetFocus
       End If
    End If
End If
End Sub

Private Sub txt_razonsocial_KeyPress(KeyAscii As Integer)
KeyAscii = GBloqueaCaracter(KeyAscii)
End Sub

Private Sub txt_razonsocial_LostFocus()
'If txt_tipodoc.Text = "TICKET FACTURA" And Len(txt_razonsocial.Text) = 0 Then
'    MsgBox "Debe Ingresar una Razon social", vbExclamation, "Atencion"
'    txt_razonsocial.SetFocus
'Else
    txt_razonsocial.BackColor = vbWhite
'End If
End Sub

Private Sub txt_ruc_GotFocus()
txt_ruc.BackColor = vbCyan
Call valida_cabezera1
Call valida_cabezera2
End Sub

Private Sub txt_ruc_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Or KeyCode = 13 Then
    Call valida_RUCcliente("KD")
End If
If KeyCode = vbKeyUp Then
   If TXT_IDCLIENTE.Enabled = True Then
      TXT_IDCLIENTE.SetFocus
   End If
End If
End Sub

Private Sub txt_ruc_KeyPress(KeyAscii As Integer)
 KeyAscii = GBloqueanonumeros(KeyAscii)
End Sub

Private Sub txt_ruc_LostFocus()
txt_ruc.BackColor = vbWhite
End Sub

Private Sub txtArticulo_GotFocus()
Dim DOCTYPEID As String
Dim NBRDOCUMENT As Double

Call valida_cabezera1
If Not pbln_errorcab Then
    Call valida_cabezera2
End If
If Not pbln_errorcab Then
    Call valida_cabezera3
End If
  
If pbln_errorcab Then
    Exit Sub
End If

If gstrtipoventas = "A" Then
    DOCTYPEID = mobj_cventasgen.obtenertipoticket
    NBRDOCUMENT = Val(txt_NBRDOCUMENT.Text)
Else
    DOCTYPEID = dtc_tdocumento.BoundText
    NBRDOCUMENT = Val(dtc_serie.BoundText + txt_NBRDOCUMENT.Text)
End If

'POR LA INCIDENCIA DE RECIBIER EL ENFOQUE DESPUES DE GRABAR DOC.
If numDocumentoT <> NBRDOCUMENT Then  'compara n doc. grabado y el n doc. autogenerado
    If mobj_cventasgen.ExisteDocumento(DOCTYPEID, NBRDOCUMENT, GstrSiteProce) Then
       MsgBox "Documento Ya Existe" + Chr(13) + "Modifique el Numero de Documento", vbExclamation, "Datos Incorrectos"
       Exit Sub
    End If
End If

Call valida_head

txtArticulo.BackColor = vbCyan
End Sub
Sub valida_head()
If (Not mbln_cabezeraprotegida) And MrsGrilla.RecordCount > 0 Then    ' si la cabezera esta desprotegida
    Call GRABAR_CABEZERA_TEMPORAL       'grabar o actualizar los datos
End If                                  'solo se actualiza si no hay registros

If MrsGrilla.RecordCount = 1 Then ' HAY ALGUN REGISTROS
    ESTADO_CABEZERA (False)  'DESACTIVAR CABEZERA
End If
End Sub

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

If KeyCode = vbKeyDown Or KeyCode = 13 Then
    Call validaarticulo
End If
If KeyCode = vbKeyUp Then
    If Not mbln_cabezeraprotegida Then
        txt_direccion.SetFocus
    Else
        DBDetalle.SetFocus
    End If
End If
If KeyCode = vbKeyF2 Then
    Call cmdBuscaArticulo_Click
End If
 

End Sub
Private Sub txtArticulo_KeyPress(KeyAscii As Integer)
 KeyAscii = GBloqueaCaracter(KeyAscii)
 If KeyAscii = vbKeyTab Then Exit Sub
End Sub

Private Sub txtArticulo_KeyUp(KeyCode As Integer, Shift As Integer)
On Error Resume Next
'MM : Jorge Illescas
'Validando para Scneers Rapidos: Motivo de caida de inventario Inicial: 11/03/2006 - Trujillo
If KeyCode = 74 And Right(Trim(txtArticulo), 1) = "J" Then
    If GBlnPermiteVentaCantidadProducto Then
        If txtArticulo.Text = Empty Or Not IsNumeric(Mid(txtArticulo.Text, 1, Len(txtArticulo.Text) - 1)) Then
            MsgBox "Cantidad no valida", vbExclamation, "Atención"
            txtArticulo.Text = Empty
            txtArticulo.SetFocus
            Exit Sub
        Else
            dblCantidad = CDbl(Mid(txtArticulo.Text, 1, Len(txtArticulo.Text) - 1))
            'txtArticulo.SelStart = Len(txtArticulo.Text)
            txtArticulo.Text = Empty
            Exit Sub
        End If
    End If
End If
End Sub

Private Sub txtArticulo_LostFocus()
 txtArticulo.BackColor = vbWhite
End Sub

Private Sub valida_codigocliente(STRID As String)
Dim lsid As String
Dim i As Integer
GblnAfecto = True
lsid = Trim(TXT_IDCLIENTE.Text)
'---------------------------------------------------
If gstrtipoventas = "A" Then         'VENTA AUTOMATICA
    If Len(lsid) = 0 Then
        txt_ruc.Text = ""
        Call valida_RUCcliente("CC")
        If STRID = "KD" Then
            txtArticulo.SetFocus
        End If
        Call Datosclientepordefecto
        txt_tcambio.Text = gdblMontoTipoCambio
    Else
       Set grscliente = mobj_cventasgen.ListarDatosdeClienteFactura(lsid)
       If grscliente.EOF Then  'codigo de cliente no existe
            'ingresar datos
            If pasar_ruc(lsid) Then
                txt_ruc.Text = Trim(TXT_IDCLIENTE.Text)
            Else
                txt_ruc.Text = ""
            End If
            txt_razonsocial.Text = ""
            txt_direccion.Text = ""
            If STRID = "KD" Then
                txt_ruc.SetFocus
            End If
            Call Datosclientepordefecto
            txt_tcambio.Text = gdblMontoTipoCambio
        Else
            Call GAsignarDatosdeCliente
            GBlnClienteCargado = True
            If STRID = "KD" Or STRID = "LF" Then    ' SI ES KEYDOWN O LOSTFOCUS ASIGNAR DIRECCION
                If pasar_ruc(grscliente!ruc) Then
                    txt_ruc.Text = Trim(grscliente!ruc)       'SI SE ESTA RESTAURANDO el documentoNO ASIGNAR
                Else
                    txt_ruc.Text = ""
                End If
            txt_razonsocial.Text = grscliente!RAZONSOCIAL
            txt_direccion.Text = grscliente!DIRECCION
            End If
            txt_tcambio.Text = gdblMontoTipoCambio
            GblnconPlacas = mobj_cventasgen.VerificarClienteconPlaca(TXT_IDCLIENTE.Text)
            If MintTipoCliente = 2 Then
               cmdadelanto.Enabled = True
            End If
            
            'llenar datos obtenidos del recordset
            If STRID = "KD" Then
                txt_ruc.SetFocus
            End If
        End If
    End If
'---------------------------------------------------
Else         'VENTA MANUAL --------------------------------
    If Len(lsid) = 0 Then
        'ES MANUAL, SE ESCOGIO FACTURA Y NO INGRESO CODIGO
        If dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipofactura Then
            MsgBox "Debe ingresar Codigo Cliente", vbExclamation, "Error"
        Else
            If STRID = "KD" Then
                txt_razonsocial.SetFocus
            End If
        End If
        Call Datosclientepordefecto
        txt_tcambio.Text = gdblMontoTipoCambio
    Else    'si ingreso codigo, pasar a ruc
       Set grscliente = mobj_cventasgen.ListarDatosdeClienteFactura(lsid)
       If grscliente.EOF Then  'codigo de cliente no existe
            'ingresar datos
            If pasar_ruc(lsid) Then
                txt_ruc.Text = Trim(TXT_IDCLIENTE.Text)
            Else
                txt_ruc.Text = ""
            End If
            txt_razonsocial.Text = ""
            txt_direccion.Text = ""
            If STRID = "KD" Then
                txt_ruc.SetFocus
            End If
            Call Datosclientepordefecto
            txt_tcambio.Text = gdblMontoTipoCambio
        Else
            Call GAsignarDatosdeCliente
            GBlnClienteCargado = True
            GblnconPlacas = mobj_cventasgen.VerificarClienteconPlaca(TXT_IDCLIENTE.Text)
            'llenar datos obtenidos del recordset
            If STRID = "KD" Or STRID = "LF" Then    ' SI ES KEYDOWN O LOSTFOCUS ASIGNAR DIRECCION
                If pasar_ruc(grscliente!ruc) Then
                    txt_ruc.Text = Trim(grscliente!ruc)       'SI SE ESTA RESTAURANDO el documentoNO ASIGNAR
                Else
                    txt_ruc.Text = ""
                End If
                txt_razonsocial.Text = grscliente!RAZONSOCIAL
                txt_direccion.Text = grscliente!DIRECCION
            End If
            txt_tcambio.Text = gdblMontoTipoCambio
            
            If MintTipoCliente = 2 Then
               cmdadelanto.Enabled = True
            End If

            If STRID = "KD" Then
                txt_ruc.SetFocus
            End If
        End If
    End If
End If
If GstrMonedaLimiteCredito = "" Then
   GstrMonedaLimiteCredito = GStrMonedaCaja
End If
End Sub
Public Sub validaarticulo()
Dim lstr_idproducto As String
Dim strid_cliente As String
Dim lstr_monedaprod As String    'moneda del producto
Dim ldat_fecha As Date
Dim ldou_precio As Double
Dim rs_temporal As ADODB.Recordset
Dim blnEditarPrecio As Boolean

Dim codarti_codBarrPeso As String
Dim cant_codBarrPeso As String

lstr_idproducto = Trim(txtArticulo.Text)  '**desglosar si es codigo de barra de peso
If Left(lstr_idproducto, 2) = "22" Or Left(lstr_idproducto, 2) = "00" Or sw_codBarrPeso = True Then   'SE TRATA DE UN CODIGO DE BARRAS DE PESO
   sw_codBarrPeso = True
   codarti_codBarrPeso = IIf(compactCodBarrPeso, lstr_idproducto, Mid(Trim(lstr_idproducto), 3, 5))   'SE EXTRAE EL CODIGO DEL ARTICULO
End If

strid_cliente = Trim(TXT_IDCLIENTE.Text)
Set rs_prod = mobj_cventasgen.obtenerprecio(strid_cliente, IIf(sw_codBarrPeso, codarti_codBarrPeso, lstr_idproducto))

blnEditarPrecio = rs_prod!EDITPRICE
ctnprecio.Enabled = blnEditarPrecio

If IsNull(rs_prod!DESCR) Then
    MsgBox "Codigo no Existe", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If
If Not rs_prod!stkstore And gstrtipoventas = "A" Then
    MsgBox "Producto no puede Venderse en tienda", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If

If IsNull(rs_prod!stksales) Or rs_prod!stksales Then
    MsgBox "Producto esta bloqueado para la venta", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If

If IsNull(rs_prod!Status) Or (Not rs_prod!Status) Then
    MsgBox "Producto Desactivado", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If


If rs_prod!stkitem = True Then

    If IsNull(rs_prod!precio) Or rs_prod!precio <= 0 Then
        MsgBox "Producto con precio incorrecto", vbExclamation, "Atencion"
        txtArticulo.SetFocus
        Exit Sub
    End If
    
    If rs_prod!stdcostpen <= 0 Or rs_prod!stdcostusd <= 0 Then
        MsgBox "Producto con Costo incorrecto " & CStr(rs_prod!SKU), vbExclamation, "Atencion"
        txtArticulo.SetFocus
        Exit Sub
    End If
    
Else
    

End If


If (rs_prod!curyid = GstrCodMonedaBase And rs_prod!stdcostpen > rs_prod!precio) Or _
                        (rs_prod!curyid = GstrMonedaExtranjera And rs_prod!stdcostusd > rs_prod!precio) Then
    MsgBox "Producto con relacion Costo/Precio incorrecto", vbExclamation, "Atencion"
    txtArticulo.SetFocus
    Exit Sub
End If

If rs_prod!stock <= 0 Then
   If rs_prod!stkitem = True Then
    If Not GIntPermiteStkNegativo Then
        MsgBox "Producto Sin Stock", vbExclamation, "Atencion"
        txtArticulo.Text = ""
        txtArticulo.SetFocus
        Exit Sub
    End If
   End If
End If
    
Set rs_temporal = MrsGrilla.Clone
If rs_temporal.RecordCount > 0 And (Not mbln_editandoproducto) Then
'Mi Mercado: Jorge Luis Illescas------------------------------------------------------------
    rs_temporal.MoveFirst
    Do While Not rs_temporal.EOF
        If Trim(rs_temporal!INVTIDSKU) = Trim(rs_prod!SKU) Then
'            MsgBox "Producto Ya esta Registrado", vbExclamation, "Atencion"
            Call editar_producto_SaltoAutomatic
            Call validaarticulo
'            txtArticulo.Text = Empty
'            txtArticulo.SetFocus
            Exit Sub
        End If
        rs_temporal.MoveNext
    Loop
' ------------------------------------------------------------------------------------------
End If
      
ldat_fecha = dtp_fecha.Value
    
If mbln_editandoproducto Then
    ldou_precio = Val(ctnprecio.Text)
Else
    mbln_articuloencontrado = True
    lblDescripcion.Caption = rs_prod!DESCR
    lstr_monedaprod = rs_prod!curyid
    ldou_precio = rs_prod!precio
    'CONvERTIR EL PRECIO
    'si la moneda cliente igual a moneda producto
    If GstrMonedaLimiteCredito = lstr_monedaprod Then     ' no es necesario convertir
        ctnprecio.Text = rs_prod!precio
    Else                'hay que convertir
        If lstr_monedaprod = GstrCodMonedaBase Then       ' si esta en moneda nacional
            ctnprecio.Text = mobj_cventasgen.ConvertirMoneda(ldou_precio, GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecPrecio)
        Else
            ctnprecio.Text = mobj_cventasgen.ConvertirMoneda(ldou_precio, GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecPrecio)
        End If
    End If

End If
        
' SI ESTA ACTIVADO EL SALTO AUTOMATICO PONER LA CANTIDAD Y GRABAR EL REGISTRO
If gstrtipoventas = "A" Then                     '  VENTA AUTOMATICA
    If Not GBlnPermiteVentaCantidadProducto Then
          If GBlnpermitesaltoautomatico And (Not mbln_editandoproducto) And rs_prod!CLASSID <> GstrCategoriaFuels Then
              ctnUnidades.Text = gIntsaltoautomatico
              If Val(ctnUnidades.Text) > rs_prod!stock And (Not GIntPermiteStkNegativo) Then
                  MsgBox "Cantidad Mayor al stock Disponible", vbExclamation, "Atencion"
                  ctnUnidades.SetFocus   '*****************COCO************************************************
                  Exit Sub
              End If
        
              Call grabarregistro
              Call valida_head
              txtArticulo.SetFocus
          Else
              If rs_prod!CLASSID <> GstrCategoriaFuels Then
                  CTN_SUBTOTAL.Enabled = False
                 
                  If rs_prod!stkitem = False Then ' Si no es Inventariable
                     CTN_SUBTOTAL.Enabled = True
                  End If
                  
                  If Not mbln_editandoproducto Then
                      ctnUnidades.Text = "1"
                  End If
                  ctnUnidades.SetFocus
              Else
                  CTN_SUBTOTAL.Enabled = True
                  CTN_SUBTOTAL.SetFocus
              End If
          End If      'fin de if de permite salto automatico
    Else 'nuevo
          If GBlnpermitesaltoautomatico And (Not mbln_editandoproducto) And rs_prod!CLASSID <> GstrCategoriaFuels Then
              If dblCantidad = 0 Then
                 ctnUnidades.Text = gIntsaltoautomatico  '** aplicar la cantidad del codigo de barras peso
                 If Left(lstr_idproducto, 2) = "22" Or Left(lstr_idproducto, 2) = "00" Then   'SE TRATA DE UN CODIGO DE BARRAS DE PESO
                    'recuperando cantidad pesada d articulo
                    cant_codBarrPeso = Left(Mid(lstr_idproducto, 8, 5), 2) + "." + Right(Mid(lstr_idproducto, 8, 5), 3)
                    ctnUnidades.Text = CDbl(cant_codBarrPeso) 'convirtiendo en decimales y asignadole A CANTIDAD VENDIDA
                 End If
              Else
                    ctnUnidades.Text = dblCantidad
              End If
              dblCantidad = 0
              
              If Val(ctnUnidades.Text) > rs_prod!stock And (Not GIntPermiteStkNegativo) Then
                  If rs_prod!stkitem = True Then
                    MsgBox "Cantidad Mayor al stock Disponible", vbExclamation, "Atencion"
                    ctnUnidades.SetFocus
                    Exit Sub
                  End If
              End If
              
              'Valida articulo en el display *****************Jorge Illescas mi mercado********************
'              Call VerDisplay(GstrDisplay, Trim(rs_prod!DESCR), _
                                            Trim(ctnUnidades.Text) + " X " + Trim(CStr(rs_prod!precio)))
'              Call VerDisplay(GstrDisplay, Alineacion("C", 20, Len(Trim(CStr(rs_prod!precio)))), Trim(CStr(rs_prod!precio)))
              '********************************************************************************************
              
              Call grabarregistro
              Call valida_head
              txtArticulo.SetFocus
          Else 'edicion
              If rs_prod!CLASSID <> GstrCategoriaFuels Then
                  CTN_SUBTOTAL.Enabled = False
                  
                  If rs_prod!stkitem = False Then ' Si no es Inventariable
                     CTN_SUBTOTAL.Enabled = True
                  End If

                  If Not mbln_editandoproducto Then
                      If dblCantidad = 0 Then
                        ctnUnidades.Text = "1"
                      Else
                        ctnUnidades.Text = dblCantidad
                      End If
                      dblCantidad = 0
                  End If
                  If ctnprecio.Enabled = True Then
                     'MM. Jorge Illescas
                     If swEditSaltoAutomatico = False Then
                        ctnprecio.SetFocus
                     End If
                  Else
                     If ctnUnidades.Enabled = True Then
                        ctnUnidades.SetFocus
                     End If
                  End If
                  'Mi Mercado:  Jorge Illescas:-----------------------------------------------------------------
                  'Permite guardar automaticamente el registro que se esta duplicando pero modicando su cantidad
                  If swEditSaltoAutomatico Then
                     Call grabarregistro
                     Call valida_head
                     txtArticulo.SetFocus
                     swEditSaltoAutomatico = False
                  End If
                  '---------------------------------------------------------------------------------------------
              Else
                  CTN_SUBTOTAL.Enabled = True
                  CTN_SUBTOTAL.SetFocus
              End If
          End If      'fin de if de permite salto automatico
    End If
'----------------------------------------------------------------------------------
Else    'VENTA MANUAL
    If rs_prod!CLASSID <> GstrCategoriaFuels Then
        CTN_SUBTOTAL.Enabled = False
        
        If rs_prod!stkitem = False Then ' Si no es Inventariable
           CTN_SUBTOTAL.Enabled = True
        End If
        
        If Not mbln_editandoproducto Then
            ctnUnidades.Text = "1"
        End If
        
    Else
        CTN_SUBTOTAL.Enabled = True
    End If
    
    If ctnprecio.Enabled = True Then
       ctnprecio.SetFocus
    Else
       ctnUnidades.SetFocus
    End If
End If  'fin del if de tipo de ventas

'desactivando SW de control si es codigo de barra de peso
sw_codBarrPeso = False
'desactivando SW de control si se compacto codigo de barras
compactCodBarrPeso = False

End Sub

Public Sub CARGAGRILLA(ByVal MDblIdentificador As Double)
Dim LdblImpuesto As Double
Dim BlnExisteunNoAfecto As Boolean
Dim BlnTodosLosImpIguales As Boolean
 
LdblTotalBase = 0
LdblTotalExt = 0
LDblIGVBase = 0
LDblIGVExt = 0
LDblSubAfectoBase = 0
LDblSubAfectoExt = 0
LDblNoAfectoBase = 0
LDblNoAfectoExt = 0
 
 Set MrsGrilla = MOBJ_CVENTASCSTORE.ObtenerDatosTMPSCTORE(MDblIdentificador, GintDecResultado)
     
  '***************************************************
  ' Parte que recalcula los Datos de los Resultados
  '***************************************************
   
  If Not MrsGrilla.EOF Then
   MrsGrilla.MoveFirst
   
   'Capturo el Primer Impuesto de la Grilla
   LdblImpuesto = MrsGrilla.Fields("PORCENTTAXIGV")
   'Inicializo la variable si es falso todos son Afectos
   BlnExisteunNoAfecto = False
   'Inicializo la variable Por defecto todos los impuestos son iguales
   BlnTodosLosImpIguales = True
   
   Do While Not MrsGrilla.EOF
     If MrsGrilla!PORCENTTAXIGV > 0 Then
       'Comparo los impuestos para revisar si son iguales
       If MrsGrilla.Fields("PORCENTTAXIGV") <> LdblImpuesto Then
          BlnTodosLosImpIguales = False
       End If
       LDblSubAfectoBase = LDblSubAfectoBase + MrsGrilla!SUBTOTALPEN
       LDblSubAfectoExt = LDblSubAfectoExt + MrsGrilla!SUBTOTALUSD
     Else
       LDblNoAfectoBase = LDblNoAfectoBase + MrsGrilla!SUBTOTALPEN
       LDblNoAfectoExt = LDblNoAfectoExt + MrsGrilla!SUBTOTALUSD
       BlnExisteunNoAfecto = True
     End If
     
     LDblIGVBase = LDblIGVBase + MrsGrilla!TAXPEN
     LDblIGVExt = LDblIGVExt + MrsGrilla!TAXUSD
     LdblTotalBase = LdblTotalBase + MrsGrilla!TOTALPEN
     LdblTotalExt = LdblTotalExt + MrsGrilla!TOTALUSD
     MrsGrilla.MoveNext
   Loop
      
   If BlnExisteunNoAfecto = False Then ' Es decir Todos son Afectos
      ' Ademas se tiene que verificar que que todos los impuestos son iguales
      If BlnTodosLosImpIguales = True Then
        LDblSubAfectoBase = LdblTotalBase / (1 + (LdblImpuesto / 100))
        LDblSubAfectoExt = LdblTotalExt / (1 + (LdblImpuesto / 100))
        LDblIGVBase = LdblTotalBase - LDblSubAfectoBase
        LDblIGVExt = LdblTotalExt - LDblSubAfectoExt
      End If
   End If
   
  End If
  
  '*********************************************************************************
  'Esta parte asigna a las Etiquetas de los Resultados los Valores Calculados arriba
  'Teniendo en Consideración la Moneda del Cliente y de la Caja
  '*********************************************************************************
  
     If GstrMonedaLimiteCredito = GstrCodMonedaBase Then
        ' Si la Moneda del Cliente no está Vacía Manda su Moneda
       txt_subtotal.Text = GFormatodeNumero(LDblSubAfectoBase, GintDecResultado)
       TXT_NOAFECTO.Text = GFormatodeNumero(LDblNoAfectoBase, GintDecResultado)
       txt_igv.Text = GFormatodeNumero(LDblIGVBase, GintDecResultado)
       txt_total.Text = GFormatodeNumero(LdblTotalBase, GintDecResultado)
     Else
       txt_subtotal.Text = GFormatodeNumero(LDblSubAfectoExt, GintDecResultado)
       TXT_NOAFECTO.Text = GFormatodeNumero(LDblNoAfectoExt, GintDecResultado)
       txt_igv.Text = GFormatodeNumero(LDblIGVExt, GintDecResultado)
       txt_total.Text = GFormatodeNumero(LdblTotalExt, GintDecResultado)
     End If
       LDblSubAfectoBase = Round(LDblSubAfectoBase, GintDecResultado)
       LDblNoAfectoBase = Round(LDblNoAfectoBase, GintDecResultado)
       LDblIGVBase = Round(LDblIGVBase, GintDecResultado)
       LdblTotalBase = Round(LdblTotalBase, GintDecResultado)
       LDblSubAfectoExt = Round(LDblSubAfectoExt, GintDecResultado)
       LDblNoAfectoExt = Round(LDblNoAfectoExt, GintDecResultado)
       LDblIGVExt = Round(LDblIGVExt, GintDecResultado)
       LdblTotalExt = Round(LdblTotalExt, GintDecResultado)
       

      Set DBDetalle.DataSource = MrsGrilla
    'BDETALLE.Refresh
      Call FormatoGrilla
      If MrsGrilla.RecordCount > 0 Then
         MrsGrilla.MoveLast
      End If
   '*************************************************
End Sub
   
Public Sub FormatoGrilla()
DBDetalle.Columns(0).Caption = "Reg"
DBDetalle.Columns(0).Width = 380
DBDetalle.Columns(0).AllowSizing = False

DBDetalle.Columns(1).Width = 1350 '
DBDetalle.Columns(1).Caption = "Codigo"
DBDetalle.Columns(1).AllowSizing = False

DBDetalle.Columns(2).Caption = "Descripcion"
DBDetalle.Columns(2).Width = 4200
DBDetalle.Columns(2).AllowSizing = False

DBDetalle.Columns(3).Caption = "Precio"
DBDetalle.Columns(3).Width = 1200  'Precio
DBDetalle.Columns(3).Alignment = dbgRight
DBDetalle.Columns(3).NumberFormat = GMascara(GintDecPrecio)
DBDetalle.Columns(3).AllowSizing = False

DBDetalle.Columns(4).Caption = "%Impto"
DBDetalle.Columns(4).Width = 590
DBDetalle.Columns(4).Alignment = dbgRight
DBDetalle.Columns(4).NumberFormat = GMascara(GintDecResultado)
DBDetalle.Columns(4).AllowSizing = False

DBDetalle.Columns(5).Caption = "Cantidad"
DBDetalle.Columns(5).Width = 780
DBDetalle.Columns(5).Alignment = dbgRight
DBDetalle.Columns(5).NumberFormat = GMascara(GintDecStock)
DBDetalle.Columns(5).AllowSizing = False

   If GstrMonedaLimiteCredito = GstrCodMonedaBase Then
      DBDetalle.Columns(6).Visible = True       'mostrara moneda nacional
      DBDetalle.Columns(6).Width = 1400
      DBDetalle.Columns(6).Alignment = dbgRight
      DBDetalle.Columns(6).NumberFormat = GMascara(GintDecResultado)
      DBDetalle.Columns(6).Caption = "Total"
      DBDetalle.Columns(6).AllowSizing = False
      
      DBDetalle.Columns(7).Visible = False      'oculta moneda extranjera
   Else
      DBDetalle.Columns(7).Visible = True       'mostrara moneda extranjera
      DBDetalle.Columns(7).Width = 1400
      DBDetalle.Columns(7).Alignment = dbgRight
      DBDetalle.Columns(7).NumberFormat = GMascara(GintDecResultado)
      DBDetalle.Columns(7).Caption = "Total"
      DBDetalle.Columns(7).AllowSizing = False
      DBDetalle.Columns(6).Visible = False      'oculta la moneda nacional
   End If

'ocultar campos para calculos internos
DBDetalle.Columns(8).Visible = False            'oculta SUBTOTALPEN
DBDetalle.Columns(9).Visible = False            'oculta SUBTOTALUSD
DBDetalle.Columns(10).Visible = False           'oculta TAXPEN
DBDetalle.Columns(11).Visible = False           'oculta TAXUSD
DBDetalle.Columns(12).Visible = False           'oculta  % igv

End Sub
Private Sub valida_RUCcliente(STRID As String)
Dim lsid As String
Dim lbl_pasar As Boolean
Dim i As Integer
Dim numero As Double
Dim lstr_ndocumento As String
Dim lstr_tfac As String
lstr_tfac = mobj_cventasgen.obtenertipofactura
lsid = Trim(txt_ruc.Text)

If gstrtipoventas = "A" Then        'emision automatico de ticket
    If Len(lsid) = 0 Then
        txt_tipodoc.Text = "TICKET BOLETA"
        If STRID = "KD" Then
            txt_razonsocial.SetFocus
        End If
    Else
        If Len(lsid) < 11 Then
            MsgBox "Debe ingresar 11 digitos", vbExclamation, "RUC Incorrecto"
            txt_tipodoc.Text = "TICKET BOLETA"
        Else
            If GstrImprFacPreImpresa Then
                txt_tipodoc.Text = "FACTURA"
            Else
                txt_tipodoc.Text = "TICKET FACTURA"
            End If
            If STRID = "KD" Then
                txt_razonsocial.SetFocus
            End If
        End If
    End If
    'Permite obtenewr el numetro de la boleta
    If Not GstrImprFacPreImpresa Then
       txt_NBRDOCUMENT.Text = CStr(mobj_cventasgen.obtenernroticket(GstrPuntodeVenta, txt_tipodoc.Text))
    End If
    
    'dtc_serie.Text = Mid(lstr_ndocumento, 1, 3)
Else        'ingreso manual de documentos
    'si es tipo factura y no se ha ingresado un ruc
    If Len(lsid) = 0 And dtc_tdocumento.BoundText = lstr_tfac Then
        MsgBox "Debe Ingresar un RUC", vbExclamation, "Atencion"
    Else
        If Len(lsid) < 11 And dtc_tdocumento.BoundText = lstr_tfac Then
            MsgBox "Debe Ingresar 11 digitos en el RUC", vbExclamation, "Atencion"
        Else
            If txt_razonsocial.Enabled Then
                txt_razonsocial.SetFocus
            End If
        End If
    End If
End If

End Sub
Public Sub grabarregistro()
Dim dou_CORRNBR As Double
Dim str_DOCTYPEID As String
Dim dou_NBRDOCUMENT As Double
Dim int_nlin As Integer
Dim str_SITEID As String
Dim str_INVTIDSKU As String
Dim str_CURYID As String
Dim str_DATEDOC As String
Dim str_DATEPROCESALES As String
Dim dou_NBRTURN As Double
Dim dou_PORCENTTAXIGV As Double
Dim dou_PORCENTTAXISC As Double
Dim dou_TOTALPEN As Double
Dim dou_TOTALUSD As Double
Dim dou_TAXPEN As Double
Dim dou_TAXUSD As Double
Dim byt_STKITEM As Byte
Dim byt_STKFISI As Byte
Dim dou_SLS_PRICE As Double
Dim dou_SLSPRICESALE As Double
Dim dou_STDCOSTPEN As Double
Dim dou_STDCOSTUSD As Double
Dim str_INVTIDALTER As String
Dim dou_QTY As Double
Dim str_USERID As String
Dim STR_DESCR As String
Dim STRUNIDAD As String
Dim montDescItem1PORC As Double
                                
dou_CORRNBR = pdbl_correlativo
If gstrtipoventas = "A" Then
    str_DOCTYPEID = mobj_cventasgen.obtenertipoticket
Else
    str_DOCTYPEID = dtc_tdocumento.BoundText
    dou_NBRDOCUMENT = Val(dtc_serie.BoundText + txt_NBRDOCUMENT.Text)
End If

If MrsGrilla.RecordCount > 0 Then
    int_nlin = MrsGrilla!lin
Else
    int_nlin = 0
End If
str_SITEID = GstrSiteProce

'CODIGO DE ARTICULO
If DescuentoItem = True Then
   str_INVTIDSKU = DBDetalle.Columns(1).Text
Else
   str_INVTIDSKU = Trim(rs_prod!SKU)
End If

str_DATEDOC = CStr(dtp_fecha.Value)
str_DATEPROCESALES = CStr(dtp_fechapro.Value)
dou_NBRTURN = mobj_cventasgen.obtenerturnoventas
dou_PORCENTTAXISC = 0   'USO FUTURO
dou_PORCENTTAXIGV = rs_prod!taxvalue

Dim nTotalPen As Double  'Permite saber total temporal -antes de aplicar descuentos

If GstrMonedaLimiteCredito = GstrCodMonedaBase Then     ' GRABAR EN MONEDA BASE Y CALCULAR MONEDA EXTRANJERA
    str_CURYID = GstrCodMonedaBase
    'calcular el total si no es fuel
    If rs_prod!CLASSID <> GstrCategoriaFuels Then
        dou_TOTALPEN = Round(Val(ctnUnidades.Text) * Val(ctnprecio.Text), GintDecResultado)
        
        'DE AQUI CALCULAR EL DESCUENTO POR ITEM Y/O DOCUMENTO-------------------------------------------------
        If DescuentoItem = True Then
           If TipoDescuento = 1 Then     'Porcentaje
              nTotalPen = Round(Val(DBDetalle.Columns(3).Text) * Val(DBDetalle.Columns(5).Text), GintDecResultado)
              dou_TOTALPEN = Round(nTotalPen - (nTotalPen * montDescItem1PORC / 100), GintDecResultado)
              'HALLAR % A GRABAR EN CAMPO DESCUENTO 1
'              montDescItem1PORC
           ElseIf TipoDescuento = 2 Then 'Monto
              nTotalPen = Round(Val(DBDetalle.Columns(3).Text) * Val(DBDetalle.Columns(5).Text), GintDecResultado)
              dou_TOTALPEN = Round(nTotalPen - montDescItem1PORC, GintDecResultado)
              'HALLAR % A GRABAR EN CAMPO DESCUENTO 1
'              montDescItem1PORC
           End If
        End If
        If descuentoAdicional = True Then
           If TipoDescuento = 1 Then     'Porcentaje
'              nTotalPen = Round(Val(DBDetalle.Columns(3).Text) * Val(DBDetalle.Columns(5).Text), GintDecResultado)
'              dou_TOTALPEN = Round(nTotalPen - (nTotalPen * montDescItem1PORC / 100), GintDecResultado)
'               Dim I As Integer
'               For I = 1 To 5
'                  DBDetalle.Bookmark = I
'               Next I
                   
           ElseIf TipoDescuento = 2 Then 'Monto
              
           End If
        End If
        '-----------------------------------------------------------------------------------------------------
    Else       'si es fuel calcular la cantidad segun el total
        dou_TOTALPEN = Val(CTN_SUBTOTAL.Text)
    End If
    If GblnAfecto Then
        dou_TOTALUSD = mobj_cventasgen.ConvertirMoneda(dou_TOTALPEN, GstrCodMonedaBase, GstrMonedaExtranjera, str_DATEPROCESALES, GstrTipoCambioVentas, GintDecResultado)
        dou_TAXPEN = Round(dou_TOTALPEN / (100 + dou_PORCENTTAXIGV) * dou_PORCENTTAXIGV, GintDecResultado)
        dou_TAXUSD = mobj_cventasgen.ConvertirMoneda(dou_TAXPEN, GstrCodMonedaBase, GstrMonedaExtranjera, str_DATEPROCESALES, GstrTipoCambioVentas, GintDecResultado)
    End If
Else                                        ' GRABAR EN MONEDA EXTRANJERA Y CALCULAR MONEDA BASE
    str_CURYID = GstrMonedaExtranjera
    'calcular el total si no es fuel
    If rs_prod!CLASSID <> GstrCategoriaFuels Then
        dou_TOTALUSD = Round(Val(ctnUnidades.Text) * Val(ctnprecio.Text), GintDecResultado)
    Else       'si es fuel calcular la cantidad segun el total
        dou_TOTALUSD = Val(CTN_SUBTOTAL.Text)
    End If
    dou_TOTALPEN = mobj_cventasgen.ConvertirMoneda(dou_TOTALUSD, GstrMonedaExtranjera, GstrCodMonedaBase, str_DATEPROCESALES, GstrTipoCambioVentas, GintDecResultado)
    
    If GblnAfecto Then
        dou_PORCENTTAXIGV = rs_prod!taxvalue
        dou_TAXUSD = Round(dou_TOTALUSD / (100 + dou_PORCENTTAXIGV) * dou_PORCENTTAXIGV, GintDecResultado)
        dou_TAXPEN = mobj_cventasgen.ConvertirMoneda(dou_TAXUSD, GstrMonedaExtranjera, GstrCodMonedaBase, str_DATEPROCESALES, GstrTipoCambioVentas, GintDecResultado)
    End If
End If


If Not GblnAfecto Then
    dou_PORCENTTAXIGV = 0
    dou_TAXUSD = 0
    dou_TAXPEN = 0
End If
    
byt_STKITEM = rs_prod!stkitem
byt_STKFISI = rs_prod!stkfisi
dou_SLS_PRICE = rs_prod!preciodat

'PRECIO
If DescuentoItem = True Then
   dou_SLSPRICESALE = DBDetalle.Columns(3).Text
Else
   dou_SLSPRICESALE = Val(ctnprecio.Text)
End If

dou_STDCOSTPEN = rs_prod!stdcostpen
dou_STDCOSTUSD = rs_prod!stdcostusd
str_INVTIDALTER = IIf(IsNull(rs_prod!ALTERN), "", rs_prod!ALTERN)

'CANTIDAD
If DescuentoItem = True Then
   dou_QTY = DBDetalle.Columns(5).Text
Else
   dou_QTY = Val(ctnUnidades.Text)
End If

'DESCRIPCION
If DescuentoItem = True Then
   STR_DESCR = DBDetalle.Columns(2).Text
Else
   STR_DESCR = lblDescripcion.Caption
End If

STRUNIDAD = rs_prod!unidad

If mbln_editandoproducto Then

MOBJ_CVENTASCSTORE.actualizarcstoreDetalle dou_CORRNBR, str_DOCTYPEID, _
                                    dou_NBRDOCUMENT, int_nlin, str_SITEID, str_INVTIDSKU, _
                                    str_CURYID, str_DATEDOC, str_DATEPROCESALES, _
                                    dou_NBRTURN, dou_PORCENTTAXIGV, dou_PORCENTTAXISC, _
                                    dou_TOTALPEN, dou_TOTALUSD, _
                                    dou_TAXPEN, dou_TAXUSD, byt_STKITEM, _
                                    byt_STKFISI, dou_SLS_PRICE, _
                                    dou_SLSPRICESALE, dou_STDCOSTPEN, _
                                    dou_STDCOSTUSD, str_INVTIDALTER, _
                                    dou_QTY, STR_DESCR, STRUNIDAD
Else
MOBJ_CVENTASCSTORE.GrabarcstoreTmp dou_CORRNBR, str_DOCTYPEID, dou_NBRDOCUMENT, _
                                    str_SITEID, str_INVTIDSKU, str_CURYID, _
                                    str_DATEDOC, str_DATEPROCESALES, _
                                    dou_NBRTURN, dou_PORCENTTAXIGV, _
                                    dou_PORCENTTAXISC, dou_TOTALPEN, _
                                    dou_TOTALUSD, dou_TAXPEN, dou_TAXUSD, _
                                    byt_STKITEM, byt_STKFISI, dou_SLS_PRICE, _
                                    dou_SLSPRICESALE, dou_STDCOSTPEN, _
                                    dou_STDCOSTUSD, str_INVTIDALTER, dou_QTY, _
                                    STR_DESCR, STRUNIDAD
End If

mbln_articuloencontrado = False
mbln_editandoproducto = False
txtArticulo.Text = ""
lblDescripcion.Caption = ""
ctnprecio.Text = ""
ctnUnidades.Text = ""
CTN_SUBTOTAL.Text = ""
'If descuentoItem = False Then
'  txtArticulo.SetFocus
'End If
txtArticulo.Locked = False
Call CARGAGRILLA(pdbl_correlativo)

End Sub
Sub valida_NUMERODOCUMENTO(STRID As String)
Dim DOCTYPEID As String
Dim NBRDOCUMENT As Double
        
If gstrtipoventas = "A" Then        'facturacion automatica
    If Len(Trim(txt_NBRDOCUMENT.Text)) = 0 Then
        MsgBox "Debe Ingresar un numero de documento", vbExclamation, "Atencion"
    Else
       If STRID = "KD" Then
           If TXT_IDCLIENTE.Enabled = True Then
              TXT_IDCLIENTE.SetFocus
           End If
        End If
    End If
Else        'facturacion manual
    If Len(Trim(txt_NBRDOCUMENT.Text)) = 0 Then
        MsgBox "Debe Ingresar un numero de documento", vbExclamation, "Atencion"
    Else
        DOCTYPEID = dtc_tdocumento.BoundText
        NBRDOCUMENT = Val(dtc_serie.BoundText + txt_NBRDOCUMENT.Text)
               
        If mobj_cventasgen.ExisteDocumento(DOCTYPEID, NBRDOCUMENT, GstrSiteProce) Then
            MsgBox "Documento Ya Existe" + Chr(13) + "Modifique el Numero de Documento", vbExclamation, "Datos Incorrectos"
            Exit Sub
        End If
        If STRID = "KD" Then
           If TXT_IDCLIENTE.Enabled = True Then
              TXT_IDCLIENTE.SetFocus
           End If
        End If
    End If
End If

End Sub
Sub borrar_valores()
    TXT_IDCLIENTE = ""
'    txt_tipodoc.Text = ""
    txt_razonsocial.Text = ""
    txt_direccion.Text = ""
    txt_ruc.Text = ""
    txtArticulo.Text = ""
    ctnUnidades.Text = ""
    dblCantidad = 0
    lblDescripcion.Caption = ""
    txt_subtotal.Text = ""
    txt_igv.Text = ""
    txt_total.Text = ""
    LdblTotalBase = 0
    LdblTotalExt = 0
    LDblIGVBase = 0
    LDblIGVExt = 0
    LDblSubAfectoBase = 0
    LDblSubAfectoExt = 0
    LDblNoAfectoBase = 0
    LDblNoAfectoExt = 0
    LDblTOTALNOTAFFECTPEN = 0
    LDblTOTALNOTAFFECTUSD = 0
    LDblTOTRETURNEDPEN = 0
    LDblTOTRETURNEDUSD = 0
    LDblTOTCASHPEN = 0
    LDblTOTCASHUSD = 0
    GSTRPLACA = ""
    GLONKILOMETRAJE = 0
    GBlnClienteCargado = False
    GblnconPlacas = False
End Sub

Function pasar_ruc(ByVal StrRuc As String) As Boolean
Dim i As Integer
pasar_ruc = True
StrRuc = Trim(StrRuc)
For i = 1 To Len(StrRuc)
    If Not IsNumeric(Mid(StrRuc, i, 1)) Then
        pasar_ruc = False
        Exit For
    End If
Next
End Function
Public Sub GAsignarDatosdeCliente()
   
   If IsNull(grscliente!credito) Then
    MintTipoCliente = 0
   Else
    MintTipoCliente = grscliente!credito
   End If
      
   MintCustomer_user9CS = grscliente!user9
      
   If Not IsNull(grscliente!TIPOCLIENTE) Then
     GstrTipoClienteDescr = grscliente!TIPOCLIENTE
   Else
     GstrTipoClienteDescr = Empty       'cambiar por cliente id contado
   End If
   ' Variables de Manejo para el Límite de Crédito
   
   GstrIddeEstado = grscliente!IDESTADO ' A,H,R,I,O
   GstrDescrEstado = grscliente!ESTADO
      
   If IsNull(grscliente!MONEDACREDITO) Then
      GstrMonedaLimiteCredito = GStrMonedaCaja
   Else
      GstrMonedaLimiteCredito = grscliente!MONEDACREDITO
   End If
        
   If GstrMonedaLimiteCredito = GstrCodMonedaBase Then
      'Establecer Nombres de las Etiquetas
      'Con la Moneda de la Caja por defecto
       TXT_MONEDATOTAL.Text = GstrSimboloMonedaBase
   Else
       TXT_MONEDATOTAL.Text = GstrSimboloMonedaExt
   End If

   If IsNull(grscliente!TIPODECAMBIO) Or Len(Trim(grscliente!TIPODECAMBIO)) = 0 Then
        GstrTipodeCambio = GstrTipoCambioVentas
   Else
        GstrTipodeCambio = grscliente!TIPODECAMBIO
   End If
   
    If GStrMonedaCaja = GstrCodMonedaBase Then
        gdblMontoTipoCambio = mobj_cventasgen.ObtenerMontoTipodeCambio(GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipodeCambio)
    Else
        gdblMontoTipoCambio = mobj_cventasgen.ObtenerMontoTipodeCambio(GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipodeCambio)
    End If
   'si no hay tipo de cambio no se debe vender
   GintDiasdeGracia = grscliente!DIASDEGRACIA
   
   If gstrtipoventas = "A" Then
      GdblLimiteCredito = mobj_cventasgen.ConvertirMoneda(grscliente!LIMITECRED, GstrMonedaLimiteCredito, GStrMonedaCaja, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecResultado)
      GdblDeudaVigente = mobj_cventasgen.ConvertirMoneda(grscliente!DEUDACLIENTE, GstrMonedaLimiteCredito, GStrMonedaCaja, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecResultado)
   Else
      GdblLimiteCredito = mobj_cventasgen.ConvertirMoneda(grscliente!LIMITECRED, GstrMonedaLimiteCredito, GStrMonedaCaja, dtp_fechapro.Value, GstrTipodeCambio, GintDecResultado)
      GdblDeudaVigente = mobj_cventasgen.ConvertirMoneda(grscliente!DEUDACLIENTE, GstrMonedaLimiteCredito, GStrMonedaCaja, dtp_fechapro.Value, GstrTipodeCambio, GintDecResultado)
   End If
   
   GdblSaldoDisponible = GdblLimiteCredito - GdblDeudaVigente
   
   If gstrtipoventas = "A" Then
      GdblMontoExtra = mobj_cventasgen.ConvertirMoneda(grscliente!EXTRA, GstrMonedaLimiteCredito, GStrMonedaCaja, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecResultado)
   Else
      GdblMontoExtra = mobj_cventasgen.ConvertirMoneda(grscliente!EXTRA, GstrMonedaLimiteCredito, GStrMonedaCaja, dtp_fechapro.Value, GstrTipodeCambio, GintDecResultado)
   End If
      
   
   GblnAfecto = grscliente!afecto
   'Variable que Indica que los Datos del Cliente
   'Fueron Cargados con éxito
      
   MBlndatosasignados = True
End Sub
Public Sub CARGACABEZERALOADSALE(gdouloadsales)
Dim RS_TEMP As ADODB.Recordset
Set RS_TEMP = MOBJ_CVENTASCSTORE.obtenercabezeratransgrabadas(gdouloadsales)
dtc_tdocumento.BoundText = RS_TEMP!DOCTYPEID


'txt_NBRDOCUMENT.Text = Trim(Str(RS_TEMP!NBRDOCUMENT))


dtp_fecha.Value = RS_TEMP!DATEDOC
TXT_IDCLIENTE.Text = RS_TEMP!custidss
txt_ruc.Text = RS_TEMP!taxregnbr
txt_razonsocial.Text = RS_TEMP!CUSTNAME
txt_direccion.Text = RS_TEMP!ADDR1
'LA CABEZERA DEBE DESACTIVARSE
End Sub
Public Sub ESTADO_CABEZERA(ByVal BOL_ESTADO As Boolean)
'SI TIPO DE VENTA NO ES AUTOMATICO DESACTIVAR TAMBIEN CAMPOS ADICIONALES

TXT_IDCLIENTE.Enabled = BOL_ESTADO
txt_ruc.Enabled = BOL_ESTADO
txt_razonsocial.Enabled = BOL_ESTADO
cmd_bcliente.Enabled = BOL_ESTADO
txt_direccion.Enabled = BOL_ESTADO
mbln_cabezeraprotegida = Not BOL_ESTADO

If gstrtipoventas <> "A" Then
    dtc_tdocumento.Enabled = BOL_ESTADO
    dtc_serie.Enabled = BOL_ESTADO
    dtc_tdocumento.Enabled = BOL_ESTADO
    dtp_fecha.Enabled = BOL_ESTADO
    dtp_fechapro.Enabled = BOL_ESTADO
    dtc_serie.Enabled = BOL_ESTADO
    txt_NBRDOCUMENT.Enabled = BOL_ESTADO
    dtc_tnegocio.Enabled = BOL_ESTADO
    dtc_vendedor.Enabled = BOL_ESTADO
End If

End Sub
Public Sub FORMATONBRDOCUMENT()
Dim LS_NDOC As String
LS_NDOC = Trim(txt_NBRDOCUMENT.Text)
txt_NBRDOCUMENT.Text = String(7 - Len(LS_NDOC), "0") + LS_NDOC
End Sub
Private Sub GRABAR_CABEZERA_TEMPORAL()
'grabar si existe alguna linea

Dim ldou_loadsale As Double
Dim CORRNBR As Double
Dim DOCTYPEID As String
Dim NBRDOCUMENT As Double
Dim TYPEPAYMENTID As String
Dim STKINVENTORY As Byte
Dim SITEID As String
Dim curyid As String
Dim TERMID As String
Dim SALESPERID As String
Dim USERID As String
Dim DATEDOC As String
Dim DATEPROCESALES As String
Dim PERPOST As String
Dim TAXIGVID As String
Dim TAXISCID As String
Dim TOTALPEN As Double
Dim TOTALUSD As Double
Dim SUBTOTALPEN As Double
Dim SUBTOTALUSD As Double
Dim TAXIGVPEN As Double
Dim TAXIGVUSD As Double
Dim TAXISCPEN As Double
Dim TAXISCUSD As Double
Dim TOTALNOTAFFECTPEN As Double
Dim TOTALNOTAFFECTUSD As Double
Dim TOTRETURNEDPEN As Double
Dim TOTRETURNEDUSD As Double
Dim TOTCASHPEN As Double
Dim TOTCASHUSD As Double
Dim custidss As String
Dim taxregnbr As String
Dim CUSTNAME As String
Dim ADDR1 As String
Dim PLACA As String
Dim NBRBONUS As Double
Dim CURYTYPEID As String
Dim CURYRATE As Double
Dim PROMOTIONCARDID As String
Dim POINTNUMBER As Integer
Dim SALESPOINT As String
Dim KILOMETRAJE As Integer
Dim typesales As String
Dim STR_TIPONEGOCIO As String

If gstrtipoventas = "A" Then
    DOCTYPEID = mobj_cventasgen.obtenertipoticket
    STR_TIPONEGOCIO = Gstrtiponegocio
Else
    DOCTYPEID = dtc_tdocumento.BoundText
    STR_TIPONEGOCIO = dtc_tnegocio.BoundText
End If

NBRDOCUMENT = Val(txt_NBRDOCUMENT.Text)
TYPEPAYMENTID = "00"
STKINVENTORY = 1
SITEID = GstrSiteProce
curyid = "PEN"
TERMID = "00"
SALESPERID = GstrCodigoVENDEDOR
USERID = GCUSERID
DATEDOC = CStr(dtp_fecha.Value)
DATEPROCESALES = CStr(dtp_fechapro.Value)
PERPOST = ""
TAXIGVID = 0
TAXISCID = 0
TOTALPEN = Val(txt_total.Text)
TOTALUSD = 0
SUBTOTALPEN = (txt_subtotal.Text)
SUBTOTALUSD = 0
TAXIGVPEN = Val(txt_igv.Text)
TAXIGVUSD = 0
TAXISCPEN = 0
TAXISCUSD = 0
TOTALNOTAFFECTPEN = Val(TXT_NOAFECTO.Text)
TOTALNOTAFFECTUSD = 0
TOTRETURNEDPEN = 0
TOTRETURNEDUSD = 0
TOTCASHPEN = 0
TOTCASHUSD = 0
custidss = TXT_IDCLIENTE.Text
taxregnbr = txt_ruc.Text
CUSTNAME = txt_razonsocial.Text
ADDR1 = txt_direccion.Text
PLACA = ""
NBRBONUS = 0
CURYTYPEID = GstrTipoCambioVentas
CURYRATE = Val(txt_tcambio.Text)
PROMOTIONCARDID = ""
POINTNUMBER = 0
SALESPOINT = GstrPuntodeVenta
KILOMETRAJE = 0
typesales = gstrtipoventas

'MsgBox "Grabando"
'VERIFICAR QUE LA TRANSACION NO ESTE GRABADA YA
If mobj_cventasgen.existecorrelativotemporal(pdbl_correlativo) Then
    ' ya esta grabada, hay que actualizar
'MsgBox "actualizando"
mobj_cventasgen.actualizatransaccion pdbl_correlativo, DOCTYPEID, NBRDOCUMENT, TYPEPAYMENTID, _
                   STKINVENTORY, SITEID, curyid, TERMID, SALESPERID, USERID, _
                   DATEDOC, DATEPROCESALES, PERPOST, TAXIGVID, TAXISCID, _
                   TOTALPEN, TOTALUSD, SUBTOTALPEN, SUBTOTALUSD, TAXIGVPEN, _
                   TAXIGVUSD, TAXISCPEN, TAXISCUSD, TOTALNOTAFFECTPEN, _
                   TOTALNOTAFFECTUSD, TOTRETURNEDPEN, _
                    TOTRETURNEDUSD, TOTCASHPEN, TOTCASHUSD, _
                   custidss, taxregnbr, CUSTNAME, PLACA, NBRBONUS, CURYTYPEID, _
                   CURYRATE, PROMOTIONCARDID, POINTNUMBER, SALESPOINT, KILOMETRAJE, _
                   typesales, ADDR1, STR_TIPONEGOCIO
Else

'MsgBox "insertando"
mobj_cventasgen.grabartransaccion pdbl_correlativo, DOCTYPEID, NBRDOCUMENT, TYPEPAYMENTID, _
                   STKINVENTORY, SITEID, curyid, TERMID, SALESPERID, USERID, _
                   DATEDOC, DATEPROCESALES, PERPOST, TAXIGVID, TAXISCID, _
                   TOTALPEN, TOTALUSD, SUBTOTALPEN, SUBTOTALUSD, TAXIGVPEN, _
                   TAXIGVUSD, TAXISCPEN, TAXISCUSD, TOTALNOTAFFECTPEN, _
                   TOTALNOTAFFECTUSD, TOTRETURNEDPEN, _
                    TOTRETURNEDUSD, TOTCASHPEN, TOTCASHUSD, _
                   custidss, taxregnbr, CUSTNAME, PLACA, NBRBONUS, CURYTYPEID, _
                   CURYRATE, PROMOTIONCARDID, POINTNUMBER, SALESPOINT, KILOMETRAJE, _
                   typesales, ADDR1, STR_TIPONEGOCIO

End If
End Sub
Private Sub GRABAR_VENTA(ByVal strtipoventa As String, Optional IntAdelanto As Integer = 0)
Dim CORRNBR As Double
Dim DOCTYPEID As String
Dim NBRDOCUMENT As Double
Dim TYPEPAYMENTID As String
Dim STKINVENTORY As Byte
Dim SITEID As String
Dim curyid As String
Dim TERMID As String
Dim SALESPERID As String
Dim USERID As String
Dim DATEDOC As String
Dim DATEPROCESALES As String
Dim TAXIGVID As String
Dim TAXISCID As String
Dim TAXISCPEN As Double
Dim TAXISCUSD As Double
Dim custidss As String
Dim taxregnbr As String
Dim CUSTNAME As String
Dim PLACA As String
Dim NBRBONUS As Double
Dim CURYTYPEID As String
Dim CURYRATE As Double
Dim PROMOTIONCARDID As String
Dim POINTNUMBER As Integer
Dim SALESPOINT As String
Dim KILOMETRAJE As Long
Dim typesales As String
Dim PORCENTDISCOUNT1 As Double
Dim PORCENTDISCOUNT2 As Double
Dim TOTDISCOUNTPEN As Double
Dim TOTDISCOUNTUSD As Double
Dim ERROR As Integer
Dim STR_RAZONSOCIAL As String
Dim STR_RUC As String
Dim STR_DIRECCION As String
Dim IntTurno As Integer
Dim STR_CAJERO As String
Dim STR_TIPODOC As String
Dim STR_TIPONEGOCIO As String
Dim xx As Date

'Convertir en letras el número para mostrar en Factura Pre - Impresa
Dim numero As String
Dim Letras As String
Dim sCentimos As String
Dim sMoneda As String
'Configurando nombre de moneda y los centimos
sMoneda = "Soles"
sCentimos = "Centimos"

If gstrtipoventas = "A" Then
    'Determina si se imprimira Factura Pre-Impresa
    If GstrImprFacPreImpresa Then
        DOCTYPEID = dtc_tdocumento.BoundText
        NBRDOCUMENT = Val(dtc_serie.BoundText + txt_NBRDOCUMENT.Text)
        STR_TIPODOC = "Factura"
    Else
        DOCTYPEID = mobj_cventasgen.obtenertipoticket
        NBRDOCUMENT = Val(txt_NBRDOCUMENT.Text)
        STR_TIPODOC = "Ticket"
    End If
'    STR_TIPODOC = "Ticket"
    STR_TIPONEGOCIO = dtc_tnegocio.BoundText
    SALESPERID = GstrCodigoVENDEDOR
'    DATEDOC = CStr(DateTime.Date) + " " + CStr(DateTime.Time)
    DATEDOC = CStr(DateTime.Date)
Else
    DOCTYPEID = dtc_tdocumento.BoundText
    STR_TIPODOC = Trim(txt_tipodoc.Text)
    NBRDOCUMENT = Val(dtc_serie.BoundText + txt_NBRDOCUMENT.Text)
    STR_TIPONEGOCIO = dtc_tnegocio.BoundText
    SALESPERID = dtc_vendedor.BoundText
    DATEDOC = CStr(dtp_fecha.Value)
End If

TYPEPAYMENTID = strtipoventa
STKINVENTORY = 1            '-------------------------------------------
SITEID = GstrSiteProce
curyid = GstrMonedaLimiteCredito
TERMID = "00"               '-------------------------------------------

USERID = GCUSERID

DATEPROCESALES = CStr(dtp_fechapro.Value)

TAXIGVID = ""                '-------------------------------------------
TAXISCID = ""
TAXISCPEN = 0
TAXISCUSD = 0
PORCENTDISCOUNT1 = 0
PORCENTDISCOUNT2 = 0
TOTDISCOUNTPEN = 0
TOTDISCOUNTUSD = 0

custidss = TXT_IDCLIENTE.Text
taxregnbr = txt_ruc.Text
CUSTNAME = txt_razonsocial.Text
PLACA = GSTRPLACA
NBRBONUS = 0
CURYTYPEID = GstrTipoCambioVentas   '-------------------------------------------
CURYRATE = Val(txt_tcambio.Text)
PROMOTIONCARDID = ""
POINTNUMBER = 0
SALESPOINT = GstrPuntodeVenta
KILOMETRAJE = GLONKILOMETRAJE
typesales = gstrtipoventas

IntTurno = mobj_cventasgen.obtenerturnoventas
STR_RAZONSOCIAL = Trim(txt_razonsocial.Text)
STR_RUC = Trim(txt_ruc.Text)
STR_DIRECCION = Trim(txt_direccion.Text)
STR_CAJERO = Trim(dtc_vendedor.Text)

If MintTipoCliente = 0 Then ' SI NO ES CREDITO ACTUALIZAR DATOS O AGREGAR CLIENTE
     
   MOBJ_CVENTASCSTORE.OP_AGREGACLIENTECSTORE custidss, STR_RUC, STR_RAZONSOCIAL, STR_DIRECCION, _
                                                       DATEPROCESALES, USERID

End If


ERROR = MOBJ_CVENTASCSTORE.grabarventa(pdbl_correlativo, DOCTYPEID, _
                   NBRDOCUMENT, TYPEPAYMENTID, _
                   STKINVENTORY, SITEID, curyid, TERMID, SALESPERID, USERID, _
                   DATEDOC, DATEPROCESALES, TAXIGVID, TAXISCID, _
                   LdblTotalBase, LdblTotalExt, LDblSubAfectoBase, _
                   LDblSubAfectoExt, LDblIGVBase, _
                   LDblIGVExt, TAXISCPEN, TAXISCUSD, LDblNoAfectoBase, _
                   LDblNoAfectoExt, 0, 0, _
                   PORCENTDISCOUNT1, PORCENTDISCOUNT2, _
                   TOTDISCOUNTPEN, TOTDISCOUNTUSD, LDblTOTRETURNEDPEN, _
                    LDblTOTRETURNEDUSD, LDblTOTCASHPEN, LDblTOTCASHUSD, _
                   custidss, taxregnbr, CUSTNAME, PLACA, NBRBONUS, CURYTYPEID, _
                   CURYRATE, PROMOTIONCARDID, POINTNUMBER, SALESPOINT, KILOMETRAJE, _
                   STR_TIPONEGOCIO, gstrtipoventas, IntAdelanto)

'error = MOBJ_CVENTASCSTORE.grabarventa(pdbl_correlativo, DOCTYPEID, _
'                   NBRDOCUMENT, TYPEPAYMENTID, _
'                   STKINVENTORY, SITEID, curyid, TERMID, SALESPERID, USERID, _
'                   DATEDOC, DATEPROCESALES, TAXIGVID, TAXISCID, _
'                   LdblTotalBase, LdblTotalExt, LDblSubAfectoBase, _
'                   LDblSubAfectoExt, LDblIGVBase, _
'                   LDblIGVExt, TAXISCPEN, TAXISCUSD, LDblNoAfectoBase, _
'                   LDblNoAfectoExt, _
'                   PORCENTDISCOUNT1, PORCENTDISCOUNT2, _
'                   TOTDISCOUNTPEN, TOTDISCOUNTUSD, LDblTOTRETURNEDPEN, _
'                   LDblTOTRETURNEDUSD, LDblTOTCASHPEN, LDblTOTCASHUSD, _
'                   custidss, taxregnbr, CUSTNAME, PLACA, NBRBONUS, CURYTYPEID, _
'                   CURYRATE, PROMOTIONCARDID, POINTNUMBER, SALESPOINT, KILOMETRAJE, _
'                   STR_TIPONEGOCIO, gstrtipoventas, IntAdelanto)

If ERROR = 0 Then
     'captura el numero del documento grabado
     numDocumentoT = NBRDOCUMENT
'    If gstrtipoventas = "A" Then
'         mobj_cventasgen.aumentarnroticket GstrPuntodeVenta, txt_tipodoc.Text ' INCREMENTAR EL NUMERO DE TICKET SEGUN EL TIPO
'    Else
'        mobj_cventasgen.aumentarnrodocumento dtc_tdocumento.BoundText, dtc_serie.BoundText, GstrSiteProce, GstrPuntodeVenta, Val(txt_NBRDOCUMENT.Text) ' INCREMENTAR EL NUMERO DE DOCUMENTO SEGUN EL TIPO
'    End If
    
    'MM:    Jorge Illescas  --->  INCREMENTAR EL NUMERO DE DOCUMENTO SEGUN EL TIPO
    'Aumenta correlativo de Factura Pre-Impresa
    If GstrImprFacPreImpresa Then
       mobj_cventasgen.aumentarnrodocumento dtc_tdocumento.BoundText, dtc_serie.BoundText, GstrSiteProce, GstrPuntodeVenta, Val(txt_NBRDOCUMENT.Text)
    End If
        
    Dim rs_tmptarjetas As ADODB.Recordset
    Dim rs_tmpvales As ADODB.Recordset
    
    If gstrtipoventas = "A" Then
               
        If TYPEPAYMENTID = GC_TARJETACRED Or TYPEPAYMENTID = GC_OTROS Then
            Set rs_tmptarjetas = New ADODB.Recordset
            Set rs_tmptarjetas = mobj_cventasgen.obtenertarjetasventa(DOCTYPEID, NBRDOCUMENT, GstrSiteProce)
        Else
            Set rs_tmptarjetas = Nothing
        End If
        
        If TYPEPAYMENTID = GC_VALESCRED Then
            Set rs_tmpvales = New ADODB.Recordset
            Set rs_tmpvales = mobj_cventasgen.obtenervales(DOCTYPEID, NBRDOCUMENT, GstrSiteProce)
        Else
            Set rs_tmpvales = Nothing
        End If
       
       If TYPEPAYMENTID <> GC_TARJETACRED And gstrtipoventas = "A" Then
          MBLN_INICIO = False
          F_RESUMEN.Show  'ventana de resumen
        End If
'
        'verdadero *** restaurar
'        Call Imprimir_Ticketcstore(STR_TIPODOC, CStr(NBRDOCUMENT), 40, STR_RAZONSOCIAL, STR_RUC, _
                                STR_DIRECCION, curyid, _
                                pdbl_correlativo, LDblSubAfectoBase, LDblSubAfectoExt, _
                                LDblIGVBase, LDblIGVExt, LdblTotalBase, LdblTotalExt, _
                                LDblNoAfectoBase, LDblNoAfectoExt, LDblTOTCASHPEN, LDblTOTCASHUSD, _
                                LDblTOTRETURNEDPEN, LDblTOTRETURNEDUSD, _
                                MrsGrilla, TYPEPAYMENTID, IntTurno, STR_CAJERO, _
                                Val(POINTNUMBER), PLACA, rs_tmptarjetas, 0, , rs_tmpvales)
        If GstrImprFacPreImpresa Then
           'Imprime Factura Pre-Impresa
            crFacturaMM.ReportFileName = GstrReportesVta + "rpt_Factura_MM_2.rpt"

            crFacturaMM.StoredProcParam(0) = CStr(NBRDOCUMENT)
            crFacturaMM.StoredProcParam(1) = GstrSiteProce
                      
            'MM: Jorge Illescas-----------
            'Convirtiendo Numeros a Letras
            numero = CStr(LdblTotalBase)
            Letras = Numero2Letra(numero, , sMoneda & " ", sCentimos & " ")
        
            crFacturaMM.Formulas(1) = "formTotLetras= stringvar totletras; totletras:='" & UCase(Letras) & "'"
            
            crFacturaMM.WindowTitle = "Reporte de Factura"
            crFacturaMM.WindowShowPrintSetupBtn = True
            crFacturaMM.WindowShowSearchBtn = True
            crFacturaMM.WindowState = crptMaximized

            crFacturaMM.Action = 1
        Else
           'Imprimie Ticket
            Call Imprimir_Ticketcstore_PantImpre(STR_TIPODOC, CStr(NBRDOCUMENT), 40, STR_RAZONSOCIAL, STR_RUC, _
                                STR_DIRECCION, curyid, _
                                pdbl_correlativo, LDblSubAfectoBase, LDblSubAfectoExt, _
                                LDblIGVBase, LDblIGVExt, LdblTotalBase, LdblTotalExt, _
                                LDblNoAfectoBase, LDblNoAfectoExt, LDblTOTCASHPEN, LDblTOTCASHUSD, _
                                LDblTOTRETURNEDPEN, LDblTOTRETURNEDUSD, _
                                MrsGrilla, TYPEPAYMENTID, IntTurno, STR_CAJERO, _
                                Val(POINTNUMBER), PLACA, rs_tmptarjetas, 0, , rs_tmpvales, IIf(Len(STR_RUC) = 0, GStrDispoTickBol, GStrDispoTickFac))
        End If
        Set rs_tmptarjetas = Nothing
    End If
    
    
    Call borrar_valores
    Call inicio
    
    MBLN_INICIO = True
    
Else
    MsgBox "Error Grabando Venta", vbCritical, "Error"
End If

Set rs_tmpvales = Nothing
Set rs_tmptarjetas = Nothing
End Sub

Sub anular_ticket()
Dim li_resp As Integer
li_resp = MsgBox("Esta Seguro que desea Anular el Documento", vbYesNo, "Precaucion")
If li_resp = vbYes Then
    
End If
End Sub

Sub eliminar_ticket()
Dim li_resp As Integer
li_resp = MsgBox("Esta Seguro que desea Eliminar el Documento ", vbYesNo, "Precaucion")
If li_resp = vbYes Then
    
End If
End Sub

Sub busquedaventas()
fbuscardocumentos.pstr_tnegocio = dtc_tnegocio.BoundText

fbuscardocumentos.Show vbModal
If pdbl_documentobuscado <> 0 Then
    'recuperar documento y marcar flag como consulta
    pbln_consulta = True
End If
pdbl_documentobuscado = 0

End Sub

Sub Datosclientepordefecto()
    MintTipoCliente = 0
    GstrMonedaLimiteCredito = GStrMonedaCaja
    TXT_MONEDATOTAL.Text = GstrSimboloMoneda
    GstrTipodeCambio = GstrTipoCambioVentas
    If GStrMonedaCaja = GstrCodMonedaBase Then
        gdblMontoTipoCambio = mobj_cventasgen.ObtenerMontoTipodeCambio(GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipodeCambio)
    Else
        gdblMontoTipoCambio = mobj_cventasgen.ObtenerMontoTipodeCambio(GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipodeCambio)
    End If
    GblnconPlacas = False
    cmdadelanto.Enabled = False
    GBlnClienteCargado = False
    GblnAfecto = True
    GstrCondiciondePago = "00"
End Sub

Sub valida_cabezera1()

If gstrtipoventas = "A" Then


Else
    If dtc_tdocumento.Text = "" Then
        MsgBox "Debe Escoger un tipo de documento", vbExclamation, "Precaucion"
        dtc_tdocumento.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
    If dtc_serie.Text = "" Then
        MsgBox "Debe Escoger una serie de documentos", vbExclamation, "Precaucion"
        dtc_serie.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
    If Val(txt_NBRDOCUMENT.Text) = 0 Then
        MsgBox "Debe Ingresar un numero de documento", vbExclamation, "Precaucion"
        dtc_serie.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
            
    ' Hay que Obtener las fechas de Proceso de Ventas / y la Fecha de Proceso
    Dim DatFechaProcesoVentas As Date
    Dim DatFechaProceso As Date
            
    DatFechaProcesoVentas = MobjUtilSetup.ObtenerSetupVentas!DATEPROCESALES
    DatFechaProceso = MobjUtilSetup.ObtenerSetupGeneral!DATEPROCE
            
    ' **********************************************
                                                
    If dtp_fechapro.Value > DatFechaProcesoVentas Then
        MsgBox " La fecha de proceso ingresada es mayor que la fecha de Venta", vbExclamation, "Error"
        dtp_fechapro.Value = DatFechaProcesoVentas
        If dtp_fechapro.Enabled = True Then
           dtp_fechapro.SetFocus
        End If
        
        pbln_errorcab = True
        Exit Sub
    End If

'ESTE CAMBIO PUEDE SERT CRUCIAL PARA EL FUNCIONANMIENTO DEL SISTEMA
'    If dtp_fechapro.Value < DatFechaProceso Then
'        MsgBox " La fecha Ingresada es menor que la fecha de Proceso", vbExclamation, "Error"
'        dtp_fechapro.Value = DatFechaProceso
'        If dtp_fechapro.Enabled = True Then
'           dtp_fechapro.SetFocus
'        End If
'        pbln_errorcab = True
'        Exit Sub
'    End If
    
    ' Parte anexada para verificar Zeta
    
        Dim Lrstemp As ADODB.Recordset
        Dim Lutil As UTIL_SETUP.C_SETUP
        Set Lutil = New UTIL_SETUP.C_SETUP
        Set Lrstemp = Lutil.Auxiliar3("SELECT Salespoint,Dateprocesales FROM OP_ZETA  WHERE DATEPROCESALES='" & Format(dtp_fechapro.Value, "yyyymmdd") & "'")
                
'@ Jorge: anulado para ingreso de documentos en la misma fecha de proceso antes de zeta---------------------
'        If Lrstemp.EOF Then ' Si está vacío el recordset
'           'Permite verificartr que ya se hayan realizado zetas, para la fecha de proceso seleccionado
'           MsgBox "La fecha de proceso no es válida para procesar documentos", vbDefaultButton1 + vbExclamation, "Mensaje"
'           dtp_fechapro.Value = DatFechaProcesoVentas
'           If dtp_fechapro.Enabled = True Then
'               dtp_fechapro.SetFocus
'           End If
'           pbln_errorcab = True
'           Exit Sub
'        End If
'----------------------------------------------------------------------------------------------------------
        'If Weekday(dtp_fechapro.Value) = 1 Then
        '   MsgBox "La fecha de proceso no es válida para procesar documentos", vbDefaultButton1 + vbExclamation, "Mensaje"
        '   dtp_fechapro.Value = DatFechaProcesoVentas
        '   If dtp_fechapro.Enabled = True Then
        '       dtp_fechapro.SetFocus
        '   End If
        '   pbln_errorcab = True
        '   Exit Sub
        'End If

   ' Fin de Parte Anexada para verificar el Zeta
   
   
    If dtp_fecha.Value > DatFechaProcesoVentas Then
        MsgBox " La fecha del Documento ingresada es mayor que la fecha de Venta", vbExclamation, "Error"
        dtp_fecha.Value = DatFechaProcesoVentas
        If dtp_fecha.Enabled = True Then
           dtp_fecha.SetFocus
        End If
        pbln_errorcab = True
        Exit Sub
    End If

End If
pbln_errorcab = False
End Sub

Sub valida_cabezera2()
If pbln_errorcab Then
    Exit Sub    ' ya existe un error
End If
If gstrtipoventas = "A" Then
    If GstrImprFacPreImpresa Then
        If Len(Trim(TXT_IDCLIENTE.Text)) = 0 And _
                dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipofactura And _
                    Me.ActiveControl.Name <> "TXT_IDCLIENTE" Then
            MsgBox "Debe Ingresar  Codigo Cliente", vbExclamation, "Precaucion"
            If TXT_IDCLIENTE.Enabled = True Then
               TXT_IDCLIENTE.SetFocus
            End If
            pbln_errorcab = True
            Exit Sub
        End If
    End If
Else
    If Len(Trim(TXT_IDCLIENTE.Text)) = 0 And _
            dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipofactura And _
                Me.ActiveControl.Name <> "TXT_IDCLIENTE" Then
        MsgBox "Debe Ingresar  Codigo Cliente", vbExclamation, "Precaucion"
        If TXT_IDCLIENTE.Enabled = True Then
           TXT_IDCLIENTE.SetFocus
        End If
        pbln_errorcab = True
        Exit Sub
    End If
End If
pbln_errorcab = False
End Sub
Sub valida_cabezera3()
Dim lstr_tfact As String
If pbln_errorcab Then
    Exit Sub    ' ya existe un error
End If
lstr_tfact = mobj_cventasgen.obtenertipofactura
If gstrtipoventas = "A" Then
    If Len(Trim(txt_ruc.Text)) = 0 And txt_tipodoc.Text = "TICKET FACTURA" Then
        MsgBox "Debe Ingresar un RUC", vbExclamation, "Precaucion"
        txt_ruc.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
    If Len(Trim(txt_ruc.Text)) < 11 And txt_tipodoc.Text = "TICKET FACTURA" Then
        MsgBox "Debe Ingresar 11 digitos en el RUC", vbExclamation, "Precaucion"
        txt_ruc.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
    If txt_tipodoc.Text = "TICKET FACTURA" And _
        Len(txt_razonsocial.Text) = 0 And _
        Me.ActiveControl.Name <> "txt_razonsocial" Then
        MsgBox "Debe Ingresar una Razon social", vbExclamation, "Atencion"
        If txt_razonsocial.Enabled Then
            txt_razonsocial.SetFocus
        End If
        pbln_errorcab = True
        Exit Sub
    End If
    If Len(Trim(txt_ruc.Text)) > 0 And txt_tipodoc.Text = "TICKET BOLETA" Then
        MsgBox "Una Boleta no debe tener RUC", vbExclamation, "Precaucion"
        txt_ruc.Text = ""
        'pbln_errorcab = True
        Exit Sub
    End If

Else
    If Len(Trim(txt_ruc.Text)) = 0 And dtc_tdocumento.BoundText = lstr_tfact Then
        MsgBox "Debe Ingresar un RUC", vbExclamation, "Precaucion"
        txt_ruc.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
    If Len(Trim(txt_ruc.Text)) < 11 And dtc_tdocumento.BoundText = lstr_tfact Then
        MsgBox "Debe Ingresar 11 digitos en el RUC", vbExclamation, "Precaucion"
        txt_ruc.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
    If dtc_tdocumento.BoundText = lstr_tfact And _
        Len(txt_razonsocial.Text) = 0 And _
        Me.ActiveControl.Name <> "txt_razonsocial" Then
        MsgBox "Debe Ingresar una Razon social", vbExclamation, "Atencion"
        txt_razonsocial.SetFocus
        pbln_errorcab = True
        Exit Sub
    End If
    If Len(Trim(txt_ruc.Text)) > 0 And dtc_tdocumento.BoundText = mobj_cventasgen.obtenertipoboleta Then
        MsgBox "Una Boleta no debe tener RUC", vbExclamation, "Precaucion"
        txt_ruc.Text = ""
        'pbln_errorcab = True
        Exit Sub
    End If
End If
pbln_errorcab = False
End Sub

Sub cierra_objetos()
 Set mobj_cseguridad = Nothing
 Set MOBJ_CMONEDA = Nothing
 Set mobj_cdocumento = Nothing
 Set mobj_cventasgen = Nothing
 Set MOBJ_CVENTASCSTORE = Nothing
 Set Mobj_Correlativo = Nothing
 Set grscliente = Nothing
 Set MrsGrilla = Nothing
 Set rs_prod = Nothing
 Set MobjUtilSetup = Nothing
 Set MobjMovimientos = Nothing
End Sub


'mobj_cventasgen.obtenertiponc



