VERSION 5.00
Object = "{90F3D7B3-92E7-44BA-B444-6A8E2A3BC375}#1.0#0"; "actskin4.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form f_ingresovalesadelantoPlaya 
   Caption         =   "Ingreso de Vales por Compra"
   ClientHeight    =   4725
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6810
   LinkTopic       =   "Form1"
   ScaleHeight     =   4725
   ScaleWidth      =   6810
   StartUpPosition =   3  'Windows Default
   Begin ACTIVESKINLibCtl.SkinLabel txttotvalesacum 
      Height          =   615
      Left            =   4800
      OleObjectBlob   =   "f_ingresovalesadelantoPlaya.frx":0000
      TabIndex        =   14
      Top             =   3840
      Width           =   1335
   End
   Begin ACTIVESKINLibCtl.Skin sknIngresoVales 
      Left            =   3840
      OleObjectBlob   =   "f_ingresovalesadelantoPlaya.frx":0066
      Top             =   3960
   End
   Begin VB.TextBox txt_esoles 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   3240
      MaxLength       =   9
      TabIndex        =   1
      Top             =   1200
      Width           =   1815
   End
   Begin VB.Frame Frame1 
      Height          =   15
      Left            =   120
      TabIndex        =   5
      Top             =   165
      Visible         =   0   'False
      Width           =   6045
      Begin VB.TextBox txtkilometraje 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   420
         Left            =   1800
         MaxLength       =   10
         TabIndex        =   7
         Top             =   840
         Visible         =   0   'False
         Width           =   2175
      End
      Begin VB.TextBox txtplaca 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   420
         Left            =   1800
         MaxLength       =   12
         TabIndex        =   6
         Top             =   360
         Visible         =   0   'False
         Width           =   2175
      End
      Begin VB.Label Label3 
         Caption         =   "Kilometraje"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   480
         TabIndex        =   9
         Top             =   840
         Visible         =   0   'False
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "Placa"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   480
         TabIndex        =   8
         Top             =   360
         Visible         =   0   'False
         Width           =   675
      End
   End
   Begin VB.CommandButton cmdcancelar 
      Caption         =   "Cancelar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   240
      Picture         =   "f_ingresovalesadelantoPlaya.frx":029A
      TabIndex        =   3
      Top             =   3840
      Width           =   1455
   End
   Begin VB.CommandButton cmdaceptarprodadi 
      Caption         =   "Aceptar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1800
      Picture         =   "f_ingresovalesadelantoPlaya.frx":05A4
      TabIndex        =   4
      Tag             =   "R ASDASD"
      Top             =   3840
      Width           =   1455
   End
   Begin VB.TextBox txtnrovale 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   240
      MaxLength       =   9
      TabIndex        =   0
      Top             =   1200
      Width           =   2385
   End
   Begin VB.CommandButton cmdregistrarvales 
      Caption         =   "Registrar Vale >>"
      Height          =   465
      Left            =   5160
      TabIndex        =   2
      Top             =   1200
      Width           =   1455
   End
   Begin MSDataGridLib.DataGrid DbVales 
      Height          =   1785
      Left            =   210
      TabIndex        =   12
      Top             =   1800
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   3149
      _Version        =   393216
      BackColor       =   -2147483624
      HeadLines       =   1
      RowHeight       =   15
      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            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   3
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            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
      BeginProperty Column02 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
         BeginProperty Column02 
         EndProperty
      EndProperty
   End
   Begin ACTIVESKINLibCtl.SkinLabel SkinLabel2 
      Height          =   375
      Left            =   240
      OleObjectBlob   =   "f_ingresovalesadelantoPlaya.frx":08AE
      TabIndex        =   15
      Top             =   420
      Width           =   3015
   End
   Begin ACTIVESKINLibCtl.SkinLabel txttotvales 
      Height          =   375
      Left            =   4200
      OleObjectBlob   =   "f_ingresovalesadelantoPlaya.frx":0932
      TabIndex        =   16
      Top             =   360
      Width           =   2295
   End
   Begin ACTIVESKINLibCtl.SkinLabel Label7 
      Height          =   375
      Left            =   3480
      OleObjectBlob   =   "f_ingresovalesadelantoPlaya.frx":0990
      TabIndex        =   17
      Top             =   360
      Width           =   495
   End
   Begin VB.Label Label5 
      Caption         =   "Monto"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3240
      TabIndex        =   13
      Top             =   840
      Width           =   1455
   End
   Begin VB.Label Label2 
      Caption         =   "Nro de Vale"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   210
      TabIndex        =   11
      Top             =   840
      Width           =   1455
   End
   Begin VB.Label lblcorrelativo 
      Height          =   375
      Left            =   240
      TabIndex        =   10
      Top             =   4080
      Visible         =   0   'False
      Width           =   1545
   End
   Begin VB.Image Imgdetalle 
      Height          =   480
      Left            =   2640
      Picture         =   "f_ingresovalesadelantoPlaya.frx":09F4
      Top             =   1200
      Visible         =   0   'False
      Width           =   480
   End
