Top Ad unit 728 × 90

Application de gestion pharmaceutique avec Visual Basic .net

Voici les étapes à suivre :

La gestion est devenue une opération indispensable, c’est pour cette raison qu’on abordera dans cet article  une conception avec une  interface qui  permettra d’informatiser le système  d’une pharmacie.




Ressources logicielles :

Analyse :

PowerAMC Evaluation 11

Développement :

· Visual basic 2008

· Microsoft Access 2007


1. Cahier des charges :

1-1 : Analyse des besoins :

Cette démarche nous permettra d'identifier les besoins rencontrés par un pharmacien afin de mener à bon port sa gestion pharmaceutique.
Durant cette étude les besoins rencontrés sont les suivants :
  • Gérer les opérations de ventes.
  • Gérer les opérations vis à vis les fournisseurs.
  • Gérer la liste des médicaments.
  • Gérer les familles de médicaments.
  • Gérer les différents stocks.
  • Gérer les différentes commandes.
1-2 : Règles de gestion :
  • La table Médicament est définie par un code, un libellé et un prix.
  • La table Stock est définie par un numéro de stock et la quantité de médicament.
  • La table  Famille est définie par un code et une désignation.
  • La table Fournisseur est définie par un code, un nom, une adresse, une ville et un numéro de téléphone.
  • La table vente est définie par un numéro, une date et un montant.
  • Un médicament peut être stocké dans un ou plusieurs stocks.
  • Un médicament appartient à une et une seule famille.
  • Un médicament peut être vendu plusieurs fois selon la quantité demandée.
  • La commande peut faire l'objet de plusieurs médicaments.
  • Un stock contient plusieurs médicaments.
  • Une famille rassemble plusieurs médicaments.
  • Un fournisseur peut fournir plusieurs commandes.
  • Une commande est fournie par un et un seul fournisseur.
  • Une vente peut faire l'objet de plusieurs médicaments.
1-3 : Modèle Conceptuel des Données -MCD-:

 1-3 : Modèle Logique des Données -MLD-:


 2. Réalisation du projet:
Cette partie contient les descriptions des différentes interfaces VB avec les codes sources des différents boutons de commande.
Médicament:

 Public Class Médicament
    Private Sub GroupBox3_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox3.Enter
    End Sub
    Private Sub Médicament_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error GoTo etiq
        If cn.State = ConnectionState.Closed Then
            Call connect()
        End If
Exit Sub
etiq:
With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton liste des médicaments
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error GoTo etiq
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "SELECT Médicament.*, Stockmed.Numstock, Stockmed.QuantitéMedi, Commande.Codefournisseur FROM Commande INNER JOIN ((Médicament INNER JOIN Stockmed ON Médicament.CodeMedicament = Stockmed.CodeMedicament) INNER JOIN commandemed ON Médicament.CodeMedicament = commandemed.CodeMédicament) ON Commande.Numcommande = commandemed.Numcommande"
        datread = req.ExecuteReader
        If Not datread.HasRows Then
            MsgBox("La table est vide  !", MsgBoxStyle.Exclamation, "Opération d'affichage")
        Else
            Do While datread.Read
                ListBox1.Items.Add(datread.GetValue(0) & "-----" & datread.GetValue(1) & "-----" & datread.GetValue(2) & "-----" & datread.GetValue(3) & "-----" & datread.GetValue(4) & "-----" & datread.GetValue(5) & "-----" & datread.GetValue(6))
            Loop
        End If
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton commander
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error GoTo etiq
        Me.Hide()
        Commande.Show()
        Commande.TextBox1.Text = Me.TextBox1.Text
        Commande.TextBox4.Text = Me.TextBox2.Text
        Commande.TextBox5.Text = Me.TextBox3.Text
        Commande.TextBox7.Text = Me.TextBox5.Text
        Commande.TextBox9.Text = Me.TextBox4.Text
Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton rechercher
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        On Error GoTo etiq
        Dim reqrech As New OleDb.OleDbCommand
        Dim reqrech2 As New OleDb.OleDbCommand
        Dim datreadrech, datreadrech2 As OleDb.OleDbDataReader
        reqrech.Connection = cn
        reqrech.CommandType = CommandType.Text
        reqrech.CommandText = "select * from Médicament where CodeMedicament = '" & TextBox1.Text & "'"
        datreadrech = reqrech.ExecuteReader
        reqrech2.Connection = cn
        reqrech2.CommandType = CommandType.Text
        reqrech2.CommandText = "select * from stockmed  where CodeMedicament = '" & TextBox1.Text & "'"
        datreadrech2 = reqrech2.ExecuteReader
        If Not datreadrech.HasRows Then
            MsgBox("Le numéro du médicament recherché n'existe pas ", MsgBoxStyle.Exclamation, "Opération de recherche")
        Else
            MsgBox("La recherche est fructueuse !", MsgBoxStyle.Information, "Opération de recherche")
            datreadrech.Read()
            TextBox1.Text = datreadrech.GetValue(0)
            TextBox2.Text = datreadrech.GetValue(2)
            TextBox3.Text = datreadrech.GetValue(1)
            TextBox4.Text = datreadrech.GetValue(3)
            datreadrech2.Read()
            TextBox5.Text = datreadrech2.GetValue(0)
        End If
        datreadrech.Close()
        datreadrech2.Close()
        Exit Sub
