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
| Imports System
Imports System.Data
Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Public Class Form1
Public connection As OleDbConnection 'Connexion
Public command As OleDbCommand 'Commande
Public dataReader As OleDbDataReader 'Data reader (simple)
Public dataAdapter As OleDbDataAdapter 'Data adapter (multiple)
Public dataSet As New DataSet 'Data set
Public SQL As String 'Requête
Public dataTable As DataTable 'Data table
Public dataRow As DataRow 'Ligne
Public rowNumber As Integer 'Enregistrement
Public connectionString As String 'String de connexion
Public commandBuilder As OleDbCommandBuilder 'Command builder
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Ouverture de connexion
connectionString = "provider = microsoft.ace.oledb.12.0 ; datasource = " & Application.StartupPath & "\DB_Kicks.accdb; Persist Security Info = false; Initial Catalog = Test"
connection = New System.Data.OleDb.OleDbConnection
connection.ConnectionString = connectionString
connection.Open()
'Création de requête SQL
SQL = "SELECT * FROM Games"
'Création de commande
command = New OleDbCommand(SQL, connection)
'Création du data reader (lecture champs simples)
dataReader = command.ExecuteReader()
'Création du data adapter (lecture de plusieurs champs)
dataAdapter = New OleDbDataAdapter(command)
'Instance de commande avec la connexion
command.Connection = (connection)
'Chargement du data set
dataAdapter.Fill(dataSet, "Games")
'Chargement de la data table
dataTable = dataSet.Tables("Games")
'Assignation de la valeur de lignes
rowNumber = dataTable.Rows.Count
'Création de CheckBox pour chaque enregistrement de match
Dim i As Integer = 0
For i = 0 To rowNumber - 1
Dim BOXG As New CheckBox
With BOXG
.Name = "BOX_Game" & i + 1
.Text = dataTable.Rows(i).Item("Team" & " (" & "Location" & ")")
.Font = New System.Drawing.Font("Microsoft Sans Serif", 11)
.Location = New System.Drawing.Point(592, 37 + 28 * i)
End With
Next
i = 0
'Modification de la requête pour passer à la table des coups de pieds
SQL = "SELECT * FROM Kicks"
command = New OleDbCommand(SQL, connection)
dataReader = command.ExecuteReader()
dataAdapter = New OleDbDataAdapter(command)
command.Connection = (connection)
dataAdapter.Fill(dataSet, "Games")
dataTable = dataSet.Tables("Games")
rowNumber = dataTable.Rows.Count
'Création de PictureBox pour chaque coup de pied
For i = 0 To rowNumber - 1
Dim KickPBOX As New PictureBox
With KickPBOX
.Name = "Kick " & i + 1
.Location = New System.Drawing.Point(dataTable.Rows(i).Item("abs"), dataTable.Rows(i).Item("ord"))
Dim converted As Boolean = dataTable.Rows(i).Item("Converted")
If converted = True Then
.BackgroundImage = Image.FromFile(Application.StartupPath & "greenball.png")
.BackgroundImageLayout = ImageLayout.Zoom
Else : .BackgroundImage = Image.FromFile(Application.StartupPath & "redball.png")
.BackgroundImageLayout = ImageLayout.Zoom
End If
End With
Next
End Sub
Private Sub BOX_All_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BOX_All.CheckedChanged
BOX_Converted.Checked = BOX_All.Checked
BOX_Missed.Checked = BOX_All.Checked
BOX_Centered.Checked = BOX_All.Checked
BOX_Offset.Checked = BOX_All.Checked
End Sub
End Class |
Partager