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
| Public Function rafraichirGraphCourbeDateDerive(ByRef mscGraph As MSChart, ByVal nomProjet As String, Optional ByVal nbHistoAAfficher As Integer = 50, Optional ByVal afficherAPartirDe As Integer = 0)
Dim query As String
Dim nbEnregistrements As Integer 'nombre d'enregistrements retournés par une requête
Dim tableauDeValeurs() As Variant 'permet de stocker les valeurs des séries avant de les affecter au MSChart
Dim i As Integer 'parcours les lignes de tableauDeValeurs
Dim dateFin As Single
Dim dateDebut As Single
Dim dateFinReestime As Single
Dim nbrDateSnapShot As Single
Dim DateSnapShot As Single
'récupération des informations nécessaire au dessin du graph
query = "SELECT `dateSnapShot`, `dateFinEstimee`, `dateDebutEstimee`, `dateFinReestimee`, COUNT(`dateSnapShot`) " & _
"FROM `snapshotprojet`, `infosprojet` " & _
"WHERE `infosprojet`.`nomProjet` = '" & nomProjet & "' " & _
"AND `snapshotprojet`.`idInfosProjet` = `infosprojet`.`idInfosProjet` " & _
"ORDER BY `dateSnapShot` ASC"
rst.Open query, cnx
dateDebut = rst.Fields(2)
dateFin = rst.Fields(1)
dateFinReestimee = rst.Fields(3)
nbrDateSnapShot = rst.Fields(4)
DateSnapShot = rst.Fields(0)
MsgBox nbrDateSnapShot
'on compte le nombre d'enregistrements retournés par la requête
While Not rst.EOF
nbEnregistrements = nbEnregistrements + 1
rst.MoveNext
Wend
rst.MoveFirst 'on remet le pointeur au début
If nbEnregistrements >= 2 Then
mscGraph.Visible = True
txtErreurGraph.Visible = False
With mscGraph
.Repaint = False
.ColumnCount = 1
.RowCount = nbrDateSnapShot
.chartType = VtChChartType2dLine
.Column = 1
For i = 1 To nbrDateSnapShot
.Row = i
.RowLabel = CDate(CDate(DateSnapShot))
.Data = CLng(CDate(dateFinReestime))
Next i
.Repaint = True
End With
End If
rst.Close
End Function |
Partager