按钮代码
Dim d1 As Date = e.Form.Controls("DateTimePicker1").Value
Dim d2 As Date = e.Form.Controls("DateTimePicker2").Value
Dim filter1 As String
Dim filter2 As String
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 & "#"
w = d2.DayOfWeek '算出今天是星期几
dt1 = d2.AddDays(-w) '获取本周的第一天
dt2 = d2.AddDays(6 - w) '获取本周的最后一天
filter2 = "回款日期 >= #" & 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 & "#"
y = d2.Year
m = d2.Month
dt1 = New Date(y, m, 1)
dt2 = New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
filter2 = "回款日期 >= #" & dt1 & "# and 回款日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton3").Checked Then
Dim y As Integer = Date.Today.Year
Dim dt1 As New Date(y, 1, 1)
Dim dt2 As New Date(y, 12, 31)
filter1 = "回款日期 >= #" & dt1 & "# and 回款日期 <= #" & dt2 & "#"
y = Date.Today.Year
dt1 = New Date(y, 1, 1)
dt2 = New Date(y, 12, 31)
filter2 = "回款日期 >= #" & dt1 & "# and 回款日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton4").Checked Then
filter1 = "1=1"
filter2 = "1=1"
End If
e.Form.Controls("Label7").Text = DataTables("表a").Compute("sum(销售额)", filter1)
e.Form.Controls("Label01").Text = DataTables("表a").Compute("sum(销售额)", filter2)
e.Form.Controls("Label8").Text = DataTables("表a").Compute("sum(利润)", filter1)
e.Form.Controls("Label13").Text = format(val(e.Form.Controls("Label8").Text) / val(e.Form.Controls("Label7").Text) * 100, "#.00") & "%"
e.Form.Controls("Label7").Text = DataTables("表a").Compute("sum(销售额)", filter1)
e.Form.Controls("Label29").Text = DataTables("表a").Compute("sum(销售额)", filter2)
e.Form.Controls("Label27").Text = DataTables("表a").Compute("sum(合计成本)", filter1)
e.Form.Controls("Label26").Text = format(val(e.Form.Controls("Label27").Text) / val(e.Form.Controls("Label7").Text) * 100, "#.00") & "%"
e.Form.Controls("Label7").Text = DataTables("表a").Compute("sum(销售额)", filter1)
e.Form.Controls("Label05").Text = DataTables("表a").Compute("sum(销售额)", filter2)
e.Form.Controls("Label9").Text = DataTables("表a").Compute("sum(货物成本)", filter1)
e.Form.Controls("Label14").Text = format(val(e.Form.Controls("Label9").Text) / val(e.Form.Controls("Label7").Text) * 100, "#.00") & "%"
e.Form.Controls("Label7").Text = DataTables("表a").Compute("sum(销售额)", filter1)
e.Form.Controls("Label08").Text = DataTables("表a").Compute("sum(销售额)", filter2)
e.Form.Controls("Label10").Text = DataTables("表a").Compute("sum(物流成本)", filter1)
e.Form.Controls("Label15").Text = format(val(e.Form.Controls("Label10").Text) / val(e.Form.Controls("Label7").Text) * 100, "#.00") & "%"
e.Form.Controls("Label7").Text = DataTables("表a").Compute("sum(销售额)", filter1)
e.Form.Controls("Label09").Text = DataTables("表a").Compute("sum(销售额)", filter2)
e.Form.Controls("Label11").Text = DataTables("表a").Compute("sum(其它成本)", filter1)
e.Form.Controls("Label16").Text = format(val(e.Form.Controls("Label11").Text) / val(e.Form.Controls("Label7").Text) * 100, "#.00") & "%"