VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Object = "{69F9D01E-F1DE-11D4-9536-002018603DA2}#7.0#0"; "ControlNumber.ocx"
Begin VB.Form FrmIngManual 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Ingreso Manual de Conceptos - Parte Diario (05.090.00)"
   ClientHeight    =   3930
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   8325
   LinkTopic       =   "Ingreso Manual de Conceptos - Parte Diario"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   3930
   ScaleWidth      =   8325
   Begin MiControl.CtrlNumber CtrlDepositoTienda 
      Height          =   315
      Left            =   6000
      TabIndex        =   26
      Top             =   3480
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlNumber3 
      Height          =   315
      Left            =   6240
      TabIndex        =   31
      Top             =   840
      Visible         =   0   'False
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlCobranzas 
      Height          =   315
      Left            =   6000
      TabIndex        =   25
      Top             =   3180
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlAfericion 
      Height          =   315
      Left            =   6000
      TabIndex        =   24
      Top             =   2880
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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.Frame Frame3 
      Caption         =   "Otros"
      Height          =   1215
      Left            =   3840
      TabIndex        =   32
      Top             =   2640
      Width           =   4395
      Begin MiControl.CtrlNumber CtrlNumber1 
         Height          =   315
         Left            =   2160
         TabIndex        =   36
         Top             =   840
         Width           =   1935
         _ExtentX        =   3413
         _ExtentY        =   556
         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 Label10 
         Caption         =   "DEPOSITO TIENDA"
         Height          =   255
         Left            =   240
         TabIndex        =   35
         Top             =   840
         Width           =   1695
      End
      Begin VB.Label Label9 
         Caption         =   "COBRANZAS"
         Height          =   255
         Left            =   240
         TabIndex        =   34
         Top             =   540
         Width           =   1695
      End
      Begin VB.Label Label8 
         Caption         =   "AFERICION"
         Height          =   255
         Left            =   240
         TabIndex        =   33
         Top             =   240
         Width           =   1875
      End
   End
   Begin MiControl.CtrlNumber CtrlTotal2 
      Height          =   315
      Left            =   6000
      TabIndex        =   23
      Top             =   2280
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      BackColor       =   -2147483643
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MiControl.CtrlNumber CtrlPagAdel 
      Height          =   315
      Left            =   6000
      TabIndex        =   22
      Top             =   1860
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlPagDif 
      Height          =   315
      Left            =   6000
      TabIndex        =   21
      Top             =   1560
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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.Frame Frame2 
      Caption         =   "Pagos"
      Height          =   1335
      Left            =   3840
      TabIndex        =   27
      Top             =   1320
      Width           =   4395
      Begin VB.Label Label12 
         Caption         =   "PAGO DE DIFERENCIAS"
         Height          =   255
         Left            =   240
         TabIndex        =   30
         Top             =   300
         Width           =   1875
      End
      Begin VB.Label Label11 
         Caption         =   "PAGO ADELANTADO"
         Height          =   255
         Left            =   240
         TabIndex        =   29
         Top             =   600
         Width           =   1695
      End
      Begin VB.Label Label7 
         Caption         =   "TOTAL"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   28
         Top             =   1020
         Width           =   1035
      End
      Begin VB.Line Line2 
         X1              =   120
         X2              =   4200
         Y1              =   900
         Y2              =   900
      End
   End
   Begin MiControl.CtrlNumber CtrlTotal 
      Height          =   315
      Left            =   1560
      TabIndex        =   20
      Top             =   3420
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      BackColor       =   -2147483643
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MiControl.CtrlNumber CtrlOtros 
      Height          =   315
      Left            =   1560
      TabIndex        =   19
      Top             =   3000
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlTelefono 
      Height          =   315
      Left            =   1560
      TabIndex        =   18
      Top             =   2640
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlMobil 
      Height          =   315
      Left            =   1560
      TabIndex        =   17
      Top             =   2280
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlGas 
      Height          =   315
      Left            =   1560
      TabIndex        =   16
      Top             =   1920
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 CtrlServicios 
      Height          =   315
      Left            =   1560
      TabIndex        =   15
      Top             =   1560
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   556
      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 cmdConfirmar 
      Caption         =   "Confirmar"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2685
      TabIndex        =   9
      Top             =   660
      Width           =   1545
   End
   Begin VB.CommandButton cmdBuscar 
      Height          =   465
      Left            =   6120
      MouseIcon       =   "FrmIngManual.frx":0000
      MousePointer    =   99  'Custom
      Picture         =   "FrmIngManual.frx":0152
      Style           =   1  'Graphical
      TabIndex        =   8
      ToolTipText     =   "Buscar Registro de Control de Combustible"
      Top             =   60
      Visible         =   0   'False
      Width           =   645
   End
   Begin VB.CommandButton cmdBusAlmacen 
      Enabled         =   0   'False
      Height          =   375
      Left            =   4920
      MouseIcon       =   "FrmIngManual.frx":0684
      MousePointer    =   99  'Custom
      Picture         =   "FrmIngManual.frx":07D6
      Style           =   1  'Graphical
      TabIndex        =   7
      ToolTipText     =   "Buscar Almacén"
      Top             =   240
      Width           =   375
   End
   Begin Crystal.CrystalReport crControlCombust 
      Left            =   6945
      Top             =   60
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
   Begin MSDataListLib.DataCombo dtcAlmacen 
      Height          =   315
      Left            =   1140
      TabIndex        =   10
      Top             =   255
      Width           =   3735
      _ExtentX        =   6588
      _ExtentY        =   556
      _Version        =   393216
      Enabled         =   0   'False
      Style           =   2
      Text            =   ""
   End
   Begin MSComCtl2.DTPicker dtpFechaProc 
      Height          =   315
      Left            =   1140
      TabIndex        =   11
      Top             =   690
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   556
      _Version        =   393216
      Enabled         =   0   'False
      CalendarBackColor=   16777152
      Format          =   48431105
      CurrentDate     =   37567
   End
   Begin VB.Frame Frame1 
      Caption         =   "Tienda"
      Height          =   2535
      Left            =   60
      TabIndex        =   0
      Top             =   1320
      Width           =   3735
      Begin VB.Line Line1 
         X1              =   120
         X2              =   3600
         Y1              =   2040
         Y2              =   2040
      End
      Begin VB.Label Label6 
         Caption         =   "TOTAL"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   2160
         Width           =   1035
      End
      Begin VB.Label Label5 
         Caption         =   "OTROS"
         Height          =   255
         Left            =   240
         TabIndex        =   5
         Top             =   1740
         Width           =   1035
      End
      Begin VB.Label Label4 
         Caption         =   "TELEFONO"
         Height          =   255
         Left            =   240
         TabIndex        =   4
         Top             =   1380
         Width           =   1035
      End
      Begin VB.Label Label3 
         Caption         =   "MOBIL MART"
         Height          =   255
         Left            =   240
         TabIndex        =   3
         Top             =   1020
         Width           =   1035
      End
      Begin VB.Label Label2 
         Caption         =   "GAS"
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Top             =   660
         Width           =   795
      End
      Begin VB.Label Label1 
         Caption         =   "SERVICIOS"
         Height          =   255
         Left            =   240
         TabIndex        =   1
         Top             =   300
         Width           =   975
      End
   End
   Begin VB.Label lblAlmacen 
      AutoSize        =   -1  'True
      Caption         =   "Almacen"
      Height          =   195
      Left            =   300
      TabIndex        =   14
      Top             =   255
      Width           =   615
   End
   Begin VB.Label lblFechaInicio 
      Caption         =   "Fecha Proceso"
      Height          =   435
      Left            =   285
      TabIndex        =   13
      Top             =   660
      Width           =   720
   End
   Begin VB.Shape Shape1 
      Height          =   1230
      Left            =   60
      Top             =   60
      Width           =   5985
   End
   Begin VB.Label lblEstado 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000004&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000002&
      Height          =   120
      Left            =   4440
      TabIndex        =   12
      Top             =   720
      Width           =   75
   End
   Begin VB.Image Image1 
      Height          =   465
      Left            =   6825
      Picture         =   "FrmIngManual.frx":0D08
      Stretch         =   -1  'True
      Top             =   60
      Width           =   465
   End
