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
|
Dim query As String = ""
query = "select Round((cast(sum(DP.Duree_Pointee) as float) - cast(sum(vue.Duree_Alloue) as float)) / 3600,2) as Ecart,vue.MICRO, vue.ILO " & _
"From (SELECT VPassage.U as UP,VPassage.micro,V.ILO,SUM(v.TPS_SG_S * Vpassage.QP) Duree_Alloue " & _
"FROM VPassage INNER JOIN VAlloue as V ON VPassage.Grade = V.GRADE AND VPassage.U = V.U AND VPassage.MICRO = V.MICRO " & _
"AND VPassage.JL = V.JL AND VPassage.IGA = V.IGA WHERE VPassage.JL !='00' and V.DateRef = (Select di_V_DateRef from dbo.DIM_Version_Alloue where di_v_Lib = 'Actuelle') " & _
"AND VPassage.DATE = convert(varchar,getdate(),103) AND V.ILO <> '000' GROUP BY VPassage.U, VPassage.JL, V.ILO ,VPassage.micro " & _
"UNION ALL " & _
"SELECT VPassage.U,VPassage.micro,V1.ILO,SUM(v1.TPS_HG_S * Vpassage.QP) Duree_Alloue FROM VPassage " & _
"INNER JOIN VAlloue as V1 ON VPassage.Grade = V1.GRADE AND VPassage.U = V1.U AND VPassage.MICRO = V1.MICRO AND VPassage.JL = V1.JL AND VPassage.IGA = V1.IGA " & _
"WHERE VPassage.JL !='00' and V1.DateRef = (Select di_V_DateRef from dbo.DIM_Version_Alloue where di_v_Lib = 'Actuelle') " & _
"AND VPassage.DATE = convert(varchar,getdate(),103) and V1.ILO <> '000' and v1.TPS_hG_S > 0 GROUP BY VPassage.U, VPassage.JL, V1.ILO ,VPassage.micro) as Vue " & _
"inner join (select v1.UP, v1.ILO, v1.Duree_Pointee,v1.MICRO from (select VP.UP , vg.MICRO ,VG.ILO ,sum(VP.Duree) as duree_Pointee from VPointage VP " & _
"inner join (select distinct [OF], I, JL, IGA from VPassage) vpa on vp.[OF] = vpa.[OF] and vp.I = vpa.I and vp.jalon=vpa.jl " & _
"inner join (select MAX(dateref) as dateref, Micro, JL, Ilo, IGA from vgamme where Ilo != '000' group by Micro, JL, Ilo, IGA) VG " & _
"on vg.micro = VP.micro and vg.JL = VP.Jalon and vg.IGA = Vpa.IGA Where VP.[OF] <> ' ' AND VP.[OF] <> 'INDIRECT' AND VP.[OF] <> 'MODIRECT' " & _
"and Date = convert(varchar,getdate(), 103) and UP = '" & LeSite & "' group by VP.UP ,VG.Ilo, VP.TPSPSG, VP.TPSPHG, vg.MICRO ) as v1 " & _
"group by v1.up, v1.ILO, v1.Duree_Pointee,v1.MICRO) as DP on Vue.UP = DP.UP AND Vue.ILO = DP.ILO and vue.MICRO = DP.MICRO " & _
"where vue.ilo IN (" & Ilot & ") Group by vue.MICRO,vue.ILO order by vue.ILO "
Dim oData As New SqlDataAdapter(query, cnn1)
Dim ds As New DataSet
Dim oCmd As New SqlCommand(query, cnn1)
cnn1.Open()
oData.Fill(ds, "Graph_Alloue_Pointe")
cnn1.Close()
Chart_Al_Po.DataSource = ds.Tables("Graph_Alloue_Pointe")
Dim Series1 As Series = Chart_Al_Po.Series("Series1")
Chart_Al_Po.Series(Series1.Name).XValueMember = "Micro"
Chart_Al_Po.Series(Series1.Name).YValueMembers = "Ecart" |
Partager