End
Attribute VB_Name = "f_ingresovalesadelantoPlaya"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MrsTemVales As ADODB.Recordset
Private MobjVentascombustible As DB_OP_FACTURACION.C_VENTASPLAYA
Public GBlnUsuarioCreditoOK As Boolean
Public MrslistadodeProductos As ADODB.Recordset


Public MrsListadoArticulos As ADODB.Recordset
Public Gintayuda As Integer
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As Variant
Public GrecibeColumnaOpcional2 As Variant
Public GrecibeColumnaOpcional3 As Variant
 

Public GintStatus As Integer
Public GintBloqueaVentas As Integer
Public GintEsCombustible As Integer
Public GintVentCombenAutomatic As Integer
Private Sub cmdaceptarprodadi_Click()
   'Validación de Monto Total de Vale Acumulado
   
   If CDbl(txttotvalesacum.Caption) <> CDbl(txttotvales.Caption) Then
      MsgBox "El Total Acumulado no puede ser diferente al Monto Total de Vales", vbDefaultButton1 + vbExclamation, "Advertencia"
      txtnrovale.SetFocus
      Exit Sub
   End If
      
   'Validación de Factura

'   If Trim(txtdocumento.Text) = Empty Then
'      MsgBox "Debe Ingresar el Nº Factura", vbDefaultButton1 + vbExclamation, "Advertencia"
'      txtdocumento.SetFocus
'      Exit Sub
'   End If
   
   'Validacion de la Placa
   
'   If txtplaca.Enabled = True Then
'     If MobjVentascombustible.VerificarPlacadeCliente(FDatosClientCombust.txtcodcliente, txtplaca.Text) = False Then
'        MsgBox "Número de Placa no existe para este Cliente", vbDefaultButton1 + vbExclamation, "Advertencia"
'        txtplaca.SetFocus
'        Exit Sub
'     Else
'      '  f_ventascstore.GSTRPLACA = txtplaca.Text
'     End If
'   End If
   
   'Validacion del Numero de Vale
   
   If FDatosClientCombust.MintTipoCliente <> 0 Then ' EL CLIENTE NO ES CONTADO
        If MrsTemVales.RecordCount <= 0 Then  '' Or IsNull(DbVales.Bookmark) Then
           MsgBox "Debe Ingresar Número de Vale", vbDefaultButton1 + vbExclamation, "Advertencia"
           txtnrovale.SetFocus
           Exit Sub
        End If
   End If

   'Validacion del Kilometraje

'   If txtplaca.Enabled = True Then
'      If Trim(txtkilometraje.Text) = Empty Then
'         If FDatosClientCombust.MintTipoCliente <> 0 Then
'            MsgBox "Ingrese Kilometraje", vbDefaultButton1 + vbExclamation, "Advertencia"
'            txtkilometraje.SetFocus
'            Exit Sub
'         End If
'      End If
'   End If

'    FDatosClientCombust.LDblTOTRETURNEDPEN = 0
'    FDatosClientCombust.LDblTOTRETURNEDUSD = 0
    
  ' f_ventascstore.LDblTOTCASHPEN = LdblTotalBase
  ' f_ventascstore.LDblTOTCASHUSD = LdblTotalExt
      
    gbln_ventaefectuada = True
    
    If GblnVienedePendientes = False Then
       FDatosClientCombust.GrabarDatosenTemporal
    Else  'Actualizar
       FDatosClientCombust.ActualizarDatosenTemporal
       FTranspendientes.GactualizarPendientes
    End If
    
    FDatosClientCombust.GBlnUsuarioEfectivoOK = True
    
    Unload Me
End Sub

