Attribute VB_Name = "Module1"
Public Sub AgregarCliProEnTmp(ByVal lngCORRNBR As Long, ByVal StrCodPro As String, _
                                ByVal StrDesPro As String, ByVal IntDesc As String, ByVal IntPorDes As Double, Optional VarAux As Variant)

    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim strSQL As String

    On Error GoTo TrataError
   
    strSQL = " EXEC Tmp_CustInvtInsProc " & lngCORRNBR & ",'" & StrCodPro & "','" & _
                                                StrDesPro & "','" & IntDesc & "'," & IntPorDes

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

End Sub

Public Function ListarProductos(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 INVTIDSKU as Codigo,DESCRP as Descripcion,PORCDESC as Porcentaje,DESCU as Operador FROM OP_CUSTINVT WHERE CUSTIDSS = '" & strCUSTIDSS & "'"

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

    'GetObjectContext.SetAbort
    
   'ERR.Raise ERR.Number, "DB_OP_MANTENIMIENTOS.ListarProductos", ERR.Description

End Function


Public Function SeleccionaEnTmpCustPro(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 INVTIDSKU as Codigo,DESCRP as Descripcion,PORCDESC as Porcentaje,DESCU as Operador FROM tmp_OP_CUSTINVT WHERE CORRNBR = '" & strCUSTIDSS & "'"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified

    Set SeleccionaEnTmpCustPro = rs

    'GetObjectContext.SetComplete

    Exit Function

TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort

   'ERR.Raise ERR.Number, "DB_OP_MANTENIMIENTOS.ListarProductos", ERR.Description

End Function



Public Sub ActualizarCliProEnTmp(ByVal lngCORRNBR As Long, ByVal StrCodPro As String, _
                                  ByVal StrDesPro As String, ByVal IntDesc As String, _
                                  ByVal DblPorDes As Double, Optional VarAux As Variant)
                                
    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    
    strSQL = " EXEC Tmp_CustInvtUpdProc " & lngCORRNBR & ",'" & StrCodPro & "','" & _
                                              StrDesPro & "','" & IntDesc & "'," & _
                                              DblPorDes & ""
    
    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.ActualizarCliProEnTmp", LStrMensajeError
    
End Sub



Public Sub EliminarCliProEnTmp(ByVal lngCORRNBR As Long, ByVal strCUSTWARRANTYTYPEID 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 Tmp_CustInvtDelProc " & lngCORRNBR & ",'" & _
                                               strCUSTWARRANTYTYPEID & "'"
    
    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.EliminarCliProEnTmp", LStrMensajeError
    
End Sub



