-- 作者:sxqq123
-- 发布时间:2013/8/2 15:33:00
--
在大师帮助下实现了上述功能,现将代码发出和大家共享
Dim dt As Date = e.DataRow("日期") If dt.Day < 26 Then dt = dt.AddMonths(-1) End If Dim dt1 As Date = New Date(dt.Year,dt.Month ,26) Dim dt2 As Date = dt1.AddMonths(1).AddDays(-1) If e.DataCol.name = "日期" Then If e.DataRow.IsNull("日期") = False Dim Filter As String Filter = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "#" Tables("蒸发收碱").Filter = Filter End If End If
Select Case e.DataCol.Name Case "数量" Dim dr As DataRow Dim drs As List(of DataRow) drs = e.DataTable.Select("液碱标号=\'" & e.DataRow("液碱标号") & "\' and 日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "#", "日期 ") If drs.Count = 1 Then e.DataRow("全月用量_标号统计")=e.DataRow("数量") Else drs = e.DataTable.Select("液碱标号=\'" & e.DataRow("液碱标号") & "\' and 日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "#", "日期 ") For i As Integer = 1 To drs.Count-1 drs(i)("全月用量_标号统计") = drs(i-1)("全月用量_标号统计") + drs(i)("数量") Next End If End Select Select Case e.DataCol.Name Case "数量" Dim dr As DataRow Dim drs As List(of DataRow) drs = e.DataTable.Select("供货厂家=\'" & e.DataRow("供货厂家") & "\' and 日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "#", "日期 ") If drs.Count = 1 Then e.DataRow("全月用量_厂家统计")=e.DataRow("数量") Else drs = e.DataTable.Select("供货厂家=\'" & e.DataRow("供货厂家") & "\' and 日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "#", "日期 ") For i As Integer = 1 To drs.Count-1 drs(i)("全月用量_厂家统计") = drs(i-1)("全月用量_厂家统计") + drs(i)("数量") Next End If End Select
Select Case e.DataCol.Name Case "数量" Dim dr As DataRow Dim drs As List(of DataRow) drs = e.DataTable.Select("供货厂家=\'" & e.DataRow("供货厂家") & "\' and 日期 >= #" & e.DataRow("日期").Year & "/1/1# ") If drs.Count = 1 Then e.DataRow("全年用量_厂家统计")=e.DataRow("数量") Else drs = e.DataTable.Select("供货厂家=\'" & e.DataRow("供货厂家") & "\' and 日期 >= #" & e.DataRow("日期").Year & "/1/1# ") For i As Integer = 1 To drs.Count-1 drs(i)("全年用量_厂家统计") = drs(i-1)("全年用量_厂家统计") + drs(i)("数量") Next End If End Select Select Case e.DataCol.Name Case "数量" Dim dr As DataRow Dim drs As List(of DataRow) drs = e.DataTable.Select("液碱标号=\'" & e.DataRow("液碱标号") & "\' and 日期 >= #" & e.DataRow("日期").Year & "/1/1# " ) If drs.Count = 1 Then e.DataRow("全年用量_标号统计")=e.DataRow("数量") Else drs = e.DataTable.Select("液碱标号=\'" & e.DataRow("液碱标号") & "\' and 日期 >= #" & e.DataRow("日期").Year & "/1/1# ") For i As Integer = 1 To drs.Count-1 drs(i)("全年用量_标号统计") = drs(i-1)("全年用量_标号统计") + drs(i)("数量") Next End If End Select DataTables("蒸发收碱").Save()
|