End
Attribute VB_Name = "FrmIngManual"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Programador: Pablo Neyra
' Empresa JLYM, para Brigneti
' Modulo de Registro de Ventas Tienda, de forma manual.
Option Explicit

'*************************************
'Variables para el Control de la Barra General
 Public pb_editar As Boolean
 Public pb_agregar As Boolean
 Public pb_primerregistro As Boolean
 Public pb_ultimoregistro As Boolean
 Public pbderecho_agregar As Boolean
 Public pbderecho_consultar As Boolean
 Public pbderecho_editar As Boolean
 Public pbderecho_borrar As Boolean
 Public pbderecho_imprimir As Boolean
 Public pbderecho_anular As Boolean
 Public pbderecho_emitir As Boolean
 Public pb_tiposcreen As String
'*******************************************************************************************************************
' Variables para las ayudas
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String
Public GrecibeColumnaOpcional2 As String
Public GrecibeColumnaOpcional3 As String
'*************************************
' Objetos para cargar las ayudas

Private objAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Private ObjCtrlFuel As DB_OP_MANTENIMIENTOS.C_CTRLFUEL
Private MobjVentasGeneral  As DB_OP_FACTURACION.C_VENTASGENERAL
'*******************************************************************************

Dim objCorrelativo As DB_CORRELATIVO.C_Correlativos

