Pages

dimanche 30 octobre 2011

mini projet : gestion des vols avec visual basic .net


De nos  jours, les entreprises, organisations aussi petites quelles soient optent  pour l’informatisation de  leur système, pour les avantages qu’il leurs procure :
La facilite d’accès aux informations et la gestion  du  travail que se  soit pour le stock, la paie du personnel, la vente, l’achat, la maintenance, et toute autre information qu’on avait du mal à faire autrefois manuellement  et des cas où il  fallait nous déplacer  pour le faire, aujourd’hui c’est devenu possible  sans bouger et tout en investissant un tout petit effort.
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 Compagnie aérienne.


 Ressources logicielles :
 Analyse :

PowerAMC  Evaluation 11

 Développement :

·       Visual basic 2008
·       Microsoft Access 2007
·       Sunisoft IrisSkin For .net
 
1. Partie analyse :
1-1 : Analyse des besoins :
Cette démarche d’étude permet à identifier les besoins d’une compagnie aérienne. En effet nous avons réalisé une petite étude on s’appuie sur les informations disponible sur les sites web des compagnies très connue comme Royale Air Maroc et Jet4you.
 Durant cette étude on a pu identifier les besoins suivants :
Gérer les Réservations.
Gérer l’organisation de vols.
 Gérer les avions.
Gérer les lignes.
Gérer les pilotes.
Gérer les remises.
Gérer la sécurité.


1.2. Le modèle conceptuel de donnée (MCD): 

 
1.2.1. Les tables  :
Chaque Pilote  est caractérisé par :
N°pilote, nom, prénom, nationalité, adresse et N°Téléphone.
Chaque Vol est caractérisé par :
N°vol, date de départ et l’heure d’arrivé.
Chaque Avion est caractérisé par :
N°avion, Nom et capacité  total.
Chaque ligne est caractérisé par :
Aéroport de départ, aéroport d’arrivée et prix unitaire.
Chaque Passager est caractérisé par :
N°réservation, nom, prénom, N°passeport, Titre, nationalité et adresse mail.
Chaque Classe est caractérisé par :
Type classe et remise.
Chaque Catégorie est caractérisé par :
Type catégorie et remise.
1.2.2. Les cardinalités :

Un pilote peut être affecter de 1,n  vol
 Un vol peut être affecter de 1,n pilote
 Une ligne  concerne  1,n  vol
 Un vol concerne 1,1 ligne
Un passager peut réserver  dans 1, n vol
 Un vol peut avoir 1, n réservation
Un passager appartient  à 1,1 catégorie
Une catégorie peut avoir 1, n passager
Un passager peut réserver  dans 1, n classes
Une classe peut avoir 1, n passager
Un avion effectue 1, n vol
Un vol effectue par 1,1 avion
 Un avion contient 1, n classe
Une classe on peut trouver  dans 1, n avions
Un vol peut avoir 1, n nombre de réservation d’une classe
Une classe peut être réserver 1,n dans un vol

 1.3. Le modèle logique de donnée (MLD) : 
 
2. Partie développement :
Le module :
Imports System
Imports System.Data
Imports System.Data.OleDb

Module Module1
    Public cn As OleDb.OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\adil\Desktop\mini projet vb.net\base de données vb\gestion.mdb")
    Public numero_aller As Integer
    Public numero_retour As Integer
    Public type_res As String
    Public type_class As String

End Module
 
Réservation :
La fermeture de  la form :

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        cn.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As        System.EventArgs) Handles MyBase.Load
      

     Try
          
            cn.Open()
            Dim req1 As New OleDb.OleDbCommand
            Dim datread1 As OleDb.OleDbDataReader

            req1.Connection = cn

            req1.CommandType = CommandType.Text
            req1.CommandText = " select distinct aeroport_depart from
                                   ligne"
            datread1 = req1.ExecuteReader
            While datread1.Read
                ComboBox1.Items.Add(datread1.GetValue(0))
                ComboBox2.Items.Add(datread1.GetValue(0))
            End While
    Catch ex As Exception

            MsgBox(ex.Message)

    End Try
  End Sub

Radio button : Aller simple :

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If RadioButton1.Checked = True Then
            DateTimePicker2.Enabled = False
            type_res = "Aller simple"
        End If

    End Sub
Radio button : Aller/Retour :

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        If RadioButton2.Checked = True Then
            DateTimePicker2.Enabled = True
            type_res = "Aller - Retour"

        End If
    End Sub

Button : Rechercher :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.Text = "Aéroport de depart" Then
            MsgBox("il faut selectionner l'aéroport de depart")
        ElseIf ComboBox2.Text = "Aéroport d'arrivée" Then
            MsgBox("il faut selectionner l'aéroport d'arrivée")

        ElseIf RadioButton1.Checked = True Then
            Form2.Show()
          
        Me.Hide()
        Else
           
           Form3.Show()
            Me.Hide()
        End If
    End Sub
ComboBox : Aéroport de depart :

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text <> "Aéroport de depart" Then
            ComboBox2.Items.Clear()
            ComboBox2.Text = "Aéroport d'arrivée"

            Dim req1 As New OleDb.OleDbCommand
            Dim datread1 As OleDb.OleDbDataReader

            req1.Connection = cn
            req1.CommandType = CommandType.Text
            req1.CommandText = " select distinct aeroport_arrivee from ligne where aeroport_depart ='" & ComboBox1.Text & "' "

            datread1 = req1.ExecuteReader
            While datread1.Read
                ComboBox2.Items.Add(datread1.GetValue(0))
            End While
        End If
    End Sub

