VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{69F9D01E-F1DE-11D4-9536-002018603DA2}#7.0#0"; "ControlNumber.ocx"
Begin VB.Form fpagoefectivo 
   Caption         =   "Pago en Efectivo"
   ClientHeight    =   6660
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7575
   LinkTopic       =   "Form3"
   ScaleHeight     =   6660
   ScaleWidth      =   7575
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame5 
      Height          =   2055
      Left            =   0
      TabIndex        =   42
      Top             =   2100
      Width           =   7455
      Begin VB.TextBox TXT_NTARJETA 
         Height          =   315
         Index           =   0
         Left            =   3840
         MaxLength       =   20
         TabIndex        =   4
         Top             =   180
         Width           =   1935
      End
      Begin VB.TextBox TXT_NTARJETA 
         Height          =   315
         Index           =   1
         Left            =   3840
         MaxLength       =   20
         TabIndex        =   8
         Top             =   540
         Width           =   1935
      End
      Begin VB.TextBox TXT_NTARJETA 
         Height          =   315
         Index           =   2
         Left            =   3840
         MaxLength       =   20
         TabIndex        =   12
         Top             =   900
         Width           =   1935
      End
      Begin VB.TextBox TXT_NTARJETA 
         Height          =   315
         Index           =   3
         Left            =   3840
         MaxLength       =   20
         TabIndex        =   16
         Top             =   1260
         Width           =   1935
      End
      Begin VB.TextBox TXT_NTARJETA 
         Height          =   315
         Index           =   4
         Left            =   3840
         MaxLength       =   20
         TabIndex        =   20
         Top             =   1560
         Width           =   1935
      End
      Begin MiControl.CtrlNumber ctrl_monto 
         Height          =   390
         Index           =   0
         Left            =   5760
         TabIndex        =   5
         Top             =   180
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   688
         BackColor       =   -2147483643
         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 MSDataListLib.DataCombo DTC_TARJETA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   0
         Left            =   360
         TabIndex        =   2
         Top             =   180
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo DTC_MONEDA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   0
         Left            =   2400
         TabIndex        =   3
         Top             =   180
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MiControl.CtrlNumber ctrl_monto 
         Height          =   390
         Index           =   1
         Left            =   5760
         TabIndex        =   9
         Top             =   540
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   688
         BackColor       =   -2147483643
         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 MSDataListLib.DataCombo DTC_TARJETA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   1
         Left            =   360
         TabIndex        =   6
         Top             =   540
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo DTC_MONEDA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   1
         Left            =   2400
         TabIndex        =   7
         Top             =   540
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MiControl.CtrlNumber ctrl_monto 
         Height          =   390
         Index           =   2
         Left            =   5760
         TabIndex        =   13
         Top             =   900
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   688
         BackColor       =   -2147483643
         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 MSDataListLib.DataCombo DTC_TARJETA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   2
         Left            =   360
         TabIndex        =   10
         Top             =   900
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo DTC_MONEDA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   2
         Left            =   2400
         TabIndex        =   11
         Top             =   900
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MiControl.CtrlNumber ctrl_monto 
         Height          =   390
         Index           =   3
         Left            =   5760
         TabIndex        =   17
         Top             =   1260
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   688
         BackColor       =   -2147483643
         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 MSDataListLib.DataCombo DTC_TARJETA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   3
         Left            =   360
         TabIndex        =   14
         Top             =   1260
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo DTC_MONEDA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   3
         Left            =   2400
         TabIndex        =   15
         Top             =   1260
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MiControl.CtrlNumber ctrl_monto 
         Height          =   390
         Index           =   4
         Left            =   5760
         TabIndex        =   21
         Top             =   1620
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   688
         BackColor       =   -2147483643
         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 MSDataListLib.DataCombo DTC_TARJETA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   4
         Left            =   360
         TabIndex        =   18
         Top             =   1620
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo DTC_MONEDA 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """S/."" #,##0.00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   10250
            SubFormatType   =   0
         EndProperty
         Height          =   315
         Index           =   4
         Left            =   2400
         TabIndex        =   19
         Top             =   1620
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         _Version        =   393216
         IntegralHeight  =   0   'False
         MatchEntry      =   -1  'True
         Style           =   2
         Text            =   ""
      End
   End
   Begin VB.Frame Frame4 
      Caption         =   "Faltante"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   675
      Left            =   0
      TabIndex        =   37
      Top             =   4200
      Width           =   7455
      Begin MiControl.CtrlNumber pusd 
         Height          =   390
         Left            =   4860
         TabIndex        =   38
         Top             =   210
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   688
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin MiControl.CtrlNumber ppen 
         Height          =   390
         Left            =   1320
         TabIndex        =   39
         Top             =   210
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   688
         BackColor       =   -2147483643
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.Label Label8 
         Caption         =   "O..."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3480
         TabIndex        =   47
         Top             =   240
         Width           =   495
      End
      Begin VB.Label Label2 
         Caption         =   "$"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   4560
         TabIndex        =   41
         Top             =   240
         Width           =   255
      End
      Begin VB.Label Label1 
         Caption         =   "S/."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   960
         TabIndex        =   40
         Top             =   240
         Width           =   255
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "Vuelto"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   0
      TabIndex        =   34
      Top             =   4920
      Width           =   7455
      Begin VB.Label LBL_MONEDAV 
         Caption         =   "MONEDA"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   240
         TabIndex        =   36
         Top             =   240
         Width           =   1695
      End
      Begin VB.Label LBL_MONTOV 
         Caption         =   "MONTO"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5520
         TabIndex        =   35
         Top             =   240
         Width           =   1695
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Efectivo"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   0
      TabIndex        =   29
      Top             =   960
      Width           =   7455
      Begin MiControl.CtrlNumber txt_edolares 
         Height          =   390
         Left            =   3360
         TabIndex        =   1
         Top             =   210
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   688
         BackColor       =   -2147483643
         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.TextBox txt_tc 
         Alignment       =   1  'Right Justify
         Enabled         =   0   'False
         Height          =   320
         Left            =   6480
         TabIndex        =   32
         TabStop         =   0   'False
         Top             =   240
         Width           =   855
      End
      Begin MiControl.CtrlNumber txt_esoles 
         Height          =   390
         Left            =   1380
         TabIndex        =   0
         Top             =   240
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   688
         BackColor       =   -2147483643
         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 lbl_pen 
         Caption         =   "S/."
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   960
         TabIndex        =   33
         Top             =   240
         Width           =   255
      End
      Begin VB.Label lbl_usd 
         Caption         =   "$"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3240
         TabIndex        =   31
         Top             =   240
         Width           =   255
      End
      Begin VB.Label Label3 
         Caption         =   "T.C.:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5880
         TabIndex        =   30
         Top             =   240
         Width           =   495
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Total"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   0
      TabIndex        =   26
      Top             =   180
      Width           =   7455
      Begin VB.Label LBL_MONTOT 
         Caption         =   "MONTO"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5640
         TabIndex        =   28
         Top             =   240
         Width           =   1695
      End
      Begin VB.Label LBL_MONEDAT 
         Caption         =   "MONEDA"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   240
         TabIndex        =   27
         Top             =   240
         Width           =   1695
      End
   End
   Begin VB.CommandButton cmd_cambiomoneda 
      Caption         =   "&Cambio Moneda"
      Height          =   855
      Left            =   2040
      Picture         =   "fpagoefectivo.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   25
      Top             =   5760
      Width           =   1335
   End
   Begin VB.CommandButton cmd_vuelto 
      Caption         =   "&Vuelto"
      Enabled         =   0   'False
      Height          =   855
      Left            =   120
      Picture         =   "fpagoefectivo.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   24
      Top             =   5760
      Width           =   1335
   End
   Begin VB.CommandButton CMD_ACEPTAR 
      Caption         =   "&Aceptar"
      CausesValidation=   0   'False
      Height          =   855
      Left            =   4440
      Picture         =   "fpagoefectivo.frx":0614
      Style           =   1  'Graphical
      TabIndex        =   22
      Tag             =   "R ASDASD"
      Top             =   5760
      Width           =   1215
   End
   Begin VB.CommandButton CMD_CANCELAR 
      Cancel          =   -1  'True
      Caption         =   "&Cancelar"
      CausesValidation=   0   'False
      Height          =   855
      Left            =   6120
      Picture         =   "fpagoefectivo.frx":091E
      Style           =   1  'Graphical
      TabIndex        =   23
      Top             =   5760
      Width           =   1335
   End
   Begin VB.Label Label7 
      Caption         =   "Monto"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6060
      TabIndex        =   46
      Top             =   1860
      Width           =   795
   End
   Begin VB.Label Label6 
      Caption         =   "Nro.Tarjeta"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4140
      TabIndex        =   45
      Top             =   1860
      Width           =   1275
   End
   Begin VB.Label Label5 
      Caption         =   "Moneda"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2640
      TabIndex        =   44
      Top             =   1860
      Width           =   855
   End
   Begin VB.Label Label4 
      Caption         =   "Tipo Tarjeta"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   660
      TabIndex        =   43
      Top             =   1860
      Width           =   1395
   End
End
Attribute VB_Name = "fpagoefectivo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mobj_cventasgen As DB_OP_FACTURACION.C_VENTASGENERAL
Dim gstr_monedavuelto As String
Dim gDBL_montopagadobase As Double
Dim gDBL_montopagadoext As Double
Dim gDBL_montoventaPEN As Double
Dim gDBL_montoventaUSD As Double
Dim lbln_cambio As Boolean
Dim gdou_tipocambio As Double
Dim gDBL_vueltopen As Double
Dim gDBL_vueltousd As Double
Dim TOTCARDUSD As Double
Dim TOTCARDpen As Double
Dim ldbl_pagopen As Double
Dim ldbl_pagousd As Double
Dim pbln_inicio As Boolean


Private Sub CMD_ACEPTAR_Click()
If gstr_monedavuelto = GstrCodMonedaBase Then
    If gDBL_montoventaPEN > gDBL_montopagadobase Then
        MsgBox "Monto Pagado Insuficiente", vbExclamation, "Atencion"
        Exit Sub
    End If
Else
    If gDBL_montoventaUSD > gDBL_montopagadoext Then
        MsgBox "Monto Pagado Insuficiente", vbExclamation, "Atencion"
        Exit Sub
    End If
End If

If grabartarjetas Then
    'llamar al procedimiento de grabado
    
    If gstr_monedavuelto = GstrCodMonedaBase Then 'convertir moneda extranjera a nacional
        f_ventascstore.LDblTOTRETURNEDPEN = gDBL_vueltopen
        f_ventascstore.LDblTOTRETURNEDUSD = 0
    Else
        f_ventascstore.LDblTOTRETURNEDUSD = gDBL_vueltousd
        f_ventascstore.LDblTOTRETURNEDPEN = 0
        
    End If
    
    f_ventascstore.LDblTOTCASHPEN = Val(txt_esoles.Text)
    f_ventascstore.LDblTOTCASHUSD = Val(txt_edolares.Text)
    
    gbln_ventaefectuada = True
    F_RESUMEN.LBL_MONEDAT.Caption = LBL_MONEDAT.Caption
    F_RESUMEN.LBL_MONTOT.Caption = GFormatodeNumero(LBL_MONTOT.Caption, GintDecResultado)
    F_RESUMEN.Lbl_pagopen.Caption = GFormatodeNumero(ldbl_pagopen, 2)
    F_RESUMEN.Lbl_pagousd.Caption = GFormatodeNumero(ldbl_pagousd, 2)
    F_RESUMEN.Lbl_vueltopen.Caption = GFormatodeNumero(f_ventascstore.LDblTOTRETURNEDPEN, 2)
    F_RESUMEN.Lbl_vueltousd.Caption = GFormatodeNumero(f_ventascstore.LDblTOTRETURNEDUSD, 2)
    Unload Me
    'Me.Hide
End If
' procedimiento de grabado
End Sub

Private Sub cmd_cambiomoneda_Click()
If Val(LBL_MONTOV.Caption) = 0 Then
    Exit Sub
End If
lbln_cambio = Not lbln_cambio
If gstr_monedavuelto = GstrCodMonedaBase Then 'convertir moneda extranjera a nacional
    gstr_monedavuelto = GstrMonedaExtranjera
    LBL_MONTOV.Caption = GFormatodeNumero(gDBL_vueltousd, GintDecPrecio)
    LBL_MONEDAV.Caption = GstrSimboloMonedaExt
 Else
    gstr_monedavuelto = GstrCodMonedaBase
    LBL_MONTOV.Caption = GFormatodeNumero(gDBL_vueltopen, GintDecPrecio)
    LBL_MONEDAV.Caption = GstrSimboloMonedaBase
 End If
 If lbln_cambio And Val(LBL_MONTOV.Caption) > 0 Then
    cmd_vuelto.Enabled = True
 Else
    cmd_vuelto.Enabled = False
 End If
 
End Sub

Private Sub cmd_Cancelar_Click()
    Unload Me
End Sub


Private Sub cmd_vuelto_Click()
fcstorevuelto.lbl_pen.Caption = lbl_pen.Caption
fcstorevuelto.lbl_usd.Caption = lbl_usd.Caption

If GstrMonedaLimiteCredito = GstrCodMonedaBase Then
    fcstorevuelto.txt_edolares.Text = Val(LBL_MONTOV.Caption)
Else
    fcstorevuelto.txt_esoles.Text = Val(LBL_MONTOV.Caption)
End If
fcstorevuelto.txt_tc.Text = txt_tc.Text
fcstorevuelto.Show vbModal

If gbln_ventaefectuada Then
    If grabartarjetas Then  'grabar movimientos de tarjetas
        'llamar al procedimiento de grabado
        'MsgBox "Transaccion Grabada", vbInformation, "OK"
                 
        f_ventascstore.LDblTOTCASHPEN = Val(txt_esoles.Text)
        f_ventascstore.LDblTOTCASHUSD = Val(txt_edolares.Text)
        
        gbln_ventaefectuada = True
        F_RESUMEN.LBL_MONEDAT.Caption = LBL_MONEDAT.Caption
        F_RESUMEN.LBL_MONTOT.Caption = LBL_MONTOT.Caption
        F_RESUMEN.Lbl_pagopen.Caption = GFormatodeNumero(ldbl_pagopen, 2)
        F_RESUMEN.Lbl_pagousd.Caption = GFormatodeNumero(ldbl_pagousd, 2)
        F_RESUMEN.Lbl_vueltopen.Caption = GFormatodeNumero(f_ventascstore.LDblTOTRETURNEDPEN, 2)
        F_RESUMEN.Lbl_vueltousd.Caption = GFormatodeNumero(f_ventascstore.LDblTOTRETURNEDUSD, 2)
    
        Unload Me
    End If
End If
End Sub

Private Sub ctrl_monto_GotFocus(Index As Integer)
ctrl_monto(Index).BackColor = vbCyan
End Sub

Private Sub ctrl_monto_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    Call calculavuelto
    
    If gDBL_montopagadobase >= gDBL_montoventaPEN Then
        CMD_ACEPTAR.SetFocus
    Else
        If Index < 4 Then
            DTC_TARJETA(Index + 1).SetFocus
        End If
    End If
End If
If KeyCode = vbKeyDown Then
    If Index < 4 Then
        ctrl_monto(Index + 1).SetFocus
    Else
        CMD_ACEPTAR.SetFocus
    End If
End If
If KeyCode = vbKeyUp Then
    If Index > 0 Then
        ctrl_monto(Index - 1).SetFocus
    Else
        TXT_NTARJETA(0).SetFocus
    End If
End If

End Sub

Private Sub ctrl_monto_LostFocus(Index As Integer)
ctrl_monto(Index).BackColor = vbWhite
Call calculavuelto
End Sub

Private Sub DTC_MONEDA_GotFocus(Index As Integer)
DTC_MONEDA(Index).BackColor = vbCyan
End Sub

Private Sub DTC_MONEDA_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
    Unload Me
End If
If KeyCode = 13 Then
    TXT_NTARJETA(Index).SetFocus
End If
If KeyCode = vbKeyDown Then
    If Index < 4 Then
        KeyCode = 0
        DTC_MONEDA(Index + 1).SetFocus
    Else
        KeyCode = 0
        TXT_NTARJETA(4).SetFocus
    End If
End If
If KeyCode = vbKeyUp Then
    KeyCode = 0
    If Index > 0 Then
        DTC_MONEDA(Index - 1).SetFocus
    Else
        DTC_TARJETA(0).SetFocus
    End If
End If
End Sub

Private Sub DTC_MONEDA_LostFocus(Index As Integer)
DTC_MONEDA(Index).BackColor = vbWhite
Call calculavuelto
End Sub

Private Sub DTC_TARJETA_GotFocus(Index As Integer)
DTC_TARJETA(Index).BackColor = vbCyan
If DTC_MONEDA(Index).BoundText = "" Then
    DTC_MONEDA(Index).BoundText = gstr_monedavuelto
End If
End Sub

Private Sub DTC_TARJETA_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
    Unload Me
End If

If KeyCode = 13 Then
    DTC_MONEDA(Index).SetFocus
End If
If KeyCode = vbKeyDown Then
    If Index < 4 Then
        KeyCode = 0
        DTC_TARJETA(Index + 1).SetFocus
    Else
        KeyCode = 0
        DTC_MONEDA(4).SetFocus
    End If
End If
If KeyCode = vbKeyUp Then
    KeyCode = 0
    If Index > 0 Then
        DTC_TARJETA(Index - 1).SetFocus
    Else
        txt_edolares.SetFocus
    End If
End If

End Sub

Private Sub DTC_TARJETA_LostFocus(Index As Integer)
DTC_TARJETA(Index).BackColor = vbWhite
End Sub

Private Sub Form_Activate()
If Not pbln_inicio Then
    If gstr_monedavuelto = GstrCodMonedaBase Then
        txt_esoles.SetFocus
    Else
        txt_edolares.SetFocus
    End If
    
    If GstrMonedaLimiteCredito = GstrCodMonedaBase Then 'convertir moneda extranjera a nacional
        gDBL_montoventaPEN = Val(LBL_MONTOT.Caption)
        gDBL_montoventaUSD = mobj_cventasgen.ConvertirMoneda(gDBL_montoventaPEN, GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
    Else
        gDBL_montoventaUSD = Val(LBL_MONTOT.Caption)
        gDBL_montoventaPEN = mobj_cventasgen.ConvertirMoneda(gDBL_montoventaUSD, GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
    End If
    pbln_inicio = True
    
End If
End Sub

Private Sub Form_Load()
Dim I As Integer
Set mobj_cventasgen = New DB_OP_FACTURACION.C_VENTASGENERAL
For I = 0 To 4
    ctrl_monto(I).Decimales = GintDecPrecio
    ctrl_monto(I).Enteros = 10
    ctrl_monto(I).PermitirNegativos = False
    ctrl_monto(I).Text = "0"
    Call CargaDataCombo(DTC_TARJETA(I), mobj_cventasgen.ListartarjetaAyuda, "CARDid", "descr")
   Call CargaDataCombo(DTC_MONEDA(I), mobj_cventasgen.ListarmonedaAyuda, "CURYID", "descr")
Next

txt_esoles.Enteros = 10
txt_esoles.PermitirNegativos = False
txt_esoles.Decimales = GintDecPrecio
txt_esoles.Text = 0
txt_edolares.Enteros = 10
txt_edolares.PermitirNegativos = False
txt_edolares.Decimales = GintDecPrecio
txt_edolares.Text = 0

gdou_tipocambio = Val(txt_tc.Text)
gstr_monedavuelto = GstrMonedaLimiteCredito

ppen.Enabled = False
ppen.Enteros = 10
ppen.Decimales = GintDecPrecio

pusd.Enabled = False
pusd.Enteros = 10
pusd.Decimales = GintDecPrecio

lbln_cambio = False
pbln_inicio = False

Me.Top = 350
Me.Left = 650
End Sub

Private Sub txt_edolares_GotFocus()
txt_edolares.BackColor = vbCyan
End Sub

Private Sub txt_edolares_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
    txt_esoles.SetFocus
End If

If KeyCode = vbKeyDown Then
    Call calculavuelto
    If gDBL_montopagadobase >= gDBL_montoventaPEN Then
        CMD_ACEPTAR.SetFocus
    Else
        DTC_TARJETA(0).SetFocus
    End If
End If

End Sub

Private Sub txt_edolares_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Call calculavuelto
    If gDBL_montopagadobase >= gDBL_montoventaPEN Then
        CMD_ACEPTAR.SetFocus
    Else
        DTC_TARJETA(0).SetFocus
    End If
End If
End Sub

Private Sub txt_edolares_LostFocus()
txt_edolares.BackColor = vbWhite
Call calculavuelto
End Sub

Private Sub txt_esoles_GotFocus()
txt_esoles.BackColor = vbCyan
End Sub

Private Sub txt_esoles_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
    'Call calculavuelto
    If gDBL_montopagadobase >= gDBL_montoventaPEN Then
        CMD_ACEPTAR.SetFocus
    Else
        txt_edolares.SetFocus
    End If
End If
End Sub

Private Sub txt_esoles_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Call calculavuelto
    If gDBL_montopagadobase >= gDBL_montoventaPEN Then
        CMD_ACEPTAR.SetFocus
    Else
        txt_edolares.SetFocus
    End If
End If
End Sub

Private Sub txt_esoles_LostFocus()
txt_esoles.BackColor = vbWhite
Call calculavuelto
'Call CALCULARESTOUSD
End Sub
Sub CALCULARESTOUSD()
Dim LUSD As Double
Dim LPEN As Double

If gstr_monedavuelto = GstrCodMonedaBase Then 'convertir moneda extranjera a nacional
        LPEN = gDBL_montoventaPEN - Val(txt_esoles.Text)
        LUSD = mobj_cventasgen.ConvertirMoneda(LPEN, GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
        txt_edolares.Text = Str(LUSD)
    Else
    
End If
Call BORRATARJETA(0)
End Sub
Sub BORRATARJETA(ByVal inicio As Integer)
For inicio = 0 To 4
    ctrl_monto(inicio).Text = "0"
Next
End Sub
Sub calculavuelto()
Dim I As Integer

gDBL_montopagadobase = 0
gDBL_montopagadoext = 0
gDBL_vueltopen = 0
gDBL_vueltousd = 0
ldbl_pagopen = Val(txt_esoles.Text)
ldbl_pagousd = Val(txt_edolares.Text)
If ldbl_pagopen + ldbl_pagousd > 0 Then
    f_ventascstore.GINT_TIPOPAGO = 1
End If

For I = 0 To 4
    If Not DTC_MONEDA(I).BoundText = Empty Then
        If Val(ctrl_monto(I).Text) > 0 Then
            If f_ventascstore.GINT_TIPOPAGO = 1 Then
                f_ventascstore.GINT_TIPOPAGO = 3
            Else
                f_ventascstore.GINT_TIPOPAGO = 2
            End If
        End If
        If DTC_MONEDA(I).BoundText = GstrCodMonedaBase Then
            ldbl_pagopen = ldbl_pagopen + Val(ctrl_monto(I).Text)
        Else
            ldbl_pagousd = ldbl_pagousd + Val(ctrl_monto(I).Text)
        End If
    End If
Next


If GstrMonedaLimiteCredito = GstrCodMonedaBase Then 'convertir moneda extranjera a nacional
    gDBL_montopagadobase = ldbl_pagopen + mobj_cventasgen.ConvertirMoneda(ldbl_pagousd, GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
    gDBL_montopagadoext = mobj_cventasgen.ConvertirMoneda(gDBL_montopagadobase, GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
Else
    gDBL_montopagadoext = ldbl_pagousd + mobj_cventasgen.ConvertirMoneda(ldbl_pagopen, GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
    gDBL_montopagadobase = mobj_cventasgen.ConvertirMoneda(gDBL_montopagadoext, GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
End If

'CALCULAR VUELTO SEGUN LA MONEDA
If gstr_monedavuelto = GstrCodMonedaBase Then 'convertir moneda extranjera a nacional
    If gDBL_montopagadobase >= gDBL_montoventaPEN Then  'hay vuelto en moneda nacional
         gDBL_vueltopen = Round(gDBL_montopagadobase - gDBL_montoventaPEN, GintDecPrecio)
         gDBL_vueltousd = mobj_cventasgen.ConvertirMoneda(gDBL_vueltopen, GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
         LBL_MONTOV.Caption = GFormatodeNumero(gDBL_vueltopen, GintDecPrecio)
         ppen.Text = "0"
         pusd.Text = "0"
    Else
        gDBL_vueltopen = 0
        gDBL_vueltousd = 0
        LBL_MONTOV.Caption = 0
        ppen.Text = gDBL_montoventaPEN - gDBL_montopagadobase
        pusd.Text = mobj_cventasgen.ConvertirMoneda(Val(ppen.Text), GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
    End If
Else
    If gDBL_montopagadoext >= gDBL_montoventaUSD Then  'hay vuelto en moneda extrajera
         gDBL_vueltousd = Round(gDBL_montopagadoext - gDBL_montoventaUSD, GintDecPrecio)
         gDBL_vueltopen = mobj_cventasgen.ConvertirMoneda(gDBL_vueltousd, GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
         LBL_MONTOV.Caption = GFormatodeNumero(gDBL_vueltousd, GintDecPrecio)
         ppen.Text = "0"
         pusd.Text = "0"
    Else
        gDBL_vueltopen = 0
        gDBL_vueltousd = 0
        LBL_MONTOV.Caption = 0
        pusd.Text = gDBL_montoventaUSD - gDBL_montopagadoext
        ppen.Text = mobj_cventasgen.ConvertirMoneda(Val(pusd.Text), GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipoCambioVentas, GintDecPrecio)
    End If
End If

End Sub

Function validar_tarjetas() As Boolean
'Dim lint_lin As Integer

'lint_lin = 1
'rs_tarjetas.MoveFirst
'Do While Not rs_tarjetas.EOF
'    If rs_tarjetas!curyid = "" Then
'        MsgBox "Debe Ingresar Moneda en la linea " + lint_lin, vbExclamation, "Falta Informacion"
'        validar_tarjetas = False
'        Exit Sub
'    End If
'
'    If rs_tarjetas!CARDID = "" Then
'        MsgBox "Debe Ingresar Tipo en la linea " + lint_lin, vbExclamation, "Falta Informacion"
'        validar_tarjetas = False
'        Exit Sub
'    End If
'
'    lint_lin = lint_lin + 1
'    rs_tarjetas.MoveNext
'Loop

End Function
Private Sub TXT_NTARJETA_GotFocus(Index As Integer)
TXT_NTARJETA(Index).BackColor = vbCyan
End Sub
Private Sub TXT_NTARJETA_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
        ctrl_monto(Index).SetFocus
End If
If KeyCode = vbKeyDown Then
    If Index < 4 Then
        TXT_NTARJETA(Index + 1).SetFocus
    Else
        ctrl_monto(4).SetFocus
    End If
End If
If KeyCode = vbKeyUp Then
    If Index > 0 Then
        TXT_NTARJETA(Index - 1).SetFocus
    Else
        DTC_MONEDA(0).SetFocus
    End If
End If
End Sub
Private Sub TXT_NTARJETA_LostFocus(Index As Integer)
TXT_NTARJETA(Index).BackColor = vbWhite
End Sub


Function grabartarjetas() As Boolean

Dim strCARDID As String
Dim strNBRCARD As String
Dim strcuryid As String
Dim ldbl_montocard As Double
Dim I As Integer

For I = 0 To 4
    If Val(ctrl_monto(I).Text) > 0 Then
        If DTC_TARJETA(I).Text = Empty Then   ' no hay tarjeta
            MsgBox "Debe Seleccionar Tarjeta en la Linea " + Str(I + 1), vbExclamation, "Falta Informacion"
            DTC_TARJETA(I).SetFocus
            grabartarjetas = False
            Exit Function
        End If
        
        If DTC_MONEDA(I).Text = Empty Then   ' no hay moneda
            MsgBox "Debe Seleccionar una Moneda  en la Linea " + Str(I + 1), vbExclamation, "Falta Informacion"
            DTC_MONEDA(I).SetFocus
            grabartarjetas = False
            Exit Function
        End If
        If TXT_NTARJETA(I) = Empty Then  ' no hay No.tarjeta
            MsgBox "Debe Ingresar No. de Tarjeta en la Linea " + Str(I + 1), vbExclamation, "Falta Informacion"
            TXT_NTARJETA(I).SetFocus
            grabartarjetas = False
            Exit Function
        End If
    Else
        DTC_TARJETA(I).Text = ""
        DTC_MONEDA(I).Text = ""
        TXT_NTARJETA(I).Text = ""
    End If
Next

For I = 0 To 4
    If Val(ctrl_monto(I).Text) > 0 Then
        ldbl_montocard = Val(ctrl_monto(I).Text)
        If DTC_MONEDA(I).BoundText = GstrCodMonedaBase Then
            TOTCARDpen = ldbl_montocard
            TOTCARDUSD = mobj_cventasgen.ConvertirMoneda(TOTCARDpen, GstrCodMonedaBase, GstrMonedaExtranjera, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecPrecio)
        Else
            TOTCARDUSD = ldbl_montocard
            TOTCARDpen = mobj_cventasgen.ConvertirMoneda(TOTCARDUSD, GstrMonedaExtranjera, GstrCodMonedaBase, GDatFechaProcesoVentas, GstrTipodeCambio, GintDecPrecio)
        End If
        strcuryid = DTC_MONEDA(I).BoundText
        strCARDID = DTC_TARJETA(I).BoundText
        strNBRCARD = TXT_NTARJETA(I).Text
        mobj_cventasgen.grabarsalescard pdbl_correlativo, GstrSiteProce, strCARDID, strNBRCARD, strcuryid, TOTCARDpen, TOTCARDUSD
    End If
Next
grabartarjetas = True
End Function

