Bonsoir.
Je reviens sur ce forum pour un autre problème.
Je fais toujours un mini projet , sur l'informatisation d'un cabinet medical.
Nom : vb1.PNG
Affichages : 1942
Taille : 70,2 Ko

Tous mes boutons sont fonctionnels ainsi que (suiv , prec , prem , derni , recherche)
sauf le boutons de l'ajout (Nouveau) et celui de la suppressions .
En faite , je sais pas comment faire pour enregistrer de nouvelles données (nom , prenom patient ect.. , les consultations ect..) en couplant le datagridview et textbox.text dans ma base de données access (2007)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Public Class Form1
    Dim Cnx As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Kane\Desktop\Cabinet Medical\Cabinet Medical.mdb")
    Dim daPat As New OleDbDataAdapter("Select * From Patients", Cnx)
    Dim daCons As New OleDbDataAdapter("Select * From Consultations , Medicaments , Contient Where Medicaments.NumMedicament = Contient.NumMedicament AND Consultations.NumConsult = Contient.NumConsult", Cnx)
    Dim dst As New DataSet
    Dim dtPat As DataTable
    Dim dtCons As DataTable
    Dim numligne As Integer
    Dim NumPtnt As Long
    Dim DtGridBS As New BindingSource
    Sub affichePat()
        TextNumPat.Text = dtPat.Rows(numligne).Item(0)
        TextNom.Text = dtPat.Rows(numligne).Item(1)
        TextPre.Text = dtPat.Rows(numligne).Item(2)
        TextSex.Text = dtPat.Rows(numligne).Item(3)
        TextDne.Text = dtPat.Rows(numligne).Item(4)
        TextProf.Text = dtPat.Rows(numligne).Item(5)
        TextAds.Text = dtPat.Rows(numligne).Item(6)
    End Sub
    Sub afficheCons()
        daCons.Fill(dst, "Consultations")
        dtCons = dst.Tables("Consultations")
        affichePat()
        DataGridView1.DataSource = dtCons
        DtGridBS.DataSource = dtCons
        Me.DataGridView1.Columns(8).Visible = False
        Me.DataGridView1.Columns(9).Visible = False
        DtGridBS.Filter = "NumPtnt = '" & TextNumPat.Text & "'"
    End Sub
    Sub afficheBD()
        DtGridBS.Filter = "NumPtnt = '" & TextNumPat.Text & "'"
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Cnx.Open()
            numligne = 0
            daPat.Fill(dst, "Patients")
            dtPat = dst.Tables("Patients")
            affichePat()
            afficheCons()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub BtnSuiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSuiv.Click
        numligne += 1
        If numligne = dtPat.Rows.Count Then
            numligne = 0
        End If
        affichePat()
        afficheBD()
    End Sub
 
    Private Sub BtnPrec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrec.Click
        numligne -= 1
        If numligne < 0 Then
            numligne = dtPat.Rows.Count - 1
        End If
        affichePat()
        afficheBD()
    End Sub
 
    Private Sub BtnPrem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrem.Click
        numligne = 0
        affichePat()
        afficheBD()
    End Sub
 
    Private Sub BtnDern_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDern.Click
        numligne = dtPat.Rows.Count - 1
        affichePat()
        afficheBD()
    End Sub
 
    Private Sub BtnRech_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRech.Click
        Dim R As Integer
        R = InputBox("Entrer l'IDentifiant du Patient")
        numligne = 0
        While R <> dtPat.Rows(numligne).Item(0) And numligne < dtPat.Rows.Count - 1
            numligne += 1
        End While
        If numligne = dtPat.Rows.Count - 1 And R <> dtPat.Rows(numligne).Item(0) Then
            MsgBox("Patient Non Trouve ou Inconnue")
        Else
            affichePat()
            afficheBD()
        End If
    End Sub
End Class