Button : Annuler :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

Button radio : economique :

    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
        type_class = "economique"
    End Sub
Button radio : homme d’affaire :

    Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
       
type_class = "homme d'affaire"

     End Sub

 
Button : Prècedent :

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form1.Show()
        Me.Close()
    End Sub
Button : Suivant :

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim trouve1 As Integer = 0
        Dim trouve2 As Integer = 0

        For i As Integer = 0 To DataGridView1.RowCount - 1
            If DataGridView1.Item(0, i).Value = True Then
                trouve1 = trouve1 + 1
                numero_aller = DataGridView1.Item(1, i).Value
            End If
        Next

        For i As Integer = 0 To DataGridView2.RowCount - 1
            If DataGridView2.Item(0, i).Value = True Then
                trouve2 = trouve2 + 1
                numero_retour = DataGridView2.Item(1, i).Value
            End If
        Next
 If trouve1 = 0 Then
           


            MsgBox("vous n'avez pas selectionner un vol d'aller !!!!")
        ElseIf trouve1 > 1 Then
            MsgBox("vous avez selectionner plusieurs vols d'aller en meme temps !!!!")
        ElseIf trouve2 = 0 Then
            MsgBox("vous n'avez pas selectionner un vol de retour!!!!")
        ElseIf trouve2 > 1 Then
            MsgBox("vous avez selectionner plusieurs vols de retour en meme temps !!!!")
        Else

            Form4.Show()
            Me.Hide()
        End If

    End Sub
Chargement de la form :

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        If Form1.RadioButton5.Checked Then
            req1.CommandText = " SELECT N°vol,date_depart,heure_depart
FROM(SELECT vol.N°vol, vol.date_depart, vol.heure_depart, place_reserver.type_classe, place_reserver.nb_reservation, avion.N°avion, capacité.nb_place, vol.aeroport_depart, vol.aeroport_arrivee, vol.duree_vol FROM (classe INNER JOIN ((avion INNER JOIN capacité ON avion.N°avion = capacité.N°avion) INNER JOIN vol ON avion.N°avion = vol.N°avion) ON classe.type_classe = capacité.type_classe) INNER JOIN place_reserver ON (vol.N°vol = place_reserver.N°vol) AND (classe.type_classe = place_reserver.type_classe)) where aeroport_depart='" & Form1.ComboBox1.Text & "' and aeroport_arrivee='" & Form1.ComboBox2.Text &
"' and type_classe='economique' and nb_reservation < nb_place and date_depart> #" & Date.Today.ToString("MM/dd/yyyy") & "# "

        ElseIf Form1.RadioButton6.Checked Then

            req1.CommandText = " SELECT N°vol,date_depart,heure_depart FROM(SELECT vol.N°vol, vol.date_depart, vol.heure_depart, place_reserver.type_classe, place_reserver.nb_reservation, avion.N°avion, capacité.nb_place, vol.aeroport_depart, vol.aeroport_arrivee, vol.duree_vol FROM (classe INNER JOIN ((avion INNER JOIN capacité ON avion.N°avion = capacité.N°avion) INNER JOIN vol ON avion.N°avion = vol.N°avion) ON classe.type_classe = capacité.type_classe) INNER JOIN place_reserver ON (vol.N°vol = place_reserver.N°vol) AND (classe.type_classe = place_reserver.type_classe)) where aeroport_depart='" & Form1.ComboBox1.Text & "' and aeroport_arrivee='" & Form1.ComboBox2.Text & "' and type_classe='homme d''affaire' and nb_reservation < nb_place and date_depart> #" & Date.Today.ToString("MM/dd/yyyy") & "# "
      
 End If
        datread1 = req1.ExecuteReader

       If Not datread1.HasRows Then
            MsgBox("aucun vol n'ai organiser pour le moment !!!")
        Else
            While datread1.Read
   
   DataGridView1.Rows.Add(False, datread1.GetValue(0), datread1.GetDateTime(1).ToString("dd/MM/yyyy"), datread1.GetDateTime(2).ToString("HH:mm"))
            End While
        End If

        Dim req2 As New OleDb.OleDbCommand
        Dim datread2 As OleDb.OleDbDataReader

        req2.Connection = cn

        req2.CommandType = CommandType.Text
        If Form1.RadioButton5.Checked Then
            req2.CommandText = " SELECT N°vol,date_depart,heure_depart FROM(SELECT vol.N°vol, vol.date_depart, vol.heure_depart, place_reserver.type_classe, place_reserver.nb_reservation, avion.N°avion, capacité.nb_place, vol.aeroport_depart, vol.aeroport_arrivee, vol.duree_vol FROM (classe INNER JOIN ((avion INNER JOIN capacité ON avion.N°avion = capacité.N°avion) INNER JOIN vol ON avion.N°avion = vol.N°avion) ON classe.type_classe = capacité.type_classe) INNER JOIN place_reserver ON (vol.N°vol = place_reserver.N°vol) AND (classe.type_classe = place_reserver.type_classe)) where aeroport_depart='" & Form1.ComboBox2.Text & "' and aeroport_arrivee='" & Form1.ComboBox1.Text & "' and type_classe='economique' and nb_reservation < nb_place and date_depart> #" & Date.Today.ToString("MM/dd/yyyy") & "# "

        ElseIf Form1.RadioButton6.Checked Then

            req2.CommandText = " SELECT N°vol,date_depart,heure_depart FROM(SELECT vol.N°vol, vol.date_depart, vol.heure_depart, place_reserver.type_classe, place_reserver.nb_reservation, avion.N°avion, capacité.nb_place, vol.aeroport_depart, vol.aeroport_arrivee, vol.duree_vol FROM (classe INNER JOIN ((avion INNER JOIN capacité ON avion.N°avion =