etiq:
 With Err()
MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton modifier
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        On Error GoTo etiq
        Dim reqmodif As New OleDb.OleDbCommand
        reqmodif.Connection = cn
        reqmodif.CommandType = CommandType.Text
        reqmodif.CommandText = "update médicament set libellemedicament='" & TextBox2.Text & "',codefamille='" & Val(TextBox3.Text) & "',prix='" & Val(TextBox4.Text) & "'where codemedicament ='" & TextBox1.Text & "'"
        reqmodif.ExecuteNonQuery()
        Dim reqmodiff As New OleDb.OleDbCommand
        reqmodiff.Connection = cn
        reqmodiff.CommandType = CommandType.Text
        reqmodiff.CommandText = "update stockmed set numstock ='" & TextBox5.Text & "' where codemedicament ='" & TextBox1.Text & "'"
        reqmodiff.ExecuteNonQuery()
        MsgBox("L'opération de modification est efféctuée avec succés!", MsgBoxStyle.Information, "Opération de modification")
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton supprimer
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        On Error GoTo etiq
        Dim reqsuppr As New OleDb.OleDbCommand
        Dim reqsuppr1 As New OleDb.OleDbCommand
        Dim reqsuppr2 As New OleDb.OleDbCommand
        Dim reqsuppr3 As New OleDb.OleDbCommand
        Dim reqmod As New OleDb.OleDbCommand
reqsuppr1.Connection = cn
        reqsuppr1.CommandType = CommandType.Text
        reqsuppr1.CommandText = "delete * from commandemed where codemédicament='" & TextBox1.Text & "'"
        reqsuppr1.ExecuteNonQuery()
        reqsuppr2.Connection = cn
        reqsuppr2.CommandType = CommandType.Text
        reqsuppr2.CommandText = "delete * from stockmed where codemedicament='" & TextBox1.Text & "'"
        reqsuppr2.ExecuteNonQuery()
        reqsuppr3.Connection = cn
        reqsuppr3.CommandType = CommandType.Text
        reqsuppr3.CommandText = "delete * from ventemed where codemédicament='" & TextBox1.Text & "'"
        reqsuppr3.ExecuteNonQuery()
 reqsuppr.Connection = cn
 reqsuppr.CommandType = CommandType.Text
        reqsuppr.CommandText = "delete * from médicament where codemedicament='" & TextBox1.Text & "'"
        reqsuppr.ExecuteNonQuery()
        MsgBox("L'opération de suppression est efféctuée avec succés !", MsgBoxStyle.Information, " Opération de suppression")
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton réinitialiser
   
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        On Error GoTo etiq
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        ListBox1.Items.Clear()
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton Quitter
    Private Sub Button8_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        On Error GoTo etiq
        Me.Hide()
        Pharmacie.Show()
Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source
 End With
 End Sub