Dim lngCorrelativo As Long 'correlativo por usuario, que se almacenara en cada insert en temporal
Dim lngNumeroContometro As Long  'almacenara el correlativo del contómetro de precio obtenido de In_Setup
Dim lngSecuencia As Long ' guardara el número de Item del detalle


Dim blnModificando As Boolean ' flag para controlar la modificación de un registro
Dim blnEditando As Boolean ' flag para controlar si se esta editando un registro
Dim intCancelar As Integer
Dim blnDatosOK As Boolean
Dim intErr As Integer
Dim MstrFechaProc As String
Public Mlbnautorizado As Boolean

Public Sub actualizar_registro()
End Sub

Private Sub cmdBusAlmacen_Click()
    'Lineas que llaman al Formulario de Búsqueda
    
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "siteid"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1000
    ArrayBusqueda(2, 1) = "name"
    ArrayBusqueda(2, 2) = "Descripción "
    ArrayBusqueda(2, 3) = 4000
      
    FBusquedasVta.GObtenerRegistros objAlmacen.ListarAlmacenesPorStatus(1), ArrayBusqueda, 2, 2
    FBusquedasVta.Show vbModal
    
    If GrecibeUbicacion <> 0 Then
        dtcAlmacen.BoundText = GrecibeColumnaID
    End If
End Sub

Private Sub CmdBuscar_Click()
'    FBuscarCtrlFuel.Show vbModal
End Sub

Private Sub cancelarIngreso()
        blnEditando = False
        
        Call Limpiar
        Call HabilitaCampos(False)
        Call HabilitaBotones(True)

End Sub

Private Sub Nuevo_Registro()
    blnEditando = True
        
    Call HabilitaCampos(True)
    Call HabilitaBotones(False)
    Call Limpiar
    
    'dtcAlmacen.SetFocus
End Sub


Private Sub Salir()
    Unload Me
End Sub

Public Sub CargaDatos(strSITEID As String, datFECHA As Date, StrEstado As String)