capacité.N°avion) INNER JOIN vol ON avion.N°avion = vol.N°avion) ON classe.type_classe = capacité.type_classe) INNER JOIN place_reserver ON (vol.N°vol = place_reserver.N°vol) AND (classe.type_classe = place_reserver.type_classe)) where aeroport_depart='" & Form1.ComboBox2.Text & "' and aeroport_arrivee='" & Form1.ComboBox1.Text & "' and type_classe='homme d''affaire' and nb_reservation < nb_place and date_depart> #" & Date.Today.ToString("MM/dd/yyyy") & "# "
        End If

        datread2 = req2.ExecuteReader

        If Not datread2.HasRows Then
            MsgBox("aucun vol n'ai organiser pour le moment !!!")
       
     
            Else
            While datread2.Read
                DataGridView2.Rows.Add(False, datread2.GetValue(0), datread2.GetDateTime(1).ToString("MM/dd/yyyy"), datread2.GetDateTime(2).ToString("HH:mm"))
            End While
        End If
    End Sub
 
Button : Prècedent :

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  Form1.Show()
        Me.Close()
    End Sub
Button : Suivant :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim trouve As Integer = 0
        For i As Integer = 0 To DataGridView1.RowCount - 1
            If DataGridView1.Item(0, i).Value = True Then
                trouve = trouve + 1
                numero_aller = DataGridView1.Item(1, i).Value
            End If
        Next
        If trouve = 0 Then
         


  MsgBox("vous n'avez pas selectionner une vol !!!!")
        ElseIf trouve > 1 Then
            MsgBox("vous avez selectionner plusieurs vols en meme temps !!!!")
        Else
            Form4.Show()
            Me.Hide()
        End If
    End Sub
Button : chargement de la form:

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader

        req1.Connection = cn

        req1.CommandType = CommandType.Text
        If Form1.RadioButton5.Checked Then
            req1.CommandText = " SELECT N°vol,date_depart,heure_depart FROM(SELECT vol.N°vol, vol.date_depart, vol.heure_depart, place_reserver.type_classe, place_reserver.nb_reservation, avion.N°avion, capacité.nb_place, vol.aeroport_depart, vol.aeroport_arrivee, vol.duree_vol FROM (classe INNER JOIN ((avion INNER JOIN capacité ON avion.N°avion = capacité.N°avion) INNER JOIN vol ON avion.N°avion = vol.N°avion) ON classe.type_classe = capacité.type_classe) INNER JOIN place_reserver ON (vol.N°vol = place_reserver.N°vol) AND (classe.type_classe = place_reserver.type_classe)) where aeroport_depart='" & Form1.ComboBox1.Text & "' and aeroport_arrivee='" & Form1.ComboBox2.Text & "' and type_classe='economique' and nb_reservation < nb_place and date_depart> #" & Date.Today.ToString("MM/dd/yyyy") & "# "

        ElseIf Form1.RadioButton6.Checked Then

            req1.CommandText = " SELECT N°vol,date_depart,heure_depart FROM(SELECT vol.N°vol, vol.date_depart, vol.heure_depart, place_reserver.type_classe, place_reserver.nb_reservation, avion.N°avion, capacité.nb_place, vol.aeroport_depart, vol.aeroport_arrivee, vol.duree_vol FROM (classe INNER JOIN ((avion INNER JOIN capacité ON avion.N°avion = capacité.N°avion) INNER JOIN vol ON avion.N°avion = vol.N°avion) ON
classe.type_classe = capacité.type_classe) INNER JOIN place_reserver ON (vol.N°vol = place_reserver.N°vol) AND (classe.type_classe = place_reserver.type_classe)) where aeroport_depart='" & Form1.ComboBox1.Text & "' and aeroport_arrivee='" & Form1.ComboBox2.Text & "' and type_classe='homme d''affaire' and nb_reservation < nb_place and date_depart> #" & Date.Today.ToString("MM/dd/yyyy") & "# "
        End If
        datread1 = req1.ExecuteReader
        If Not datread1.HasRows Then
            MsgBox("aucun vol n'ai organiser pour le moment !!!")
        Else
            While datread1.Read
                DataGridView1.Rows.Add(False, datread1.GetValue(0), datread1.GetDateTime(1).ToString("dd/MM/yyyy"), datread1.GetDateTime(2).ToString("HH:mm"))
            End While
     

  End If

    End Sub

 
Imports System.Net.Mail
Imports System.Net.Mail.SmtpClient
Imports System.Net.Mail.MailMessage
Imports System.Net.NetworkCredential
Public Class Form4
Button : Prècedent :

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Form1.RadioButton1.Checked Then
            Form2.Show()
            Me.Close()
        Else
            Form3.Show()
            Me.Close()
        End If
    End Sub
