Dim d1 As Date = e.Form.Controls("DateTimePicker5").Value
If d1 = Nothing Then d1 = Date.Today
Dim filter1 As String = ""
If e.Form.Controls("RadioButton1").Checked Then
filter1 = "订单日期 = #" & d1 & "#"
ElseIf e.Form.Controls("RadioButton2").Checked Then
Dim w As Integer = d1.DayOfWeek '算出今天是星期几
Dim dt1 As Date = d1.AddDays(0 - w) '获取本周的第一天 ,星期一到星期天
Dim dt2 As Date = d1.AddDays(6 - w) '获取本周的最后一天
filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton3").Checked Then
Dim y As Integer = d1.Year
Dim m As Integer = d1.Month
Dim dt1 As New Date(y, m, 1)
Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton4").Checked Then
Dim y As Integer = d1.Year
Dim q As Integer = (d1.Month - 1) \ 3 + 1 '计算现在是第几个季度
Dim dt1 As New Date(y, 3 * (q - 1) + 1, 1) '获取本季度的第一天
Dim dt2 As New Date(y, 3 * q, Date.DaysInMonth(y,3 * q)) '获取本季度的最后一天
filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton5").Checked Then
Dim y As Integer = d1.Year
Dim dt1 As New Date(y, 1, 1)
Dim dt2 As New Date(y, 12, 31)
filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton6").Checked Then
filter1 = "1=1"
Else If e.Form.Controls("RadioButton14").Checked Then
filter1 = "订单日期 < #" & d1 & "#"
End If
Dim c6 As String = e.Form.controls("ComboBox6").Value
If c6 <> "全部" Then
Dim tt As Table = e.Form.Controls("Table10").Table
If tt.Current IsNot Nothing Then
filter1 &= " and " & c6 & " = '" & tt.Current(c6) & "'"
End If
End If
Dim tp As DateGroupEnum = 0
Dim g As New GroupTableBuilder("临时统计表", DataTables("表A"))
g.Groups.AddDef("订单日期", tp, "日期")
g.Totals.AddDef("销售额")
g.Totals.AddDef("成本合计")
g.Totals.AddDef("利润合计")
g.Totals.AddDef("采购成本")
g.Totals.AddDef("返点成本")
g.VerticalTotal = True
g.Filter = filter1
g.Build()
'Dim t As Table = Tables("临时统计表")
't.Sort = "日期"
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("临时统计表") '定义一个变量t引用数据表
Dim sm As Integer = 0
Chart= Forms("统计窗口").Controls("Chart1") ' 引用窗口中的图表
chart.SeriesList.Clear
chart.AxisX.ClearValueLabel
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Dim r As Row = t.Rows(t.count-1)
sm = r("销售额")
For Each c As Col In t.Cols
If c.name <> "日期" Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = c.caption & "(" & r(c.name) & ")" '设置图系的标题
Series.Y(0) = r(c.name) '指定值
Series.DataLabelText = Math.Round(r(c.name)*100/sm,2) & "%" '计算百分比
End If
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)