On Error GoTo TrataError
    Call Limpiar
    
    dtcAlmacen.BoundText = strSITEID
    dtpFechaProc.Value = datFECHA
    lblEstado.Caption = StrEstado
      
    '-------------------------------Pablo N.
    Dim RsDat As ADODB.Recordset
    Set RsDat = New ADODB.Recordset
    Dim SqlDat As String
    Dim DBc As ADODB.Connection
    Set DBc = New ADODB.Connection
    DBc.Open "FILEDSN=conexionsies"
    RsDat.CursorLocation = adUseClient
    SqlDat = "SELECT SERVICIOS, GAS, MOBIL, TELEFONO, OTROS, PAG_DIFERENCIA, PAG_ADELANTADO, AFERICION, COBRANZAS,DEPOSITO_TIENDA From OP_PD_MANUAL " & _
                " WHERE SITEID = '" & strSITEID & "' AND DATEPROCESALES = '" & Format(datFECHA, "YYYYMMDD") & "'"
    RsDat.Open SqlDat, DBc, adOpenDynamic
    If RsDat.EOF Or RsDat.BOF Then
        blnEditando = True
        Exit Sub
    End If
    RsDat.MoveFirst
    blnEditando = False
    Controles
    CtrlServicios.Text = Format(IIf(IsNull(RsDat.Fields("SERVICIOS")), "0.00", RsDat.Fields("SERVICIOS")), "###,###,##0.00")
    CtrlGas.Text = Format(IIf(IsNull(RsDat.Fields("GAS")), "0.00", RsDat.Fields("GAS")), "###,###,##0.00")
    CtrlMobil.Text = Format(IIf(IsNull(RsDat.Fields("MOBIL")), "0.00", RsDat.Fields("MOBIL")), "###,###,##0.00")
    CtrlTelefono.Text = Format(IIf(IsNull(RsDat.Fields("TELEFONO")), "0.00", RsDat.Fields("TELEFONO")), "###,###,##0.00")
    CtrlOtros.Text = Format(IIf(IsNull(RsDat.Fields("OTROS")), "0.00", RsDat.Fields("OTROS")), "###,###,##0.00")
    CtrlPagDif.Text = Format(IIf(IsNull(RsDat.Fields("PAG_DIFERENCIA")), "0.00", RsDat.Fields("PAG_DIFERENCIA")), "###,###,##0.00")
    CtrlPagAdel.Text = Format(IIf(IsNull(RsDat.Fields("PAG_ADELANTADO")), "0.00", RsDat.Fields("PAG_ADELANTADO")), "###,###,##0.00")
    CtrlAfericion.Text = Format(IIf(IsNull(RsDat.Fields("AFERICION")), "0.00", RsDat.Fields("AFERICION")), "###,###,##0.00")
    CtrlDepositoTienda.Text = Format(IIf(IsNull(RsDat.Fields("DEPOSITO_tienda")), "0.00", RsDat.Fields("DEPOSITO_tienda")), "###,###,##0.00")
    CtrlCobranzas.Text = Format(IIf(IsNull(RsDat.Fields("COBRANZAS")), "0.00", RsDat.Fields("COBRANZAS")), "###,###,##0.00")
    DBc.Close
    '-------
    Call Sumar
    Call Sumar2
    Exit Sub
    
TrataError:
    Call Limpiar
    MsgBox "Nro de Ingreso no Registrado en Almacen Seleccionado", vbExclamation, "Error en Consulta"
End Sub

Private Sub cmdConfirmar_Click()
On Error GoTo TrataError
   
    If ObjCtrlFuel.RegistroCerrado(dtcAlmacen.BoundText, dtpFechaProc.Value) Then
        MsgBox "Parte Diario ya fue Cerrado ", vbExclamation, "Confirmar"
        dtpFechaProc.SetFocus
        Exit Sub
    End If
    
    Screen.MousePointer = 11
    
    Call CargaDatos(dtcAlmacen.BoundText, dtpFechaProc.Value, "")
    
'    lngCorrelativo = objCorrelativo.ObtenerCorrelativo(GCUSERID)
    
    Call HabilitaCampos(True)
    
    cmdConfirmar.Enabled = False
    dtcAlmacen.Enabled = False
    cmdBusAlmacen.Enabled = False
    dtpFechaProc.Enabled = False
        
    CtrlServicios.SetFocus
    
    Screen.MousePointer = 0
    Exit Sub
TrataError:
    Screen.MousePointer = 0
End Sub

Private Sub CtrlAfericion_GotFocus()
    CtrlAfericion.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlAfericion_LostFocus()
    CtrlGas.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlDepositoTienda_GotFocus()
CtrlDepositoTienda.BackColor = GC_ColorEnfoque
End Sub


