以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 同表,根据双列(品名和型号规格两列)累计数量 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=93606) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:xh2207 -- 发布时间:2016/12/2 10:32:00 -- 同表,根据双列(品名和型号规格两列)累计数量
的代码如下: datacolchanged
Select Case e.DataCol.Name
请问:根据品名和型号规格累计数量(即同品名和型号数量累加)的代码如何修改?谢谢! 要求的效果如下表:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2016/12/2 10:52:00 -- 试试 Select Case e.DataCol.Name Case "品名","型号规格", "数量" Dim drs As List(of DataRow) Dim Filter As String Filter = "[_SortKey] >= " & e.DataRow("_SortKey") & " And [品名] = \'" & e.DataRow("品名") & "\' and 型号规格 = \'" & e.DataRow("型号规格") & "\'" drs = e.DataTable.Select(Filter) For Each dr As DataRow In drs Filter = "[_SortKey] <= " & dr("_SortKey") & " And [品名] = \'" & dr("品名") & "\' and 型号规格 = \'" & dr("型号规格") & "\'" Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter) dr("本品名型号规格累计") = Val1 Next Filter = "" If e.DataCol.Name = "品名" AndAlso e.OldValue IsNot Nothing Then Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [品名] = \'" & e.OldValue & "\' and 型号规格 = \'" & e.DataRow("型号规格") & "\'" ElseIf e.DataCol.Name = "型号规格" AndAlso e.OldValue IsNot Nothing Then Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [品名] = \'" & e.DataRow("品名") & "\' and 型号规格 = \'" & e.OldValue & "\'" End If If Filter > "" Then drs = e.DataTable.Select(Filter) For Each dr As DataRow In drs Filter = "[_SortKey] <= " & dr("_SortKey") & " And [品名] = \'" & dr("品名") & "\'and 型号规格 = \'" & dr("型号规格") & "\'" Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter) dr("本品名型号规格累计") = Val1 Next End If End Select |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:xh2207 -- 发布时间:2016/12/2 12:01:00 -- 行,谢谢了! |