Private Sub enregistrer_Click(sender As Object, e As EventArgs) Handles enregistrer.Click
Dim bdd As ADODB.Connection
Dim enreg As ADODB.Recordset
Dim cSQL As String
bdd = New ADODB.Connection
enreg = New ADODB.Recordset
Dim sourceDB As String
sourceDB = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=G2-INFO-A.accdb; Jet OLEDB:Database Password=1234"
Dim converPonde As Integer = Val(ponderation.Text)
cSQL = "INSERT INTO cours(codecours, libellecours, ponderation) VALUES ('" & codecours.Text & "','" & libellecours.Text & "', '" & converPonde & "')"
bdd.Open(sourceDB)
enreg.Open(cSQL, bdd, , , )
bdd.Close()
bdd = Nothing
enreg = Nothing
effacer()
MsgBox("OK")
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim bdd As ADODB.Connection
Dim enreg As ADODB.Recordset
Dim cSQL As String
bdd = New ADODB.Connection
enreg = New ADODB.Recordset
Dim sourceDB As String
sourceDB = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=G2-INFO-A.accdb; Jet OLEDB:Database Password=1234"
Dim converPonde As Integer = Val(ponderation.Text)
cSQL = "SELECT * FROM cours WHERE codecours = '" & codecours.Text & "' "
bdd.Open(sourceDB)
enreg.Open(cSQL, bdd, , , )

If Not enreg.EOF Then
libellecours.Text = enreg.Fields(1).Value
ponderation.Text = enreg.Fields(2).Value
Else
MsgBox("L'enregistrement n'existe pas")
End If

bdd.Close()
bdd = Nothing
enreg = Nothing

End Sub

Public Sub effacer()
codecours.Text = ""
libellecours.Text = ""
ponderation.Text = ""
End Sub

Private Sub nettoyer_Click(sender As Object, e As EventArgs) Handles nettoyer.Click
effacer()

End Sub

Private Sub supprimer_Click(sender As Object, e As EventArgs) Handles supprimer.Click
Dim bdd As ADODB.Connection
Dim enreg As ADODB.Recordset
Dim cSQL As String
bdd = New ADODB.Connection
enreg = New ADODB.Recordset
Dim sourceDB As String
sourceDB = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=G2-INFO-A.accdb; Jet OLEDB:Database Password=1234"
Dim converPonde As Integer = Val(ponderation.Text)
Dim confirmation As String

confirmation = MsgBox("Voulez-vous vraiment supprimer ?", MsgBoxStyle.YesNo)
If confirmation = vbYes Then
cSQL = "DELETE FROM cours WHERE codecours = '" & codecours.Text & "' "
bdd.Open(sourceDB)
enreg.Open(cSQL, bdd, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
bdd.Close()
bdd = Nothing
enreg = Nothing
effacer()
MsgBox("Supression effectuée")
End If
End Sub

Private Sub modifier_Click(sender As Object, e As EventArgs) Handles modifier.Click
Dim bdd As ADODB.Connection
Dim enreg As ADODB.Recordset
Dim cSQL As String
bdd = New ADODB.Connection
enreg = New ADODB.Recordset
Dim sourceDB As String
sourceDB = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=G2-INFO-A.accdb; Jet OLEDB:Database Password=1234"
Dim converPonde As Integer = Val(ponderation.Text)
cSQL = "SELECT * FROM cours WHERE codecours = '" & codecours.Text & "' "
bdd.Open(sourceDB)
enreg.Open(cSQL, bdd, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
If Not enreg.EOF Then
enreg.Fields("libellecours").Value = libellecours.Text
enreg.Fields("ponderation").Value = converPonde
enreg.UpdateBatch()
End If

bdd.Close()
bdd = Nothing
enreg = Nothing
effacer()
MsgBox("Modification effectuée")
'End If

End Sub

Private Sub quitter_Click(sender As Object, e As EventArgs) Handles quitter.Click
End
End Sub