Bouton choisir
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        On Error GoTo etiq
        Me.Hide()
        famille.Show()
        Exit Sub
etiq:
        With Err()
MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Left = Label1.Left - 10
        If Label1.Left < 0 Then
            Label1.Left = 280
        End If
    End Sub
       End Class
Commande




Public Class Commande
Bouton listes des commandes  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error GoTo etiq
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "select * from Commande"
        datread = req.ExecuteReader
        If Not datread.HasRows Then
            MsgBox("La table est vide  !", MsgBoxStyle.Exclamation, "Opération d'affichage")
        Else
            Do While datread.Read
                ListBox1.Items.Add(datread.GetValue(0) & "---" & datread.GetValue(1) & "---" & datread.GetValue(2) & "---" & datread.GetValue(3))
            Loop
        End If
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton réinitialiser
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        On Error GoTo etiq
        ListBox1.Items.Clear()
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Commande_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
Bouton quitter
   
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        On Error GoTo etiq
        Me.Hide()
        Médicament.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton enregistrer la commande   
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error GoTo etiq
        Dim reqcom1 As New OleDb.OleDbCommand
        Dim reqcom2 As New OleDb.OleDbCommand
        Dim reqcom3 As New OleDb.OleDbCommand
        Dim reqcom4 As New OleDb.OleDbCommand
        Dim reqcom5 As New OleDb.OleDbCommand
        Dim reqcom6 As New OleDb.OleDbCommand
        Dim reqqq As New OleDb.OleDbCommand
        Dim datr As OleDb.OleDbDataReader
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        Dim reqmod3 As New OleDb.OleDbCommand
        Dim reqcom7 As New OleDb.OleDbCommand
        Dim datread2 As OleDb.OleDbDataReader
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "SELECT * FROM Stockmed where ([numstock]='" & TextBox7.Text & "' And [codemedicament]='" & TextBox1.Text & "')"
        datread2 = req.ExecuteReader
        datread2.Read()
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = "select * from commande where numcommande = '" & TextBox3.Text & "'"
        datread1 = req1.ExecuteReader
        datread1.Read()
        reqqq.Connection = cn
        reqqq.CommandType = CommandType.Text
        reqqq.CommandText = "Select * from médicament where codemedicament ='" & TextBox1.Text & "'"
        datr = reqqq.ExecuteReader
        If Not datr.HasRows Then
            If Not datread1.HasRows Then
                reqcom1.Connection = cn
                reqcom1.CommandType = CommandType.Text
                reqcom1.CommandText = "insert into Commande values('" & TextBox3.Text & "','" & TextBox6.Text & "','" & TextBox2.Text & "','" & Val(TextBox10.Text) & "')"
                reqcom1.ExecuteNonQuery()
            Else
                reqmod3.Connection = cn
                reqmod3.CommandType = CommandType.Text
                reqmod3.CommandText = "update commande set [montantcommande] = [montantcommande] + " & Val(TextBox10.Text) & " where ([numcommande]='" & TextBox3.Text & "')"
                reqmod3.ExecuteNonQuery()
            End If
            reqcom2.Connection = cn
            reqcom2.CommandType = CommandType.Text
            reqcom2.CommandText = "insert into Médicament values('" & TextBox1.Text & "','" & Val(TextBox5.Text) & "','" & TextBox4.Text & "','" & Val(TextBox9.Text) & "')"
            reqcom2.ExecuteNonQuery()
            reqcom3.Connection = cn
            reqcom3.CommandType = CommandType.Text
            reqcom3.CommandText = "insert into Commandemed values('" & TextBox3.Text & "','" & TextBox1.Text & "','" & TextBox8.Text & "')"
            reqcom3.ExecuteNonQuery()
            reqcom7.Connection = cn
            reqcom7.CommandType = CommandType.Text
            reqcom7.CommandText = "insert into  stockmed values ('" & TextBox7.Text & "','" & TextBox1.Text & "','" & Val(TextBox8.Text) & "')"
            reqcom7.ExecuteNonQuery()
            reqcom5.Connection = cn
            reqcom5.CommandType = CommandType.Text
            reqcom5.CommandText = "update stock set [quantité] = [quantité] +" & Val(TextBox8.Text) & " where numstock ='" & TextBox7.Text & "'"
            reqcom5.ExecuteNonQuery()
        Else
            If Not datread2.HasRows Then
                reqcom7.Connection = cn
                reqcom7.CommandType = CommandType.Text
                reqcom7.CommandText = "insert into  stockmed values ('" & TextBox7.Text & "','" & TextBox1.Text & "','" & Val(TextBox8.Text) & "')"
                reqcom7.ExecuteNonQuery()
            Else
                reqcom5.Connection = cn