Private Sub CtrlDepositoTienda_LostFocus()
CtrlDepositoTienda.BackColor = GC_ColorDefecto
End Sub


Private Sub CtrlGas_change()
    Call Sumar
End Sub

Private Sub CtrlGas_GotFocus()
    CtrlGas.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlGas_LostFocus()
    CtrlGas.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlMobil_change()
    Call Sumar
End Sub

Private Sub CtrlMobil_GotFocus()
    CtrlMobil.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlMobil_LostFocus()
    CtrlMobil.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlPagDif_change()
    Call Sumar2
End Sub

Private Sub CtrlPagDif_GotFocus()
    CtrlPagDif.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlPagDif_LostFocus()
    CtrlPagDif.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlPagAdel_change()
    Call Sumar2
End Sub

Private Sub CtrlPagAdel_GotFocus()
    CtrlPagAdel.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlPagAdel_LostFocus()
    CtrlPagAdel.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlOtros_change()
    Call Sumar
End Sub

Private Sub CtrlOtros_GotFocus()
    CtrlOtros.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlOtros_LostFocus()
    CtrlOtros.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlServicios_change()
    Call Sumar
End Sub

Private Sub CtrlServicios_GotFocus()
    CtrlServicios.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlServicios_LostFocus()
    CtrlServicios.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlCobranzas_GotFocus()
    CtrlCobranzas.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlCobranzas_LostFocus()
    CtrlCobranzas.BackColor = GC_ColorDefecto
End Sub

Private Sub CtrlTelefono_change()
    Call Sumar
End Sub

Private Sub CtrlTelefono_GotFocus()
    CtrlTelefono.BackColor = GC_ColorEnfoque
End Sub

Private Sub CtrlTelefono_LostFocus()
    CtrlTelefono.BackColor = GC_ColorDefecto
End Sub

Private Sub dtcAlmacen_GotFocus()
    dtcAlmacen.BackColor = GC_ColorEnfoque
End Sub

Private Sub dtcAlmacen_LostFocus()
    dtcAlmacen.BackColor = GC_ColorDefecto
End Sub

Private Sub Sumar()
    CtrlTotal.Text = str(Val(CtrlServicios.Text) + Val(CtrlGas.Text) + Val(CtrlMobil.Text) + Val(CtrlTelefono.Text) + Val(CtrlOtros.Text))
    CtrlTotal.Text = Format(CtrlTotal.Text, "###,###,##0.00")
    CtrlTotal.Enteros = 7
    CtrlTotal.Decimales = GintDecResultado
    CtrlTotal.Enabled = False
End Sub

Private Sub Sumar2()
    CtrlTotal2.Text = str(Val(CtrlPagDif.Text) + Val(CtrlPagAdel.Text))
    CtrlTotal2.Text = Format(CtrlTotal2.Text, "###,###,##0.00")
    CtrlTotal2.Enteros = 7
    CtrlTotal2.Decimales = GintDecResultado
    CtrlTotal2.Enabled = False
End Sub

Private Sub Form_Activate()

    Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
    Call gactualiza_barra(Me)
    If pbderecho_consultar = False Then
       Unload Me
    End If
End Sub

Private Sub Form_Load()
Controles
Screen.MousePointer = 11
'********************************************************************************
 'Código que se Tiene que Copiar para Invocar a la Rutina de Seguridad para poder
  Call gseguridad(Me)
  pbderecho_consultar = True
  If pbderecho_consultar Then
         Call InstanciaObjetos
         
         dtpFechaProc.Value = GDatFechaProceso
            
         Call HabilitaCampos(False)
         Call HabilitaBotones(True)
         Call LlenaDataCombos
         intErr = 0
        
  Else
     MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
     Screen.MousePointer = 0
     Exit Sub
  End If
 '********************************************************************************
 
        Me.Top = 100
        Me.Left = (Screen.Width - Me.Width) / 2
    
Screen.MousePointer = 0
End Sub

