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_TIPOMOVIMIENTO"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Clase C_TIPOMOVIMIENTO
' Funciones Básicas de Mantenimiento
'               AgregarTipoMovimiento
'               EliminarTipoMovimiento
'               ActualizarTipoMovimiento
'               ListarPorTiposMovimientoID
'               ListarTiposMovimientos
Option Explicit

Public Sub AgregarTipoMovimiento(ByVal strTYPEDOCID As String, ByVal strDESCR As String, _
                                 ByVal bytINOUT As Byte, ByVal bytSTKVALUE As Byte, ByVal bytSTKCOSPRICE As Byte, _
                                 ByVal bytSTKAVGCOST As Byte, ByVal strPRELVLID As String, _
                                 ByVal bytSTKBUY As Byte, ByVal bytSTKVENDOR As Byte, ByVal bytSTKAVERAGE As Byte, ByVal strDESCR_ABR As String, ByVal strMostrar 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 IN_TypeDocInsProc '" & strTYPEDOCID & "','" & strDESCR & "'," & _
                                            bytINOUT & "," & bytSTKVALUE & "," & bytSTKCOSPRICE & "," & _
                                            bytSTKAVGCOST & ",'" & strPRELVLID & "'," & bytSTKBUY & "," & _
                                            bytSTKVENDOR & "," & bytSTKAVERAGE & ",'" & strDESCR_ABR & "','" & strMostrar & "'"

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

End Sub

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

End Sub

Public Sub ActualizarTipoMovimiento(ByVal strTYPEDOCID As String, ByVal strDESCR As String, _
                                    ByVal bytINOUT As Byte, ByVal bytSTKVALUE As Byte, ByVal bytSTKCOSPRICE As Byte, _
                                    ByVal bytSTKAVGCOST As Byte, ByVal strPRELVLID As String, _
                                    ByVal bytSTKBUY As Byte, ByVal bytSTKVENDOR As Byte, ByVal bytSTKAVERAGE As Byte, ByVal strDESCR_ABR As String, ByVal strMostrar As String, Optional VarAux As Variant)
    
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC IN_TypeDocUpdProc '" & strTYPEDOCID & "','" & strDESCR & "'," & _
                                            bytINOUT & "," & bytSTKVALUE & "," & bytSTKCOSPRICE & "," & _
                                            bytSTKAVGCOST & ",'" & strPRELVLID & "'," & bytSTKBUY & "," & _
                                            bytSTKVENDOR & "," & bytSTKAVERAGE & ",'" & strDESCR_ABR & "','" & strMostrar & "'"

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

End Sub

Public Function ListarPorTiposMovimientoID(ByVal strTYPEDOCID 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_SelProcIn_TypeDoc '" & strTYPEDOCID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set ListarPorTiposMovimientoID = 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.ListarPorTiposMovimientoID", Err.Description

End Function

Public Function ListarTiposMovimientos(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM In_TypeDoc "
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarTiposMovimientos = 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.ListarTiposMovimientos", Err.Description

End Function

' Función que devuelve un recordset especialmente
' para las ayudas

Public Function ListarTiposMovimientosAyuda(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT TypeDocId,Descr FROM In_TypeDoc "
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set ListarTiposMovimientosAyuda = 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.ListarTiposMovimientosAyuda", Err.Description

End Function

Public Function ListarPorTipoMovimiento(ByVal strINOUT As String, Optional VarAux As Variant) As Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    ' PARA FILTRAR LOS MOVIMIENTOS POR DESEMSAMBLE
    strSQL = " SELECT INTYPEDESIN,INTYPEDESOUT FROM IN_SETUP "

    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    If strINOUT = "1" Then
        strSQL = " SELECT TypeDocId,Descr FROM In_TypeDoc where INOUT='" & strINOUT & "' AND TYPEDOCID<>'" & rs!INTYPEDESIN & "' AND STKDISPLAY=1"
    Else
        'SE PUEDE HACER DE TODO EN SALIDAS
        strSQL = " SELECT TypeDocId,Descr FROM In_TypeDoc where INOUT='" & strINOUT & "' AND STKDISPLAY=1"
    End If
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarPorTipoMovimiento = 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.ListarPorTipoMovimiento", Err.Description

End Function

Public Function ListarTipoMovimientoDes(ByVal strINOUT As String, Optional VarAux As Variant) As Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT TypeDocId,Descr FROM In_TypeDoc where INOUT='" & strINOUT & "'"

    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarTipoMovimientoDes = 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.ListarPorTipoMovimiento", Err.Description

End Function


' FUNCION QUE VERIFICA SI UN MOVIMIENTO ES DE TIPO COMPRA
' DATO DE ENTRADA : CODIGO DEL MOVIMIENTO

Public Function MovimientoPorCompra(ByVal strTYPEDOCID As String, Optional VarAux As Variant) As Boolean
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    
    strSQL = " SELECT STKBUY FROM IN_TYPEDOC WHERE TYPEDOCID='" & strTYPEDOCID & "'"
    
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic

    If rs.RecordCount <> 0 Then
        MovimientoPorCompra = rs!STKBUY
    Else
        MovimientoPorCompra = True
    End If
    '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.MovimientoPorCompra", Err.Description

End Function

Public Function CodigoMovimientoDes(ByVal strINOUT As String, Optional VarAux As Variant) As String
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT INTYPEDESIN,INTYPEDESOUT FROM IN_SETUP "

    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    If strINOUT = "1" Then
        CodigoMovimientoDes = rs!INTYPEDESIN
    Else
        CodigoMovimientoDes = rs!INTYPEDESOUT
    End If
    
    '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.ListarPorTipoMovimiento", 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
