VB Dot Net VERSION COMPLETE CODES SOURCES
VB Dot Net VERSION COMPLETE CODES SOURCES
VB Dot Net VERSION COMPLETE CODES SOURCES
‘Fournisseur MS SqlServeur
Imports System.Data.SqlClient
Phase 2
Zone Décalaration (Déclaration Au Début de la classe)
‘Déclaration Pour Fournisseur MS Access
Private con As New OleDbConnection
Private dtadapter As New OleDbDataAdapter("select *from EMPLOYE", con)
Private dtset As New DataSet
Phase 3
Inserer les Codes de connexion dans une Forme Evénement Load
'Connexion avec Base De Données (Localisée Bin) ACCDB(2007+)
‘Ligne con.ConnectionString uniquement Pour Fournisseur MS Access
con.ConnectionString = "provider=microsoft.Ace.oledb.12.0;data source= bibnet.accdb"
con.Open()
'Identification Table ou requête Exemple la Table T1
dtadapter.Fill(dtset, "EMPLOYE")
'Remplissage GridView par le Contenu de la table T1 (Nomée Grid)
G_EMPLOYE.DataSource = dtset.Tables("EMPLOYE")
con.Close()
Codes Effaçer (Bouton)
L’application et la base de données
'Bouton Effaçer
C_ID.Text = Nothing
T_Nom.Text = Nothing
T_Prenom.Text = Nothing
Insérer un message comme boite de confirmation
Etape 1 : Zone Déclaration
Dim x As DialogResult
Etape 2 : Zone Code du Bouton
x = MessageBox.Show("Voulez Vous Vraiment ", "Gestion ", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If x = MsgBoxResult.Yes Then
‘Votre Bloc de Codes
End If
1
Code Dot Net : Connexion. 2021/2022 Formateur : L.KARIM.
NewLigne(0) = C_ID.Text
NewLigne(1) = T_Nom.Text
NewLigne(2) = T_PRENOM.Text
' Ajout de la ligne à la table
dtset.Tables("EMPLOYE").Rows.Add(NewLigne)
' Création CommandBuilder
'(genere automatiquement l'update entre le dataSet et la base de donnée
Dim CmdBuild As OleDb.OleDbCommandBuilder
CmdBuild = New OleDb.OleDbCommandBuilder(dtadapter)
dtadapter.InsertCommand = CmdBuild.GetInsertCommand
dtadapter.Update(dtset, " EMPLOYE")
MsgBox("Ajout Avec Succes", MsgBoxStyle.Information)
con.Close()
Else
MsgBox("Vous Devez Remplir Tous Les Champs SVP", MsgBoxStyle.Exclamation)
End If
Else
MsgBox("ID Existe Déjà", MsgBoxStyle.Critical)
End If
If sw = 0 Then
MsgBox("ID Introuvable", MsgBoxStyle.Critical)
End If
For s = 0 To Me.G_EMPLOYE.RowCount - 2
If a = Me.G_EMPLOYE.Item(0, s).Value Then
sw = 1
C_ID.Text = Me.G_EMPLOYE.Item(0, s).Value
T_NOM.Text = Me.G_EMPLOYE.Item(1, s).Value
T_PRENOM.Text = Me.G_EMPLOYE.Item(2, s).Value
End If
Next
If sw = 0 Then
MsgBox("ID Introuvable", MsgBoxStyle.Critical)
End If
Méthode 3 : Combo Box (Evénement C_ID_SelectedIndexChanged)
N.B. : Avant de saisir le Code de cette méthode veuillez saisir le code de rechargement des
élèments du Combo lors du démarrage de la Forme.
Etape 1 : Form_Load
'Rechargement Combo : pour la Préparer à la recherche.
For s = 0 To Me.G_EMPLOYE.RowCount - 2
C_ID.Items.Add(Me.G_EMPLOYE.Item(0, s).Value)
Next
Etape 2 : C_ID_SelectedIndexChanged
If C_ID.Text <> "" Then
For s = 0 To Me.G_EMPLOYE.RowCount - 2
If C_ID.Text = Me.G_EMPLOYE.Item(0, s).Value Then
T_NOM.Text = Me.G_EMPLOYE.Item(1, s).Value
T_PRENOM.Text = Me.G_EMPLOYE.Item(2, s).Value
2
Code Dot Net : Connexion. 2021/2022 Formateur : L.KARIM.
End If
Next
End If
Méthode 4 : Grid (Evénement Grid_CellClick)
Dim ligneencours As Integer
ligneencours = G_EMPLOYE.CurrentRow.Index
C_ID.Text = G_EMPLOYE.Item(0, ligneencours).Value
T_NOM.Text = G_EMPLOYE.Item(1, ligneencours).Value
T_PRENOM.Text = G_EMPLOYE.Item(2, ligneencours).Value
Dim x As Integer
Dim sw As Integer
sw = 0
x = 0
GridText.Rows.Clear()
For s = 0 To Form1.Grid.RowCount - 2
If Txt.Text = Form1.Grid.Item(0, s).Value Then
sw = 1
Me.GridText.Rows.Add()
Me.GridText.Item(0, x).Value = Form1.Grid.Item(0, s).Value
Me.GridText.Item(1, x).Value = Form1.Grid.Item(1, s).Value
Me.GridText.Item(2, x).Value = Form1.Grid.Item(2, s).Value
x = x + 1
End If
Next
If sw = 0 Then
MsgBox("Référence Introuvable", MsgBoxStyle.Critical)
End If
Méthode 2 : Boite de Message InputBox (Bouton Evénement Click)
Dim a As Integer
Dim x As Integer
Dim sw As Integer
sw = 0
x = 0
a = InputBox("Entrer la Référence Demandé", "Projet Test")
Gridinput.Rows.Clear()
For s = 0 To Form1.Grid.RowCount - 2
If a = Form1.Grid.Item(0, s).Value Then
sw = 1
Me.Gridinput.Rows.Add()
Me.Gridinput.Item(0, x).Value = Form1.Grid.Item(0, s).Value
Me.Gridinput.Item(1, x).Value = Form1.Grid.Item(1, s).Value
Me.Gridinput.Item(2, x).Value = Form1.Grid.Item(2, s).Value
x = x + 1
End If
Next
If sw = 0 Then
MsgBox("Référence Introuvable", MsgBoxStyle.Critical)
End If
Méthode 3 : Combo Box (Evénement C1_SelectedIndexChanged)
Dim x As Integer
x = 0
C1.Items.Clear()
Grid.Rows.Clear()
For s = 0 To Form1.Grid.RowCount - 2
If C1.Text = Form1.Grid.Item(0, s).Value Then
Me.Grid.Rows.Add()
Me.Grid.Item(0, x).Value = Form1.Grid.Item(0, s).Value
Me.Grid.Item(1, x).Value = Form1.Grid.Item(1, s).Value
Me.Grid.Item(2, x).Value = Form1.Grid.Item(2, s).Value
x = x + 1
End If
C1.Items.Add(Form1.Grid.Item(0, s).Value)
Next
3
Code Dot Net : Connexion. 2021/2022 Formateur : L.KARIM.
Codes Modification (Bouton Modification)
L’application et la base de données
« Base de Données Local »
If MsgBox("voulez vous vraiment Modifier cet enregistrement", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
Dim sw As Integer = 0
Dim x As Integer
For s = 0 To Me.G_EMPLOYE.RowCount - 2
If C_ID.Text = Me.G_EMPLOYE.Item(0, s).Value Then
sw = 1
x = s
s = Me.G_EMPLOYE.RowCount - 2
End If
Next
If sw = 1 Then
Dim ligneencours As Integer
ligneencours = x
Dim cle As String
cle = G_EMPLOYE.Item(0, ligneencours).Value
Dim matable As DataTable
matable = dtset.Tables("EMPLOYE")
Dim laligne As DataRow()
laligne = matable.Select("ID=" & cle)
laligne(0).Item(1) = T_NOM.Text
laligne(0).Item(2) = T_PRENOM.Text
base(dtadapter, "EMPLOYE")
Else
MsgBox("ID N’Existe Pas", MsgBoxStyle.Critical)
End If
End If
Codes Suppression
L’application et la base de données
'Bouton Suppression
x = MessageBox.Show("Voulez Vous Vraiment Supprimer Cet Enregistrement", "Gestion BIBNET",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If x = MsgBoxResult.Yes Then
Dim x As Integer
For s = 0 To Me.G_EMPLOYE.RowCount - 2
If C_ID.Text = Me.G_EMPLOYE.Item(0, s).Value Then
x = s
End If
Next
4
Code Dot Net : Connexion. 2021/2022 Formateur : L.KARIM.
'ici nous allons ouvrir la connexion pour accéder et utiliser la base de données distante
Dim cmdbuilder As OleDbCommandBuilder
cmdbuilder = New OleDb.OleDbCommandBuilder(dtadapter)
dtadapter.DeleteCommand = cmdbuilder.GetDeleteCommand
dtadapter.Update(dtset, "EMPLOYE")
MsgBox("Suppression Effectuée dans la base de données Distante", MsgBoxStyle.Information)
End If
con.Close()
http://www.universal-soundbank.com/
E.Mail
L’application et la base de données
Phase 1 Au Début Insérer :
Imports System.Net.Mail
Générer un QR Code
‘Ligne De Code création QR Code
Qr1.Text = "Nom :" + T1.Text() & vbCrLf & "Prénom :" + T2.Text() & vbCrLf & "CIN :" + T3.Text()
Impression
1. Insérer les contrôles PrintDialog1 et PrintDocument1
2. PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
PrintDocument1.Print()
End If