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_HIST_PRE_CLI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Historial de Precios para Clientes
' Clase C_HIST_PRE_CLI

Public Sub AgregarHistorialPrecCli(ByVal strPRCLVLCUSTID As String, ByVal strSITEID As String, _
                             ByVal strCURYID As String, ByVal strDESCR As String, ByVal datSTARTDATEPRICE As Date, _
                             ByVal datENDDATEPRICE As Date, ByVal bytAPPROVA1 As Byte, ByVal strUSERIDAPPROVA1 As String, _
                             ByVal datDATETIMEAUTORIZED1 As Date, ByVal bytAPPROVA2 As Byte, ByVal strUSERIDAPPROVA2 As String, _
                             ByVal datDATETIMEAUTORIZED2 As Date, ByVal strSITEIDSOURCE As String, ByVal strTYPEPRCLVLCUST As String, ByVal lngCORREL As Long, Optional VarAux As Variant)
                             
   
    Dim con As ADODB.Connection
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC GrabarCabHistPrecCliProc '" & strPRCLVLCUSTID & "','" & strSITEID & "','" & _
                                strCURYID & "','" & strDESCR & "','" & _
                                Format(datSTARTDATEPRICE, "YYYY/DD/MM") & "','" & Format(datENDDATEPRICE, "YYYY/DD/MM") & "'," & _
                                bytAPPROVA1 & ",'" & strUSERIDAPPROVA1 & "','" & Format(datDATETIMEAUTORIZED1, "YYYY/DD/MM") & "'," & bytAPPROVA2 & ",NULL" & _
                                ",'" & IIf(Year(Format(datDATETIMEAUTORIZED02, "DD/MM/YYYY") < 1900), "1900/01/01", Format(datDATETIMEAUTORIZED02, "YYYY/DD/MM")) & "','" & strSITEIDSOURCE & "','" & strTYPEPRCLVLCUST & "'," & _
                                "NULL,NULL,NULL,NULL," & lngCORREL
                                

    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, con, adOpenStatic
    
    'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:

Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
     If Not rs Is Nothing Then
        Set rs = 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_MA_MANTENIMIENTOS.AgregarHistorialPrecCli", LStrMensajeError
     
End Sub

Public Sub ModificarHistorialPrecCli(ByVal strPRCLVLCUSTID As String, ByVal strSITEID As String, ByVal strDESCR As String, _
                             ByVal datSTARTDATEPRICE As Date, ByVal datENDDATEPRICE As Date, ByVal lngCORREL As Long, Optional VarAux As Variant)
                             
   
    Dim con As ADODB.Connection
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC ModificarListaPrecioCliProc '" & strPRCLVLCUSTID & "','" & strSITEID & "','" & strDESCR & "','" & _
                                Format(datSTARTDATEPRICE, "YYYY/DD/MM") & "','" & Format(datENDDATEPRICE, "YYYY/DD/MM") & "'," & lngCORREL
                                

    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, con, adOpenStatic
    

    'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:

Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
     If Not rs Is Nothing Then
        Set rs = 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_MA_MANTENIMIENTOS.ModificarHistorialPrecCli", LStrMensajeError
     
End Sub