reqcom5.CommandType = CommandType.Text
                reqcom5.CommandText = "update stockmed set [quantitémedi] = [quantitémedi] +" & Val(TextBox8.Text) & " where numstock ='" & TextBox7.Text & "'"
                reqcom5.ExecuteNonQuery()
End If
            reqcom5.Connection = cn
            reqcom5.CommandType = CommandType.Text
            reqcom5.CommandText = "update stock set [quantité] = [quantité] +" & Val(TextBox8.Text) & " where numstock ='" & TextBox7.Text & "'"
            reqcom5.ExecuteNonQuery()
If Not datread1.HasRows Then
reqcom1.Connection = cn
                reqcom1.CommandType = CommandType.Text
                reqcom1.CommandText = "insert into Commande values('" & TextBox3.Text & "','" & TextBox6.Text & "','" & TextBox2.Text & "','" & Val(TextBox10.Text) & "')"
                reqcom1.ExecuteNonQuery()
            Else
                reqmod3.Connection = cn
                reqmod3.CommandType = CommandType.Text
                reqmod3.CommandText = "update commande set [montantcommande] = [montantcommande] + " & Val(TextBox10.Text) & " where ([numcommande]='" & TextBox3.Text & "')"
                reqmod3.ExecuteNonQuery()
            End If
            reqcom3.Connection = cn
            reqcom3.CommandType = CommandType.Text
            reqcom3.CommandText = "insert into Commandemed values('" & TextBox3.Text & "','" & TextBox1.Text & "','" & TextBox8.Text & "')"
            reqcom3.ExecuteNonQuery()
End If
        datread1.Close()
        datread2.Close()
        datr.Close()
MsgBox("L'opération d'ajout est efféctuée avec succés !", MsgBoxStyle.Information, "Opération d'ajout")
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Left = Label1.Left - 10
        If Label1.Left < 0 Then
            Label1.Left = 280
        End If
    End Sub
End Class

Famille:

Public Class famille
Bouton valider
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error GoTo etiq
        Médicament.TextBox3.Text = Me.TextBox1.Text
        Me.Hide()
        Médicament.Show()
Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton quitter
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error GoTo etiq
        Me.Hide()
        Médicament.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error GoTo etiq
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "select * from famille"
        datread = req.ExecuteReader
        If Not datread.HasRows Then
            MsgBox("La table est vide !", MsgBoxStyle.Exclamation, "Opération d'affichage")
        Else
            Do While datread.Read
                ListBox1.Items.Add(datread.GetValue(0) & "---" & datread.GetValue(1))
            Loop
        End If
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Left = Label1.Left - 10
        If Label1.Left < 0 Then
            Label1.Left = 280
        End If
    End Sub
End Class
Fournisseur:


