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
| Dim myPane As ZedGraph.GraphPane = ZedGraphControl1.GraphPane
' Set the titles and axis labels
myPane.Title.Text = "La quantité de stock disponible"
myPane.XAxis.Title.Text = " Désignation"
myPane.YAxis.Title.Text = "Quantité"
Try
'Chaîne de connexion
Dim connectString As String = "Data Source=***;Initial Catalog=***;User ID=****; password = ******"
'Objet connection
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectString)
'--------------------------------------------------------------------------------------
'Ouverture
connection.Open()
Dim list = New PointPairList()
Dim y As Int32
Dim i As Int32
For i = 1 To 34
Dim x As String = "select designation from stock "
Dim Command As New SqlClient.SqlCommand(x, connection)
Command.ExecuteNonQuery()
Dim command1 As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT quantité FROM stock where designation = ' " & x & " ' ", connection)
Dim reader As SqlClient.SqlDataReader = command1.ExecuteReader
If reader.Read Then
y = reader.GetInt32(0)
End If
list.Add(x, y)
Next i
' Generate a red bar with "Curve 1" in the legend
Dim myBar As BarItem = myPane.AddBar("Curve 1", list, Color.DarkSlateBlue)
myBar.Bar.Fill = New Fill(Color.SkyBlue, Color.White, Color.Purple)
' Draw the X tics between the labels instead of at the labels
myPane.XAxis.MajorTic.IsBetweenLabels = True
' Fill the axis background with a color gradient
myPane.Chart.Fill = New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)
' Fill the pane background with a color gradient
myPane.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0F)
' Calculate the Axis Scale Ranges
ZedGraphControl1.AxisChange()
connection.Close()
Catch ex As Exception
System.Diagnostics.Debug.WriteLine("erreur")
End Try |
Partager