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_CLIENTE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' EDGAR CANCHO RUIZ
' Clase C_Cliente
' Funciones Básicas de Mantenimiento
'               AgregarCliente
'               EliminarCliente
'               ActualizarCliente
'               ListarPorClienteID
'               ListarClientes
'               ListarClientesAyuda
Option Explicit

Public Sub AgregarCliente(ByVal strCUSTIDSS As String, ByVal strDIAPAGO As String, ByVal strTERMIDSUM As String, _
                          ByVal strCUSTID As String, ByVal strTAXREGNBR As String, ByVal strCUSTNAME As String, _
                          ByVal strADDR1 As String, ByVal strADDR2 As String, ByVal strPHONE As String, _
                          ByVal strFAX As String, ByVal strCUSTZONEID As String, ByVal strCOUNTRYID As String, _
                          ByVal strSTATEID As String, ByVal strCITYID As String, ByVal strCUSTCLASSID As String, _
                          ByVal strTAXID1 As String, ByVal strTAXID2 As String, ByVal strCURYTYPEID As String, _
                          ByVal strTERMIDDOC As String, ByVal datDATEORIG As Date, _
                          ByVal datDATEPROC As Date, ByVal intDAYGRACE As Integer, ByVal strCURYID As String, _
                          ByVal strSALESPERID As String, ByVal strUSERID As String, ByVal strCUSTSTATUS As String, _
                          ByVal lngCORRNBR As Long, ByVal dblMTOTOTLIMIT As Double, ByVal bytAFFECT 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 CustomerInsProc '" & strCUSTIDSS & "','" & strDIAPAGO & "','" & strTERMIDSUM & "','" & _
                                        strCUSTID & "','" & strTAXREGNBR & "','" & strCUSTNAME & "','" & _
                                        strADDR1 & "','" & strADDR2 & "','" & strPHONE & "','" & _
                                        strFAX & "','" & strCUSTZONEID & "','" & strCOUNTRYID & "','" & _
                                        strSTATEID & "','" & strCITYID & "','" & strCUSTCLASSID & "','" & _
                                        strTAXID1 & "','" & strTAXID2 & "','" & strCURYTYPEID & "','" & _
                                        strTERMIDDOC & "','" & Format(datDATEORIG, "YYYY/DD/MM") & "','" & _
                                        Format(datDATEPROC, "YYYY/DD/MM") & "'," & intDAYGRACE & ",'" & strCURYID & "','" & _
                                        strSALESPERID & "','" & strUSERID & "','" & strCUSTSTATUS & "'," & lngCORRNBR & "," & dblMTOTOTLIMIT & "," & bytAFFECT & "," & _
                                        "NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL"

    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.AgregarCliente", LStrMensajeError
    
End Sub

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

End Sub

Public Sub ActualizarCliente(ByVal strCUSTIDSS As String, ByVal strDIAPAGO As String, ByVal strTERMIDSUM As String, _
                             ByVal strCUSTID As String, ByVal strTAXREGNBR As String, ByVal strCUSTNAME As String, _
                             ByVal strADDR1 As String, ByVal strADDR2 As String, ByVal strPHONE As String, _
                             ByVal strFAX As String, ByVal strCUSTZONEID As String, ByVal strCOUNTRYID As String, _
                             ByVal strSTATEID As String, ByVal strCITYID As String, ByVal strCUSTCLASSID As String, _
                             ByVal strTAXID1 As String, ByVal strTAXID2 As String, ByVal strCURYTYPEID As String, _
                             ByVal strTERMIDDOC As String, ByVal datDATEORIG As String, _
                             ByVal datDATEPROC As String, ByVal intDAYGRACE As Integer, ByVal strCURYID As String, _
                             ByVal strSALESPERID As String, ByVal strUSERID As String, ByVal strCUSTSTATUS As String, _
                             ByVal lngCORRNBR As Long, ByVal dblMTOTOTLIMIT As Double, ByVal bytAFFECT As Byte, Optional VarAux As Variant)
                             
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC CUSTOMERUpdProc '" & strCUSTIDSS & "','" & strDIAPAGO & "','" & strTERMIDSUM & "','" & _
                                        strCUSTID & "','" & strTAXREGNBR & "','" & strCUSTNAME & "','" & _
                                        strADDR1 & "','" & strADDR2 & "','" & strPHONE & "','" & _
                                        strFAX & "','" & strCUSTZONEID & "','" & strCOUNTRYID & "','" & _
                                        strSTATEID & "','" & strCITYID & "','" & strCUSTCLASSID & "','" & _
                                        strTAXID1 & "','" & strTAXID2 & "','" & strCURYTYPEID & "','" & _
                                        strTERMIDDOC & "','" & datDATEORIG & "','" & _
                                        datDATEPROC & "'," & intDAYGRACE & ",'" & strCURYID & "','" & _
                                        strSALESPERID & "','" & strUSERID & "','" & strCUSTSTATUS & "'," & lngCORRNBR & "," & dblMTOTOTLIMIT & "," & bytAFFECT

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

End Sub

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

End Function

Public Function ListarClientes(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    If VarAux = Empty Then
        VarAux = 0
    End If
    
    If VarAux = 0 Then
        strSQL = " SELECT * FROM CUSTOMER "
    Else
        strSQL = " SELECT * FROM CUSTOMER WHERE CUSTCLASSID='00'"
    End If
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
       
    Set ListarClientes = 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.ListarClientes", Err.Description

End Function
 
Public Function ListarClientesAyudaNocontado(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT CUSTIDSS,CUSTNAME FROM CUSTOMER where CUSTCLASSID <> '00' "
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarClientesAyudaNocontado = 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.ListarClientesAyudaNocontado", Err.Description

End Function
 
 
 
 
Public Function ListarClientesAyudaTPC(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT CUSTIDSS,CUSTNAME FROM CUSTOMER WHERE CUSTSTATUSID='A' ORDER BY CUSTNAME"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarClientesAyudaTPC = 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.ListarClientesAyudaTPC", Err.Description

End Function

Public Function ListarClientesAyuda(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    If VarAux = Empty Then
        VarAux = 0
    End If
    
    If VarAux = 0 Then
        strSQL = " SELECT CUSTIDSS,CUSTNAME FROM CUSTOMER "
    Else
        strSQL = " SELECT CUSTIDSS,CUSTNAME FROM CUSTOMER WHERE CUSTCLASSID='00'"
    End If
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarClientesAyuda = 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.ListarClientesAyuda", Err.Description

End Function

Public Function ListarGarantiasAyuda(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT CUSTWARRANTYTYPEID,DECRCUSTWARRANTY FROM CUSTWARRANTYTYPE"

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

End Function

Public Function ListarPlacas(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 BADGE as Nro_Placa FROM OP_CUSTBADGE WHERE CUSTIDSS='" & strCUSTIDSS & "'"

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

End Function

Public Function ListarTarjetas(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 CARDPASSWORD as Clave,DESCRCUSTCARD as Descripcion,EXPIREDATE as Expiracion FROM OP_CUSTCARD WHERE CUSTIDSS='" & strCUSTIDSS & "'"

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

End Function

Public Function ListarGarantias(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 CUSTWARRANTYTYPEID AS Tipo,DESCRGAR as Descripcion,TOTGAR as Monto, " & _
             " EXPIREDATE as Expiracion,CURYID as Moneda FROM custwarranty WHERE CUSTIDSS='" & strCUSTIDSS & "'"

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

End Function

Public Function ListarCreditos(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 SITEID as Almacen,PORCENTLIMITED as Porcentaje_Limite,CREDLIMITED as Monto_Limite,PORCENTSURPLUS as Porcentaje_Excedente,MTOSURPLUS as Monto_Excedente,CURRBAL as Deuda,(CREDLIMITED-CURRBAL) as Saldo FROM OP_CUST_LIMIT WHERE CUSTIDSS='" & strCUSTIDSS & "'"

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

End Function


Public Function TiposListasPreciosAyuda(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " select PRCLVLCUSTID,DESCR from  OP_PRCLVLCUST where status=1"

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

End Function

Public Function ListarDiasPagoAyuda(Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = "select DIAPAGID,DESCR from XDIAS_PAGO"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies"
            
    Set ListarDiasPagoAyuda = 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.ListarDiasPagoAyuda", Err.Description

End Function

Public Sub AgregarPlacaEnTmp(ByVal lngCORRNBR As Long, ByVal strBADGE 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_Op_CustBadgeInsProc " & lngCORRNBR & ",'" & _
                                               strBADGE & "'"
    
    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.AgregarPlacaEnTmp", LStrMensajeError
    
End Sub

Public Sub EliminarPlacaEnTmp(ByVal lngCORRNBR As Long, ByVal strBADGE 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_Op_CustBadgeDelProc " & lngCORRNBR & ",'" & _
                                               strBADGE & "'"
    
    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.EliminarPlacaEnTmp", LStrMensajeError
    
End Sub

Public Function SeleccionaEnTmpCustBadge(ByVal lngCORRNBR As Long, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT BADGE as Nro_Placa FROM TMP_OP_CUSTBADGE WHERE CORRNBR=" & lngCORRNBR
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    Set SeleccionaEnTmpCustBadge = 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.SeleccionaEnTmpCustBadge", Err.Description

End Function

Public Sub AgregarTarjetaEnTmp(ByVal lngCORRNBR As Long, ByVal strCARDPASSWORD As String, ByVal datEXPIREDATE As Date, _
                               ByVal strDESCRCUSTCARD 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_Op_CustCardInsProc " & lngCORRNBR & ",'" & strCARDPASSWORD & "','" & Format(datEXPIREDATE, "YYYY/DD/MM") & "','" & _
                                               strDESCRCUSTCARD & "'"
    
    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.AgregarTarjetaEnTmp", LStrMensajeError
    
End Sub

Public Sub EliminarTarjetaEnTmp(ByVal lngCORRNBR As Long, ByVal strCARDPASSWORD 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_Op_CustCardDelProc " & lngCORRNBR & ",'" & _
                                               strCARDPASSWORD & "'"
    
    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.EliminarTarjetaEnTmp", LStrMensajeError
    
End Sub

Public Sub ActualizarTarjetaEnTmp(ByVal lngCORRNBR As Long, ByVal strCARDPASSWORD As String, ByVal datEXPIREDATE As Date, _
                                  ByVal strDESCRCUSTCARD 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_Op_CustCardUpdProc " & lngCORRNBR & ",'" & strCARDPASSWORD & "','" & Format(datEXPIREDATE, "YYYY/DD/MM") & "','" & _
                                               strDESCRCUSTCARD & "'"
    
    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.ActualizarTarjetaEnTmp", LStrMensajeError
    
End Sub


Public Function SeleccionaEnTmpCustCard(ByVal lngCORRNBR As Long, Optional VarAux As Variant) As ADODB.Recordset


    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT CARDPASSWORD as Clave,DESCRCUSTCARD as Descripcion,EXPIREDATE as Expiracion FROM TMP_OP_CUSTCARD WHERE CORRNBR=" & lngCORRNBR
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    Set SeleccionaEnTmpCustCard = 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.SeleccionaEnTmpCustCard", Err.Description

End Function

Public Sub AgregarGarantiaEnTmp(ByVal lngCORRNBR As Long, ByVal strCUSTWARRANTYTYPEID As String, ByVal dblTOTGAR As Double, _
                                ByVal strDESCRGAR As String, ByVal datEXPIREDATE As Date, ByVal strCURYID 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_CustWarrantyInsProc " & lngCORRNBR & ",'" & strCUSTWARRANTYTYPEID & "'," & dblTOTGAR & ",'" & _
                                                strDESCRGAR & "','" & Format(datEXPIREDATE, "YYYY/DD/MM") & "','" & strCURYID & "'"
    
    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.AgregarGarantiaEnTmp", LStrMensajeError
    
End Sub

Public Sub EliminarGarantiaEnTmp(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_CustWarrantyDelProc " & 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.EliminarGarantiaEnTmp", LStrMensajeError
    
End Sub

Public Sub ActualizarGarantiaEnTmp(ByVal lngCORRNBR As Long, ByVal strCUSTWARRANTYTYPEID As String, ByVal dblTOTGAR As Double, _
                                  ByVal strDESCRGAR As String, ByVal datEXPIREDATE As Date, ByVal strCURYID 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_CustWarrantyUpdProc " & lngCORRNBR & ",'" & strCUSTWARRANTYTYPEID & "'," & dblTOTGAR & ",'" & _
                                                strDESCRGAR & "','" & Format(datEXPIREDATE, "YYYY/DD/MM") & "','" & strCURYID & "'"
    
    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.ActualizarGarantiaEnTmp", LStrMensajeError
    
End Sub


Public Function SeleccionaEnTmpCustWarranty(ByVal lngCORRNBR As Long, Optional VarAux As Variant) As ADODB.Recordset


    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT CUSTWARRANTYTYPEID AS Tipo,DESCRGAR as Descripcion,TOTGAR as Monto, " & _
             " EXPIREDATE as Expiracion,CURYID as Moneda FROM TMP_custwarranty WHERE CORRNBR = " & lngCORRNBR
 
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    Set SeleccionaEnTmpCustWarranty = 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.SeleccionaEnTmpCustWarranty", Err.Description

End Function


Public Sub AgregarCreditoEnTmp(ByVal lngCORRNBR As Long, ByVal strSITEID As String, _
                               ByVal dblPORCENTLIMITED As Double, ByVal dblCREDLIMITED As Double, ByVal dblCURRBAL As Double, _
                               ByVal dblPORCENTSURPLUS As Double, ByVal dblMTOSURPLUS 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_Cust_LimitInsProc " & lngCORRNBR & ",'" & strSITEID & "'," & _
                                              dblPORCENTLIMITED & "," & dblCREDLIMITED & "," & dblCURRBAL & "," & _
                                              dblPORCENTSURPLUS & "," & dblMTOSURPLUS
    
    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.AgregarCreditoEnTmp", LStrMensajeError
    
End Sub

Public Sub EliminarCreditoEnTmp(ByVal lngCORRNBR As Long, ByVal strSITEID 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_Cust_LimitDelProc " & lngCORRNBR & ",'" & _
                                              strSITEID & "'"
    
    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.EliminarCreditoEnTmp", LStrMensajeError
    
End Sub

Public Sub ActualizarCreditoEnTmp(ByVal lngCORRNBR As Long, ByVal strSITEID As String, _
                                  ByVal dblPORCENTLIMITED As Double, ByVal dblCREDLIMITED As Double, _
                                  ByVal dblPORCENTSURPLUS As Double, ByVal dblMTOSURPLUS 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_Cust_LimitUpdProc " & lngCORRNBR & ",'" & strSITEID & "'," & _
                                              dblPORCENTLIMITED & "," & dblCREDLIMITED & "," & _
                                              dblPORCENTSURPLUS & "," & dblMTOSURPLUS
    
    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.ActualizarCreditoEnTmp", LStrMensajeError
    
End Sub


Public Function SeleccionaEnTmpCust_Limit(ByVal lngCORRNBR As Long, 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,PORCENTLIMITED as Porcentaje_Limite,CREDLIMITED as Monto_Limite,PORCENTSURPLUS as Porcentaje_Excedente,MTOSURPLUS as Monto_Excedente,CURRBAL as Deuda,(CREDLIMITED-CURRBAL) as Saldo FROM TMP_OP_CUST_LIMIT WHERE CORRNBR = " & lngCORRNBR
 
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    Set SeleccionaEnTmpCust_Limit = 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.SeleccionaEnTmpCust_Limit", Err.Description

End Function

Public Sub CargarTablasTemporales(ByVal lngCORRNBR As Long, ByVal strCUSTIDSS As String, Optional VarAux As Variant)
    Dim strSQL As String
    Dim con As ADODB.Connection
    
    On Error GoTo TrataError
    
    strSQL = " EXEC CargarTablasTemporalesProc " & lngCORRNBR & ",'" & strCUSTIDSS & "'"
    
    
    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.CargarTablasTemporales", Err.Description
End Sub


Public Function ObtienePorcentajeEnTmpCust_Limit(ByVal lngCORRNBR As Long, Optional VarAux As Variant) As Double


    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " SELECT SUM(PORCENTLIMITED) as PorcentajeTotal FROM TMP_OP_CUST_LIMIT WHERE CORRNBR = " & lngCORRNBR
 
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    If IsNull(rs!PorcentajeTotal) Then
        ObtienePorcentajeEnTmpCust_Limit = 0
    Else
        ObtienePorcentajeEnTmpCust_Limit = rs!PorcentajeTotal
    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.ObtienePorcentajeEnTmpCust_Limit", Err.Description

End Function


Public Sub RecalculaCreditosClientes(ByVal lngCORRNBR As Long, ByVal dblMTOTOTLIMIT As Double, ByVal intDecimales As Integer, Optional VarAux As Variant)
                                
    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    
    strSQL = " EXEC RecalculaCreditosClientesProc " & lngCORRNBR & "," & dblMTOTOTLIMIT & "," & intDecimales
    
    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.RecalculaCreditosClientes", LStrMensajeError
    
End Sub

Public Function ExistenVentasConVariosVales(ByVal datFECHAINI As Date, ByVal datFECHAFIN As Date, _
                                            ByVal StrEstado As String, ByVal IntTodos As Integer, Optional VarAux As Variant) As Boolean
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    Dim lngCantVales As Long
    Dim lngCantDocum As Long
    
    On Error GoTo TrataError
    
    ExistenVentasConVariosVales = False
    
    If IntTodos = 1 Then
       strSQL = " SELECT COUNT(*) as NumReg FROM OP_SALES AS S JOIN OP_BONUS AS B " & _
                " ON S.DOCTYPEID=B.DOCTYPEID AND S.NBRDOCUMENT=B.NBRDOCUMENT AND S.SITEID=B.SITEID AND S.CUSTIDSS=B.CUSTIDSS " & _
                " WHERE S.TYPEPAYMENTID IN ('06') AND S.DOCSTATUSID<>'AN' AND " & _
                " S.DATEPROCESALES>='" & Format(datFECHAINI, "DD/MM/YYYY") & "' AND S.DATEPROCESALES<='" & Format(datFECHAFIN, "DD/MM/YYYY") & "'"
    Else
       strSQL = " SELECT COUNT(*) as NumReg FROM OP_SALES AS S JOIN OP_BONUS AS B " & _
                " ON S.DOCTYPEID=B.DOCTYPEID AND S.NBRDOCUMENT=B.NBRDOCUMENT AND S.SITEID=B.SITEID AND S.CUSTIDSS=B.CUSTIDSS " & _
                " WHERE S.TYPEPAYMENTID IN ('06') AND S.DOCSTATUSID = '" & StrEstado & "' AND " & _
                " S.DATEPROCESALES>='" & Format(datFECHAINI, "DD/MM/YYYY") & "' AND S.DATEPROCESALES<='" & Format(datFECHAFIN, "DD/MM/YYYY") & "'"
    End If
    
    'strSQL = " SELECT COUNT(*) as NumReg FROM OP_SALES AS S JOIN OP_BONUS AS B " & _
    '         " ON S.DOCTYPEID=B.DOCTYPEID AND S.NBRDOCUMENT=B.NBRDOCUMENT AND S.SITEID=B.SITEID AND S.CUSTIDSS=B.CUSTIDSS " & _
    '         " WHERE S.TYPEPAYMENTID IN ('06') AND S.DOCSTATUSID<>'AN' AND " & _
    '         " S.DATEPROCESALES>='" & Format(datFECHAINI, "DD/MM/YYYY") & "' AND S.DATEPROCESALES<='" & Format(datFECHAFIN, "DD/MM/YYYY") & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    lngCantVales = rs!numreg
    
    If IntTodos = 1 Then
       strSQL = " SELECT COUNT(*) as NumReg FROM OP_SALES AS S " & _
                " WHERE S.TYPEPAYMENTID IN ('06') AND S.DOCSTATUSID<>'AN' AND " & _
                " S.DATEPROCESALES>='" & Format(datFECHAINI, "DD/MM/YYYY") & "' AND S.DATEPROCESALES<='" & Format(datFECHAFIN, "DD/MM/YYYY") & "'"
    Else
       strSQL = " SELECT COUNT(*) as NumReg FROM OP_SALES AS S " & _
                " WHERE S.TYPEPAYMENTID IN ('06') AND S.DOCSTATUSID ='" & StrEstado & "' AND " & _
                " S.DATEPROCESALES>='" & Format(datFECHAINI, "DD/MM/YYYY") & "' AND S.DATEPROCESALES<='" & Format(datFECHAFIN, "DD/MM/YYYY") & "'"
    End If
    
    'strSQL = " SELECT COUNT(*) as NumReg FROM OP_SALES AS S " & _
    '         " WHERE S.TYPEPAYMENTID IN ('06') AND S.DOCSTATUSID<>'AN' AND " & _
    '         " S.DATEPROCESALES>='" & Format(datFECHAINI, "DD/MM/YYYY") & "' AND S.DATEPROCESALES<='" & Format(datFECHAFIN, "DD/MM/YYYY") & "'"
        
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    lngCantDocum = rs!numreg
    
    If lngCantVales <> lngCantDocum Then
        ExistenVentasConVariosVales = 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.ExistenVentasConVariosVales", Err.Description

End Function

Public Function Auxiliar1(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    
    strSQL = " EXEC CUSTOMER_SITE_InsProc '" & VarAux1(1, 1) & "','" & VarAux1(1, 2) & "','" & VarAux1(1, 3) & "','" & _
                                        VarAux1(1, 4) & "','" & VarAux1(1, 5) & "','" & VarAux1(1, 6) & "'," & _
                                        VarAux1(1, 7)
    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 Function
    
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.C_CLIENTE.Auxiliar1", LStrMensajeError
    
End Function


Public Function Auxiliar2(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim strSQL As String

    On Error GoTo TrataError
    
    
    strSQL = " EXEC CUSTOMER_SITE_UpdProc '" & VarAux1(1, 1) & "','" & VarAux1(1, 2) & "','" & VarAux1(1, 3) & "','" & _
                                        VarAux1(1, 4) & "','" & VarAux1(1, 5) & "','" & VarAux1(1, 6) & "'," & _
                                        VarAux1(1, 7)
    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 Function
    
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.C_CLIENTE.Auxiliar2", LStrMensajeError
    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_CLIENTE.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_CLIENTE.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_CLIENTE.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_CLIENTE.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_CLIENTE.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_CLIENTE.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_CLIENTE.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_CLIENTE.Auxiliar10", Err.Description
End Function

Public Sub AgregarProductoEnTmp(ByVal lngCORRNBR As Long, ByVal strSITEID As String, _
                               ByVal dblPORCENTLIMITED As Double, ByVal dblCREDLIMITED As Double, ByVal dblCURRBAL As Double, _
                               ByVal dblPORCENTSURPLUS As Double, ByVal dblMTOSURPLUS 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_Cust_LimitInsProc " & lngCORRNBR & ",'" & strSITEID & "'," & _
    ''                                          dblPORCENTLIMITED & "," & dblCREDLIMITED & "," & dblCURRBAL & "," & _
    ''                                          dblPORCENTSURPLUS & "," & dblMTOSURPLUS
        
                                              
    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.AgregarProductoEnTmp", LStrMensajeError
    
End Sub

Public Function SeleccionaEnTmpProductos(ByVal lngCORRNBR As Long, Optional VarAux As Variant) As ADODB.Recordset


    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = "SELECT * FROM TMP_PRODSKUDESC WHERE CORRNBR = " & lngCORRNBR
 
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
    
    Set SeleccionaEnTmpProductos = 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.SeleccionaEnTmpProductos", Err.Description

End Function
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
    'GlngCorrelativo, FMaestroClientes.lblCodigo7.Caption, Trim(TxtCodigoPro.Text), Trim(Me.TxtDescripPro.Text), Me.ChkDesc.Value, GFormatodeNumero(CDbl(ctnMontoGar.Text), GintDecResultado)

    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