Private Sub Controles()
    
    CtrlServicios.Enteros = 7
    CtrlServicios.Decimales = GintDecResultado
    CtrlServicios.ValorPorDefecto
    CtrlServicios.Enabled = True
    
    CtrlGas.Enteros = 7
    CtrlGas.Decimales = GintDecResultado
    CtrlGas.ValorPorDefecto
    CtrlGas.Enabled = True
    
    CtrlMobil.Enteros = 7
    CtrlMobil.Decimales = GintDecResultado
    CtrlMobil.ValorPorDefecto
    CtrlMobil.Enabled = True
    
    CtrlTelefono.Enteros = 7
    CtrlTelefono.Decimales = GintDecResultado
    CtrlTelefono.ValorPorDefecto
    CtrlTelefono.Enabled = True
    
    CtrlOtros.Enteros = 7
    CtrlOtros.Decimales = GintDecResultado
    CtrlOtros.ValorPorDefecto
    CtrlOtros.Enabled = True
    
    CtrlTotal.Enteros = 7
    CtrlTotal.Decimales = GintDecResultado
    CtrlTotal.ValorPorDefecto
    CtrlTotal.Enabled = False
    
    '--------------
    
    CtrlPagDif.Enteros = 7
    CtrlPagDif.Decimales = GintDecResultado
    CtrlPagDif.ValorPorDefecto
    CtrlPagDif.Enabled = True
    
    CtrlPagAdel.Enteros = 7
    CtrlPagAdel.Decimales = GintDecResultado
    CtrlPagAdel.ValorPorDefecto
    CtrlPagAdel.Enabled = True
    
    CtrlTotal2.Enteros = 7
    CtrlTotal2.Decimales = GintDecResultado
    CtrlTotal2.ValorPorDefecto
    CtrlTotal2.Enabled = False
    
    '-------------
    
    CtrlAfericion.Enteros = 7
    CtrlAfericion.Decimales = GintDecResultado
    CtrlAfericion.ValorPorDefecto
    CtrlAfericion.Enabled = True
    
    CtrlCobranzas.Enteros = 7
    CtrlCobranzas.Decimales = GintDecResultado
    CtrlCobranzas.ValorPorDefecto
    CtrlCobranzas.Enabled = True
        
    CtrlDepositoTienda.Enteros = 7
    CtrlDepositoTienda.Decimales = GintDecResultado
    CtrlDepositoTienda.ValorPorDefecto
    CtrlDepositoTienda.Enabled = True
End Sub
    
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If blnEditando Then
        If MsgBox("Desea Salir y Cancelar el registro de Contómetro actual? ", vbQuestion + vbYesNo, "Salir") = vbNo Then
            Cancel = 1
        Else
            Cancel = 0
            blnEditando = False
            pb_agregar = False
            pb_editar = False
            Call gdesactiva_barra
        End If
    Else
        pb_editar = False
        Call gdesactiva_barra
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call DestruyeObjetos
End Sub

' Procedimiento para cargar DataCombos
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

' Procedimiento de carga de los DataCombos del formulario
Private Sub LlenaDataCombos()
    Call CargaDataCombo(dtcAlmacen, objAlmacen.ListarAlmacenesPorStatus(1), "SiteId", "Name")
End Sub

Private Sub InstanciaObjetos()
    
    Set ObjCtrlFuel = New DB_OP_MANTENIMIENTOS.C_CTRLFUEL
    Set objAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set objCorrelativo = New DB_CORRELATIVO.C_Correlativos
    Set MobjVentasGeneral = New DB_OP_FACTURACION.C_VENTASGENERAL
    
End Sub

Private Sub DestruyeObjetos()
    
    Set ObjCtrlFuel = Nothing
    Set objAlmacen = Nothing
    Set objCorrelativo = Nothing
    Set MobjVentasGeneral = Nothing
End Sub

