'''...Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim s_date As New Date(y, m-1,22)
Dim e_date As New Date(y, m,21)
Dim Filter As String
Filter = "日期 >= '" & s_date & "' And 日期 <= '" & e_date & "'"
DataTables("十监区管理").LoadFilter = Filter & "And 区分 ='砂场生产数据录入'"
DataTables("十监区管理").Load
Dim ls As New List(Of String)
Do While s_date < e_date.AddDays(-7)
ls.Add("日期>='" & s_date & "' And 日期<='" & s_date.AddDays(6) & "'")
s_date = s_date.AddDays(7)
Loop
ls.Add("日期>='" & s_date & "' And 日期<='" & e_date & "'")
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("部门", Gettype(String), 50)
dtb.AddDef("年", Gettype(String), 50)
dtb.AddDef("月", Gettype(String), 50)
dtb.AddDef("组别", Gettype(String), 50)
dtb.AddDef("管组民警", Gettype(String), 50)
dtb.AddDef("项目", Gettype(String), 50)
Dim 周别 As Integer
For Each l As String In ls
周别+=1
dtb.AddDef("第" & 周别 & "周", GetType(Double))
Next
Tables(e.Form.Name & "_Table1").DataSource = dtb.BuildDataSource
Dim i As Integer
For Each v As String() In DataTables("十监区管理").GetUniqueValues("","部门","年","月","组别","管组民警")
Dim s() As String ={"总产量(KG)","总废品(KG)","废品率(%)"}
For i = 0 To s.Length -1
Dim dr1 As DataRow = Tables(e.form.Name & "_Table1").DataTable.AddNew()
dr1("部门") = v(0)
dr1("年") = v(1)
dr1("月") = v(2)
dr1("组别") = v(3)
dr1("管组民警") = v(4)
dr1("项目") = s(i)
Next
Next
Dim Arys As List(Of String())
Dim Ar As DataRow
Dim dt1 As Date
Dim dt2 As Date
Dim Filter1 As String
Dim Val,Val1,Val2,Val3 As Double
Arys = DataTables("十监区管理").GetUniqueValues("","部门","年","月","组别","管组民警")
For Each Ary As String() In Arys
Filter = "[部门] = '" & Ary(0) & "'And 年='" & Ary(1) & "'And 月 = '" & Ary(2) & "'And 组别='" & Ary(3) & "'And 管组民警='" & Ary(4) & "' And 项目='总产量(KG)'"
If Filter > "" Then
Ar = DataTables(e.form.Name & "_Table1").Find(Filter)
If Ar IsNot Nothing Then
For Each l As String In ls
Filter1 = l & " And [部门] = '" & Ary(0) & "'And 年='" & Ary(1) & "'And 月 = '" & Ary(2) & "'And 组别='" & Ary(3) & "'And 管组民警='" & Ary(4) & "' And 区分 ='砂场生产数据录入'"
Val= DataTables("十监区管理").Compute("Sum(数值)",Filter1 & " And 数据统计项目='总成品(个)'")
Val1= DataTables("十监区管理").Compute("Sum(数值)",Filter1 & " And 数据统计项目='单重(公斤)'")
Val2 = Val * Val1
MessageBox.Show(Filter1 & " And 数据统计项目='总成品(个)'")
MessageBox.Show("总成品数:" & Val & "单重:" & Val1 & "总产量:" & Val2)
If Val2 > 0 Then
Ar("第" & 周别 & "周") = Val2
Else
Ar("第" & 周别 & "周") = 0
End If
Next
End If
End If
Next
e.Sender.Checked = False
这个代码应该怎么改? 先根据日期生成几个星期周列(例如 第一周,第二周),然后计算这个日期的时间段的数值,写入想对应的星期周的 总产量(KG) 的行中