'''...
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim s_date As New Date(y, 1,1)
Dim e_date As New Date(y, 12,31)
Dim Filter As String
Filter = "日期 >= '" & s_date & "' And 日期 <= '" & e_date & "'"
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "SELECT DISTINCT [_Identify],日期,部门,报表名称,项目,数据统计项目,统计类型,数值,统计部门,年,月,管组民警,组别,款号,品名,模具规格,工件名称,工件规格,区分 from{十监区管理} Where " & Filter & "And (组别 ='大件组' Or 组别='小件组')"
dt = cmd.ExecuteReader()
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(Double))
dtb.AddDef("二月", Gettype(Double))
dtb.AddDef("三月", Gettype(Double))
dtb.AddDef("四月", Gettype(Double))
dtb.AddDef("五月", Gettype(Double))
dtb.AddDef("六月", Gettype(Double))
dtb.AddDef("七月", Gettype(Double))
dtb.AddDef("八月", Gettype(Double))
dtb.AddDef("九月", Gettype(Double))
dtb.AddDef("十月", Gettype(Double))
dtb.AddDef("十一月", Gettype(Double))
dtb.AddDef("十二月", Gettype(Double))
Tables(e.Form.Name & "_Table1").DataSource = dtb.BuildDataSource
Dim i As Integer
For Each v As String() In dt.GetUniqueValues("","部门","组别","管组民警")
Dim s() As String ={"额定工时","实际工时","产量(吨)"}
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("项目") = 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 = dt.GetUniqueValues("","部门","组别","管组民警","数据统计项目")
For Each Ary As String() In Arys
Filter = "[部门] = '" & Ary(0) & "' And 组别='" & Ary(1) & "'And 管组民警='" & Ary(2) & "' And 项目='" & Ary(3) & "'"
If Filter > "" Then
Ar = DataTables(e.form.Name & "_Table1").Find(Filter)
If Ar IsNot Nothing Then
Dim Vals() As String = {"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"}
For index As Integer = 0 To Vals.Length - 1
dt1 = New Date(y, index+1, 1)
dt2 = New Date(y, index+1, Date.DaysInMonth(y,index+1)) '获取该月的最后一天
Filter1 = "日期>='" & dt1 & "'And 日期<='" & dt2 & "' And [部门] = '" & Ary(0) & "' And 组别='" & Ary(1) & "'And 管组民警='" & Ary(2) & "' And 数据统计项目='" & Ary(3) & "' And 区分 ='生产数据录入'"
Val= dt.Compute("Sum(数值)",Filter1)
If Val > 0 Then
Ar(Vals(index)) = Val
Else
Ar(Vals(index)) = 0
End If
Next
End If
End If
Next
Tables(e.form.Name & "_Table1").Datatable.Datacols.Add("累计",GetType(Double),"[一月]+[二月]+[三月]+[四月]+[五月]+[六月]+[七月]+[八月]+[九月]+[十月]+[十一月]+[十二月]")
Tables(e.form.Name & "_Table1").AutoSizeCols