Private Sub HabilitaCampos(blnValor As Boolean)
    CtrlServicios.Enabled = blnValor
    CtrlGas.Enabled = blnValor
    CtrlMobil.Enabled = blnValor
    CtrlTelefono.Enabled = blnValor
    CtrlOtros.Enabled = blnValor
    CtrlDepositoTienda.Enabled = blnValor

    
    CtrlTotal.Enteros = 7
    CtrlTotal.Decimales = GintDecResultado
    CtrlTotal.Enabled = False
    
    CtrlPagDif.Enabled = blnValor
    CtrlPagAdel.Enabled = blnValor
    
    CtrlTotal2.Enteros = 7
    CtrlTotal2.Decimales = GintDecResultado
    CtrlTotal2.Enabled = False
    
    CtrlAfericion.Enabled = blnValor
    
    CtrlCobranzas.Enabled = blnValor
    
End Sub

Private Sub HabilitaBotones(blnValor As Boolean)
'    If blnValor Then
'
'        cmdImprimir.Enabled = pbderecho_imprimir
'
'    Else
'
'        cmdImprimir.Enabled = blnValor
'
'    End If
End Sub
Private Sub Limpiar()
'funcionabilidad    : pone en blanco todos los controles de un formulario

Dim curcontrol As Control
    With Me
    For Each curcontrol In .Controls
        If TypeOf curcontrol Is TextBox Then
                curcontrol.Text = ""
        End If
         If TypeOf curcontrol Is DataCombo Then
                 curcontrol.Text = ""
        End If
         If TypeOf curcontrol Is ComboBox Then
            If curcontrol.Style <> 2 Then
                curcontrol.Text = ""
            End If
        End If
        If TypeOf curcontrol Is CtrlNumber Then
              curcontrol.ValorPorDefecto
        End If
        If TypeOf curcontrol Is CheckBox Then
              curcontrol.Value = 0
        End If
        
        If TypeOf curcontrol Is DTPicker Then
              curcontrol.Value = GDatFechaProceso
        End If
    
    Next
    End With
    
    'dtpFechaProceso.Value = GDatFechaProceso
    
    lblEstado.Caption = Empty

    Call LlenaDataCombos

End Sub

Private Sub GrabaRegistros()
On Error GoTo errhandler

    Dim dblDiferencia As Double
    dblDiferencia = 0
        
    Screen.MousePointer = 11
        
    If ValidaDatos = True Then 'si los datos se ingresaron correctamente
    
        If MsgBox("Desea Grabar datos de Manuales? ", vbQuestion + vbYesNo, "Confirmar Grabación") = vbNo Then
            Call cancelarIngreso
            Exit Sub
        End If
        
        If blnEditando Then 'SI SE ESTA AGREGANDO
            Call GrabarRegistrosProc("I")
            lblEstado.Caption = "NO CERRADO"
        Else
            Call GrabarRegistrosProc("U")
        End If
        
        blnEditando = False
        
        MsgBox "Registro de Montos Manuales grabado Correctamente."
'        If MsgBox("Registro de Montos Manuales grabado Correctamente.Desea Imprimir? ", vbQuestion + vbYesNo, "Mensaje") = vbNo Then
'           GoTo SALTO
'        Else
'           Call cmdImprimir_Click
'        End If
        
SALTO:

        Call HabilitaCampos(False)
        Call HabilitaBotones(True)
        Screen.MousePointer = 0
        
    End If

Exit Sub

errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Advertencia"
    intErr = 1
    Screen.MousePointer = 0
End Sub

Private Sub GrabarRegistrosProc(ByVal strTipo As String)
    
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_UpdParteDMontosManual '" & strTipo & "','" & dtcAlmacen.BoundText & "','" & _
                    Format(dtpFechaProc.Value, "YYYYMMDD") & "'," & Val(CtrlServicios.Text) & "," & _
                                            Val(CtrlGas.Text) & "," & Val(CtrlMobil.Text) & "," & _
                                            Val(CtrlTelefono.Text) & "," & Val(CtrlOtros.Text) & "," & _
                                            Val(CtrlPagDif.Text) & "," & Val(CtrlPagAdel.Text) & "," & _
                                            Val(CtrlAfericion.Text) & "," & Val(CtrlCobranzas.Text) & "," & Val(CtrlDepositoTienda.Text)
    
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    con.Execute strSQL

    ''GetObjectContext.SetComplete
    
    Exit Sub

