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
|
Try
Dim a As New Métier.alerte
Dim requete As String = "SELECT COUNT(*) AS Nombre FROM alerte where date_alerte > '" & DateTimePicker1.Value.ToString("MM/dd/yyyy ") & "' and date_alerte <'" & DateTimePicker2.Value.ToString("MM/dd/yyyy ") & "' "
Dim reader1 As SqlClient.SqlDataReader = a.consulter_alerte(requete)
Dim nombre As Int32
While reader1.Read
nombre = reader1.GetInt32(0)
End While
Dim tab(nombre) As String
Dim t(nombre) As String
Dim im As New images
Dim myPane As ZedGraph.GraphPane = im.ZedGraphControl1.GraphPane
' Set the titles and axis labels
myPane.Title.Text = "Statistiques sur les toutes les pannes"
myPane.XAxis.Title.Text = " période"
myPane.YAxis.Title.Text = "Pannes(PC)"
Dim connectString As String = "Data Source=SARA\GMAO;Initial Catalog=GMAO;User ID=sa; password = 21009324"
'Objet connection
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectString)
'--------------------------------------------------------------------------------------
'Ouverture
connection.Open()
Dim i As Integer = 0
Dim command1 As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT id_pc_testeur , date_alerte FROM alerte where date_alerte > '" & DateTimePicker1.Value.ToString("MM/dd/yyyy ") & "' and date_alerte <'" & DateTimePicker2.Value.ToString("MM/dd/yyyy ") & "' ", Connection)
Dim reader As SqlClient.SqlDataReader = command1.ExecuteReader
While reader.Read
t(i) = reader.GetString(0)
tab(i) = reader.GetString(1)
' Set the XAxis labels
myPane.XAxis.Scale.TextLabels = tab
' Set the XAxis to Text typeab
myPane.XAxis.Type = AxisType.Text
myPane.YAxis.Scale.TextLabels = t
myPane.YAxis.Type = AxisType.Text
' Generate a red bar with "Curve 1" in the legend
Dim myBar As BarItem = myPane.AddBar("Pc testeur", Nothing, t(i), 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)
myBar.Bar.Fill.RangeMin = 0
myBar.Bar.Fill.RangeMax = 4
i = i + 1
End While
reader.Close()
' Calculate the Axis Scale Ranges
im.ZedGraphControl1.AxisChange()
im.ShowDialog()
' connection.Close()
Catch
MsgBox("ooooooops", MsgBoxStyle.OkOnly)
End Try |
Partager