代码,自己改动。学着自己看懂变通
Dim d1 As Date = e.Form.Controls("DateTimePicker1").Value
Dim filter1 As String = "1=1"
If e.Form.Controls("RadioButton1").Checked Then
Dim w As Integer = d1.DayOfWeek '算出今天是星期几
Dim dt1 As Date = d1.AddDays(-w) '获取本周的第一天
Dim dt2 As Date = d1.AddDays(6 - w) '获取本周的最后一天
filter1 = "回款日期 >= #" & dt1 & "# and 回款日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton2").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("RadioButton3").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("RadioButton5").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("RadioButton4").Checked Then
filter1 = "1=1"
End If
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim dt As DataTable = DataTables("表A") '定义一个变量t引用数据表
Chart = e.Form.Controls("Chart2") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型改为Bar(条形)
Chart.SeriesList.Clear() '清除图表原来的图系
Dim qys As List(Of String) = dt.GetValues("区域", "区域 is not null")
Dim tjs As String() = {"销售额","货物成本","物流成本","其它成本","合计成本","利润"}
For Each qy As String In qys
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = qy '设置图系的标题
Series.Length = qys.Count '设置图系的长度
For r As Integer = 0 To tjs.length - 1
Dim sum As Double = dt.Compute("sum(" & tjs(r) & ")", filter1 & " And 区域 = '" & qy & "'")
Series.X(r) = r
Series.Y(r) = sum
Next
Next
msgbox(1)
For r As Integer = 0 To tjs.length - 1
Chart.AxisX.SetValueLabel(r, tjs(r)) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列