TrataError:

Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     
     Err.Raise LVarNumeroError, "DB_MA_MANTENIMIENTOS.ActualizarMoneda", LStrMensajeError

End Sub


Private Function ValidaDatos() As Boolean
ValidaDatos = True
blnDatosOK = True
    If Not (ValidaDatosCab) Then
        ValidaDatos = False
        blnDatosOK = False
        Exit Function
    End If
    If Not (ValidaDatosDet) Then
        ValidaDatos = False
        blnDatosOK = False
        Exit Function
    End If
End Function

Private Function ValidaDatosCab() As Boolean
ValidaDatosCab = True

    Exit Function
    
Final:
    ValidaDatosCab = False
        
End Function

Private Function ValidaDatosDet() As Boolean
ValidaDatosDet = True

    
End Function

Public Sub agregar_registro()

    Call Nuevo_Registro
    pb_agregar = True
    pb_editar = True
    Call gagregar_registro(Me, dtcAlmacen)
    cmdConfirmar.Enabled = True
    dtcAlmacen.BoundText = GstrSiteProce
    cmdBusAlmacen.Enabled = True
    dtpFechaProc.Enabled = True
            
End Sub

Public Sub descartar_registro()
    ' Revertir cambios
    cancelarIngreso
    Call gdescartar_registro(Me)
    Call HabilitaCampos(False)
    cmdBuscar.Enabled = True
    cmdConfirmar.Enabled = False
    dtcAlmacen.Enabled = False
    cmdBusAlmacen.Enabled = False
    dtpFechaProc.Enabled = False
    CtrlTotal.Enteros = 7
    CtrlTotal.Decimales = GintDecResultado
    CtrlTotal.ValorPorDefecto
    CtrlTotal.Enabled = False
    
    CtrlPagDif.Enabled = False
    CtrlPagAdel.Enabled = False
    CtrlTotal2.Enteros = 7
    CtrlTotal2.Decimales = GintDecResultado
    CtrlTotal2.ValorPorDefecto
    CtrlTotal2.Enabled = False
End Sub

Public Sub modificar_registro()
'    Nuevo_Registro
End Sub

Public Sub grabar_registro()
    
    Call GrabaRegistros
    If intErr = 0 Then
        If blnDatosOK Then
            pb_agregar = False
            pb_editar = False
            Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
            Call gactualiza_barra(Me)
            cmdBuscar.Enabled = True
'            cmdRegistros.Enabled = True
'            cmdRecalcular.Enabled = False
        End If
    Else
        intErr = 0
    End If
    
End Sub


Public Sub salir_formulario()
    Salir
End Sub

Private Sub DesabilitaCabecera()
    
    dtcAlmacen.Enabled = False
    cmdBusAlmacen.Enabled = False
    dtpFechaProc.Enabled = False
    cmdConfirmar.Enabled = False
    
End Sub

Public Sub imprimir()
    'cmdImprimir_Click
End Sub

Public Sub borrar_registro()
   
    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    If GVDATO(dtcAlmacen.BoundText) = "" Then
        MsgBox "Seleccione algún registro que desee eliminar", vbExclamation, "Eliminación"
        Exit Sub
    End If
    
    If lblEstado.Caption <> Empty Then
        If lblEstado.Caption = "CERRADO" Then
            MsgBox "No se puede Eliminar, Parte Diario ya fue Cerrado ", vbExclamation, "Eliminación"
            Exit Sub
        End If
    End If
    
    If MsgBox("Seguro que desea eliminar todos los registros", vbYesNo + vbQuestion, "Eliminación") = vbNo Then
       Screen.MousePointer = 0
       Exit Sub
    End If
                   
    Screen.MousePointer = 11
                   
    'ObjCtrlFuel.EliminarControlCombustible dtcAlmacen.BoundText, dtpFechaProc.Value
'    Call CargaGrid(0)
'    MsgBox "Registro Eliminados con exito", vbInformation, "Eliminación"
    Screen.MousePointer = 0
Exit Sub
TrataError:
    Screen.MousePointer = 0
    MsgBox Err.Description, vbDefaultButton1 + vbExclamation, "Advertencia"
End Sub
