VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FIngresoVales 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Ingreso de Vales Internos (Consumo Interno)"
   ClientHeight    =   4470
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7590
   Icon            =   "FIngresodeVales.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   4470
   ScaleWidth      =   7590
   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            =   7680
      MaxLength       =   10
      TabIndex        =   13
      Text            =   "101"
      Top             =   240
      Width           =   615
   End
   Begin VB.TextBox txtnomconductor 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   240
      MaxLength       =   80
      TabIndex        =   1
      Top             =   1380
      Width           =   5535
   End
   Begin VB.CommandButton cmdregistrarvales 
      Caption         =   "Registrar >>"
      Height          =   465
      Left            =   4200
      TabIndex        =   2
      Top             =   585
      Width           =   1500
   End
   Begin MSDataGridLib.DataGrid DbVales 
      Height          =   2250
      Left            =   240
      TabIndex        =   5
      Top             =   1920
      Width           =   5535
      _ExtentX        =   9763
      _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.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            =   240
      MaxLength       =   10
      TabIndex        =   0
      Top             =   585
      Width           =   2175
   End
   Begin VB.CommandButton cmdaceptarprodadi 
      Caption         =   "Aceptar"
      Enabled         =   0   'False
      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            =   5880
      Picture         =   "FIngresodeVales.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   6
      Tag             =   "R ASDASD"
      Top             =   1920
      Width           =   1575
   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            =   5880
      Picture         =   "FIngresodeVales.frx":0614
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   3000
      Width           =   1575
   End
   Begin VB.Frame Frame1 
      Height          =   960
      Left            =   75
      TabIndex        =   3
      Top             =   4380
      Visible         =   0   'False
      Width           =   5505
      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            =   4800
         TabIndex        =   4
         Top             =   285
         Visible         =   0   'False
         Width           =   2175
      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            =   75
         TabIndex        =   10
         Top             =   255
         Width           =   1335
      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            =   3315
         TabIndex        =   9
         Top             =   315
         Visible         =   0   'False
         Width           =   1215
      End
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "Conductor"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   240
      TabIndex        =   12
      Top             =   1080
      Width           =   1110
   End
   Begin VB.Image Imgdetalle 
      Height          =   480
      Left            =   5880
      Picture         =   "FIngresodeVales.frx":091E
      Top             =   600
      Width           =   480
   End
   Begin VB.Label lblcorrelativo 
      Height          =   375
      Left            =   7320
      TabIndex        =   11
      Top             =   990
      Visible         =   0   'False
      Width           =   1545
   End
   Begin VB.Label lblDoc 
      AutoSize        =   -1  'True
      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          =   300
      Left            =   240
      TabIndex        =   8
      Top             =   285
      Width           =   645
   End
End
Attribute VB_Name = "FIngresoVales"
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

Private MrsTemVales As ADODB.Recordset
Private MobjVentascombustible As DB_OP_FACTURACION.C_VENTASPLAYA
Public GBlnUsuarioCreditoOK As Boolean
Public CORRELATIVO As Double
Public CODCLI      As String
Public NROVALE     As Double
Public TOTAL       As Double
Public PLACA       As String
Public CONDUCTOR   As String