Public Class Fournisseur
    Bouton afficher
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error GoTo etiq
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "select * from fournisseur"
        datread = req.ExecuteReader
        If Not datread.HasRows Then
            MsgBox("La table est vide !", MsgBoxStyle.Exclamation, "Opération d'affichage")
        Else
            Do While datread.Read
                ListBox1.Items.Add(datread.GetValue(0) & "---" & datread.GetValue(1) & "---" & datread.GetValue(2) & "---" & datread.GetValue(3) & "---" & datread.GetValue(4))
            Loop
        End If
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Fournisseur_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error GoTo etiq
        If cn.State = ConnectionState.Closed Then
            Call connect()
        End If
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton ajouter
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error GoTo etiq
        Dim reqajout As New OleDb.OleDbCommand
        reqajout.Connection = cn
        reqajout.CommandType = CommandType.Text
        reqajout.CommandText = "insert into fournisseur values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"
        reqajout.ExecuteNonQuery()
        MsgBox("L'opération d'ajout est efféctuée avec succés!", MsgBoxStyle.Information, "Opération d'ajout")
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton rechercher
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        On Error GoTo etiq
        Dim reqrech As New OleDb.OleDbCommand
        Dim datreadrech As OleDb.OleDbDataReader
        reqrech.Connection = cn
        reqrech.CommandType = CommandType.Text
        reqrech.CommandText = "select * from Fournisseur where CodeFournisseur = '" & TextBox1.Text & "'"
        datreadrech = reqrech.ExecuteReader
        If Not datreadrech.HasRows Then
            MsgBox("Le numéro du fournisseur recherché n'existe pas ", MsgBoxStyle.Exclamation, "Opération de recherche")
        Else
            MsgBox("La recherche est fructueuse !", MsgBoxStyle.Information, "Opération de recherche")
            datreadrech.Read()
            TextBox1.Text = datreadrech.GetValue(0)
            TextBox2.Text = datreadrech.GetValue(1)
            TextBox3.Text = datreadrech.GetValue(2)
            TextBox4.Text = datreadrech.GetValue(3)
            TextBox5.Text = datreadrech.GetValue(4)
        End If
        datreadrech.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton modifier
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        On Error GoTo etiq
        Dim reqmodif As New OleDb.OleDbCommand
        reqmodif.Connection = cn
        reqmodif.CommandType = CommandType.Text
        reqmodif.CommandText = "update Fournisseur set Nom='" & TextBox2.Text & "',Adresse='" & TextBox3.Text & "',Ville='" & TextBox4.Text & "',Tél='" & TextBox5.Text & "'where codefournisseur ='" & TextBox1.Text & "'"
        reqmodif.ExecuteNonQuery()
        MsgBox("L'opération de modification est efféctuée avec succés!", MsgBoxStyle.Information, "Opération de modification")
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton supprimer
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        On Error GoTo etiq
        Dim reqsuppr As New OleDb.OleDbCommand
        reqsuppr.Connection = cn
        reqsuppr.CommandType = CommandType.Text
        reqsuppr.CommandText = "delete * from Fournisseur where CodeFournisseur='" & TextBox1.Text & "'"
        reqsuppr.ExecuteNonQuery()
        MsgBox("L'opération de suppression est efféctuée avec succés!", MsgBoxStyle.Information, "Opération de suppression")
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton réinitialiser
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        On Error GoTo etiq
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text() = ""
        TextBox5.Text = ""
        ListBox1.Items.Clear()
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton quitter
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        On Error GoTo etiq
        Me.Hide()
        MdiParent.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label6.Left = Label6.Left - 10
        If Label6.Left < 0 Then
            Label6.Left = 280
        End If
    End Sub
End Class

Stock:


