VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsRecherche"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'------------------------------------------------
' Auteur CH
'   Date création : origine
'   Date modification : 10/08/2006 - JR
'------------------------------------------------

Option Explicit

Private rec As Recordset
Private strRequete As String

Public pNum As String 'fait
Public pNumProjet As String 'fait
Public pNumDemandeur As String  'fait
Public pDateCreation As Date
Public pDateCreationstr As String

Public pChercher As String
Public pNumPriorite As String
Public pNumDificulte As String
Public pCharge As String
Public pNumStatus As String

Public pDateCloture As Date
Public pDateCloturestr As String

Public pNumMox As String
Public pNumVersion As String
Public plstEcrans As ListBox
Public pListeEcran As String
              
Public Sub Vider()
    strRequete = ""
    pNum = ""
    pNumProjet = ""
    pNumDemandeur = ""
    pDateCreationstr = ""
    pChercher = ""
    pNumPriorite = ""
    pNumDificulte = ""
    pCharge = ""
    pNumStatus = ""
    pDateCloturestr = ""
    pNumMox = ""
    pNumVersion = ""
    pListeEcran = ""
End Sub


Public Function Complete3() As String
 Dim sql As String
        sql = ""
        sql = sql & "select ligne.*, blocecran.*,ecrans.*, "
        sql = sql & " projet.nom,Utilisateur.nom, Utilisateur.prenom,version.version, priorite.nom, Difficulter.nom, Statut.nom "
        sql = sql & " from  ligne,blocecran, ecrans, projet, Utilisateur,version, priorite, Difficulter,Statut  "
        sql = sql & " where ligne.idligne=blocecran.idligne "
        sql = sql & " and  blocecran.idecran = ecrans.idecran "
        sql = sql & " and  ecrans.idProjet = projet.idProjet "
        sql = sql & " and  ligne.idDemandeur = Utilisateur.idUtilisateur "
        sql = sql & " and  ligne.idVersion = Version.idVersion "
        sql = sql & " and  ligne.idPriorite = Priorite.idPriorite "
        sql = sql & " and  ligne.IdDifficulte = Difficulter.idDiffculte "
        sql = sql & " and  ligne.idStatus = Statut.idStatus "
        
        If pNum <> "" Then
            sql = sql & " and ligne.idligne =" & Val(pNum) & " "
        End If
        
        If pNumProjet <> "" Then
            sql = sql & " and projet.idProjet =" & Val(pNumProjet) & " "
        End If
        
        If pNumDemandeur <> "" Then
            sql = sql & " and ligne.idDemandeur =" & Val(pNumDemandeur) & " "
        End If
        
        If pDateCreationstr <> "" Then
            sql = sql & " and ligne.DateCreation =#" & Format(pDateCreation, "MM/DD/YYYY") & "# "
        End If
        'chercher sujet precision remarque
        If pChercher <> "" Then
            sql = sql & " and ( ligne.sujet like '*" & pChercher & "*' "
            sql = sql & " or ligne.precision like '*" & pChercher & "*' "
            sql = sql & " or ligne.remarque like '*" & pChercher & "*' )  "
        End If
        
        'priorite
        If pNumPriorite <> "" Then
            sql = sql & " and ligne.idPriorite =" & Val(pNumPriorite) & " "
        End If
        'difficulte
        If pNumDificulte <> "" Then
            sql = sql & " and ligne.IdDifficulte =" & Val(pNumDificulte) & " "
        End If
        'Charge
        If pCharge <> "" Then
            If IsNumeric(pCharge) Then
                  sql = sql & " and ligne.Charge =" & Val(pCharge) & " "
            End If
        End If
        'statut
        If pNumStatus <> "" Then
            sql = sql & " and ligne.idStatus =" & Val(pNumStatus) & " "
        End If
        'DateCloture
        If pDateCloturestr <> "" Then
            sql = sql & " and ligne.DateCloture =#" & Format(pDateCloture, "MM/DD/YYYY") & "# "
        End If
        
        'Version
        If pNumVersion <> "" Then
            sql = sql & " and ligne.idVersion =" & Val(pNumVersion) & " "
        End If
        
Dim i As Integer
Dim TabEcran() As String
        'Ecran
        If pListeEcran <> "" Then
            TabEcran = Split(pListeEcran, ";")
            If InStr(pListeEcran, ";") <= 0 Then
                ReDim TabEcran(0)
                TabEcran(0) = pListeEcran
            End If
            
            
            sql = sql & " and ( "
            For i = 0 To UBound(TabEcran)
                If i > 0 Then sql = sql & " or "
                sql = sql & " ecrans.idecran =" & Val(TabEcran(i)) & " "
            Next i
            sql = sql & " ) "
        
        End If
        
        
        Complete3 = sql
                    
 End Function



Private Function Ajouter_filtre_Or(Filtre As String, Ajout As String) As String
    If Filtre <> "" Then
        Ajouter_filtre_Or = Filtre & " or " & Ajout
    Else
        Ajouter_filtre_Or = Ajout
    End If
End Function

Private Function Ajouter_filtre_And(Filtre As String, Ajout As String) As String
    If Filtre <> "" Then
        Ajouter_filtre_And = Filtre & " and " & Ajout
    Else
        Ajouter_filtre_And = Ajout
    End If
End Function


