1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Public Class Form3
Dim cnx As OleDbConnection
Dim cmd As OleDbCommand
Dim dta As OleDbDataAdapter
Dim dts As New DataSet
Dim dtt As DataTable
Dim dtr As DataRow
Dim rownum As Integer
Dim cnxstr As String
Dim cmdb As OleDb.OleDbCommandBuilder
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Veuillez remplir toutes les informations !", vbOKOnly + vbExclamation, "Erreur")
Else
Panel1.Visible = False
Panel2.Visible = True
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If ComboBox1.Text = "" Then
MsgBox("Veuillez remplir l'information !", vbOKOnly + vbExclamation, "Erreur")
Else
Panel2.Visible = False
Panel3.Visible = True
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox3.Text = "" Then
MsgBox("Veuillez remplir toutes les informations !", vbOKOnly + vbExclamation, "Erreur")
Else
'création d'une nouvelle ligne avec les données des textbox
dtr = dts.Tables.Item("Table1").NewRow
dtr("Nom") = TextBox1.Text
dtr("Prénom") = TextBox2.Text
dtr("Age") = TextBox4.Text
dtr("Rang") = ComboBox1.Text
dtr("Pays") = TextBox3.Text
dtr("Adresse e-mail") = TextBox5.Text
dtr("Console") = ComboBox2.Text
dtr("Skype") = TextBox6.Text
'ajout de la ligne dans le DataSet
dts.Tables("Table1").Rows.Add(dtr)
'création et exécution du commandbuilder pour mettre à jour le DataAdapter
cmdb = New OleDbCommandBuilder(dta)
'mise à jour des données du dataadapter (dta) à partir du commandbuilder (cmdb)
dta.Update(dts, "Table1")
'on vide le dataset pour le recréer avec les nouvelles données
dts.Clear()
dta.Fill(dts, "Table1")
dtt = dts.Tables("Table1")
Form1.Panel1.Visible = True
Me.Hide()
End If
End Sub
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cnxstr = "provider = microsoft.jet.oledb.4.0 ; data source = data.mdb;"
cnx = New OleDbConnection
cnx.ConnectionString = cnxstr
cnx.Open()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
ComboBox1.Text = ""
ComboBox2.Text = ""
If My.Settings.TeamPlateforme = "Console" Then
ComboBox2.Visible = False
End If
End Sub
End Class |
Partager