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_ingresovales 
   Caption         =   "Ingreso se Vales (Venta Credito)"
   ClientHeight    =   5025
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6270
   LinkTopic       =   "Form1"
   ScaleHeight     =   5025
   ScaleWidth      =   6270
   StartUpPosition =   3  'Windows Default
   Begin ACTIVESKINLibCtl.SkinLabel SkinLabel1 
      Height          =   255
      Left            =   90
      OleObjectBlob   =   "f_ingresovales.frx":0000
      TabIndex        =   12
      Top             =   1590
      Width           =   1455
   End
   Begin ACTIVESKINLibCtl.Skin sknIngresoVales 
      Left            =   5520
      OleObjectBlob   =   "f_ingresovales.frx":0074
      Top             =   4200
   End
   Begin VB.Frame Frame1 
      Height          =   1455
      Left            =   120
      TabIndex        =   0
      Top             =   45
      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        =   2
         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        =   1
         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          =   855
      Left            =   4440
      Picture         =   "f_ingresovales.frx":02A8
      TabIndex        =   7
      Top             =   2865
      Width           =   1695
   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          =   855
      Left            =   4440
      Picture         =   "f_ingresovales.frx":05B2
      TabIndex        =   6
      Tag             =   "R ASDASD"
      Top             =   1950
      Width           =   1695
   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          =   420
      Left            =   90
      MaxLength       =   9
      TabIndex        =   3
      Top             =   1950
      Width           =   2295
   End
   Begin VB.CommandButton cmdregistrarvales 
      Caption         =   "Registrar Vales >>"
      Height          =   465
      Left            =   2445
      TabIndex        =   4
      Top             =   1935
      Width           =   1860
   End
   Begin MSDataGridLib.DataGrid DbVales 
      Height          =   2250
      Left            =   90
      TabIndex        =   5
      Top             =   2565
      Width           =   4215
      _ExtentX        =   7435
      _ExtentY        =   3969
      _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     =   2
      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            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   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            =   90
      TabIndex        =   11
      Top             =   1530
      Visible         =   0   'False
      Width           =   1455
   End
   Begin VB.Label lblcorrelativo 
      Height          =   375
      Left            =   4635
      TabIndex        =   10
      Top             =   2025
      Visible         =   0   'False
      Width           =   1545
   End
   Begin VB.Image Imgdetalle 
      Height          =   480
      Left            =   3990
      Picture         =   "f_ingresovales.frx":08BC
      Top             =   3225
      Visible         =   0   'False
      Width           =   480
   End
End
Attribute VB_Name = "f_ingresovales"
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

Private Sub cmdaceptarprodadi_Click()
   
   'Validacion de la Placa
   
   If txtplaca.Enabled = True Then
     If MobjVentascombustible.VerificarPlacadeCliente(f_ventascstore.TXT_IDCLIENTE, 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 f_ventascstore.MintTipoCliente <> 0 Then ' EL CLIENTE NO ES CONTADO
        If MrsTemVales.EOF 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 f_ventascstore.MintTipoCliente <> 0 Then
            MsgBox "Ingrese Kilometraje", vbDefaultButton1 + vbExclamation, "Advertencia"
            txtkilometraje.SetFocus
            Exit Sub
         End If
      End If
   End If
    f_ventascstore.LDblTOTRETURNEDPEN = 0
    f_ventascstore.LDblTOTRETURNEDUSD = 0
    
  ' f_ventascstore.LDblTOTCASHPEN = LdblTotalBase
  ' f_ventascstore.LDblTOTCASHUSD = LdblTotalExt
      
    gbln_ventaefectuada = True
    Unload Me
  
End Sub
Private Sub cmdCancelar_Click()
  If MsgBox("Los Cambios realizados se perderán,Desea Continuar", vbYesNo + vbQuestion, "Advertencia") = vbYes Then
    MobjVentascombustible.EliminarVale_Temporal 1, lblcorrelativo.Caption, 0
    gbln_ventaefectuada = False
     Unload Me
  End If
End Sub
Sub RefrescarGrilla()
   Set MrsTemVales = MobjVentascombustible.ObtenerValesdeTemp(lblcorrelativo.Caption)
   Set DbVales.DataSource = MrsTemVales
   DbVales.Caption = "Registrar Vales - [F3] Eliminar "
   DbVales.Columns(0).Visible = False
   DbVales.Columns(1).Width = 3850
   DbVales.Columns(2).Visible = False
   DbVales.Refresh
End Sub

Private Sub cmdregistrarvales_Click()
If Len(Trim(txtnrovale.Text)) > 0 Then
    MobjVentascombustible.GrabarVale_Temporal Val(lblcorrelativo.Caption), CStr(f_ventascstore.TXT_IDCLIENTE.Text), CDbl(txtnrovale.Text), "NULL", 0, 0
    txtnrovale.Text = Empty
    RefrescarGrilla
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.EliminarVale_Temporal 0, lblcorrelativo.Caption, CDbl(DbVales.Columns(1).Text)
          RefrescarGrilla
      End If
     End If
  End If
End Sub

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

Private Sub Form_Activate()
    txtkilometraje.MaxLength = 10
    RefrescarGrilla
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.EliminarVale_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 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
    DbVales.SetFocus
End If

If KeyCode = vbKeyUp Then
    txtkilometraje.SetFocus
End If

End Sub

Private Sub txtnrovale_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
                              
            '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"
                cmdaceptarprodadi.SetFocus
                Exit Sub
              Else
                If MobjVentascombustible.VerificarValedeCliente(f_ventascstore.TXT_IDCLIENTE.Text, txtnrovale.Text) = False Then
                  'Hay que Insertarlo en el Temporal de OP_BONUS
                  
                   ' Hay que verificar que no este en el Temporal
                    If MobjVentascombustible.VerificarValesenTemp(lblcorrelativo.Caption, txtnrovale.Text) = False Then
                       cmdregistrarvales_Click
                    Else
                       MsgBox "Número de Vale ya fue Registrado", vbDefaultButton1 + vbExclamation, "Advertencia"
                       txtnrovale.Text = Empty
                       txtnrovale.SetFocus
                       Exit Sub
                    End If
                Else
                  MsgBox "Número de Vale ya fue registrado ", 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 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