Button : Suivant :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim req1 As New OleDb.OleDbCommand
        Dim req2 As New OleDb.OleDbCommand
        Dim req3 As New OleDb.OleDbCommand
        Dim req4 As New OleDb.OleDbCommand
               
        Dim req5 As New OleDb.OleDbCommand
        Dim req6 As New OleDb.OleDbCommand
        Dim req7 As New OleDb.OleDbCommand

        Dim categorie As String
        Dim numero As Integer
        Dim prix As Integer = 0
        Dim prix_uni As Integer = 0

 If DateDiff(DateInterval.Year, DateTimePicker1.Value, Date.Today) <2 Then
            categorie = "Bèbè"
   ElseIf DateDiff(DateInterval.Year, DateTimePicker1.Value,Date.Today) < 12 Then
            categorie = "Enfant"
        Else
            categorie = "Adulte"
        End If
        req1.Connection = cn
        req2.Connection = cn
        req3.Connection = cn
        req4.Connection = cn
        req5.Connection = cn
        req6.Connection = cn
        req7.Connection = cn

        req3.CommandText = "SELECT prix_unitaire from ligne where aeroport_depart = '" & Form1.ComboBox1.Text & "' and aeroport_arrivee='" & Form1.ComboBox2.Text & "'"
        prix_uni = req3.ExecuteScalar

        req4.CommandText = "SELECT remise from categorie  where type_categorie= '" & categorie & "' "
        prix = prix_uni - (req4.ExecuteScalar / 100) * prix_uni

        req5.CommandText = "SELECT remise from classe  where type_classe= '" & type_class & "' "
 prix = prix - (req5.ExecuteScalar / 100) * prix_uni

        req6.CommandText = "SELECT valeur_ajouter from classe  where type_classe= '" & type_class & "' "
        prix = prix + (req6.ExecuteScalar / 100) * prix_uni

        req1.CommandType = CommandType.Text
        req1.CommandText = "insert into passager(N°passport,nom_passager,prenom_passager,nationalite_passager,titre,type_categorie,mail_passager) values('" & TextBox3.Text & "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox4.Text & "','" & ComboBox1.Text & "','" & categorie & "','" & TextBox5.Text & "')"
        req1.ExecuteNonQuery()
        req2.CommandType = CommandType.Text
        req2.CommandText = "SELECT MAX(N°reservation) FROM passager"
        numero = req2.ExecuteScalar

        req1.CommandType = CommandType.Text
        req1.CommandText = "insert into

