Attribute VB_Name = "modConnection"
Option Explicit
  
Public Base As Database

Public xChaine As clibString
Public xfile As clsFichier_FSO
Public QShema As clsShemaBase
Public Recherche As clsRecherche

Public DB_file_Extension As String
Public DB_file As String
Public DB_path As String
Public DB_ConnectionString As String
Public DB_IsConnected As Boolean
Dim fso As FileSystemObject


Public Enum ListAction
    SelectionBase = 0
    Connecxion
    Connecter
    DeConection
End Enum

Public Sub Connect()
    DB_IsConnected = False
On Error GoTo fin
    Set Base = OpenDatabase(DB_path & "\" & DB_file & "." & DB_file_Extension, False, False, "MS Access;PWD=suivi")
    
    DB_IsConnected = True
    Call frmPrincipale.ActionFrame(DeConection)
    Exit Sub
fin:
    DB_IsConnected = False
    Call frmPrincipale.ActionFrame(SelectionBase)
End Sub

Public Sub UnConnect()
On Error Resume Next
    Base.Close
    DB_IsConnected = False
End Sub

  
Sub InitConnection(fullPath As String)
'Procedure qui doit allimenter et mettre a jour toutes les chqine de connection



    DB_file_Extension = xfile.getFileExtension(fullPath)
    
    
    DB_file = xfile.getFileName(fullPath)
    
    If DB_file_Extension <> "" Then
        DB_file = Replace(DB_file, "." & DB_file_Extension, "")
    Else
        DB_file = DB_file
    End If
    
    
    If DB_file_Extension <> "" Then
    
        DB_path = Replace(fullPath, "\" & DB_file & "." & DB_file_Extension, "")
    Else
        DB_path = Replace(fullPath, "\" & DB_file, "")
    End If
   
    
    
    DB_ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & fullPath


    

End Sub

Sub FinConnection()
    If DB_IsConnected Then UnConnect

End Sub

Public Sub Class_Init()
    Set xChaine = New clibString
    Set xfile = New clsFichier_FSO
    Set QShema = New clsShemaBase
    Set Recherche = New clsRecherche

    Set QShema.ProjetEncours = New clsDataProjet
    Set QShema.EcranEnCours = New clsDataEcran
    Set QShema.UtilisateurEnCours = New clsDataUtilisateur
    Set QShema.DifficulteEnCours = New clsDataDifficulter
    Set QShema.BlocEcranEnCours = New clsDataBlocEcran
    Set QShema.LigneEnCours = New ClsDataLigne
    Set QShema.PriotiteEnCours = New clsDataPriorite
    Set QShema.StatusEnCours = New clsDataStatus
    Set QShema.VersionEnCours = New clsDataVersion
    Set QShema.BlocMoxEnCours = New clsDataBloMox

End Sub

Public Sub Class_INothing()
    Set xChaine = Nothing
    Set xfile = Nothing
    Set Recherche = Nothing
    
    Set QShema.ProjetEncours = Nothing
    Set QShema.EcranEnCours = Nothing
    Set QShema.UtilisateurEnCours = Nothing
    Set QShema.DifficulteEnCours = Nothing
    Set QShema.BlocEcranEnCours = Nothing
    Set QShema.LigneEnCours = Nothing
    Set QShema.PriotiteEnCours = Nothing
    Set QShema.StatusEnCours = Nothing
    Set QShema.VersionEnCours = Nothing
    Set QShema.BlocMoxEnCours = Nothing

    Set QShema = Nothing

End Sub