Public Class Stock
Bouton quitter
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        On Error GoTo etiq
        Me.Hide()
        MdiParent.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton listes des stocks 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error GoTo etiq
        Dim req2 As New OleDb.OleDbConnection
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "SELECT Stock.*, Médicament.CodeMedicament, Stockmed.QuantitéMedi FROM Médicament INNER JOIN (Stock INNER JOIN Stockmed ON Stock.Numstock = Stockmed.Numstock) ON Médicament.CodeMedicament = Stockmed.CodeMedicament"
        datread = req.ExecuteReader
        If Not datread.HasRows Then
            MsgBox("Le numéro du stock recherché n'existe pas  !", MsgBoxStyle.Exclamation, "Opération d'affichage")
        Else
            Do While datread.Read
                ListBox1.Items.Add(datread.GetValue(0) & "---" & datread.GetValue(1) & " " & datread.GetValue(2) & " " & datread.GetValue(3))
            Loop
        End If
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Stock_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error GoTo etiq
        If cn.State = ConnectionState.Closed Then
            Call connect()
        End If
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton ajouter
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error GoTo etiq
        Dim reqajout As New OleDb.OleDbCommand
        Dim reqajout1 As New OleDb.OleDbCommand
        reqajout.Connection = cn
        reqajout.CommandType = CommandType.Text
        reqajout.CommandText = "insert into stock values('" & TextBox1.Text & "','" & Val(TextBox2.Text) & "')"
        reqajout1.Connection = cn
        reqajout1.CommandType = CommandType.Text
        reqajout1.CommandText = "insert into stockmed values('" & TextBox1.Text & "','" & TextBox3.Text & "','" & Val(TextBox4.Text) & " ')"
        reqajout.ExecuteNonQuery()
        reqajout1.ExecuteNonQuery()
        MsgBox("L'opération d'ajout est efféctuée avec succés!", MsgBoxStyle.Information, "Opération d'ajout")
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton rechercher   
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        On Error GoTo etiq
        Dim reqrech As New OleDb.OleDbCommand
        Dim datreadrech, datreadrech1 As OleDb.OleDbDataReader
        Dim reqrech2 As New OleDb.OleDbCommand
        reqrech2.Connection = cn
        reqrech.CommandType = CommandType.Text
        reqrech2.CommandText = "select * from Stockmed where numstock = '" & TextBox1.Text & "'"
        reqrech.Connection = cn
        reqrech.CommandType = CommandType.Text
        reqrech.CommandText = "select * from Stock where numstock = '" & TextBox1.Text & "'"
        datreadrech1 = reqrech2.ExecuteReader
        datreadrech = reqrech.ExecuteReader
        If Not datreadrech.HasRows Then
            MsgBox("Le numéro du stock recherché n'existe pas!", MsgBoxStyle.Exclamation, "Opération de recherche")
        Else
            MsgBox("La recherche est fructueuse !", MsgBoxStyle.Information, "Opération de recherche")
            datreadrech.Read()
            TextBox1.Text = datreadrech.GetValue(0)
            TextBox2.Text = datreadrech.GetValue(1)
            datreadrech1.Read()
            TextBox1.Text = datreadrech1.GetValue(0)
            TextBox3.Text = datreadrech1.GetValue(1)
            TextBox4.Text = datreadrech1.GetValue(2)
        End If
        datreadrech.Close()
        datreadrech1.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton supprimer
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
On Error GoTo etiq
Dim reqsuppr As New OleDb.OleDbCommand
Dim reqsuppr1 As New OleDb.OleDbCommand
Dim reqsuppr2 As New OleDb.OleDbComman
Dim reqsuppr3 As New OleDb.OleDbCommand
reqsuppr1.Connection = cn
reqsuppr1.CommandType = CommandType.Text
reqsuppr1.CommandText = "delete * from stockmed where numstock='" & TextBox1.Text & "'"
reqsuppr1.ExecuteNonQuery()
reqsuppr2.Connection = cn
reqsuppr2.CommandType = CommandType.Text
reqsuppr2.CommandText = "delete * from stock where numstock='" & TextBox1.Text & "'"
reqsuppr2.ExecuteNonQuery()
MsgBox("L'opération de suppression est efféctuée avec succés !", MsgBoxStyle.Information, " Opération de suppression")
        Exit Sub
etiq:
With Err()
MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton réinitialiser
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        On Error GoTo etiq
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        ListBox1.Items.Clear()
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Left = Label1.Left - 10
        If Label1.Left < 0 Then
            Label1.Left = 280
        End If
    End Sub
End Class
Vente:

