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
|
Try
conn = New SqlConnection()
Dim dtTest As DataTable = New DataTable
conn = connexion()
dtTest.Columns.Add("Time", GetType(Integer))
dtTest.Columns.Add("Date", GetType(String))
dtTest.Columns.Add("Type", GetType(String))
Dim x As DataTable = get_totlavacation(from_date, to_date)
sql = "select distinct(CONVERT(varchar,v.date,103)) 'Date',tc.type 'Type',SUM(v.time) 'Time',vac.Totalvacation 'Vacation',op.Totalworktime 'Worktime' from vacation v join time_code tc on tc.code=v.code, (select v1.date,SUM(v1.time) 'Totalvacation' from vacation v1 where v1.date BETWEEN '" & from_date & "' AND '" & to_date & "' group by v1.date) vac, (select distinct(op.date),SUM(op.normal_time) 'Totalworktime' from operator_card op where op.date BETWEEN '" & from_date & "' AND '" & to_date & "' group by op.date) op where v.date BETWEEN '" & from_date & "' AND '" & to_date & "' and vac.date = v.date and op.date = v.date GROUP BY v.date,tc.type,vac.Totalvacation,op.Totalworktime"
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
Dim reader As SqlDataReader = cmd.ExecuteReader
While reader.Read
Dim y As Decimal = (reader.GetValue(2) / (reader.GetValue(3) + reader.GetValue(4))) * 100.0
dtTest.Rows.Add(y, reader.GetValue(0), reader.GetValue(1))
End While
Dim dv As DataView = New DataView(dtTest)
dv.Sort = "Date asc"
Chart1.Series.Clear() 'this is just to remove the default Series in a
'VB.NET chart; you may not need this
Chart1.DataManipulator.FilterSetEmptyPoints = True 'Points that match filter will be marked as empty
Chart1.DataManipulator.FilterMatchedPoints = True 'Filter points that match Filter criteria
Chart1.DataBindCrossTable(dv, "Type", "Date", "Time", "Label=Time")
For Each cs As Series In Chart1.Series
Chart1.DataManipulator.Filter(DataVisualization.Charting.CompareMethod.EqualTo, 0, cs) 'Compare if equal to zero
cs.ChartType = SeriesChartType.Spline
cs.XValueType = ChartValueType.Date
' cs.CustomProperties = "DrawingStyle=cylinder"
cs.BorderWidth = 3
Dim dpcp As DataPointCustomProperties = New DataPointCustomProperties
Next
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try |
Partager