Private Sub CmdBusPro_Click()
     
           
     'If KeyCode = vbKeyF2 Then
       Dim LArrayBusqueda(1 To 4, 1 To 3) As Variant
              
       Gintayuda = 2
       
       LArrayBusqueda(1, 1) = "Codigo"
       LArrayBusqueda(1, 2) = "Código"
       LArrayBusqueda(1, 3) = 1200
       LArrayBusqueda(2, 1) = "Descripcion"
       LArrayBusqueda(2, 2) = "Descripción"
       LArrayBusqueda(2, 3) = 3500
       LArrayBusqueda(3, 1) = "PConvert"
       LArrayBusqueda(3, 2) = "Precio_Venta"
       LArrayBusqueda(3, 3) = 1200
       LArrayBusqueda(4, 1) = "StockActual"
       LArrayBusqueda(4, 2) = "Stock"
       LArrayBusqueda(4, 3) = 1200
       
       GrecibeUbicacion = 0
       GrecibeColumnaID = Empty
       GrecibeColumnaOpcional = Empty
       
       ' Inicializar Variables del Articulo
       GintStatus = 0
       GintBloqueaVentas = 0
       GintEsCombustible = 0
       GintVentCombenAutomatic = 0
  
       FBusquedaCombus.GObtenerRegistros MrsListadoArticulos, LArrayBusqueda, 4, 2, 7500
       '@ Jorge: Modificada la presentacion
       FBusquedaCombus.DBListar.BackColor = RGB(0, 65, 128)
       FBusquedaCombus.DBListar.ForeColor = RGB(255, 255, 255)
       FBusquedaCombus.Show vbModal
       If GrecibeUbicacion <> 0 Then
           'Verificar si Artículo está con Status Activo
           
           If GintStatus = 1 Then  ' Está Activo
             If GintBloqueaVentas = 1 Then
                MsgBox "Artículo Bloqueado para Venta", vbDefaultButton1 + vbExclamation, "Advertencia"
                Exit Sub
             End If

             If GIntVentaAutoCombust = 1 Then ' La Venta está en Automática
                ' No se pueden Seleccionar Combustibles
                If GintEsCombustible = 1 Then
                   If GintVentCombenAutomatic = 0 Then
                      MsgBox "No se puede Despachar Combustible en Venta Automática", vbDefaultButton1 + vbExclamation, "Advertencia"
                      Exit Sub
                   End If
                End If
             End If
           Else
              MsgBox "Artículo Desactivado, No se puede Vender ", vbDefaultButton1 + vbExclamation, "Advertencia"
              Exit Sub
           End If
           
           '*****************************************************************
           '''TxtProductoId.Text = GrecibeColumnaID
           '''DtcProducto.Text = GrecibeColumnaOpcional
    
           txtnrovale.SetFocus
       End If
    'End If

End Sub




Private Sub cmdCancelar_Click()
  If MsgBox("Los Cambios realizados se perderán,Desea Continuar", vbYesNo + vbQuestion, "Advertencia") = vbYes Then
    MobjVentascombustible.EliminarAdelanto_Temporal 1, lblcorrelativo.Caption, 0
    gbln_ventaefectuada = False
    txttotvalesacum.Caption = GFormatodeNumero(0, 2)
    RefrescarGrilla
    FDatosClientCombust.GBlnUsuarioEfectivoOK = False
    Unload Me
  End If
End Sub
Sub RefrescarGrilla()
  ' Set MrsTemVales = MobjVentascombustible.ObtenerValesAdeTemp(lblcorrelativo.Caption)
   Set MrsTemVales = MobjVentascombustible.ObtenerValesAdeTemp(lblcorrelativo.Caption)
   Set DbVales.DataSource = MrsTemVales
   
   If MrsTemVales.EOF Then
      txttotvalesacum.Caption = GFormatodeNumero("0", 2)
   Else
      txttotvalesacum.Caption = GFormatodeNumero("0", 2)
      MrsTemVales.MoveFirst
      Do While Not MrsTemVales.EOF
         txttotvalesacum.Caption = GFormatodeNumero(CDbl(txttotvalesacum.Caption) + CDbl(MrsTemVales.Fields("Monto_de_Orden_C")), 2)
         MrsTemVales.MoveNext
      Loop
   End If
   DbVales.Caption = "Registrar Vales - [F3] Eliminar "
   DbVales.Columns(0).Visible = False
   DbVales.Columns(1).Width = 1200
   DbVales.Columns(2).Alignment = dbgRight
   DbVales.Columns(2).Width = 1200
   ''DbVales.Columns(3).Width = 1200
   ''DbVales.Columns(4).Width = 2000
   DbVales.Refresh
