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_SETUP"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True

Public Function ObtenerSetupVentas(Optional VarAux As Variant) As ADODB.Recordset
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "select * from op_setup"
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=" & "conexionsies"
                    
   Set ObtenerSetupVentas = rs
   
   'GetObjectContext.SetComplete
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerSetupVentas", Err.Description
    
End Function

Public Function ObtenerFechaProcesoVentas(Optional VarAux As Variant) As Date
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "select DATEPROCESALES from op_setup"
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=" & "conexionsies"
                    
   ObtenerFechaProcesoVentas = rs!DATEPROCESALES
   
   'GetObjectContext.SetComplete
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerFechaProcesoVentas", Err.Description
    
End Function

Public Function ObtenerFechaProcesoInventarios(Optional VarAux As Variant) As Date
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "select DATEPROCE from setup"
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=" & "conexionsies"
                    
   ObtenerFechaProcesoInventarios = rs!DATEPROCE
   
   'GetObjectContext.SetComplete
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerFechaProcesoInventarios", Err.Description
    
End Function

Public Function ObtenerEstadoVentaCombustible(Optional VarAux As Variant) As Boolean
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "select AUTOMATICSALES from op_setup"
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=" & "conexionsies"
                    
   ObtenerEstadoVentaCombustible = rs!AUTOMATICSALES
   
   'GetObjectContext.SetComplete
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerEstadoVentaCombustible", Err.Description
    
End Function


Public Function ObtenerSetupGeneral(Optional VarAux As Variant) As ADODB.Recordset
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "select * from setup"
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=" & "conexionsies"
                    
   Set ObtenerSetupGeneral = rs
   
   'GetObjectContext.SetComplete
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerSetupGeneral", Err.Description
    
End Function

Public Function ObtenerSetupInventarios(Optional VarAux As Variant) As ADODB.Recordset
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "select *  from in_setup"
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=" & "conexionsies"
                    
   Set ObtenerSetupInventarios = rs
   'GetObjectContext.SetComplete
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerSetupInventarios", Err.Description
    
End Function


Public Sub ActualizarFechasDeProceso(ByVal datFECHAVENTAS As Date, ByVal datFECHAINVENT As Date, ByVal intTurno As Integer, Optional VarAux As Variant)
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    
    If VarAux(1, 1) = 0 Then ' Hay que Actualizar la Fecha de Venta
       strSQL = " EXEC OP_ActualizaFechasdeProcesoVentasProc '" & Format(datFECHAVENTAS, "YYYY/DD/MM") & "','" & VarAux(1, 2) & "'"
    End If
    
    If VarAux(1, 1) = 1 Then ' Hay que Actualizar la Fecha de Inventarios
       strSQL = " EXEC OP_ActualizaFechasdeProcesoInvetariosProc '" & Format(datFECHAINVENT, "YYYY/DD/MM") & "'"
    End If
       
    If VarAux(1, 1) = 2 Then ' Hay que Actualizar el Turno
       strSQL = " EXEC OP_ActualizaTurnoProc " & intTurno
    End If
       

    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, "UTIL_SETUP.ActualizarFechasDeProceso", LStrMensajeError

End Sub

Public Sub ActualizarEstadoVentaManual(ByVal blnESTADO As Boolean, Optional VarAux As Variant)
    
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    If blnESTADO Then
        strSQL = " EXEC ActualizaEstadoVentaCombustibleProc 1"
    Else
        strSQL = " EXEC ActualizaEstadoVentaCombustibleProc 0"
    End If
    
    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, "UTIL_SETUP.ActualizarEstadoVentaManual", LStrMensajeError

End Sub

Public Sub ConfirmarTurno(ByVal intTurno As Integer, ByVal datFecha As Date, Optional VarAux As Variant)
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC ConfirmarTurno_Proc " & intTurno & ",'" & Format(datFecha, "YYYY/DD/MM") & "'"
    
    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, "UTIL_SETUP.ConfirmarTurno", LStrMensajeError

End Sub

Public Function ObtenerMonedaExtranjera(ByVal StrMonedaBase As String, Optional VarAux As Variant) As String
   Dim strSQL As String
   Dim rs As ADODB.Recordset
   Dim cmd As ADODB.Recordset
    
   On Error GoTo errhandler
   
   strSQL = " SELECT CURYID FROM CURRENCY WHERE CURYID NOT IN (SELECT CURYORIG FROM SETUP) "
              
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
                
   If rs.EOF Then
      ObtenerMonedaExtranjera = Empty
   Else
      ObtenerMonedaExtranjera = rs!CURYID
   End If
      
   'GetObjectContext.SetComplete
   Exit Function
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerMonedaExtranjera", Err.Description
End Function

Public Function ObtenerUltimoCierre(Optional VarAux As Variant) As String
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "SELECT CLOSEDMONTH FROM IN_SETUP"
             
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=conexionsies"
                    
   ObtenerUltimoCierre = rs!CLOSEDMONTH
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "UTIL_SETUP.ObtenerUltimoCierre", Err.Description
    
End Function

Public Function Auxiliar1(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
        
    strSQL = " EXEC UT_Abrir_Parte_Diario_Proc '" & Format(VarAux1(1, 1), "yyyymmdd") & "','" & VarAux1(1, 2) & "','" & _
                                                    VarAux1(1, 3) & "'"
        
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    con.Execute strSQL
    
    'GetObjectContext.SetComplete
    
    Exit Function

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 Err.Number, "UTIL_SETUP.Auxiliar1", Err.Description
End Function

Public Function Auxiliar2(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
   
   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = "UT_Verificar_UsuarioProc '" & VarAux1(1, 1) & "'"
             
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=conexionsies"
                    
   If rs.EOF Then
      Auxiliar2 = 0
   Else
      Auxiliar2 = 1
   End If
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "UTIL_SETUP.Auxiliar2", Err.Description
   
End Function

Public Function Auxiliar3(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant

   Dim strSQL As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   strSQL = VarAux1
             
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=conexionsies"
                    
   Set Auxiliar3 = rs
   
   'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "UTIL_SETUP.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, "lib_trasmision.Cls_envios.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, "lib_trasmision.Cls_envios.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, "lib_trasmision.Cls_envios.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, "lib_trasmision.Cls_envios.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, "lib_trasmision.Cls_envios.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, "lib_trasmision.Cls_envios.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, "lib_trasmision.Cls_envios.Auxiliar10", Err.Description
End Function

