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_PROVEEDOR"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Clase C_PROVEEDOR
' Funciones Básicas de Mantenimiento
'               AgregarProveedor
'               EliminarProveedor
'               ActualizarProveedor
'               ListarPorProveedorID
'               ListarProveedores
Option Explicit

Public Sub AgregarProveedor(ByVal strVENDIDSS As String, ByVal strCITYID As String, ByVal strCOUNTRYID As String, ByVal strCLASSVENDORID As String, _
                            ByVal strTERMID As String, ByVal strVENDORID As String, ByVal strDESCR As String, ByVal strCONTACT As String, _
                            ByVal strTAXREGNBR As String, ByVal strADDRES As String, ByVal strADDRES2 As String, ByVal strFONO1 As String, _
                            ByVal strFONO2 As String, ByVal strFAX As String, ByVal strMAIL As String, ByVal strSTATUS As String, ByVal dblCURRBAL As Double, _
                            ByVal strCURYID As String, ByVal strCURYTYPEID As String, ByVal strTAXID 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_InsProcIN_VENDOR '" & strVENDIDSS & "','" & strCITYID & "','" & strCOUNTRYID & "','" & strCLASSVENDORID & "','" & _
                                        strTERMID & "','" & strVENDORID & "','" & strDESCR & "','" & strCONTACT & "','" & _
                                        strTAXREGNBR & "','" & strADDRES & "','" & strADDRES2 & "','" & strFONO1 & "','" & _
                                        strFONO2 & "','" & strFAX & "','" & strMAIL & "','" & strSTATUS & "'," & dblCURRBAL & ",'" & _
                                        strCURYID & "','" & strCURYTYPEID & "','" & strTAXID & "','" & 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.AgregarProveedor", LStrMensajeError
End Sub

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

End Sub

Public Sub ActualizarProveedor(ByVal strVENDIDSS As String, ByVal strCITYID As String, ByVal strCOUNTRYID As String, ByVal strCLASSVENDORID As String, _
                               ByVal strTERMID As String, ByVal strVENDORID As String, ByVal strDESCR As String, ByVal strCONTACT As String, _
                               ByVal strTAXREGNBR As String, ByVal strADDRES As String, ByVal strADDRES2 As String, ByVal strFONO1 As String, _
                               ByVal strFONO2 As String, ByVal strFAX As String, ByVal strMAIL As String, ByVal strSTATUS As String, ByVal dblCURRBAL As Double, _
                               ByVal strCURYID As String, ByVal strCURYTYPEID As String, ByVal strTAXID As String, Optional VarAux As Variant)
           
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_UpdProcIN_VENDOR '" & strVENDIDSS & "','" & strCITYID & "','" & strCOUNTRYID & "','" & strCLASSVENDORID & "','" & _
                                        strTERMID & "','" & strVENDORID & "','" & strDESCR & "','" & strCONTACT & "','" & _
                                        strTAXREGNBR & "','" & strADDRES & "','" & strADDRES2 & "','" & strFONO1 & "','" & _
                                        strFONO2 & "','" & strFAX & "','" & strMAIL & "','" & strSTATUS & "'," & dblCURRBAL & ",'" & _
                                        strCURYID & "','" & strCURYTYPEID & "','" & strTAXID & "'"
    
    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.ActualizarProveedor", LStrMensajeError

End Sub

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

End Function

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

End Function


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

End Function


Public Function ListarArticulosPorProveedor(ByVal strVENDIDSS As String, ByVal strSITEID As String, ByVal bytVALOR1 As Byte, ByVal bytVALOR2 As Byte, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC IN_ArticulosPorProveedorAlmacenProc '" & strVENDIDSS & "','" & strSITEID & "'," & bytVALOR1 & "," & bytVALOR2
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
      
    Set ListarArticulosPorProveedor = 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.ListarArticulosPorProveedor", Err.Description

End Function

Public Function ObtenerTipoCambio(ByVal strVENDIDSS As String, ByVal strCURYID As String, ByVal datFecha As Date, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " Exec ObtieneTipoCambioProc '" & strVENDIDSS & "','" & strCURYID & "','" & Format(datFecha, "YYYY/DD/MM") & "'"
        
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    
    Set ObtenerTipoCambio = 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_MOVIMIENTOS.ObtenerTipoCambio", 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
