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_inventario"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'CLASE TOMA INVENTARIO
'FUNCIONES
' 1              ACTIVAR INVENTARIO.
' 2              DESACTIVAR INVENTARIO.
' 3              CIERRE INVENTARIO.
' 4              ACTUALIZA_CATEGORIA.
' 6              ACTUALIZA_SUBCATEGORIA.
' 8              Actualiza ARTICULO.
' 1              CAT_DISPONIBLES
' 11             SUBCAT_DISPONIBLES
' 12             ART_DISPONIBLES
' 13             CAT_SELECCIONADAS
' 14             SCAT_SELECCIONADAS
' 15             ART_SELECCIONADOS
Option Explicit
Public Function ACTIVAR_TOMAINVENTARIO() As Integer
   Dim cmd As ADODB.Command
   Dim CON As ADODB.Connection
    Dim prm As ADODB.Parameter
   Dim strSQL As String
   
   On Error GoTo TrataError
   strSQL = " EXEC in_inicioinventario_proc "
   
   Set cmd = New Command
   
   Set prm = cmd.CreateParameter("return", adInteger, adParamReturnValue, , 0)
   cmd.Parameters.Append prm
   
   cmd.CommandText = strSQL
      
   Set CON = New Connection
   CON.Open "FILEDSN=conexionsies"
   cmd.ActiveConnection = CON
   cmd.Execute
    
    ACTIVAR_TOMAINVENTARIO = cmd("return")
    ' GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    If Not CON Is Nothing Then
        Set CON = Nothing
    End If
    
    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function

Public Function DESACTIVAR_TOMAINVENTARIO() As Integer

    Dim cmd As ADODB.Command
    Dim CON As ADODB.Connection
    Dim prm As ADODB.Parameter
    
    Dim strSQL As String
    On Error GoTo TrataError
    strSQL = " EXEC in_fininventario_proc "
    Set cmd = New Command
    Set prm = cmd.CreateParameter("return", adInteger, adParamReturnValue, , 0)
    cmd.Parameters.Append prm
   
    cmd.CommandText = strSQL
      
    Set CON = New Connection
    CON.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = CON
    cmd.Execute
    DESACTIVAR_TOMAINVENTARIO = cmd("return")
    ' GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    If Not CON Is Nothing Then
        Set CON = Nothing
    End If
    
    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function
Public Sub CIERRE_INVENTARIO()
    Dim cmd As ADODB.Command
    Dim CON As ADODB.Connection
    Dim strSQL As String
    On Error GoTo TrataError
    strSQL = " EXEC "
    Set cmd = New Command
    cmd.CommandText = strSQL
    Set CON = New Connection
    CON.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = CON
    cmd.Execute
    ' GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    If Not CON Is Nothing Then
        Set CON = Nothing
    End If
    
    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Sub
