VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "C_DISPENSADORES"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Function ListarCarasDisponibles(Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = "UT_CarasDisponiblesProc"
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   Set ListarCarasDisponibles = rs
   
   'GetObjectContext.SetComplete
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarCarasDisponibles", Err.Description
    
End Function
Public Function ListarCarasAsignadasaPtoVta(ByVal StrSALESPOINT As String, Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = "select SIDE,'CARA ' + SIDE from OP_SALESPOINTVSSIDE Where SALESPOINT='" & StrSALESPOINT & "'"
             
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   Set ListarCarasAsignadasaPtoVta = rs
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarCarasAsignadasaPtoVta", Err.Description
    
End Function

Public Function TotaldeCarasenEstacion(Optional VarAux As Variant) As Integer
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = "select QTYCARAS from setup "
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   TotaldeCarasenEstacion = rs!QTYCARAS
   
   If rs.EOF Then
      TotaldeCarasenEstacion = 0
   End If
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.TotaldeCarasenEstacion", Err.Description
    
End Function
Public Sub AsignarCaraaPtoVenta(ByVal StrPtoVta As String, ByVal strCARA As String, Optional VarAux As Variant)
  Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim StrSql As String

    On Error GoTo TrataError
    
    
    StrSql = " EXEC UT_AsignarCaraPtoVtaProc '" & StrPtoVta & "','" & strCARA & "'"
    
    Set cmd = New ADODB.Command
    cmd.CommandText = StrSql
      
      
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = con
       
    cmd.Execute
    
    'GetObjectContext.SetComplete
        
    Exit Sub
    
TrataError:
       
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     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.AsignarCaraaPtoVenta", LStrMensajeError
End Sub
Public Sub EliminarCarasdePtoVenta(ByVal StrPtoVta As String, Optional VarAux As Variant)
  Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim StrSql As String

    On Error GoTo TrataError
    
    
    StrSql = " EXEC UT_EliminarCaradePtoVtaProc '" & StrPtoVta & "'"
    
    Set cmd = New ADODB.Command
    cmd.CommandText = StrSql
      
      
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = con
       
    cmd.Execute
    
    'GetObjectContext.SetComplete
        
    Exit Sub
    
TrataError:
       
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     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.UT_EliminarCaradePtoVtaProc", LStrMensajeError
End Sub

Public Sub VaciarTran(ByVal strCARA As String, Optional VarAux As Variant)
  Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim StrSql As String

    On Error GoTo TrataError
    
    
'    strSQL = "DELETE FROM  tran" & Trim(strCARA)
'
'    Set cmd = New ADODB.Command
'    cmd.CommandText = strSQL
'
'
'    Set con = New ADODB.Connection
'    con.Open "FILEDSN=Gasboy"
'    cmd.ActiveConnection = con
'
'    cmd.Execute
'
'    'GetObjectContext.SetComplete
        
    Exit Sub
    
TrataError:
       
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     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.VaciarTran", LStrMensajeError
End Sub

Public Sub ActivarMangueras(Optional VarAux As Variant)
  Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim StrSql As String

    On Error GoTo TrataError
    
    
'    strSQL = " Update TURNO set STOP=.F."
'
'    Set cmd = New ADODB.Command
'    cmd.CommandText = strSQL
'
'
'    Set con = New ADODB.Connection
'    con.Open "FILEDSN=Gasboy"
'    cmd.ActiveConnection = con
'
'    cmd.Execute
'
'    'GetObjectContext.SetComplete
        
    Exit Sub
    
TrataError:
       
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     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.ActivarMangueras", LStrMensajeError
End Sub

Public Sub ActualizaTurnoActual(ByVal intTURNO As Integer, Optional VarAux As Variant)
  Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim StrSql As String

    On Error GoTo TrataError
    
    
    StrSql = " EXEC ActualizaTurnoActualProc " & intTURNO
    
    Set cmd = New ADODB.Command
    cmd.CommandText = StrSql
      
      
    Set con = New ADODB.Connection
    con.Open "FILEDSN=Conexionsies"
    cmd.ActiveConnection = con
       
    cmd.Execute
     
    'GetObjectContext.SetComplete
        
    Exit Sub
    
TrataError:
       
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     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.ActualizaTurnoActual", LStrMensajeError
End Sub

Public Function ListarTransacdeCara(ByVal strCARA As String, Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
         
   'strSQL = " Select * FROM tran" & Trim(strCARA) & " WHERE ESTADO!='CANCEL' " & _
             " Order by Fecha,Hora ASC"
             
   'Set rs = New ADODB.Recordset
   'rs.CursorLocation = adUseClient
   'rs.Open strSQL, "FILEDSN=Gasboy"
   
   'Set ListarTransacdeCara = rs
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarTransacdeCara", Err.Description
    
End Function

Public Function ListarTransacciones(ByVal strCARA As String, Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
         
'   strSQL = " Select * FROM tran" & Trim(strCARA)
'
'   Set rs = New ADODB.Recordset
'   rs.CursorLocation = adUseClient
'   rs.Open strSQL, "FILEDSN=Gasboy"
'
'   Set ListarTransacciones = rs
'
'   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarTransacciones", Err.Description
    
End Function

Public Function NumeroTransaccionesEnTemporal(ByVal lngCORRNBR As Long, Optional VarAux As Variant) As Long
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
         
   StrSql = " Select * FROM TMP_OP_HISTRANSFUEL WHERE CORRNBR=" & lngCORRNBR
             
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=Conexionsies"
   
   NumeroTransaccionesEnTemporal = rs.RecordCount
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.NumeroTransaccionesEnTemporal", Err.Description
    
End Function

Public Function ActualizarEstadoTransa(ByVal strCARA As String, ByVal StrNumeroTrans As String, ByVal NumeroDocumento As String, Optional VarAux As Variant) As ADODB.Recordset

   Dim StrSql As String
   Dim con As ADODB.Connection
   Dim cmd As ADODB.Command
    
   On Error GoTo ErrorHandler
         
'   strSQL = " Update " & Trim(strCARA) & " set Estado=CANCEL,Documento='" & NumeroDocumento & "'" & _
'            " Where Numero='" & StrNumeroTrans & "'"
'
'   Set con = New ADODB.Connection
'   con.Open "FILEDSN=GASBOY"
'
'   Set cmd.ActiveConnection = con
'   cmd.CommandText
'   cmd.Execute
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:

   If Not con Is Nothing Then
      Set con = Nothing
   End If
   If Not cmd Is Nothing Then
      Set cmd = Nothing
   End If
           
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ActualizarEstadoTransa", Err.Description
    
End Function



Public Function ValidarCaras(ByVal strCARA As String, ByVal StrPuntoVenta As String, Optional VarAux As Variant) As String
    
   Dim strmensaje As String
   Dim StrSql As String
   Dim rs As ADODB.Recordset
   
   On Error GoTo ErrorHandler
   
   Set rs = New ADODB.Recordset
         
   StrSql = " Select Case WHEN '" & strCARA & "' <= QTYSIDE THEN 'SI' " & _
            " Else 'NO' END As [RESULTADO] From SETUP "
   
   
   rs.Open StrSql, "FILEDSN=conexionsies", adOpenStatic
           
   If rs.EOF Then
      strmensaje = "No existe Número de Caras en Setup"
   Else
      If rs!RESULTADO = "NO" Then
        strmensaje = "Número de Cara no Existe"
      Else
        strmensaje = Empty
      End If
   End If
      
   If strmensaje = Empty Then
      rs.Close
      StrSql = "SELECT SIDE from OP_SALESPOINTVSSIDE where SIDE ='" & strCARA & "' AND SALESPOINT='" & StrPuntoVenta & "'"
      rs.Open StrSql, "FILEDSN=conexionsies", adOpenStatic
      
      If rs.EOF Then
         strmensaje = "Número de Cara no está asignada a Punto de Venta"
      Else
         strmensaje = Empty
      End If
   End If
   ValidarCaras = strmensaje
      
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:

   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
           
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ValidarCaras", Err.Description

End Function


Public Function AgregarEnTemporalDeTransacciones(ByVal lngCORRNBR As Long, ByVal strNUMERO As String, ByVal strSOLES As String, _
                                                  ByVal strPRODUCTO As String, ByVal strPRECIO As String, ByVal strGALONES As String, _
                                                  ByVal strCARA As String, strFECHA As String, ByVal strHORA As String, _
                                                  ByVal strESTADO As String, ByVal strDOCUMENTO As String, ByVal datFECHAPROCESO As Date, Optional VarAux As Variant)

   Dim StrSql As String
   Dim cmd As ADODB.Command
   Dim con As ADODB.Connection
    
   On Error GoTo ErrorHandler
         
   StrSql = " EXEC Tmp_Op_HistransFuelInsProc " & lngCORRNBR & ",'" & strNUMERO & "','" & strSOLES & "','" & _
                                                strPRODUCTO & "','" & strPRECIO & "','" & strGALONES & "','" & _
                                                strCARA & "','" & strFECHA & "','" & strHORA & "','" & _
                                                strESTADO & "','" & strDOCUMENTO & "','" & Format(datFECHAPROCESO, "YYYY/DD/MM") & "'"

    Set cmd = New ADODB.Command
    cmd.CommandText = StrSql
      
      
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = con
       
    cmd.Execute
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:

   If Not con Is Nothing Then
      Set con = Nothing
   End If
   If Not cmd Is Nothing Then
      Set cmd = Nothing
   End If
           
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.AgregarEnTemporalDeTransacciones", Err.Description
    
End Function

Public Function GrabarTransacciones(ByVal lngCORRNBR As Long, Optional VarAux As Variant)

   Dim StrSql As String
   Dim cmd As ADODB.Command
   Dim con As ADODB.Connection
    
   On Error GoTo ErrorHandler
         
   StrSql = " EXEC Op_HistransFuelInsProc " & lngCORRNBR

    Set cmd = New ADODB.Command
    cmd.CommandText = StrSql
      
      
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = con
       
    cmd.Execute
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:

   If Not con Is Nothing Then
      Set con = Nothing
   End If
   If Not cmd Is Nothing Then
      Set cmd = Nothing
   End If
           
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.GrabarTransacciones", Err.Description
    
End Function

' ESTE PROCEDIMIENTO REEMPLAZA A LA ANTERIOR GrabarTransacciones
' POR IDEA DE GROBER PUCHUC
Public Sub GrabarTransaccionesAlHistorico(Optional VarAux As Variant)

   Dim StrSql As String
   Dim cmd As ADODB.Command
   Dim con As ADODB.Connection
    
   On Error GoTo ErrorHandler
         
   StrSql = " EXEC CARGA_TRANHIST_PROC "

    Set cmd = New ADODB.Command
    cmd.CommandText = StrSql
      
      
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = con
       
    cmd.Execute
   
   'GetObjectContext.SetComplete
   
   Exit Sub
ErrorHandler:

   If Not con Is Nothing Then
      Set con = Nothing
   End If
   If Not cmd Is Nothing Then
      Set cmd = Nothing
   End If
           
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.GrabarTransaccionesAlHistorico", Err.Description
    
End Sub

         





Public Function Auxiliar1(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar1", Err.Description
End Function


Public Function Auxiliar2(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar2", Err.Description
End Function

Public Function Auxiliar3(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar3", Err.Description
End Function

Public Function Auxiliar4(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar4", Err.Description
End Function

Public Function Auxiliar5(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar5", Err.Description
End Function


Public Function Auxiliar6(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar6", Err.Description
End Function

Public Function Auxiliar7(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar7", Err.Description
End Function

Public Function Auxiliar8(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar8", Err.Description
End Function

Public Function Auxiliar9(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar9", Err.Description
End Function

Public Function Auxiliar10(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_DISPENSADORES.Auxiliar10", Err.Description
End Function