reservation(N°reservation,type_classe,N°vol,type_reservation,prix_reservati
on,date_reservation) values('" & numero & "','" & type_class & "','" & numero_aller & "','" & type_res & "','" & prix & "',#" & Date.Today.ToString("dd/MM/yyyy") & "#)"
        req1.ExecuteNonQuery()

        req7.CommandType = CommandType.Text
       
req7.CommandText = "update place_reserver set [nb_reservation]=[nb_reservation]+1 where type_classe='" & type_class & "' and N°vol= " & numero_aller
        req7.ExecuteNonQuery()

        If type_res = "Aller - Retour" Then
            req3.CommandText = "SELECT prix_unitaire from ligne where aeroport_depart = '" & Form1.ComboBox1.Text & "' and aeroport_arrivee='" & Form1.ComboBox2.Text & "'"
            prix_uni = req3.ExecuteScalar

            req4.CommandText = "SELECT remise from categorie  where type_categorie= '" & categorie & "' "
            prix = prix_uni - (req4.ExecuteScalar / 100) * prix_uni

            req5.CommandText = "SELECT remise from classe  where type_classe= '" & type_class & "' "
            prix = prix - (req5.ExecuteScalar / 100) * prix_uni

            req6.CommandText = "SELECT valeur_ajouter from classe  where type_classe= '" & type_class & "' "
            prix = prix + (req6.ExecuteScalar / 100) * prix_uni

            req1.CommandType = CommandType.Text
            req1.CommandText = "insert into passager(N°passport,nom_passager,prenom_passager,nationalite_passager,titre,type_categorie,mail_passager) values('" & TextBox3.Text & "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox4.Text & "','" & ComboBox1.Text & "','" & categorie & "','" & TextBox5.Text & "')"
            req1.ExecuteNonQuery()
            req2.CommandType = CommandType.Text
           req2.CommandText = "SELECT MAX(N°reservation) FROM passager"
            numero = req2.ExecuteScalar

            req1.CommandType = CommandType.Text
            req1.CommandText = "insert into reservation(N°reservation,type_classe,N°vol,type_reservation,prix_reservation,date_reservation) values('" & numero & "','" & type_class & "','" & numero_retour & "','" & type_res & "','" & prix & "',#" & Date.Today.ToString("dd/MM/yyyy") & "#)"
            req1.ExecuteNonQuery()

            req7.CommandType = CommandType.Text
            req7.CommandText = "update place_reserver set [nb_reservation]=[nb_reservation]+1 where type_classe='" & type_class & "' and N°vol= " & numero_retour
            req7.ExecuteNonQuery()
        End If

        Dim smtp As New SmtpClient
        Dim MyMSG As New MailMessage
        Dim X As New MailAddress("adress@gmail.com")
        MyMSG.From = X
        MyMSG.To.Add(TextBox3.Text)
        MyMSG.Subject = " Reservation "
        MyMSG.Body = " merci pour votre reservation. type de reservation :" & type_res & "N°vol : " & numero_aller & "N°Reservation : " & numero & "Date de depart :" & Date.Today.ToString("dd/MM/yyyy")
        smtp.Host = "smtp.gmail.com"
        smtp.Port = 587
        smtp.EnableSsl = True
        smtp.Credentials = New System.Net.NetworkCredential("adress.lines@gmail.com", "mot de pass")
        smtp.Send(MyMSG)
        MsgBox("Your Message has beent sent")
        MsgBox(" Merci,Reservation bien effectuée ")
        Form1.Close()
        Form2.Close()
        Form3.Close()
        Me.Close()
        cn.Close()

    End Sub

Annulation d’un vol :


Button afficher les vols :


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Open()
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        Dim req2 As New OleDb.OleDbCommand
        Dim datread2 As OleDb.OleDbDataReader

        req1.Connection = cn
        req2.Connection = cn

        req1.CommandType = CommandType.Text
        req2.CommandType = CommandType.Text

        req1.CommandText = "select *from (SELECT reservation.N°reservation, reservation.N°vol, passager.nom_passager, passager.prenom_passager, passager.N°passport, vol.aeroport_depart, vol.aeroport_arrivee, reservation.type_classe FROM vol INNER JOIN (passager INNER JOIN reservation ON passager.N°reservation = reservation.N°reservation) ON vol.N°vol = reservation.N°vol) where nom_passager='" & TextBox3.Text & "' and prenom_passager='" & TextBox4.Text & "' and N°vol=" & Val(TextBox2.Text) & "and N°reservation=" & Val(TextBox1.Text) & "and N°passport='" & TextBox5.Text & "' "
      
datread1 = req1.ExecuteReader

        If datread1.HasRows Then
            datread1.Read()
            Dim depart As String = datread1.GetValue(5)
            Dim arrivee As String = datread1.GetValue(6)
            req2.CommandText = "SELECT N°vol,date_depart,heure_depart FROM(SELECT vol.N°vol, vol.date_depart, vol.heure_depart, place_reserver.type_classe, place_reserver.nb_reservation, avion.N°avion, capacité.nb_place, vol.aeroport_depart, vol.aeroport_arrivee, vol.duree_vol FROM (classe INNER JOIN ((avion INNER JOIN capacité ON avion.N°avion = capacité.N°avion) INNER JOIN vol ON avion.N°avion = vol.N°avion) ON classe.type_classe = capacité.type_classe) INNER JOIN place_reserver ON (vol.N°vol = place_reserver.N°vol) AND (classe.type_classe = place_reserver.type_classe)) where aeroport_depart='" & depart & "' and aeroport_arrivee='" & arrivee & "' and type_classe='" & datread1.GetValue(7) & "' and nb_reservation < nb_place and date_depart> #" & Date.Today.ToString("MM/dd/yyyy") & "#  "
            datread2 = req2.ExecuteReader
            If Not datread2.HasRows Then
                MsgBox("aucun vol n'ai organiser pour le moment !!!")
                cn.Close()
                Me.Close()
            Else
                While datread2.Read
  
 DataGridView1.Rows.Add(False, datread2.GetValue(0), datread2.GetDateTime(1).ToString("dd/MM/yyyy"), datread2.GetDateTime(2).ToString("HH:mm"))
                End While
       End If

        Else
            MsgBox("Désolé les données ne sont pas correcte")
            cn.Close()
        End If
 End Sub

Button Modifier :

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim req1 As New OleDb.OleDbCommand

        Dim trouve As Integer = 0
        For i As Integer = 0 To DataGridView1.RowCount - 1
            If DataGridView1.Item(0, i).Value = True Then
                trouve = trouve + 1
                numero_aller = DataGridView1.Item(1, i).Value
            End If
        Next
        If trouve = 0 Then
            MsgBox("vous n'avez pas selectionner une vol !!!!")
        ElseIf trouve > 1 Then
            MsgBox("vous avez selectionner plusieurs vols en meme temps !!!!")
        Else
            req1.Connection = cn
            req1.CommandType = CommandType.Text
            req1.CommandText = "update reservation set [N°vol]=" & numero_aller & ",[date_reservation]=#" & Date.Today.ToString("MM/dd/yyyy") & "# where N°reservation=" & Val(TextBox1.Text)
            req1.ExecuteNonQuery()
     
 req1.CommandText = "update place_reserver set [nb_reservation]=[nb_reservation]-1 where N°vol=" & Val(TextBox2.Text)
            req1.ExecuteNonQuery()
            req1.CommandText = "update place_reserver set [nb_reservation]=[nb_reservation]+1 where N°vol=" & numero_aller
            req1.ExecuteNonQuery()
            MsgBox("merci, vous avez changer la date de reservation ")
            Me.Close()

        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
       



Me.Close()
    End Sub
Affichage des pilotes :


Button : Quitter :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub
Chargement de la form :

    Private Sub Form14_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        cn.Open()
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = " SELECT *from pilote"

        datread1 = req1.ExecuteReader
        If Not datread1.HasRows Then
            MsgBox("Il n'existe aucun pilote dans la liste !!! ")
            cn.Close()
            Me.Close()
        Else
          


              
While datread1.Read
DataGridView1.Rows.Add(datread1.GetValue(0), datread1.GetValue(1), datread1.GetValue(2), datread1.GetDateTime(3).ToString("dd/MM/yyyy"), datread1.GetValue(4), datread1.GetValue(5), datread1.GetValue(6))
            End While
            cn.Close()
        End If
    End Sub
Rechercher des réservations d’un vol :




Button : Afficher >> :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Open()
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader

        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = "select N°vol from vol where N°vol=" & Val(TextBox1.Text)
        datread1 = req1.ExecuteReader()
        If Not datread1.HasRows Then
            MsgBox("aucune vol n'a ce numero !!!!")
            cn.Close()

        Else
            datread1.Close()
           
req1.CommandText = "select N°reservation,type_classe,type_reservation,prix_reservation,date_reservation from reservation where N°vol=" & Val(TextBox1.Text)
            datread1 = req1.ExecuteReader

            If Not datread1.HasRows Then
                MsgBox(" Aucun passager n'a reservé dans cette vol !!!")
                cn.Close()
            Else
                For i As Integer = 0 To DataGridView1.RowCount - 1
                    DataGridView1.Rows.RemoveAt(i)
                Next

               

                    While datread1.Read
                    DataGridView1.Rows.Add(datread1.GetValue(0), datread1.GetValue(1), datread1.GetValue(2), datread1.GetValue(3), datread1.GetDateTime(4).ToString("dd/MM/yyyy"))
                End While
                cn.Close()
            End If
        End If
    End Sub
Button : Annuler :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
Rechercher des réservations d’un vol :



Button : Ajouter :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim req1 As New OleDb.OleDbCommand
        cn.Open()
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = "insert into pilote(nom_pilote,prenom_pilote,date_naiss_pilote,nationalité,tel,adresse) values('" & TextBox1.Text & "','" & TextBox4.Text & "',#" & DateTimePicker1.Value & "#,'" & TextBox3.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "')"
        req1.ExecuteNonQuery()
        cn.Close()
        Me.Close()
End Sub

Button :Annuler :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
Affichage de toutes les lignes qui existent :




Chargement de la form:

    Private Sub Form16_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        cn.Open()
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = " SELECT *from ligne"
        datread1 = req1.ExecuteReader
        If Not datread1.HasRows Then
            MsgBox("La table des vols est vide !!!")
            cn.Close()
            Me.Close()
        Else
            While datread1.Read
              
 DataGridView1.Rows.Add(datread1.GetValue(0), datread1.GetValue(1), datread1.GetValue(2))
            End While
            cn.Close()
        End If
    End Sub
Button : Quitter:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub
Modification de prix d’une ligne :




Button : chargement :

    Private Sub Form13_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cn.Open()
        If (cn.State = ConnectionState.Open) Then
            MsgBox("connexion ressuie")
        End If
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader

        req1.Connection = cn

        req1.CommandType = CommandType.Text
        req1.CommandText = " select distinct aeroport_depart from ligne"
        datread1 = req1.ExecuteReader
        While datread1.Read
            ComboBox1.Items.Add(datread1.GetValue(0))
            ComboBox2.Items.Add(datread1.GetValue(0))
        End While
        cn.Close()
    End Sub
ComboBox : Aéroport de depart :

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        cn.Open()
        If ComboBox1.Text <> "Aéroport de depart" Then
            ComboBox2.Items.Clear()
            ComboBox2.Text = "Aéroport d'arrivée"
            Dim req1 As New OleDb.OleDbCommand
            Dim datread1 As OleDb.OleDbDataReader
            req1.Connection = cn
            req1.CommandType = CommandType.Text
  req1.CommandText = " select distinct aeroport_arrivee from ligne where aeroport_depart ='" & ComboBox1.Text & "' "

            datread1 = req1.ExecuteReader
            While datread1.Read
                ComboBox2.Items.Add(datread1.GetValue(0))
            End While
        End If
        cn.Close()
    End Sub
Button : Annuler :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Close()
        Me.Close()
    End Sub
Button : Modifier:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      


        cn.Open()

        Dim req1 As New OleDb.OleDbCommand
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        If MsgBox("Est ce que vous voulez vraiment modifier le prix de cette vol ? ", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
            req1.CommandText = "update ligne set [prix_unitaire]='" & TextBox1.Text & "' where aeroport_depart='" & ComboBox1.Text & "' and aeroport_arrivee='" & ComboBox2.Text & "'"
            req1.ExecuteNonQuery()
            cn.Close()
            Me.Close()
        Else
            cn.Close()
        End If
    End Sub
Ajouter une ligne :




Button : Ajouter :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        cn.Open()
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = "select *from ligne where aeroport_depart='" & TextBox1.Text & "' and aeroport_arrivee='" & TextBox2.Text & "'"
        datread1 = req1.ExecuteReader()
        If Not datread1.HasRows Then
            req1.CommandText = "insert into ligne(aeroport_depart,aeroport_arrivee,prix_unitaire) values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "')"
           


            req1.ExecuteNonQuery()
            cn.Close()
            Me.Close()
        Else
            MsgBox("Désolé ce ligne existe dèja !!!")
        End If
    End Sub
Button : Annuler:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Close()
        Me.Close()
    End Sub
Ajouter un avion :


Button : Ajouter :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim req1 As New OleDb.OleDbCommand
        cn.Open()
        Dim som As Integer = Val(TextBox2.Text) + Val(TextBox3.Text)
        req1.Connection = cn
        req1.CommandType = CommandType.Text

        req1.CommandText = "insert into avion(nom_avion,capacité) values('" & TextBox1.Text & "','" & som & "')"
        req1.ExecuteNonQuery()
        req1.CommandText = "select max(N°avion) from avion"
        Dim num As Integer = req1.ExecuteScalar
        req1.CommandText = "insert into capacité(N°avion,type_classe,nb_place) values('" & num & "','economique','" & Val(TextBox2.Text) & "')"
        req1.ExecuteNonQuery()
      


 req1.CommandText = "insert into capacité(N°avion,type_classe,nb_place) values('" & num & "','homme d''affaire','" & Val(TextBox3.Text) & "')"
        req1.ExecuteNonQuery()
        MsgBox("operation bien effectué ")
        cn.Close()
        Me.Close()
    End Sub
Button : Annuler:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
Affichage des avions :




Chargement de la form :

Private Sub Form18_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        cn.Open()
        req1.Connection = cn

        req1.CommandType = CommandType.Text
        'modification de la requete
        req1.CommandText = " SELECT * FROM avion"

        datread1 = req1.ExecuteReader
        If Not datread1.HasRows Then
            MsgBox("La table des avions est vide !!!")
            cn.Close()
            


        Me.Close()
        Else
            While datread1.Read
                DataGridView1.Rows.Add(datread1.GetValue(0), datread1.GetValue(1), datread1.GetValue(2))
            End While
            cn.Close()
        End If
    End Sub

Button : Quitter :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub
Modifier les remises par catégorie :

 
Chargement de la form :

Private Sub Form11_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        cn.Open()
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = " SELECT *from categorie"
        datread1 = req1.ExecuteReader
        While datread1.Read
           




DataGridView1.Rows.Add(datread1.GetValue(0), datread1.GetValue(1))
        End While
        cn.Close()
    End Sub
Button : Appliquer :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        cn.Open()
        Dim req1 As New OleDb.OleDbCommand
        req1.Connection = cn
        req1.CommandType = CommandType.Text
       
If MsgBox("Est ce que vous voulez vraiment modifier les remises ? ", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
            req1.CommandText = "update categorie set [remise]='" & DataGridView1.Item(1, 0).Value & "' where type_categorie='Bèbè'"
            req1.ExecuteNonQuery()
            req1.CommandText = "update categorie set [remise]='" & DataGridView1.Item(1, 1).Value & "' where type_categorie='Enfant'"
            req1.ExecuteNonQuery()

 req1.CommandText = "update categorie set [remise]='" & DataGridView1.Item(1, 2).Value & "' where type_categorie='Adulte'"
            req1.ExecuteNonQuery()
            cn.Close()
            Me.Close()
        Else
            cn.Close()
        End If
        cn.Close()
    End Sub
Button : Annuler:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
Modifier les remises par classe :



Button : Appliquer :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Open()
        Dim req1 As New OleDb.OleDbCommand
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        If MsgBox("Est ce que vous voulez vraiment modifier les remises ? ", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
            req1.CommandText = "update classe set [remise]='" & DataGridView1.Item(1, 0).Value & "' where type_classe='economique'"
            req1.ExecuteNonQuery()
            req1.CommandText = "update classe set [remise]='" & DataGridView1.Item(1, 1).Value & "' where type_classe='homme d''affaire'"
            req1.ExecuteNonQuery()
            cn.Close()
            Me.Close()
        Else
           

        cn.Close()
        End If
    End Sub
Button : Annuler :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
Chargement de la form:

    Private Sub Form12_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim req1 As New OleDb.OleDbCommand
       


        Dim datread1 As OleDb.OleDbDataReader
        cn.Open()
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = " SELECT *from classe"       
datread1 = req1.ExecuteReader
While datread1.Read
            DataGridView1.Rows.Add(datread1.GetValue(0), datread1.GetValue(1))
        End While
        cn.Close()
    End Sub
Changement de mot de passe :



Button : Confirmer :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Open()
        Label4.Visible = False
        Label5.Visible = False

       

       
        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        req1.Connection = cn

        req1.CommandType = CommandType.Text
        req1.CommandText = "select username from securité where username ='" & TextBox1.Text & "'"
        datread1 = req1.ExecuteReader
        If Not datread1.HasRows Then
            Label4.Visible = True
           



 Label4.ForeColor = Color.Red
        Else
            datread1.Close()
            req1.CommandText = "select username,password,adresse_mail from securité where username ='" & TextBox1.Text & "' and password ='" & TextBox2.Text & "'"
            datread1 = req1.ExecuteReader
            If Not datread1.HasRows Then
                Label5.Visible = True
                Label5.ForeColor = Color.Red
            Else
                datread1.Close()

If MsgBox("vous voulez vraiment changer le mot de passe ?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
 req1.CommandText = "update securité set [password]='" & TextBox3.Text & "' where username ='" & TextBox1.Text & "' and password ='" & TextBox2.Text & "'"
                    req1.ExecuteNonQuery()
                    MsgBox("Mot de passe est modifié ", MsgBoxStyle.OkOnly)
                    Me.Close()
                End If
            End If
        End If
        cn.Close()
    End Sub
Button : Annuler:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
Changement de nom d’utilisateur :



Button : Confirmer :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Open()
        Label4.Visible = False
        Label5.Visible = False

        Dim req1 As New OleDb.OleDbCommand
        Dim datread1 As OleDb.OleDbDataReader
        req1.Connection = cn
        req1.CommandType = CommandType.Text
        req1.CommandText = "select username from securité where username ='" & TextBox1.Text & "'"
        datread1 = req1.ExecuteReader
        If Not datread1.HasRows Then
            Label4.Visible = True
            Label4.ForeColor = Color.Red


        Else
            datread1.Close()
req1.CommandText = "select username,password,adresse_mail from securité where username ='" & TextBox1.Text & "' and password ='" & TextBox2.Text & "'"
            datread1 = req1.ExecuteReader
            If Not datread1.HasRows Then
                Label5.Visible = True
                Label5.ForeColor = Color.Red
            Else
                datread1.Close()
                If MsgBox("vous voulez vraiment changer le nom de l'utilisateur ?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
                
   req1.CommandText = "update securité set [username]='" & TextBox3.Text & "' where username ='" & TextBox1.Text & "' and password ='" & TextBox2.Text & "'"
                    req1.ExecuteNonQuery()
                    MsgBox("Nom de l'utilisateur est modifié ", MsgBoxStyle.OkOnly)
                    Me.Close()
                End If
            End If
        End If
        cn.Close()
    End Sub
Button : Annuler:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
Ajout d’un nouvel utilisateur :



Button :Ajouter:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn.Open()
        Dim req1 As New OleDb.OleDbCommand
        req1.Connection = cn
        req1.CommandType = CommandType.Text
      


 If TextBox2.Text = TextBox3.Text Then
            If MsgBox("vous voulez vraiment ajoute ce nouveau utilisateur ?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
                req1.CommandText = "INSERT INTO securité values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox4.Text & "') "
                req1.ExecuteNonQuery()
                MsgBox("un nouveau utilisateur a été ajouté ", MsgBoxStyle.OkOnly)
                Me.Close()
            End If
        Else
            MsgBox("Le mot de passe entrez different que le mot de passe de confirmation !!")
        End If
        cn.Close()

End Sub
Button : Annuler :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

Conclusion

D’après la réalisation de ce travail, nous avons pu aboutir et apporter une réponse à notre problématique qui  consiste à concevoir et réaliser une application de gestion de vols, cette étude nous a aidées à approfondir et élaborer nos connaissances en méthode d’analyse Merise, Visual Basic et le langage SQL. En utilisant  différents procédures et fonctions, A travers le processus effectué, nous avons acquis et développé des qualités, aptitudes et intérêts. Ce qui va refléter positivement sur notre cursus d'étude.Ce travail nous met en confiance et nous  rend capables de concevoir et de mettre en pratique n’importe quelle application.





7 commentaires:

  1. Réponses
    1. Bonjour, pouvez vous m'envoyer le projet en visual studio avec la base de donnée access à cette adresse " yimeumi@hotmail.com " ? J'ai des problèmes dans ma conception. Merci

      Supprimer
    2. bonsoir ,s'il vous plait tu peux m'envoyer à moi le mini projet sur mon adresse email "sofienguesmi@gmail.com " si tu peux bien sur et merçi d'avence

      Supprimer
  2. Un sujet très intéressant. Bonne Lecture...

    RépondreSupprimer
  3. Bonjour, SVP c'est possible d'avoir tout le code source du projet avec le fichier Access ? Merci

    RépondreSupprimer
  4. Bonjour !
    Je suis débutant avec le Visual Basic 2008.

    Voici mon souci :

    Je crée un formulaire pour me permettre d’enregistrer, modifier ou supprimer un enregistrement sur ma table ligne de la BDD.

    Voici les codes de connexion à la Database :

    Module1

    Imports System
    Imports System.Data
    Imports System.Data.OleDb

    Module Connect_Variable
    Public cn As OleDb.OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Rodriguez.Rodriguez-PC\Documents\Visual Studio 2008\Projects\VoyageSyst\Data_Base\Db_Voyages.mdb")
    End Module

    Structure de ma table:


    Mon formulaire



    Voici les codes du Bouton Ajouter :

    Private Sub CmdAjouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdAjouter.Click
    'On vérifie que les champs sont bien remplit....
    If Trim(txtProvenance.Text) = "" Then
    MsgBox("Veuillez saisir la ville de provenance", vbCritical + vbOKOnly, "Erreur")
    txtProvenance.Focus()
    ElseIf Trim(txtDestination.Text) = "" Then
    MsgBox("Veuillez saisir la ville de destination", vbCritical + vbOKOnly, "Erreur")
    txtDestination.Focus()
    ElseIf Trim(txtPrix.Text) = "" Then
    MsgBox("Veuillez saisir le prix", vbCritical + vbOKOnly, "Erreur")
    txtPrix.Focus()
    Else
    Dim Req As New OleDb.OleDbCommand
    Dim Datread As OleDb.OleDbDataReader
    Try
    cn.Open()

    Req.Connection = cn
    Req.CommandType = CommandType.Text
    Req.CommandText = "SELECT *FROM ligne WHERE ville_provenance='" & txtProvenance.Text & "' and ville_destination='" & txtDestination.Text & "'"

    Datread = Req.ExecuteReader
    'On vérifie si la ligne existe déjà
    If Not Datread.HasRows Then
    Req.CommandText = "INSERT INTO ligne(ville_provenance, ville_destination, prix_unitaire_ligne) VALUES('" & txtProvenance.Text & "','" & txtDestination.Text & "','" & txtPrix.Text & "')"
    Req.ExecuteNonQuery()
    cn.Close()
    Else
    MsgBox("Désolé cette ligne existe dèja", vbCritical + vbOKOnly, "Erreur")
    End If
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End If
    End Sub


    Voici le message que j’ai quand je clique sur le bouton Enregistrer :




    Cependant, je voulais juste savoir comment décanter cette situation pour ce message qui s’affiche.

    RépondreSupprimer

Partenaires

Computers Blogs
Ajoutez votre site

Contactez-nous

Nom

E-mail *

Message *

Tous droits resérvés-www.exercices-corriges.com Seo Blogger Templates