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 FEditarCtrlFuel 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Edición de Registro de Combustible"
   ClientHeight    =   2865
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6090
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2865
   ScaleWidth      =   6090
   StartUpPosition =   2  'CenterScreen
   Begin MSDataListLib.DataCombo dtcArticulo 
      Height          =   315
      Left            =   1320
      TabIndex        =   0
      Top             =   240
      Width           =   3615
      _ExtentX        =   6376
      _ExtentY        =   556
      _Version        =   393216
      Style           =   2
      Text            =   ""
   End
   Begin VB.CommandButton cmdDescartar 
      Caption         =   "&Descartar"
      Height          =   330
      Left            =   4155
      TabIndex        =   5
      Top             =   2400
      Width           =   1335
   End
   Begin MiControl.CtrlNumber ctnVenta 
      Height          =   285
      Left            =   1035
      TabIndex        =   1
      Top             =   1455
      Width           =   1905
      _ExtentX        =   3360
      _ExtentY        =   503
      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 MiControl.CtrlNumber ctnPrecio 
      Height          =   330
      Left            =   3735
      TabIndex        =   2
      Top             =   1410
      Width           =   1680
      _ExtentX        =   2963
      _ExtentY        =   582
      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.CommandButton cmdAceptar 
      Caption         =   "&Aceptar"
      Height          =   330
      Left            =   2835
      TabIndex        =   4
      Top             =   2400
      Width           =   1335
   End
   Begin MiControl.CtrlNumber ctnTotal 
      Height          =   255
      Left            =   3735
      TabIndex        =   3
      Top             =   1905
      Width           =   1695
      _ExtentX        =   2990
      _ExtentY        =   450
      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 Label1 
      Caption         =   "Articulo"
      Height          =   255
      Left            =   360
      TabIndex        =   12
      Top             =   240
      Width           =   735
   End
   Begin VB.Label lblTotal 
      Caption         =   "Total"
      Height          =   240
      Left            =   3195
      TabIndex        =   11
      Top             =   1950
      Width           =   555
   End
   Begin VB.Image Image1 
      Height          =   480
      Left            =   5535
      Picture         =   "FEditarCtrlFuel.frx":0000
      Top             =   780
      Width           =   480
   End
   Begin VB.Shape Shape1 
      Height          =   1590
      Left            =   90
      Top             =   735
      Width           =   5955
   End
   Begin VB.Label lblDescripcion 
      BorderStyle     =   1  'Fixed Single
      Height          =   285
      Left            =   2205
      TabIndex        =   10
      Top             =   915
      Width           =   3210
   End
   Begin VB.Label lblCod 
      BorderStyle     =   1  'Fixed Single
      Height          =   285
      Left            =   1035
      TabIndex        =   9
      Top             =   915
      Width           =   1095
   End
   Begin VB.Label lblCodigo 
      Caption         =   "Articulo"
      Height          =   240
      Left            =   225
      TabIndex        =   8
      Top             =   960
      Width           =   600
   End
   Begin VB.Label lblVenta 
      Caption         =   "Cantidad Vendida"
      Height          =   510
      Left            =   225
      TabIndex        =   7
      Top             =   1410
      Width           =   735
   End
   Begin VB.Label lblPrecio 
      Caption         =   "Precio"
      Height          =   285
      Left            =   3195
      TabIndex        =   6
      Top             =   1455
      Width           =   600
   End
End
Attribute VB_Name = "FEditarCtrlFuel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Programador: Edgar Cancho Ruiz
' Empresa Texaco
' EDICION DE CONTROL DE PRECIOS - COMBUSTIBLE

Public MlngCorrelativo As Long
Public MblnAgregando As Boolean

Public MstrCodAlmacen As String
Public MdatFecha As Date
Public MstrCodArticulo As String
Public MstrDesArticulo As String
Public MdblVenta As Double
Public MdblPrecio As Double
Public MdblTotal As Double
Public MintSerafin As Integer

Private ObjCtrlFuel As DB_OP_MANTENIMIENTOS.C_CTRLFUEL

Private Sub cmdAceptar_Click()
On Error GoTo errhandler

    If Not MblnAgregando Then
        If MlngCorrelativo <> 0 Then
            ObjCtrlFuel.ActualizaTemporal MlngCorrelativo, MstrCodAlmacen, MdatFecha, lblCod.Caption, MdblPrecio, GFormatodeNumero(CDbl(ctnPrecio.Text), GintDecPrecio), GFormatodeNumero(CDbl(ctnVenta.Text), GintDecStock), ctnTotal.Text
        Else
            ObjCtrlFuel.ActualizaRegistro MstrCodAlmacen, MdatFecha, lblCod.Caption, MdblPrecio, GFormatodeNumero(CDbl(ctnPrecio.Text), GintDecPrecio), GFormatodeNumero(CDbl(ctnVenta.Text), GintDecStock), GCUSERID
        End If
        
        ObjCtrlFuel.INSERTA_AJUSTES MlngCorrelativo, MstrCodAlmacen, MdatFecha, MintSerafin
        
    Else
        'ObjCtrlFuel.AgregaItemAlTemporal MlngCorrelativo, MstrCodAlmacen, MdatFecha, MstrCodArticulo, GFormatodeNumero(CDbl(ctnPrecio.Text), GintDecPrecio), GFormatodeNumero(CDbl(ctnVenta.Text), GintDecStock)
        ObjCtrlFuel.AgregaItemAlTemporal MlngCorrelativo, MstrCodAlmacen, MdatFecha, lblCod.Caption, GFormatodeNumero(CDbl(ctnPrecio.Text), GintDecPrecio), GFormatodeNumero(CDbl(ctnVenta.Text), GintDecStock), GFormatodeNumero(CDbl(ctnTotal.Text), GintDecResultado)
        'INSERTO EN LA TABLA DE AJUSTES
        ObjCtrlFuel.INSERTA_AJUSTES MlngCorrelativo, MstrCodAlmacen, MdatFecha, MintSerafin
    End If
    Unload Me
    
    Exit Sub

errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Advertencia"

End Sub

Private Sub cmdDescartar_Click()
Unload Me
End Sub

Private Sub ctnPrecio_change()
On Error Resume Next
ctnTotal.Text = GFormatodeNumero(CDbl(ctnVenta.Text) * CDbl(ctnPrecio.Text), GintDecResultado)
End Sub

Private Sub ctnPrecio_GotFocus()
    ctnPrecio.BackColor = GC_ColorEnfoque
End Sub

Private Sub ctnPrecio_KeyPress(KeyAscii As Integer)
KeyAscii = BloqueSignoMenos(KeyAscii)
If KeyAscii = 13 Then
    cmdAceptar.SetFocus
End If
End Sub

Private Sub ctnPrecio_LostFocus()
    ctnPrecio.BackColor = GC_ColorDefecto
End Sub

Private Sub ctnVenta_change()
On Error Resume Next
ctnTotal.Text = GFormatodeNumero(CDbl(ctnVenta.Text) * CDbl(ctnPrecio.Text), GintDecResultado)
End Sub

Private Sub ctnVenta_GotFocus()
    ctnVenta.BackColor = GC_ColorEnfoque
End Sub

Private Sub ctnVenta_KeyPress(KeyAscii As Integer)
KeyAscii = BloqueSignoMenos(KeyAscii)
If KeyAscii = 13 Then
    ctnPrecio.SetFocus
End If
End Sub

Private Sub ctnVenta_LostFocus()
    ctnVenta.BackColor = GC_ColorDefecto
End Sub

Private Sub dtcArticulo_Change()
    lblCod.Caption = dtcArticulo.BoundText
    lblDescripcion.Caption = dtcArticulo.Text
End Sub

Private Sub dtcArticulo_Click(Area As Integer)
lblCod.Caption = dtcArticulo.BoundText
lblDescripcion.Caption = dtcArticulo.Text
End Sub

Private Sub dtcArticulo_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        ctnVenta.SetFocus
    End If
End Sub

Private Sub Form_Load()

    Controles
    Set ObjCtrlFuel = New DB_OP_MANTENIMIENTOS.C_CTRLFUEL
    
    lblCod.Caption = MstrCodArticulo
    lblDescripcion.Caption = MstrDesArticulo
    ctnPrecio.Text = GFormatodeNumero(MdblPrecio, GintDecPrecio)
    ctnVenta.Text = GFormatodeNumero(MdblVenta, GintDecStock)
    ctnTotal.Text = GFormatodeNumero(MdblTotal, GintDecResultado)
    
    If MblnAgregando Then
        FEditarCtrlFuel.Caption = "Agregando Registro de Combustible"
    End If
    
    If Trim(GStrTipoControlCombustible) = "1" Then
       
       If FControlCombustibleCredito.Mlbnautorizado = True Then
          Call CargaDataCombo(dtcArticulo, ObjCtrlFuel.SeleccionaCombustibles(0), "INVTIDSKU", "DESCR")
       Else
          Call CargaDataCombo(dtcArticulo, ObjCtrlFuel.SeleccionaCombustibles(CInt(GStrTipoControlCombustible)), "INVTIDSKU", "DESCR")
       End If
    Else
        Call CargaDataCombo(dtcArticulo, ObjCtrlFuel.SeleccionaCombustibles(CInt(GStrTipoControlCombustible)), "INVTIDSKU", "DESCR")
    End If
    
    
End Sub
 
Private Sub Controles()

    ctnPrecio.Enteros = 7
    ctnPrecio.Decimales = GintDecPrecio
    ctnPrecio.ValorPorDefecto
    ctnVenta.Enteros = 7
    ctnVenta.Decimales = GintDecStock
    ctnVenta.ValorPorDefecto
    ctnTotal.Enteros = 7
    ctnTotal.Decimales = GintDecResultado
    ctnTotal.Enabled = False
    ctnTotal.ValorPorDefecto

End Sub

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

Private Sub Resultado()
On Error Resume Next
    ctnVenta.Text = GFormatodeNumero(CDbl(ctnFinal.Text) - CDbl(ctnInicial.Text), GintDecStock)
    ctnTotal.Text = GFormatodeNumero(CDbl(ctnVenta.Text) - CDbl(ctnSerafin.Text) - CDbl(ctnOtros.Text), GintDecStock)
End Sub

Private Function BloqueSignoMenos(KeyAscii As Integer) As Integer
    If KeyAscii = 45 Then
        BloqueSignoMenos = 0
    Else
        BloqueSignoMenos = KeyAscii
    End If
End Function

Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As Recordset, istrCampo1 As String, istrCampo2 As String)

    Set objDataCombo.DataSource = rsSource
    objDataCombo.DataField = istrCampo2
    Set objDataCombo.RowSource = rsSource
    objDataCombo.ListField = istrCampo2
    objDataCombo.BoundColumn = istrCampo1
    
    If Not rsSource.EOF Then
        objDataCombo.BoundText = rsSource.Fields(istrCampo2)
    End If

End Sub

