Attribute VB_Name = "Modulerallye"
Dim rallyes As New ADODB.Connection
Option Explicit
Public Sub Etablir2_Connection()
rallyes.Provider = "Microsoft.Jet.OLEDB.4.0"
rallyes.ConnectionString = "C:\Dossier Pilote\rallyes.mdb"
rallyes.Open
End Sub
Public Sub Fermer2_Connection()
rallyes.Close
End Sub
Public Sub ajoutav(ByVal numpil As Integer, ByVal marc As String, ByVal typ As String, ByVal car As String, _
ByVal prop As String, ByVal nmcour As String, ByVal imm As String, ByVal dms As Date, ByVal hdv As Long)
    'Procédure permettant d'inserrer dans les tables tous les renseignements
Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim Avion As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Insert into Avion Values(" & numpil & ",'" & marc & "','" & typ & "','" & car & "','" & prop & "','" & nmcour & "','" & imm & "',#" & CStr(dms) & "#," & hdv & ")"
 Set Avion = Reqsql.Execute
 Call Fermer2_Connection
End Sub

Public Sub ajoutpil1(ByVal numpil As Integer, ByVal nom As String, ByVal pren As String, ByVal dl As String, ByVal nat As String, _
ByVal prof As String, ByVal ad As String, ByVal telper As Long, ByVal telpro As Long, ByVal em As String, ByVal tynuli As String, ByVal dob As Date, _
ByVal nhv As Long, ByVal qri As String, ByVal autlic As String, ByVal numpass As String, ByVal ld As String, ByVal dexp As Date)
    'Procédure permettant d'inserrer dans les tables tous les renseignements

Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim Pilote As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Insert into Pilote Values(" & numpil & ",'" & nom & "','" & pren & "','" & dl & "','" & nat & "','" & prof & "','" & ad & "'," & telper & "," & telpro & ",'" & em & "', '" & tynuli & "',#" & CStr(dob) & "#," & nhv & ",'" & qri & "','" & autlic & "','" & numpass & "','" & ld & "',#" & CStr(dexp) & "#)"
Set Pilote = Reqsql.Execute
Call Fermer2_Connection
End Sub
Public Sub ajoutpil2(ByVal numpil As Integer, ByVal nom As String, ByVal pren As String, ByVal dl As String, ByVal nat As String, _
ByVal prof As String, ByVal ad As String, ByVal telper As Long, ByVal telpro As Long, ByVal em As String, ByVal tynuli As String, ByVal dob As Date, _
ByVal nhv As Integer, ByVal qri As String, ByVal autlic As String, ByVal numpass As String, ByVal ld As String, ByVal dexp As Date)
    'Procédure permettant d'inserrer dans les tables tous les renseignements

Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim CO_Pilote As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Insert into CO_Pilote Values(" & numpil & ",'" & nom & "','" & pren & "','" & dl & "','" & nat & "','" & prof & "','" & ad & "'," & telper & "," & telpro & ",'" & em & "', '" & tynuli & "',#" & CStr(dob) & "#," & nhv & ",'" & qri & "','" & autlic & "','" & numpass & "','" & ld & "',#" & CStr(dexp) & "#)"
Set CO_Pilote = Reqsql.Execute
Call Fermer2_Connection
End Sub
Public Sub ajoutpil3(ByVal numpil1 As Integer, ByVal nom1 As String, ByVal pren1 As String, ByVal dl1 As String, ByVal nat1 As String, _
ByVal prof1 As String, ByVal ad1 As String, ByVal telper1 As Long, ByVal telpro1 As Long, ByVal em1 As String, ByVal tynuli1 As String, ByVal dob1 As Date, _
ByVal nhv1 As Integer, ByVal qri1 As String, ByVal autlic1 As String, ByVal numpass1 As String, ByVal ld1 As String, ByVal dexp1 As Date)
    'Procédure permettant d'inserrer dans les tables tous les renseignements

Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim Co_Pilote2 As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Insert into CO_Pilote2 Values(" & numpil1 & ",'" & nom1 & "','" & pren1 & "','" & dl1 & "','" & nat1 & "','" & prof1 & "','" & ad1 & "'," & telper1 & "," & telpro1 & ",'" & em1 & "', '" & tynuli1 & "',#" & CStr(dob1) & "#," & nhv1 & ",'" & qri1 & "','" & autlic1 & "','" & numpass1 & "','" & ld1 & "',#" & CStr(dexp1) & "#)"
Set Co_Pilote2 = Reqsql.Execute
Call Fermer2_Connection
End Sub
Public Sub affpil(ByVal numpil As Integer, ByRef nom As String, ByRef pren As String, ByRef dl As String, ByRef nat As String, _
ByRef prof As String, ByRef ad As String, ByRef telper As Long, ByRef telpro As Long, ByRef em As String, ByRef tynuli As String, ByRef dob As Date, _
ByRef nhv As Long, ByRef qri As String, ByRef autlic As String, ByRef numpass As String, ByRef ld As String, ByRef dexp As Date)
Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim Pilote As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Select * From Pilote Where Pilote.N°pilote =" & numpil & ""
Set Pilote = Reqsql.Execute

numpil = Pilote![N°pilote]
nom = Pilote![nom]
pren = Pilote![Prénom]
dl = Pilote![Date_et_lieu_de_naissance]
nat = Pilote![Nationalité]
prof = Pilote![Profession]
ad = Pilote![Adresse]
telper = Pilote![Tel_personnel]
telpro = Pilote![Tel_professionnel]
em = Pilote![e_mai]
tynuli = Pilote![Type_et_Numéro_Licence]
dob = Pilote![Date_d_obtention]
nhv = Pilote![Nombre_heures_vol]
qri = Pilote![Qualification_radio_internationale]
autlic = Pilote![Autres_licence_ou_qualification]
numpass = Pilote![Numéro_passeport]
ld = Pilote![Lieu_de_delivrance]
dexp = Pilote![Date_d_expiration]

Call Fermer2_Connection
End Sub
Public Sub affav(ByVal numpil As Integer, ByRef marc As String, ByRef typ As String, ByRef car As String, _
ByRef prop As String, ByRef nmcour As String, ByRef imm As String, ByRef dms As Date, ByRef hdv As Long)
Call Etablir2_Connection
Dim Reqsql As New ADODB.Command
Dim Avion As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Select * From Avion Where Avion.N°pilote =" & numpil & ""
Set Avion = Reqsql.Execute

marc = Avion![Marque_et_type]
typ = Avion![Type_et_puissance_du_ou_des_moteurs]
car = Avion![Carburant]
prop = Avion![Proprietaire_ou_exploitant]
nmcour = Avion![Nom_de_course]
imm = Avion![Immatriculation]
dms = Avion![Date_de_mise_en_service]
hdv = Avion![Heures_de_vol]

Call Fermer2_Connection
End Sub
Public Sub idno(ByVal numpil As Integer)

Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim Pilote As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Select N°pilote From Pilote Where N°pilote =  " & numpil & ""
Set Pilote = Reqsql.Execute
If Not Pilote.EOF = False Then
    MsgBox "Ce N°pilote n'existe pas, Veuillez en Choisir un autre ", vbInformation, "Information"

    Call Fermer2_Connection
       Exit Sub
    End If
Call Fermer2_Connection
  
End Sub
Public Sub suppilo(ByVal numpil As Integer, ByVal nom As String, ByVal pren As String, ByVal dl As String, ByVal nat As String, _
ByVal prof As String, ByVal ad As String, ByVal telper As Long, ByVal telpro As Long, ByVal em As String, ByVal tynuli As String, ByVal dob As Date, _
ByVal nhv As Long, ByVal qri As String, ByVal autlic As String, ByVal numpass As String, ByVal ld As String, ByVal dexp As Date)
Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim Pilote As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Delete From Pilote Where N°pilote = " & numpil & ""
Set Pilote = Reqsql.Execute
Call Fermer2_Connection
End Sub
Public Sub supav(ByVal numpil As Integer, ByVal marc As String, ByVal typ As String, ByVal car As String, _
ByVal prop As String, ByVal nmcour As String, ByVal imm As String, ByVal dms As Date, ByVal hdv As Long)
    'Procédure permettant d'inserrer dans les tables tous les renseignements
Call Etablir2_Connection

Dim Reqsql As New ADODB.Command
Dim Avion As New ADODB.Recordset
Reqsql.ActiveConnection = rallyes
Reqsql.CommandText = "Delete From Avion Where N°pilote = " & numpil & ""
 Set Avion = Reqsql.Execute
 Call Fermer2_Connection
End Sub