End Sub

Private Sub cmdregistrarvales_Click()
'    If MobjVentascombustible.Verificar_ExisteVale(CStr(f_ventascstore.TXT_IDCLIENTE.Text), CDbl(txtnrovale.Text)) = True Then
'       MsgBox "El Vale ya a sido registrado anteriormente", vbDefaultButton1 + vbExclamation, "Advertencia"
'       txtnrovale.SetFocus
'       Exit Sub
'    End If
    
     If Trim(txtnrovale.Text) = Empty Then
        MsgBox "Ingrese Número de Vale", vbDefaultButton1 + vbExclamation, "Advertencia"
        txtnrovale.SetFocus
        Exit Sub
     Else
                Dim RsSaldo As ADODB.Recordset
                Set RsSaldo = MobjVentascombustible.VerificarOrdenDdeCliente(FDatosClientCombust.txtcodcliente, txtnrovale.Text)
                If Not RsSaldo.EOF = True Then
                   If CDbl(Me.txttotvalesacum.Caption) > CDbl(Me.txt_esoles.Text) Then
                      MsgBox "Monto excede los " & Str(Me.txt_esoles.Text), vbDefaultButton1 + vbExclamation, "Mensaje"
                       Exit Sub
                   End If
                Else
                  MsgBox "Número de Vale no existe ", vbDefaultButton1 + vbExclamation, "Advertencia"
                  txtnrovale.Text = Empty
                  txtnrovale.SetFocus
                  Exit Sub
                End If
    End If
    
    If Len(Trim(txt_esoles.Text)) > 0 Or Len(Trim(txt_esoles.Text)) > 0 Then
       If (CDbl(txttotvalesacum.Caption) + CDbl(txt_esoles.Text)) > CDbl(txttotvales.Caption) Then
          MsgBox "El Monto del Nùmero de Vale sobrepasa el Monto Total a Pagar", vbDefaultButton1 + vbExclamation, "Advertencia"
          txt_esoles.Text = Empty
          txtnrovale.SetFocus
          Exit Sub
       Else
          MobjVentascombustible.GrabarValeA_Temporal CDbl(lblcorrelativo.Caption), CStr(FDatosClientCombust.txtcodcliente.Text), CDbl(txtnrovale.Text), CDbl(txt_esoles.Text)
         ' MobjVentascombustible.GrabarValeA_Temporal Val(lblcorrelativo.Caption), CStr(f_ventascstore.TXT_IDCLIENTE.Text), CDbl(txtnrovale.Text), CStr(Trim(f_ventascstore.dtc_tdocumento.BoundText)), CDbl(txtdocumento.Text), CDbl(txt_esoles.Text), CStr(Trim(txtcodigo.Text)), CStr(Trim(TxtDescripcion.Text))
          txtnrovale.Text = Empty
          txttotvalesacum.Caption = GFormatodeNumero(CDbl(txttotvalesacum.Caption) + CDbl(txt_esoles.Text), 2)
          txt_esoles.Text = Empty
          RefrescarGrilla
          txtnrovale.SetFocus
       End If
    End If
End Sub


Private Sub DbVales_GotFocus()
  Imgdetalle.Visible = True
End Sub