Public Sub ACTUALIZA_CATEGORIA(ByVal STRLISTA As String)
    Dim cmd As ADODB.Command
    Dim CON As ADODB.Connection
    Dim strSQL As String
    'On Error GoTo TrataError
    
    strSQL = " EXEC in_actualizatoma_CAT_proc """ + STRLISTA + """"
    
    Set cmd = New Command
    cmd.CommandText = strSQL
    Set CON = New Connection
    CON.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = CON
    cmd.Execute
    ' GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    If Not CON Is Nothing Then
        Set CON = Nothing
    End If
    
    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Sub

Public Sub ACTUALIZA_SUBCATEGORIA(ByVal STRLISTA As String, ByVal intnume As Integer)
    Dim cmd As ADODB.Command
    Dim CON As ADODB.Connection
    Dim strSQL As String
   
   Dim LSTR_TEMPO As String
   Dim I As Integer
   Dim LINT_POS As Integer
   Dim LINT_POSF As Integer
   
    Set cmd = New Command
    cmd.CommandText = strSQL
    Set CON = New Connection
  
    CON.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = CON
    
    strSQL = " EXEC in_borrar_cluster "
    
    cmd.CommandText = strSQL
    cmd.Execute
    
    'For I = 1 To intnume
    '    LINT_POS = InStr(2, STRLISTA, "'")
    '    LSTR_TEMPO = Mid(STRLISTA, 2, LINT_POS - 2)
    '
    '    strSQL = " EXEC IN_AGREGAR_SCAT_PROC '" + LSTR_TEMPO + "'"
    '     cmd.CommandText = strSQL
    '    cmd.Execute
   '
   '     STRLISTA = Mid(STRLISTA, LINT_POS + 2)
   ' Next
   Dim prm As ADODB.Parameter
'   Set prm = New ADODB.Parameter
    
   ' Set prm = cmd.CreateParameter("kikin", adLongVarChar, adParamInput, , STRLISTA)
   'cmd.Parameters.Append prm
   
   
    strSQL = "IN_AGREGAR_SCAT_PROC "
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = strSQL
     Set prm = cmd.CreateParameter("kikin", adVarChar, adParamInput, 8000, STRLISTA)
   cmd.Parameters.Append prm
 
    cmd.Execute
   
   
        
    strSQL = " EXEC in_actualizatoma_SCAT_proc "
    cmd.CommandText = strSQL
    cmd.Execute
    
     'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    If Not CON Is Nothing Then
        Set CON = Nothing
    End If
    
    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Sub
Public Sub ACTUALIZA_articulo(ByVal STRLISTA As String, ByVal intnume As Integer, ByVal STRLISTA2 As String, ByVal intnume2 As Integer)
    Dim cmd As ADODB.Command
    Dim CON As ADODB.Connection
    Dim strSQL As String
   
   Dim LSTR_TEMPO As String
   Dim I As Integer
   Dim LINT_POS As Integer
   Dim LINT_POSF As Integer
   
    Set cmd = New Command
    cmd.CommandText = strSQL
    Set CON = New Connection
  
    CON.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = CON
         
    'borra los articulos deseleccionados
    For I = 1 To intnume
        LINT_POS = InStr(2, STRLISTA, "'")
        LSTR_TEMPO = Mid(STRLISTA, 2, LINT_POS - 2)
        
        strSQL = " EXEC IN_eliminar_art_cluster_PROC '" + LSTR_TEMPO + "'"
         cmd.CommandText = strSQL
       cmd.Execute
    
        STRLISTA = Mid(STRLISTA, LINT_POS + 2)
    Next
        
        
    'agrega  los articulos seleccionados
    For I = 1 To intnume2
        LINT_POS = InStr(2, STRLISTA2, "'")
        LSTR_TEMPO = Mid(STRLISTA2, 2, LINT_POS - 2)
        
        strSQL = " EXEC in_actualizatoma_art_proc '" + LSTR_TEMPO + "'"
         cmd.CommandText = strSQL
         MsgBox "AGREGANDO " + LSTR_TEMPO
       cmd.Execute
    
        STRLISTA2 = Mid(STRLISTA2, LINT_POS + 2)
    Next
    
    
     'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    If Not CON Is Nothing Then
        Set CON = Nothing
    End If
    
    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Sub

Public Function CAT_DISPONIBLES() As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM VW_catdisponibles_cluster"
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    ' GetObjectContext.SetComplete
    
    Set CAT_DISPONIBLES = rs
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function

Public Function SCAT_DISPONIBLES() As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM VW_subcatdisponibles_cluster"
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    ' GetObjectContext.SetComplete
    
    Set SCAT_DISPONIBLES = rs
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function

Public Function ART_DISPONIBLES(ByVal STRSUBCAT As String) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    strSQL = " SELECT * FROM VW_ARTDISPONIBLES_CLUSTER WHERE CLASSUBID='" + STRSUBCAT + "'"
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    ' GetObjectContext.SetComplete
    
    Set ART_DISPONIBLES = rs
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function


'******************************************************************
Public Function CAT_SELECCIONADAS() As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM VW_catseleccionadas_cluster "
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    ' GetObjectContext.SetComplete
    
    Set CAT_SELECCIONADAS = rs
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function

Public Function SCAT_SELECCIONADAS() As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM VW_subcatseleccionadas_cluster"
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    ' GetObjectContext.SetComplete
    
    Set SCAT_SELECCIONADAS = rs
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function

Public Function ART_SELECCIONADOS(ByVal STRSUBCAT As String) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM VW_ARTSELECCIONADOS_CLUSTER WHERE CLASSUBID ='" + STRSUBCAT + "'"
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    ' GetObjectContext.SetComplete
    
    Set ART_SELECCIONADOS = rs
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function

Public Function ART_SELECCIONADOS_cat(ByVal STRCAT As String) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM VW_ARTSELECCIONADOS_CLUSTER WHERE CLASSID ='" + STRCAT + "'"
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenDynamic, adLockBatchOptimistic
    
    ' GetObjectContext.SetComplete
    
    Set ART_SELECCIONADOS_cat = rs
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    ' GetObjectContext.SetAbort
    ' Err.Raise Err.Number, SetErrSource(modname, "add"), Err.Description

End Function