Private Sub cmdaceptarprodadi_Click()
   'validar registro en el grid
   ''''''''''''''''''''''''''''
   'Si la Cara está Vacía se procede a emitir directamente sin grabar a temporal
      
   If Trim(FDatosClientCombust.txtcara.Text) = Empty Or GIntVentaAutoCombust = 0 Then
      If FDatosClientCombust.MrsGrilla.RecordCount < 1 Then
         MsgBox "No se ha Ingresado Ningún Producto", vbDefaultButton1 + vbExclamation, "Advertencia"
         Unload Me
         Exit Sub
      End If

      FDatosClientCombust.GStrNumeroPlaca = FIngresoVales.txtplaca.Text
      'FDatosClientCombust.GintNumeroVale = txtnrovale.Text
      If Trim(txtkilometraje.Text) <> Empty Then
         FDatosClientCombust.GdblKilometraje = txtkilometraje.Text
      Else
         FDatosClientCombust.GdblKilometraje = 0
      End If
      
      GBlnUsuarioCreditoOK = True
      FingresoCodVend.GIntdepantalla = 2
      FingresoCodVend.cmdaceptarprodadi = True
      
      If GBlnUsuarioCreditoOK = False Then
         Exit Sub
      End If
            
      FDatosClientCombust.EmitirDocumentoDirectamente 0, "", GStrCodVendedorVentaCombus, GStrCodUsuarioVentaCombus
      If GIntVentaAutoCombust = 1 Then
         Unload Me
         Unload FDatosClientCombust
      Else
         Unload Me
         FDatosClientCombust.GLimpiarDatosdePantalla
      End If
   Else
      FDatosClientCombust.GStrNumeroPlaca = FIngresoVales.txtplaca.Text
            
      If Trim(txtkilometraje.Text) <> Empty Then
         FDatosClientCombust.GdblKilometraje = txtkilometraje.Text
      Else
         FDatosClientCombust.GdblKilometraje = 0
      End If
      
      If GblnVienedePendientes = False Then
         FDatosClientCombust.GrabarDatosenTemporal
      Else  'Actualizar
         FDatosClientCombust.ActualizarDatosenTemporal
         FTranspendientes.GactualizarPendientes
      End If
      Unload Me
      Unload FDatosClientCombust
   End If
      
End Sub
Private Sub cmdCancelar_Click()

  ' Hay que Preguntar si quiere Cancelar
  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 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).Visible = False
   DbVales.Columns(2).Width = 2500
   DbVales.Refresh
   
End Sub

Private Sub cmdregistrarvales_Click()

  If Trim(txtplaca.Text) = Empty Then
     MsgBox "Ingrese N° de Placa", vbDefaultButton1 + vbExclamation, "Advertencia"
     txtplaca.SetFocus
     Exit Sub
  End If
  
  If Trim(txtnomconductor.Text) = Empty Then
     MsgBox "Ingrese Nombres del Conductor", vbDefaultButton1 + vbExclamation, "Advertencia"
     txtnomconductor.SetFocus
     Exit Sub
  End If
  
''  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
''  End If
  
  If Trim(txtnrovale.Text) <> Empty And Trim(txtnomconductor.Text) <> Empty Then
         CORRELATIVO = lblcorrelativo.Caption
         CODCLI = FDatosClientCombust.txtcodcliente
         NROVALE = txtnrovale.Text
         TOTAL = CDbl(FDatosClientCombust.ctnmontofactu.Text)
         PLACA = txtplaca.Text
         CONDUCTOR = txtnomconductor.Text
  
         MobjVentascombustible.GrabarVale_Temporal CORRELATIVO, CODCLI, NROVALE, "", 0, TOTAL, PLACA, CONDUCTOR
         txtplaca.Text = Empty: txtnomconductor.Text = Empty
             
         cmdregistrarvales.Enabled = False: cmdaceptarprodadi.Enabled = True
         cmdaceptarprodadi.SetFocus
         '---------------------------------------------------------------------
         RefrescarGrilla
         txtplaca.SetFocus
         Exit Sub
  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
          'FIngresoVales.DbVales.Columns(2).Visible = False
          '@ Jorge: para inhabilitar boton Aceptar si no existe ningun numero de Guia(vale)
          If IsNull(DbVales.Bookmark) Then
             cmdregistrarvales.Enabled = True: cmdaceptarprodadi.Enabled = False
          End If
          '-------------------------------------------------------------------------------
      End If
     End If
  End If

End Sub

Private Sub DbVales_LostFocus()
  Imgdetalle.Visible = False
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()

    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
          
    'Buscar en la Tabla op_custbadge
    'txtplaca.Enabled = FDatosClientCombust.GblnconPlacas
    'txtkilometraje.Enabled = FDatosClientCombust.GblnconPlacas
     
    If GblnVienedePendientes = True Then
       ' Cargo los datos ingresado previos
        txtplaca.Text = Trim(FDatosClientCombust.GStrNumeroPlaca)
        txtkilometraje.Text = FDatosClientCombust.GdblKilometraje
        lblcorrelativo.Caption = FDatosClientCombust.MDblIdentificador
        RefrescarGrilla
    End If
    
    '@ Jorge: añadido para cada tipo de documento----------------------
    If EsValeInterno = False Then 'Es N° Guia
       Me.Caption = "Ingreso de Vales (Venta Crédito)"
       lblDoc.Caption = "Placa:"
       cmdregistrarvales.Caption = "Registrar >>"
    End If
    
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set MobjVentascombustible = Nothing
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 FDatosClientCombust.MintTipoCliente <> 0 Then ' Si el Cliente no es Contado
                If Trim(txtkilometraje.Text) = Empty Then
                   MsgBox "Ingrese Kilometraje", vbDefaultButton1 + vbExclamation, "Advertencia"
                   Exit Sub
                End If
                txtnrovale.SetFocus
             Else
                cmdaceptarprodadi.Enabled = True
                cmdaceptarprodadi.SetFocus
             End If
          End If
          ' Fin de Validacion
        End If
     Else
        KeyAscii = 0
     End If
   End If
End Sub

Private Sub txtnomconductor_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    
    '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(txtnomconductor.Text) = Empty Then
                '@ Jorge: imprimir el mensaje apropiado
                MsgBox "Ingrese Nombres del Conductor", vbDefaultButton1 + vbExclamation, "Advertencia"
                txtnomconductor.SetFocus
                Exit Sub
             Else
                cmdregistrarvales.SetFocus
             End If
         ' Fin de Validacion
       End If
    'Else
    '   KeyAscii = 0
    'End If
End Sub

Private Sub txtplaca_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
  
    'If (KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 32) Then
      If KeyAscii = 13 Then
            'Verificar si Numero de Vale no está repetido para ese cliente
             If Trim(txtplaca.Text) = Empty Then
                MsgBox "Ingrese N° de Placa", vbDefaultButton1 + vbExclamation, "Advertencia"
                txtplaca.SetFocus
                Exit Sub
             Else
                txtnomconductor.SetFocus
             End If
             
             ''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
             ''   txtnomconductor.SetFocus
             ''End If
         ' Fin de Validacion
       End If
    'Else
    '   KeyAscii = 0
    'End If

End Sub