Private Sub DbVales_KeyUp(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyF3 Then
     If Not IsNull(DbVales.Bookmark) Then
      If MsgBox("¿ Seguro que desea Eliminar el Vale :" + Trim(DbVales.Columns(1).Text) + " ?", vbYesNo + vbQuestion, "Advertencia") = vbYes Then
          MobjVentascombustible.EliminarAdelanto_Temporal 0, lblcorrelativo.Caption, CDbl(DbVales.Columns(1).Text)
          txttotvalesacum.Caption = GFormatodeNumero(CDbl(txttotvalesacum.Caption) - CDbl(DbVales.Columns(2).Value), 2)
          RefrescarGrilla
      End If
     End If
  End If
End Sub

Private Sub DbVales_LostFocus()
  Imgdetalle.Visible = False
End Sub

Private Sub DtcProducto_Click(Area As Integer)
''TxtProductoId.Text = DtcProducto.BoundText
End Sub

Private Sub DtcProducto_DblClick(Area As Integer)
''txtnrovale.SetFocus
End Sub

Private Sub Form_Activate()
    txtkilometraje.MaxLength = 10
    RefrescarGrilla
    txtnrovale.SetFocus
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
   If KeyCode = 27 Then
      If MsgBox("Los Cambios realizados se perderán,Desea Continuar", vbYesNo + vbQuestion, "Advertencia") = vbYes Then
         MobjVentascombustible.EliminarAdelanto_Temporal 1, lblcorrelativo.Caption, 0
         Unload Me
      End If
   End If
End Sub

Private Sub Form_Load()
    ''sknIngresoVales.LoadSkin (App.Path & "\Skins\B-Studio.skn")
    ''sknIngresoVales.ApplySkin (Me.hWnd)
    
    Me.KeyPreview = True
          
    Me.Top = (Screen.Width - Me.Width) / 2
    Me.Left = (Screen.Height - Me.Height) / 2
           
    'Instanciar Objeto
    Set MobjVentascombustible = New DB_OP_FACTURACION.C_VENTASPLAYA
   ' txtplaca.Enabled = f_ventascstore.GblnconPlacas
    'txtkilometraje.Enabled = f_ventascstore.GblnconPlacas
         
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set MobjVentascombustible = Nothing
End Sub

Private Sub txt_esoles_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyDown Then
        DbVales.SetFocus
    End If
End Sub


Private Sub txt_esoles_KeyPress(KeyAscii As Integer)
 KeyAscii = GBloqueaCaracter(KeyAscii)
 
 If KeyAscii = 13 Then
'''    cmdregistrarvales.SetFocus
''' End If
    If Val(txt_esoles.Text) = 0 Then
        MsgBox "Ingrese Monto mayor a Cero", vbCritical
        txt_esoles.SetFocus
        Exit Sub
    End If
    
  If Not IsNumeric(Chr(KeyAscii)) Then
    If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
      If KeyAscii = 13 Then

         ' Inicio de Validacion

            'Verificar si Numero de Vale no está repetido para ese cliente
             If Trim(txtnrovale.Text) = Empty Then
                MsgBox "Ingrese Número de Vale", vbDefaultButton1 + vbExclamation, "Advertencia"
                txtnrovale.SetFocus
                Exit Sub
              Else
                    'MobjVentascombustible
                    Dim RsSaldo As ADODB.Recordset
                  Set RsSaldo = MobjVentascombustible.VerificarOrdenDdeCliente(FDatosClientCombust.txtcodcliente, txtnrovale.Text)
                  If Not RsSaldo.EOF = True Then
                  If RsSaldo!saldoBONUS > 0 Then  ' Aún tiene Saldo


                    If Val(FDatosClientCombust.ctnmontofactu.Text) > Val(RsSaldo!saldoBONUS) Then
                       MsgBox "Monto excede los " & Str(RsSaldo!saldoBONUS) & " Soles disponibles a facturar ", vbDefaultButton1 + vbExclamation, "Mensaje"
                       Exit Sub
                    End If
                    
                    If Val(Me.txt_esoles.Text) > Val(RsSaldo!saldoBONUS) Then
                       MsgBox "Monto excede los " & Str(RsSaldo!saldoBONUS) & " Soles disponibles a facturar ", vbDefaultButton1 + vbExclamation, "Mensaje"
                       Exit Sub
                    End If
                    Me.cmdregistrarvales.SetFocus
                 Else
                    MsgBox "Cliente no tiene Saldo Disponible", vbDefaultButton1 + vbExclamation, "Mensaje"
                    Exit Sub
                 End If
                    
                Else
                  MsgBox "Número de Orden Compra no existe ", vbDefaultButton1 + vbExclamation, "Advertencia"
                  txtnrovale.Text = Empty
                  txtnrovale.SetFocus
                  Exit Sub
                End If
             End If

         ' Fin de Validacion

       End If
    Else
       KeyAscii = 0
    End If
  End If
  End If
End Sub


Private Sub txtkilometraje_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
    txtplaca.SetFocus
End If
If KeyCode = vbKeyDown And Len(Trim(txtkilometraje.Text)) > 0 Then
    txtnrovale.SetFocus
End If
End Sub

Private Sub txtkilometraje_KeyPress(KeyAscii As Integer)
'   KeyAscii = GBloqueaCaracter(KeyAscii)
'
'   If Not IsNumeric(Chr(KeyAscii)) Then
'     If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
'       If KeyAscii = 13 Then
'          ' Inicio de Validacion
'          If txtplaca.Enabled = True Then
'            If Trim(txtkilometraje.Text) = Empty Then
'              If f_ventascstore.MintTipoCliente <> 0 Then ' Si el cliente no es contado
'                 MsgBox "Ingrese Kilometraje", vbDefaultButton1 + vbExclamation, "Advertencia"
'                 Exit Sub
'              Else
'                 cmdaceptarprodadi.SetFocus
'                 Exit Sub
'              End If
'            End If
'            txtnrovale.SetFocus
'          End If
'          ' Fin de Validacion
'        End If
'     Else
'        KeyAscii = 0
'     End If
'   End If
End Sub


Private Sub txtnrovale_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
   cmdregistrarvales.SetFocus
End If
End Sub

Private Sub txtnrovale_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueanonumeros(KeyAscii)
 
  If KeyAscii = 13 Then
'''    cmdregistrarvales.SetFocus
''' End If
    If Trim(txtnrovale.Text) = Empty Then
       MsgBox "Ingrese Número de Vale", vbCritical
       txtnrovale.SetFocus
       Exit Sub
    End If

  If Not IsNumeric(Chr(KeyAscii)) Then
    If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
       If KeyAscii = 13 Then
            'Inicio de Validacion
            'Verificar si Numero de Vale no está repetido para ese cliente
             If Trim(txtnrovale.Text) = Empty Then
                MsgBox "Ingrese Número de Vale", vbDefaultButton1 + vbExclamation, "Advertencia"
                txtnrovale.SetFocus
                Exit Sub
             Else
                'MobjVentascombustible
                If MobjVentascombustible.VerificarOrdenCdeCliente(Trim(FDatosClientCombust.txtcodcliente.Text), txtnrovale.Text) = False Then
                   If Not MobjVentascombustible.VerificarOrdenDdeCliente(Trim(FDatosClientCombust.txtcodcliente.Text), txtnrovale.Text).EOF Then
                      txt_esoles.Text = GFormatodeNumero(MobjVentascombustible.VerificarOrdenDdeCliente(Trim(FDatosClientCombust.txtcodcliente.Text), txtnrovale.Text).Fields("MONTOBONUS").Value, 2)
                      cmdregistrarvales.SetFocus
                   Else
                      MsgBox "Número de Vale no existe", vbDefaultButton1 + vbExclamation, "Advertencia"
                      txtnrovale.Text = Empty
                      txt_esoles.Text = Empty
                      txtnrovale.SetFocus
                      Exit Sub
                   End If
                Else
                   MsgBox "Número de Vale ya fue utilizado", vbDefaultButton1 + vbExclamation, "Advertencia"
                   txtnrovale.Text = Empty
                   txt_esoles.Text = Empty
                   txtnrovale.SetFocus
                   Exit Sub
                End If
             End If
         ' Fin de Validacion
       End If
    Else
       KeyAscii = 0
    End If
  End If
  End If
End Sub
Private Sub txtplaca_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
    txtkilometraje.SetFocus
End If
End Sub

Private Sub txtplaca_KeyPress(KeyAscii As Integer)
'   KeyAscii = GBloqueaCaracter(KeyAscii)
'   If KeyAscii = 13 Or KeyAscii = vbKeyDown Then
'      'Verificar si la Placa Existe para el Cliente
'      If MobjVentascombustible.VerificarPlacadeCliente(f_ventascstore.TXT_IDCLIENTE.Text, txtplaca.Text) = True Then
'          txtkilometraje.SetFocus
'      Else
'          MsgBox "Número de Placa no esiste para este Cliente", vbDefaultButton1 + vbExclamation, "Advertencia"
'          Exit Sub
'      End If
'   End If
   
End Sub

Private Sub CargaProducto()
''Set MrslistadodeProductos = New ADODB.Recordset
'' Set DtcProducto.DataSource = MrsListadoArticulos
''   ' DtcProducto.DataField = "DESCR"
''    Set DtcProducto.RowSource = MrsListadoArticulos
''    DtcProducto.ListField = "Descripcion"
''    DtcProducto.BoundColumn = "Codigo"
''    If Not MrsListadoArticulos.EOF Then
''      DtcProducto.BoundText = MrsListadoArticulos.Fields("Descripcion")
''    End If

End Sub