Public Sub AprobarLista(ByVal strPRCLVLCUSTID As String, ByVal strUSUARIO 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 AprobarListaPrecioCli '" & strPRCLVLCUSTID & "','" & strUSUARIO & "'"
    
    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_MA_MANTENIMIENTOS.AprobarLista", LStrMensajeError
End Sub

Public Sub ActualizaEstado(ByVal strPRCLVLCUSTID As String, ByVal bitSTATUS As Byte, Optional VarAux As Variant)
    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    
    strSQL = " EXEC ActualizaEstadoListaPrecioCli '" & strPRCLVLCUSTID & "'," & bitSTATUS
    
    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_MA_MANTENIMIENTOS.ActualizaEstado", LStrMensajeError
End Sub

Public Function BusquedaListadePrecio(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 = " SELECT PRCLVLCUSTID AS Cod_Lista,SITEID AS Almacen,CASE STATUS WHEN 1 THEN 'SI' WHEN 0 THEN 'NO' END AS Activado,CASE STKPRICESEND WHEN 1 THEN 'SI' WHEN 0 THEN 'NO' END AS Aprobado " & _
             " FROM OP_PRCLVLCUST ORDER BY PRCLVLCUSTID,SITEID"
                     
                     
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    Set BusquedaListadePrecio = rs
    
    'GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.BusquedaListadePrecio", Err.Description

End Function

Public Sub CopiarDetalleListaPrecCliAlTemporal(ByVal intCORRNBR As Long, ByVal strPRCLVLCUSTID As String, Optional VarAux As Variant)
    Dim strSQL As String
    Dim con As ADODB.Connection
    
    On Error GoTo TrataError
    
    strSQL = " EXEC CopiaPRCLVLCUSTDETProc " & intCORRNBR & ",'" & strPRCLVLCUSTID & "'"
    
    
    Set con = New Connection
    con.Open "FILEDSN=conexionsies"
    con.Execute strSQL
    
    'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:
    If Not con Is Nothing Then
        Set con = Nothing
    End If
    
    
    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.CopiarDetalleListaPrecCliAlTemporal", Err.Description

End Sub


Public Function ListarArticuloPorAlmacen(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 = " SELECT IN_INVENTORYDAT.INVTIDSKU,IN_INVENTORY.DESCR,IN_INVENTORYDAT.STDCOSTPEN AS COSTO,SLS_PRICE " & _
             " FROM IN_INVENTORY INNER JOIN IN_INVENTORYDAT " & _
             " ON IN_INVENTORY.INVTIDSKU=IN_INVENTORYDAT.INVTIDSKU " & _
             " WHERE SITEID='" & strSITEID & "'"
       
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    Set ListarArticuloPorAlmacen = rs
    
    'GetObjectContext.SetComplete
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.ListarArticuloPorAlmacen", Err.Description

End Function

Public Sub AgregaEnTemporalDetallelleHistPrecCli(ByVal intCORRNBR As Double, ByVal strSITEID As String, ByVal strINVTIDSKU As String, _
                                                 ByVal strDESCR As String, ByVal dblVALOR As Double, ByVal intModalidad As Integer, _
                                                 ByVal intREDONDEO As Integer, ByVal strCURYID As String, ByVal datFecha As Date, ByVal strCURYTYPEID As String, Optional VarAux As Variant)
    Dim strSQL As String
    Dim dblMontoDesc As Double
    Dim dblNuevoPrecio As Double
    Dim dblSLS_PRICE As Double
    Dim rs As ADODB.Recordset
    Dim con As ADODB.Connection
    
    On Error GoTo TrataError
    
    strSQL = "SELECT SLS_PRICE FROM IN_INVENTORYDAT WHERE SITEID='" & strSITEID & "' AND  INVTIDSKU='" & strINVTIDSKU & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    If Not rs.EOF Then
        dblSLS_PRICE = ConvertirValor(rs!SLS_PRICE, strSITEID, strCURYID, datFecha, strINVTIDSKU, strCURYTYPEID, intREDONDEO)
    Else
        dblSLS_PRICE = 0
    End If
    
    If intModalidad = 0 Then ' si le valor ingresado es el monto de descuento
        dblMontoDesc = Round(dblVALOR, intREDONDEO)
        dblNuevoPrecio = Round(dblSLS_PRICE - dblMontoDesc, intREDONDEO)
    Else
            dblNuevoPrecio = Round(dblVALOR, intREDONDEO)
            dblMontoDesc = Round(dblSLS_PRICE - dblNuevoPrecio, intREDONDEO)
    End If
    
    
    strSQL = " EXEC TMP_OP_PRCLVLCUSTDETInsProc " & intCORRNBR & ",'" & strSITEID & "'," & dblMontoDesc & "," & _
                                                 dblSLS_PRICE & "," & dblNuevoPrecio & ",'" & strINVTIDSKU & "','" & strDESCR & "'"
                                                    
    
    Set con = New Connection
    con.Open "FILEDSN=conexionsies"
    con.Execute strSQL
    
    'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:
    If Not con Is Nothing Then
        Set con = Nothing
    End If
    
    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.AgregaEnTemporalDetallelleHistPrecCli", Err.Description

End Sub


Public Sub EliminarItemEnTmpDetalleHistPrecCli(ByVal strINVTIDSKU As String, ByVal intCORRNBR As Double, Optional ByVal strSITEID As String, Optional VarAux As Variant)
   
    Dim cmd As Command
    Dim con As Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    strSQL = " EXEC TMP_OP_PRCLVLCUSTDETDelProc '" & strINVTIDSKU & "'," & intCORRNBR & ",'" & strSITEID & "'"
                                
    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, "DB_MA_MANTENIMIENTOS.EliminarItemEnTmpDetalleHistPrecCli", Err.Description
End Sub

Public Sub EliminarTodoEnTmpDetalleHistPrecCli(ByVal intCORRNBR As Double, Optional VarAux As Variant)
   
    Dim cmd As Command
    Dim con As Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    strSQL = " EXEC TMP_IN_PRICELEVELTEMDETDelTodoProc " & intCORRNBR
                                
    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, "DB_MA_MANTENIMIENTOS.EliminarTodoEnTmpDetalleHistPrecCli", Err.Description
End Sub

Public Sub ActualizaTmpDetalleHistPrecCli(ByVal intCORRNBR As Double, ByVal strSITEID As String, ByVal strINVTIDSKU As String, _
                                          ByVal dblVALOR As Double, ByVal intModalidad As Integer, ByVal intREDONDEO As Integer, _
                                          ByVal strCURYID As String, ByVal datFecha As Date, ByVal strCURYTYPEID As String, Optional VarAux As Variant)
   
    
    Dim strSQL As String
    Dim dblMontoDesc As Double
    Dim dblNuevoPrecio As Double
    Dim dblSLS_PRICE As Double
    Dim rs As ADODB.Recordset
    Dim con As ADODB.Connection
    
    On Error GoTo TrataError
    
    strSQL = "SELECT SLS_PRICE FROM IN_INVENTORYDAT WHERE SITEID='" & strSITEID & "' AND  INVTIDSKU='" & strINVTIDSKU & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    If Not rs.EOF Then
        dblSLS_PRICE = ConvertirValor(rs!SLS_PRICE, strSITEID, strCURYID, datFecha, strINVTIDSKU, strCURYTYPEID, intREDONDEO)
    Else
        dblSLS_PRICE = 0
    End If
    
    If intModalidad = 0 Then ' si le valor ingresado es el monto de descuento
        dblMontoDesc = Round(dblVALOR, intREDONDEO)
        dblNuevoPrecio = Round(dblSLS_PRICE - dblMontoDesc, intREDONDEO)
    Else
            dblNuevoPrecio = Round(dblVALOR, intREDONDEO)
            dblMontoDesc = Round(dblSLS_PRICE - dblNuevoPrecio, intREDONDEO)
    End If
    
    
    strSQL = " EXEC TMP_OP_PRCLVLCUSTDETUpdProc " & intCORRNBR & ",'" & strSITEID & "'," & dblMontoDesc & "," & _
                                                 dblSLS_PRICE & "," & dblNuevoPrecio & ",'" & strINVTIDSKU & "'"
                                                    
    
    Set con = New Connection
    con.Open "FILEDSN=conexionsies"
    con.Execute strSQL
    
    'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:
    If Not con Is Nothing Then
        Set con = Nothing
    End If
    
    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.ActualizaTmpDetalleHistPrecCli", Err.Description

End Sub

Public Function ExisteArticulo(ByVal strINVTIDSKU As String, ByVal intCORRNBR As Double, Optional VarAux As Variant) As Boolean
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    ExisteArticulo = False
    
    On Error GoTo TrataError
    
    strSQL = " SELECT INVTIDSKU " & _
             " FROM TMP_OP_PRCLVLCUSTDET " & _
             " WHERE INVTIDSKU='" & strINVTIDSKU & "' AND CORRNBR='" & intCORRNBR & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic

    If rs.RecordCount > 0 Then
        ExisteArticulo = 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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.ExisteArticulo", Err.Description

End Function

Public Function SeleccionaEnTemporalDetalleHistPrecCli(ByVal intCORRNBR As Double, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT SITEID AS Almacen,INVTIDSKU as Codigo,DESCR as Descripcion,SLS_PRICE as Prec_Ant,DISCMTO as Monto_Desc,SLS_PRICECUST as Prec_Nuevo " & _
             " FROM TMP_OP_PRCLVLCUSTDET " & _
             " WHERE CORRNBR=" & intCORRNBR & " ORDER BY INVTIDSKU,SITEID"
    
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set SeleccionaEnTemporalDetalleHistPrecCli = rs
    
    'GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.SeleccionaEnTemporalDetalleHistPrecCli", Err.Description

End Function

Public Function SeleccionaEnDetalle(ByVal strPRCLVLCUSTID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim strVENDIDSS As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
       
    strSQL = " SELECT SITEID AS Almacen,INVTIDSKU as Codigo,DESCR as Descripcion,SLS_PRICE as Prec_Ant,DISCMTO as Monto_Desc,SLS_PRICECUST as Prec_Nuevo " & _
             " FROM OP_PRCLVLCUSTDET " & _
             " WHERE PRCLVLCUSTID='" & strPRCLVLCUSTID & "' ORDER BY INVTIDSKU,SITEID"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    Set SeleccionaEnDetalle = 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.SeleccionaEnDetalle", Err.Description

End Function

Public Function SeleccionaEnCabecera(ByVal strPRCLVLCUSTID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT TOP 1 * " & _
             " FROM OP_PRCLVLCUST WHERE PRCLVLCUSTID='" & strPRCLVLCUSTID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set SeleccionaEnCabecera = 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.SeleccionaEnCabecera", Err.Description

End Function

Public Function SeleccionaListaAyuda(ByVal strSITEID As String, ByVal strPRCLVLCUSTID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * " & _
             " FROM OP_PRCLVLCUST WHERE SITEID='" & strSITEID & "' AND PRCLVLCUSTID='" & strPRCLVLCUSTID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set SeleccionaListaAyuda = 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.SeleccionaEnCabecera", Err.Description

End Function


Public Function ValidaCodigoIngresado(ByVal strSITEID As String, ByVal strINVTIDSKU As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset

    On Error GoTo TrataError

        strSQL = " SELECT IN_INVENTORYDAT.INVTIDSKU,IN_INVENTORY.DESCR,IN_INVENTORYDAT.STDCOSTPEN AS COSTO,SLS_PRICE " & _
             " FROM IN_INVENTORY INNER JOIN IN_INVENTORYDAT " & _
             " ON IN_INVENTORY.INVTIDSKU=IN_INVENTORYDAT.INVTIDSKU " & _
             " WHERE SITEID='" & strSITEID & "' AND IN_INVENTORYDAT.INVTIDSKU='" & strINVTIDSKU & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    Set ValidaCodigoIngresado = rs
    
    'GetObjectContext.SetComplete
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.ValidaCodigoIngresado", Err.Description

End Function

Public Function ConvertirValor(ByVal dblVALOR As Double, ByVal strSITEID As String, ByVal strCURYID As String, ByVal datFecha As Date, _
                               ByVal strINVTIDSKU As String, ByVal strCURYTYPEID As String, ByVal intREDONDEO As Integer, Optional VarAux As Variant) As Double
                                
    Dim strSQL As String
    Dim strMONEDA As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
        
    strSQL = " SELECT CURYID " & _
             " FROM IN_PRICELEVELTYPE " & _
             " WHERE PRECLVID=(SELECT PRECLVID FROM IN_INVENTORYDAT WHERE SITEID='" & strSITEID & "' AND INVTIDSKU='" & strINVTIDSKU & "')"
        
    Set rs = New Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    strMONEDA = rs!CURYID
            
    If strMONEDA = strCURYID Then
        ConvertirValor = dblVALOR
    Else
    
        strSQL = " Exec ObtieneTipoCambioGeneralProc " & dblVALOR & ",'" & strMONEDA & "','" & strCURYID & "','" & Format(datFecha, "YYYY/DD/MM") & "','" & strCURYTYPEID & "'," & intREDONDEO
        
        Set rs = New Recordset
        rs.CursorLocation = adUseClient
        rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
        ConvertirValor = rs!VALOR
    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_MA_MONTENIMIENTOS.ConvertirValor", Err.Description

End Function


Public Function ObtieneSiteNoLista(ByVal strPRCLVLCUSTID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " Exec op_obtienesitenolista '" & strPRCLVLCUSTID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set ObtieneSiteNoLista = 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.ObtieneSiteNoLista", Err.Description

End Function

Public Function ObtieneSiteLista(ByVal strPRCLVLCUSTID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " Exec op_obtienesitelista '" & strPRCLVLCUSTID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set ObtieneSiteLista = 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.ObtieneSiteLista", Err.Description

End Function

Public Function ObtieneCantidadSiteEnTMPDetalle(ByVal intCORRNBR As Double, Optional VarAux As Variant) As Integer
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT  DISTINCT SITEID FROM TMP_OP_PRCLVLCUSTDET WHERE CORRNBR =" & intCORRNBR
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    ObtieneCantidadSiteEnTMPDetalle = rs.RecordCount
    
    '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.ObtieneCantidadSiteEnTMPDetalle", Err.Description

End Function

Public Function ObtieneRegistrosIncorrectos(ByVal lngCORRNBR As Long, ByVal strCURYID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC ValidaPreciosEnListaPrecioClientesProc " & lngCORRNBR & ",'" & strCURYID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set ObtieneRegistrosIncorrectos = 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.ObtieneRegistrosIncorrectos", Err.Description

End Function

Public Function ObtieneCantidadRegistrosIncorrectos(ByVal lngCORRNBR As Long, ByVal strCURYID As String, Optional VarAux As Variant) As Long
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC ValidaPreciosEnListaPrecioClientesProc " & lngCORRNBR & ",'" & strCURYID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    ObtieneCantidadRegistrosIncorrectos = rs.RecordCount
    
    '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.ObtieneCantidadRegistrosIncorrectos", Err.Description

End Function


Public Function ObtieneSitesEnTMPDetalle(ByVal intCORRNBR As Double, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT  DISTINCT SITEID FROM TMP_OP_PRCLVLCUSTDET WHERE CORRNBR =" & intCORRNBR
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set ObtieneSitesEnTMPDetalle = 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.ObtieneSitesEnTMPDetalle", Err.Description

End Function


Public Function ExisteSiteEnTMPDetalle(ByVal intCORRNBR As Double, ByVal strSITEID As String, Optional VarAux As Variant) As Boolean
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    ExisteSiteEnTMPDetalle = False
    
    strSQL = " SELECT  SITEID FROM TMP_OP_PRCLVLCUSTDET WHERE CORRNBR =" & intCORRNBR & " and SITEID='" & strSITEID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    If rs.RecordCount > 0 Then
        ExisteSiteEnTMPDetalle = 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_MOVIMIENTOS.ExisteSiteEnTMPDetalle", Err.Description

End Function

Public Function ObtieneDetalleNuevoALmacen(ByVal intCORRNBR As Double, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT * FROM TMP_OP_PRCLVLCUSTDET WHERE SITEID = (SELECT top 1 siteid FROM TMP_OP_PRCLVLCUSTDET WHERE CORRNBR=" & intCORRNBR & ") " & _
             " AND CORRNBR=" & intCORRNBR
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set ObtieneDetalleNuevoALmacen = 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.ObtieneDetalleNuevoALmacen", Err.Description

End Function


Public Sub EliminarTodoEnHistPrecCli(ByVal strPRCLVLCUSTID 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 EliminarListaCliente '" & strPRCLVLCUSTID & "'"
                                
    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:
    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, "DB_MA_MANTENIMIENTOS.EliminarTodoEnHistPrecCli", Err.Description
End Sub

Public Sub EliminarRelacion_Cliente_TPC(ByVal strCUSTIDSS As String, ByVal strPRCLVLCUSTID 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 EliminarRelacion_Cliente_TPC_Proc '" & strCUSTIDSS & "','" & strPRCLVLCUSTID & "'"
                                
    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:
    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, "DB_MA_MANTENIMIENTOS.EliminarRelacion_Cliente_TPC", Err.Description
End Sub

Public Function SeleccionaListaTPC(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT DISTINCT PRCLVLCUSTID,DESCR FROM OP_PRCLVLCUST WHERE STKPRICESEND=1 AND STATUS=1"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set SeleccionaListaTPC = 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.SeleccionaListaTPC", Err.Description

End Function

Public Sub AgregarClienteTPC(ByVal strCUSTIDSS As String, ByVal strPRCLVLCUSTID As String, _
                             ByVal strUSERID As String, Optional VarAux As Variant)
                             
   
    Dim con As ADODB.Connection
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC AgregarClienteTPCProc '" & strCUSTIDSS & "','" & strPRCLVLCUSTID & "','" & _
                                strUSERID & "'"
                                

    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, con, adOpenStatic
    
    'GetObjectContext.SetComplete
    
    Exit Sub
    
TrataError:

Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
     If Not rs Is Nothing Then
        Set rs = 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_MA_MANTENIMIENTOS.AgregarHistorialPrecCli", LStrMensajeError
     
End Sub

Public Function ObtieneTPC_Por_Cliente(ByVal strCUSTIDSS As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT DISTINCT PRCLVLCUSTID as Codigo,DESCR as Descripcion " & _
             " FROM OP_PRCLVLCUST " & _
             " WHERE PRCLVLCUSTID IN (SELECT OP_CUSTOMER_PRCLVL.PRCLVLCUSTID FROM OP_CUSTOMER_PRCLVL WHERE CUSTIDSS='" & strCUSTIDSS & "')"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set ObtieneTPC_Por_Cliente = 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.ObtieneTPC_Por_Cliente", Err.Description

End Function

Public Function ObtieneClientes_Por_TPC(ByVal strPRCLVLCUSTID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT OP_CUSTOMER_PRCLVL.CUSTIDSS as Codigo,CUSTNAME as Nombre FROM OP_CUSTOMER_PRCLVL JOIN CUSTOMER ON OP_CUSTOMER_PRCLVL.CUSTIDSS=CUSTOMER.CUSTIDSS " & _
             " WHERE PRCLVLCUSTID='" & strPRCLVLCUSTID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
        
    Set ObtieneClientes_Por_TPC = 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.ObtieneClientes_Por_TPC", Err.Description

End Function

Public Function ValidaClienteTPC(ByVal strCUSTID As String, ByVal strCODTPC As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset

    On Error GoTo TrataError

        strSQL = " EXEC Valida_TPC_ClienteProc '" & strCUSTID & "',""" & strCODTPC & """"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    Set ValidaClienteTPC = rs
    
    'GetObjectContext.SetComplete
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.ValidaClienteTPC", Err.Description

End Function

Public Function ExisteClienteTPC(ByVal strCUSTID As String, ByVal strCODTPC As String, Optional VarAux As Variant) As Boolean
    Dim strSQL As String
    Dim rs As ADODB.Recordset

    On Error GoTo TrataError
    
    ExisteClienteTPC = False

    strSQL = " SELECT * FROM OP_CUSTOMER_PRCLVL WHERE CUSTIDSS='" & strCUSTID & "' AND PRCLVLCUSTID='" & strCODTPC & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
    
    If Not rs.EOF Then
        ExisteClienteTPC = 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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.ExisteClienteTPC", 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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.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_MA_MANTENIMIENTOS.C_HIST_PRE_CLI.Auxiliar10", Err.Description
End Function