Public Class Vente
Bouton Enregistrer la vente
   
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim reqajout As New OleDb.OleDbCommand
        Dim reqajout1 As New OleDb.OleDbCommand
        Dim reqmod As New OleDb.OleDbCommand
        Dim req2 As New OleDb.OleDbCommand
        Dim reqmod1, reqmod3 As New OleDb.OleDbCommand
        Dim req As New OleDb.OleDbCommand
        Dim reqmod2 As New OleDb.OleDbCommand
        Dim datread, datread1 As OleDb.OleDbDataReader
        Dim req1 As New OleDb.OleDbCommand
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = "select * from vente where Numerovente = '" & TextBox7.Text & "'"
        datread1 = req1.ExecuteReader
        datread1.Read()
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "SELECT * FROM Stockmed where ([numstock]='" & TextBox8.Text & "' And [codemedicament]='" & TextBox1.Text & "')"
        datread = req.ExecuteReader
        datread.Read()
        If datread.GetValue(2) > TextBox3.Text Then
            If datread.GetValue(2) < 10 Then
                MsgBox("Opération de vente inacssessible , veuillez vérifiez la quatité voulue !", MsgBoxStyle.Exclamation, "Opération de vente")
            Else
                If Not datread1.HasRows Then
                    reqajout.Connection = cn
                    reqajout.CommandType = CommandType.Text
                    reqajout.CommandText = "insert into vente values('" & TextBox7.Text & "','" & TextBox6.Text & "','" & TextBox5.Text & "')"
                    reqajout.ExecuteNonQuery()
                Else
                    reqmod3.Connection = cn
                    reqmod3.CommandType = CommandType.Text
                    reqmod3.CommandText = "update vente set [montantdevente] = [montantdevente] + " & Val(TextBox5.Text) & " where ([numerovente]='" & TextBox7.Text & "')"
                    reqmod3.ExecuteNonQuery()
                End If
                reqajout1.Connection = cn
                reqajout1.CommandType = CommandType.Text
                reqajout1.CommandText = "insert into ventemed values('" & TextBox7.Text & "','" & TextBox1.Text & "','" & TextBox3.Text & " ')"
                reqajout1.ExecuteNonQuery()
                reqmod1.Connection = cn
                reqmod1.CommandType = CommandType.Text
                reqmod1.CommandText = "update stock set [quantité] = [quantité] - " & Val(TextBox3.Text) & " where ([numstock]='" & TextBox8.Text & "')"
                reqmod1.ExecuteNonQuery()
                reqmod2.Connection = cn
                reqmod2.CommandType = CommandType.Text
                reqmod2.CommandText = "update stockmed set [quantitémedi] = [quantitémedi] - " & Val(TextBox3.Text) & " where ([numstock]='" & TextBox8.Text & "' And [codemedicament]='" & TextBox1.Text & "')"
                reqmod2.ExecuteNonQuery()
               
                MsgBox("L'opération d'ajout est efféctuée avec succés!", MsgBoxStyle.Information, "Opération d'ajout")
                End If
        Else
                MsgBox("Impossible d'éffectuer cette opération :quantité en stock inférieure à la quantité demandée", MsgBoxStyle.Exclamation, "Opération de vente . . .")
        End If
      
Exit Sub
End Sub
    Private Sub Vente_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error GoTo etiq
If cn.State = ConnectionState.Closed Then
            Call connect()
        End If
      
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton quitter    
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error GoTo etiq
        Me.Hide()
        MdiParent.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton liste médicaments   
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error GoTo etiq
        req.Connection = cn
        req.CommandType = CommandType.Text
        req.CommandText = "SELECT Médicament.*, Stockmed.Numstock, Stockmed.QuantitéMedi, Commande.Codefournisseur FROM Commande INNER JOIN ((Médicament INNER JOIN Stockmed ON Médicament.CodeMedicament = Stockmed.CodeMedicament) INNER JOIN commandemed ON Médicament.CodeMedicament = commandemed.CodeMédicament) ON Commande.Numcommande = commandemed.Numcommande"
        datread = req.ExecuteReader
        If Not datread.HasRows Then
            MsgBox("La table est vide  !", MsgBoxStyle.Exclamation, "Opération d'affichage")
        Else
            Do While datread.Read
                ListBox1.Items.Add(datread.GetValue(0) & "-----" & datread.GetValue(1) & "-----" & datread.GetValue(2) & "-----" & datread.GetValue(3) & "-----" & datread.GetValue(4) & "-----" & datread.GetValue(5) & "-----" & datread.GetValue(6))
            Loop
        End If
        datread.Close()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton réinitialiser   
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        On Error GoTo etiq
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        ListBox1.Items.Clear()
        datread.Close()
Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton calculer montant TTC   
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        On Error GoTo etiq
        TextBox5.Text = (Val(TextBox4.Text) + (Val(TextBox4.Text) * 0.07)) * Val(TextBox3.Text)
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Left = Label1.Left - 10
        If Label1.Left < 0 Then
            Label1.Left = 280
        End If
    End Sub
 End Class

