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_ALMACEN"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Clase C_ALMACEN
' Funciones Básicas de Mantenimiento
'               AgregarAlmacen
'               EliminarAlmacen
'               ActualizarAlmacen
'               ListarPorAlmacenID
'               ListarAlmacenes
'               almacenoriginal
Option Explicit

Public Sub AgregarAlmacen(ByVal strSITEID As String, ByVal strNAME As String, _
                          ByVal strADDR1 As String, ByVal strADDR2 As String, ByVal strCITYID As String, ByVal strCOUNTRY As String, ByVal strFONO1 As String, _
                          ByVal strFONO2 As String, ByVal strFAX As String, ByVal BytStatus As Byte, _
                          ByVal datSTARTDATEINVEN As Date, ByVal datENDDATEINVEN As Date, ByVal bytADJUST As Byte, ByVal strATTN As String, ByVal strCodigoUsuario 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  SP_InsProcSITE '" & strSITEID & "','" & strCITYID & "','" & strCOUNTRY & "','" & strNAME & "','" & _
                                    strADDR1 & "','" & strADDR2 & "','" & strFONO1 & "','" & _
                                    strFONO2 & "','" & strFAX & "','" & BytStatus & "','" & _
                                    Format(datSTARTDATEINVEN, "YYYY/DD/MM") & "','" & Format(datENDDATEINVEN, "YYYY/DD/MM") & _
                                    "','" & bytADJUST & "','" & strATTN & "','" & strCodigoUsuario & "'"
                                

    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_INV_MANTENIMIENTOS.AgregarAlmacen", LStrMensajeError
     
End Sub

Public Sub EliminarAlmacen(ByVal strSITEID As String, Optional VarAux As Variant)
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_DelProcSITE '" & strSITEID & "'"
    
    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_INV_MANTENIMIENTOS.EliminarAlmacen", LStrMensajeError

End Sub

Public Sub ActualizarAlmacen(ByVal strSITEID As String, ByVal strNAME As String, _
                             ByVal strADDR1 As String, ByVal strADDR2 As String, ByVal strCITYID As String, ByVal strCOUNTRY As String, ByVal strFONO1 As String, _
                             ByVal strFONO2 As String, ByVal strFAX As String, ByVal BytStatus As Byte, _
                             ByVal datSTARTDATEINVEN As Date, ByVal datENDDATEINVEN As Date, ByVal bytADJUST As Byte, ByVal strATTN As String, ByVal strCodigoUsuario As String, Optional VarAux As Variant)
           
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_UpdProcSITE '" & strSITEID & "','" & strCITYID & "','" & strCOUNTRY & "','" & strNAME & "','" & _
                                    strADDR1 & "','" & strADDR2 & "','" & strFONO1 & "','" & _
                                    strFONO2 & "','" & strFAX & "','" & BytStatus & "','" & _
                                    Format(datSTARTDATEINVEN, "YYYY/DD/MM") & "','" & _
                                    Format(datENDDATEINVEN, "YYYY/DD/MM") & "','" & bytADJUST & "','" & strATTN & "','" & strCodigoUsuario & "'"
                                
    
    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_INV_MANTENIMIENTOS.ActualizarAlmacen", LStrMensajeError
 
End Sub

Public Function ListarPorAlmacenID(ByVal strSITEID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_SelProcSITE '" & strSITEID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
     
    Set ListarPorAlmacenID = rs
     
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.C_ALMACEN.ListarPorAlmacenID", Err.Description

End Function

Public Function ObtenerDescripcionAlmacen(ByVal strSITEID As String, Optional VarAux As Variant) As String
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT NAME FROM SITE WHERE SITEID='" & strSITEID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
     
    ObtenerDescripcionAlmacen = rs!Name
     
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.C_ALMACEN.ObtenerDescripcionAlmacen", Err.Description

End Function

Public Function ListarAlmacenes(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM Site"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    Set ListarAlmacenes = rs
    
    ''GetObjectContext.SetComplete
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.C_ALMACEN.ListarAlmacenes", Err.Description

End Function

Public Function ListarAlmacenesAyuda(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT SITEID,NAME FROM Site order by siteid"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set ListarAlmacenesAyuda = rs
    
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.ListarAlmacenesAyuda", Err.Description

End Function
Public Function ListarAlmacenesPorStatus(ByVal BytStatus As Byte, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT SITEID,NAME FROM Site where status=" & BytStatus
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarAlmacenesPorStatus = rs
    
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.ListarAlmacenesPorStatus", Err.Description

End Function

Public Function ListarAlmacenesPorStatus2(ByVal BytStatus As Byte, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT SITEID,NAME,0 FROM Site where status=" & BytStatus
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarAlmacenesPorStatus2 = rs
    
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.ListarAlmacenesPorStatus2", Err.Description

End Function

Public Function Almacenoriginal(Optional VarAux As Variant) As String
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT sourceSITE FROM Setup "
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Almacenoriginal = rs!sourcesite
    
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.Almacenoriginal", Err.Description

End Function

Public Function ObtenerFechaIniciodeToma(ByVal strSITEID As String, Optional VarAux As Variant) As Date
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT startdateinven from site where siteid='" & strSITEID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    ObtenerFechaIniciodeToma = rs!startdateinven
    
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    ''GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.ObtenerFechaIniciodeToma", Err.Description

End Function

Public Function estadoinventarioAlmacen(Optional VarAux As Variant) As Boolean
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    On Error GoTo TrataError
    
    strSQL = " SELECT stkfisi FROM in_Setup "
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    estadoinventarioAlmacen = rs!stkfisi
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    ''GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.estadoinventarioAlmacen", Err.Description

End Function

Public Function ESTADO_AJUSTE(Optional VarAux As Variant) As Byte
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    On Error GoTo TrataError
    
    strSQL = " SELECT ADJUST FROM  VW_ADJUST "
    
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenDynamic, adLockBatchOptimistic
    ''GetObjectContext.SetComplete
    
     ESTADO_AJUSTE = rs!ADJUST
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    ''GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.ESTADO_AJUSTE", Err.Description
End Function

Public Function diferencias_excedidas(Optional VarAux As Variant) As Byte
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    On Error GoTo TrataError
    
    strSQL = " SELECT *  FROM VW_DIF_MAXIMAS"
    
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenDynamic, adLockBatchOptimistic
    
    ''GetObjectContext.SetComplete
    
    diferencias_excedidas = rs.EOF
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    ''GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_INV_MANTENIMIENTOS.diferencias_excedidas", Err.Description
End Function
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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.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_INV_ARTICULO.C_ARTICULO.Auxiliar10", Err.Description
End Function
