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

Public Sub RecalcularStock(Optional ByVal StrArticulo As String, Optional ByVal IntTipo As Integer = 0, Optional VarAux As Variant)
 Dim cmd As ADODB.Command
 Dim con As ADODB.Connection
 Dim StrSql As String
 
 On Error GoTo ErrorHandler
    
    If IntTipo = 0 Then
      StrSql = " UT_RECALCULO_STOCK_PROC "
    End If
    
    If IntTipo = 1 Then
      StrSql = " UT_RECALCULO_STOCK_ARTICULO_PROC '" & StrArticulo & "'"
    End If

    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:
 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_UT_MANTENIMIENTOS.C_PROCESOS.RecalcularStock", LStrMensajeError
     
End Sub

Public Sub CalcularCostoPromedio(ByVal lngCORRNBR As Long, ByVal strCURYID As String, ByVal strDiaInicio As String, _
                                 ByVal strDiaFin As String, ByVal strMes As String, ByVal strMesH As String, _
                                 ByVal strAnio As String, ByVal strSITEID As String, ByVal strCATEGORIA As String, _
                                 ByVal bytAlmacen As Byte, ByVal bytCategoria As Byte, Optional VarAux As Variant)
 
 Dim cmd As ADODB.Command
 Dim con As ADODB.Connection
 Dim StrSql As String
 
 On Error GoTo ErrorHandler
    
    StrSql = " CALCULA_CTO_PROMEDIO_PROC " & lngCORRNBR & ",'" & strCURYID & "','" & strDiaInicio & "','" & _
                                            strMes & "','" & strAnio & "','" & strDiaInicio & "','" & _
                                            strMes & "','" & strAnio & "','" & strMesH & "','" & _
                                            strDiaFin & "','" & strMes & "','" & strAnio & "','" & strSITEID & "',""" & _
                                            strCATEGORIA & """," & bytAlmacen & "," & bytCategoria

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

ErrorHandler:
 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_UT_MANTENIMIENTOS.C_PROCESOS.CalcularCostoPromedio", LStrMensajeError
     
End Sub


Public Sub Cierre_de_Mes(ByVal lngCORRNBR As Long, ByVal strCURYID As String, ByVal strDiaInicio As String, _
                                 ByVal strDiaFin As String, ByVal strMes As String, ByVal strMesH As String, _
                                 ByVal strAnio As String, ByVal strSITEID As String, ByVal strCATEGORIA As String, _
                                 ByVal bytAlmacen As Byte, ByVal bytCategoria As Byte, Optional VarAux As Variant)
 
 Dim cmd As ADODB.Command
 Dim con As ADODB.Connection
 Dim StrSql As String
 
 On Error GoTo ErrorHandler
    
    StrSql = " CIERRE_DE_MES_PROC " & lngCORRNBR & ",'" & strCURYID & "','" & strDiaInicio & "','" & _
                                            strMes & "','" & strAnio & "','" & strDiaInicio & "','" & _
                                            strMes & "','" & strAnio & "','" & strMesH & "','" & _
                                            strDiaFin & "','" & strMes & "','" & strAnio & "','" & strSITEID & "',""" & _
                                            strCATEGORIA & """," & bytAlmacen & "," & bytCategoria

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

ErrorHandler:
 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_UT_MANTENIMIENTOS.C_PROCESOS.Cierre_de_Mes", LStrMensajeError
     
End Sub

Public Function ObtenerDetalleTablasTranferencia(Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = " SELECT TABLEID AS Codigo,TABLENAME AS Nombre,SEQUENCE AS Secuencia,DATEFIELD as Campo,CASE CENTRAL_TO_STATION WHEN 1 THEN 'SI' ELSE '' END AS A_Estacion, " & _
            " CASE STATION_TO_CENTRAL WHEN 1 THEN 'SI' ELSE '' END as A_Central,CASE PERSITE WHEN 1 THEN 'SI' ELSE '' END  AS PorSIte,CASE RLSED WHEN 1 THEN 'SI' ELSE '' END AS Emision,TYPE,MODULEID,COMMENTS " & _
            " FROM SH_SHIPPINGTABLES "
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   Set ObtenerDetalleTablasTranferencia = 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.ObtenerDetalleTablasTranferencia", Err.Description
    
End Function

Public Sub ActualizarTablaTranferencia(ByVal strTABLEID As String, ByVal lngSEQUENCE As Long, ByVal strDATEFIELD As String, _
                                        ByVal bytCENTRAL_TO_STATION As Byte, ByVal bytSTATION_TO_CENTRAL As Byte, ByVal bytPERSITE As Byte, _
                                        ByVal bytRLSED As Byte, ByVal strCOMMENTS As String, Optional VarAux As Variant)
    Dim con As ADODB.Connection
    Dim StrSql As String
    
    On Error GoTo TrataError
    
    StrSql = " EXEC SH_SHIPPINGTABLESUpd_Proc '" & strTABLEID & "'," & lngSEQUENCE & ",'" & strDATEFIELD & "'," & _
                                               bytCENTRAL_TO_STATION & "," & bytSTATION_TO_CENTRAL & "," & bytPERSITE & "," & _
                                               bytRLSED & ",'" & strCOMMENTS & "'"
    
    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.ActualizarTablaTranferencia", LStrMensajeError

End Sub

Public Function ObtenerCabecerasResumenesInventario(Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = " SELECT * FROM IN_SUMMARY_INTRAHEAD "
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   Set ObtenerCabecerasResumenesInventario = 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.ObtenerCabecerasResumenesInventario", Err.Description
    
End Function

Public Function ObtenerDetallesResumenesInventario(Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = " SELECT * FROM IN_SUMMARY_INTRAITEM "
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   Set ObtenerDetallesResumenesInventario = 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.ObtenerDetallesResumenesInventario", Err.Description
    
End Function

Public Function ObtenerCabecerasResumenesVentas(Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = " SELECT * FROM OP_SUMMARYSALES "
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   Set ObtenerCabecerasResumenesVentas = 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.ObtenerCabecerasResumenesVentas", Err.Description
    
End Function

Public Function ObtenerDetallesResumenesVentas(Optional VarAux As Variant) As ADODB.Recordset
   Dim StrSql As String
   Dim rs As ADODB.Recordset
    
   On Error GoTo ErrorHandler
      
   StrSql = " SELECT * FROM OP_SUMMARYSALESDET "
          
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open StrSql, "FILEDSN=conexionsies"
                    
   Set ObtenerDetallesResumenesVentas = 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.ObtenerDetallesResumenesVentas", 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 = VarAux1
    
    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 LVarNumeroError, "DB_UT_MANTENIMIENTOS.Auxiliar1", LStrMensajeError
     
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_PROCESOS.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_PROCESOS.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_PROCESOS.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_PROCESOS.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_PROCESOS.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_PROCESOS.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_PROCESOS.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_PROCESOS.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_PROCESOS.Auxiliar10", Err.Description
End Function

