Chapitre II : Réalisation du logiciel
I. Quelques captures d'écran
Formulaire de chargement du logiciel GestStock :
Formulaire d'enregistrement d'un produit:
APPLICATION CLIENT/SERVEUR DE GESTION DES STOCKS
Formulaire d'identification d'un utilisateur:
Formulaire d'enregistrement d'un fournisseur:
APPLICATION CLIENT/SERVEUR DE GESTION DES STOCKS
II. Quelques codes de visual basic .net
Code de création de la classe
connection
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Connection
Sub New()
'déclaration d'une variable de type string
' variable qui va contenir les paramètres de connection
à la BDD Dim connetionString As String
'affection des paramètres de connection à la
variable connetionString connetionString = "Data Source
=SWEET-63367FA4A\SQLEXPRESS;Initial Catalog =GestStock;User ID
=feno;Password=talobouloic"
Dim connection As SqlConnection
' déclaration d'une variable de type sqlConnection
connection = New SqlConnection(connetionString)
'instanciation de l'objet connection de la classe SqlConnection
End Sub
End Class
|
Code de création de la classe Produit
|
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
Dim sql As String 'variable qui va contenir la requête
sql
sql = ("insert into Produit(libprod,marque,qtereapprov,qtealerte)
values('" & Me.TextBox1.Text & "','" & Me.TextBox2.Text & "','"
& Me.TextBox3.Text & "', '" & Me.TextBox4.Text & "')")
'instanciation d'un objet de type sqlDataAdapter
Dim adapter As New SqlDataAdapter 'new est un contructeur
Try
connection.Open() 'ouverture de la connection
adapter.InsertCommand = New SqlCommand(sql, connection)
adapter.InsertCommand.ExecuteNonQuery()
MsgBox("enregistrement effectué !! ")
Catch ex As SqlException
MsgBox(ex.ToString)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button3.Click
Dim sql As String 'variable qui va contenir la requête
sql
sql ="Update Produit set libprod=" & "'" &
Me.TextBox1.Text.Replace("'", "''") & "' ,marque =" & "'" &
Me.TextBox2.Text & "' ,qtereapprov =" & "'" & Me.TextBox3.Text
& "',qtealerte =" & "'" & Me.TextBox4.Text & "' where
codprod='" & TextBox0.Text & "'"
Dim adapter As New SqlDataAdapter
APPLICATION CLIENT/SERVEUR DE GESTION DES STOCKS
Try
connection.Open()
adapter.UpdateCommand = connection.CreateCommand
adapter.UpdateCommand.CommandText = sql
adapter.UpdateCommand.ExecuteNonQuery()
MsgBox("modification effectuée !! ")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button4.Click
Dim sql As String 'variable qui va contenir la requête
sql
connection = New SqlConnection(connetionString)
Dim adapter As New SqlDataAdapter
sql = "Delete From Produit where codprod=" & "'" &
Me.TextBox0.Text & "'" Try
connection.Open()
adapter.DeleteCommand = connection.CreateCommand
adapter.DeleteCommand.CommandText = Sql
adapter.DeleteCommand.ExecuteNonQuery()
MsgBox("Enregistrement supprimé !! ")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button9.Click
Dim mycom As SqlCommand = cnn.CreateCommand()
Dim cmd1 As SqlCommand = cnn.CreateCommand
cmd1.CommandText = "Select * From Produit where libprod like '"
& Me.TextBox5.Text & "%'"
connection.Open()
Try
Dim myread As SqlDataReader = cmd1.ExecuteReader
Do While myread.Read
Me.TextBox0.Text = myread(0).ToString Me.TextBox1.Text =
myread(1).ToString Me.TextBox2.Text = myread(2).ToString Me.TextBox3.Text =
myread(3).ToString Me.TextBox4.Text = myread(4).ToString Exit Do
Loop
myread.Close()
Catch ex As Exception MsgBox(ex.Message) End Try
connection.Close() End Sub
End Class
|