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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| Imports MySql.Data
Imports MySql.Data.MySqlClient
Public Class Form1
Dim CONNECTION As MySqlConnection
Private Sub QUITToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles QUITToolStripMenuItem1.Click
End
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = Date.Now
'Panel 1, ajouter un membre'
'Panel 2, fenêtre de connexion du membre
Panel1.Visible = False
Panel2.Visible = False
End Sub
Private Sub QuitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles QuitToolStripMenuItem.Click
' Affiche la seconde fenêtre qui servira de boîte à propos'
Form2.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Premier cas, on ajoute le nouveau cas dans la table client'
'Second cas, on annule l'ajout car le client est existant'
'On sort de l'ajour d un nouveau membre'
CONNECTION = New MySqlConnection
CONNECTION.ConnectionString = "server=localhost;userid=root;password=;database=mysqlssi"
Try
If CONNECTION.State = ConnectionState.Closed Then
CONNECTION.Open()
If TextNouveauMembre.Text.Trim() <> "" And TextAjoutPassword.Text.Trim() <> "" And TextConfirmerPassword.Text.Trim() <> "" Then
MsgBox("Nouveau membre et mot de passe introduit", MsgBoxStyle.Information, "Info")
Dim cmd As New MySqlCommand("INSERT INTO client (Nom,Password) VALUES(@nomclient,@passwordclient ", CONNECTION)
cmd.Parameters.AddWithValue("@nomclient", TextNouveauMembre.Text)
cmd.Parameters.AddWithValue("@passwordclient", TextAjoutPassword.Text)
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
MessageBox.Show("add data ok")
Else
MsgBox("Champ Nouveau membre et Mot de passe obligatoire", MsgBoxStyle.Information, "Info")
End If
End If
Catch ex As Exception
MsgBox("Connexion échouée", MsgBoxStyle.Information, "Info")
Finally
CONNECTION.Close()
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Remise des textbox à vide'
TextNouveauMembre.Text = ""
TextAjoutPassword.Text = ""
TextConfirmerPassword.Text = ""
TextEntreprise.Text = ""
TextTel.Text = ""
TextEmail.Text = ""
'On sort de l ajout d un nouveau membre'
Panel1.Visible = False
End Sub
Private Sub AjoutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AjoutToolStripMenuItem.Click
Panel1.Visible = True
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'Remettre à vide les textboxs'
TextUserName.Text = ""
TextPassword.Text = ""
Panel2.Visible = False
End Sub
Private Sub ConnexionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ConnexionToolStripMenuItem.Click
Panel2.Visible = True
End Sub
Private Sub TESTCONNEXIONToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TESTCONNEXIONToolStripMenuItem.Click
CONNECTION = New MySqlConnection
CONNECTION.ConnectionString = "server=localhost;userid=root;password=;database=mysqlssi"
Try
If CONNECTION.State = ConnectionState.Closed Then
CONNECTION.Open()
MsgBox("Connexion avec succès", MsgBoxStyle.Information, "Info")
End If
Catch ex As Exception
MsgBox("Connexion échouée", MsgBoxStyle.Information, "Info")
Finally
CONNECTION.Close()
End Try
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
' On établit la connexion '
CONNECTION = New MySqlConnection
CONNECTION.ConnectionString = "server=localhost;userid=root;password=;database=mysqlssi"
' trim empêche des caractères vides'
Try
If CONNECTION.State = ConnectionState.Closed Then
CONNECTION.Open()
If TextUserName.Text.Trim() = "" Then
MessageBox.Show("Entrez un nom d'utilisateur")
ElseIf TextPassword.Text.Trim() = "" Then
MessageBox.Show("Entrez un mot de passe")
End If
End If
Catch ex As Exception
MsgBox("Connexion échouée", MsgBoxStyle.Information, "Info")
Finally
CONNECTION.Close()
End Try
End Sub
End Class |
Partager