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("RadioButton07").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 Chart As WinForm.Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Dim series As winform.ChartSeries
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.AxisX.ClearValueLabel
Dim tp As DateGroupEnum = 0
Dim cbx = e.Form.Controls("ComboBox11")
Select Case cbx.Text
Case "年"
tp = DateGroupEnum.Year
Case "季"
tp = DateGroupEnum.Quarter
Case "月"
tp = DateGroupEnum.month
Case "周"
tp = DateGroupEnum.Week
Case "天"
tp = DateGroupEnum.None
Case Else
tp = DateGroupEnum.None
End Select
Dim g As New GroupTableBuilder("临时统计表", DataTables("订单附表"))
g.Groups.AddDef("业务往来_送货日期", tp, "日期")
g.Totals.AddDef("订单核算_合计")
g.Totals.AddDef("订单核算_单项利润")
g.Totals.AddDef("订单核算_单项成本")
g.Totals.AddDef("订单核算_采购合计")
g.Totals.AddDef("订单核算_合计返点")
'g.Filter = filter1 '全部
g.filter = filter1 & " and 订单核算_合计 <> 0" '显示大于0的
g.Build()
Dim t As Table = Tables("临时统计表")
t.Sort = "日期"
For i As Integer = 7 To 11
Dim c As WinForm.CheckBox = e.Form.Controls("CheckBox" & i)
If c.Checked Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = t.Rows.Count
Series.TooltipText = c.Text & " : {#YVAL}"
Series.Text = c.Text
For r As Integer = 0 To t.Rows.Count - 1
Series.X(r) = r
Series.Y(r) = t.Rows(r)(c.Text)
Next
End If
Next
For r As Integer = 0 To t.Rows.Count - 1
Chart.AxisX.SetValueLabel(r, t.Rows(r)("日期")) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.AxisX.AnnoRotation = - 45 'X轴标示逆时针旋转45度
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)