老师,这个统计领用数量是没有问题的,目前是因为统计出来的数据没有按照使用设备、材料编码这个分配到临时表的对应日期(如图2)。30楼的也是测试过的,改完之后如图1不是汇总的。
Dim s As String = e.form.controls("月份1").Text
Dim cn1 As String = e.form.controls("材料编码1").Text
Dim d As Date = CDate(s.Insert(4, "-") & "-01")
Dim d2 As Date = New Date(d.Year, d.Month, Date.DaysInMonth(d.Year, d.Month))
Do While d <= d2
dtb.AddDef(format(d, "yyyy-MM-dd"), GetType(Integer))
d = d.adddays(1)
Loop
Tables("使用监控台_现存量").DataSource = dtb.BuildDataSource()
Dim b As New SQLGroupTableBuilder("统计表1", "油类切消液明细")
b.C
b.Groups.AddDef("使用设备")
b.Groups.AddDef("材料编码")
b.Groups.AddDef("领用日期", DateGroupEnum.None)
b.Totals.AddDef("领用数量")
b.Filter = "使用设备 like '%A%' and 材料编码 = '" & cn1 & "'")
Dim dt As DataTable = b.Build(True)
Dim dr2 As DataRow
For Each dr As DataRow In dt.datarows
dr2 = DataTables("使用监控台_现存量").find("使用设备='" & dr("使用设备") & "' and 材料编码 ='" & dr("材料编码") & "'")
If dr2 Is Nothing Then
dr2 = DataTables("使用监控台_现存量").addnew
dr2("使用设备") = dr("使用设备")
dr2("材料编码") = e.form.controls("材料编码1").Text
End If
Dim cn As String = format(dr("领用日期"), "yyyy-MM-dd")
If Tables("使用监控台_现存量").cols.contains(cn) Then
dr2(cn) = dr("领用数量")
End If
Next
此主题相关图片如下:1.jpg
此主题相关图片如下:2.jpg