Pharmacie (Multi Documents Interface) MDI:

Private Sub MédicamentsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MédicamentsToolStripMenuItem.Click
        On Error GoTo etiq
        Dim f1 As New Médicament
        f1.MdiParent = Me
        f1.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub StocksToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StocksToolStripMenuItem.Click
        On Error GoTo etiq
        Dim f2 As New Stock
        f2.MdiParent = Me
        f2.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub VentesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VentesToolStripMenuItem.Click
        On Error GoTo etiq
        Dim f3 As New Vente
        f3.MdiParent = Me
        f3.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub FournisseursToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FournisseursToolStripMenuItem.Click
        On Error GoTo etiq
        Dim f4 As New Fournisseur
        f4.MdiParent = Me
        f4.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click
        On Error GoTo etiq
        Dim rep As String
        rep = MsgBox("voulez vous vraiment quitter Oui/Non", MsgBoxStyle.YesNo + MsgBoxStyle.Information, "Confirmation de fermeture")
        If rep = vbYes Then
            End
End If
Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub DéconncterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DéconncterToolStripMenuItem.Click
        On Error GoTo etiq
        login.Show()
        Me.Visible = False
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Private Sub AProposDeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AProposDeToolStripMenuItem.Click
On Error GoTo etiq
        Dim f4 As New apropos
        f4.MdiParent = Me
        f4.Show()
        Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
End Class

Fenêtre de connexion:


Public Class login
Bouton OK
   
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error GoTo etiq
Dim reqlog As New OleDb.OleDbCommand
        Dim datlog As OleDb.OleDbDataReader
        reqlog.Connection = cn
        reqlog.CommandType = CommandType.Text
        reqlog.CommandText = "select * from utilisateur where login = '" & TextBox1.Text & "'and password ='" & TextBox2.Text & "'"
        datlog = reqlog.ExecuteReader
        datlog.Read()
        If Not datlog.HasRows Then
            MsgBox("le nom d'utilisateur ou mot de passe invalide", MsgBoxStyle.Information)
        Else
Pharmacie.Show()
            Me.Hide()
            TextBox1.Text = ""
            TextBox2.Text = ""
End If
Exit Sub
etiq:
        With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
Bouton annuler
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error GoTo etiq
        Me.Close()
        Exit Sub
etiq:
With Err()
            MsgBox("Erreur no:" & .Number & vbCrLf & "description :" & .Description & vbCrLf & "Apparu dans :" & .Source)
        End With
    End Sub
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call connect()
End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label3.Left = Label3.Left - 10
        If Label3.Left < 0 Then
            Label3.Left = 280
        End If
    End Sub
End Class

3. Conclusion
D’après la réalisation de ce travail, nous avons pu aboutir et apporter une réponse à notre problématique qui  consiste à réaliser une application de gestion de pharmacie.
Application de gestion pharmaceutique avec Visual Basic .net Reviewed by Badr Dev on 14:53 Rating: 5

Aucun commentaire:

All Rights Reserved by Cours Réparation : On vous Explique Comment © 2014 - 2023
Powered By Blogger, Designed by Sweetheme

Formulaire de contact

Nom

E-mail *

Message *

Fourni par Blogger.
Pour Trouvez D'autre Solution ... !!
Cliquer Sur " J'aime " ^_^