以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 求帮助:动态表达式代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=46507) |
||||
-- 作者:xh2207 -- 发布时间:2014/2/24 21:52:00 -- 求帮助:动态表达式代码 根据帮助,已完成了入仓明细表中流水账的一部分功能。即修改(含增行、删行)了今单入仓数列的数量,被修改行的材料累计入仓数量会随之变化。具体的代码如下: Select Case e.DataCol.Name Case "存货编码","数量" Dim drs As List(of DataRow) Dim Filter As String drs = e.DataTable.Select(Filter) For Each dr As DataRow In drs Filter = "[_SortKey] <= " & dr("_SortKey") & " And [存货编码] = \'" & dr("存货编码") & "\'and & parent.项目名称 = \'" & Tables("入仓主表").current("项目名称") & "\'" Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter) dr("累计入仓数量") = Val1 Next If e.DataCol.Name = "存货编码" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [存货编码] = \'" & e.OldValue & "\'" drs = e.DataTable.Select(Filter) For Each dr As DataRow In drs Filter = "[_SortKey] <= " & dr("_SortKey") & " And [存货编码] = \'" & dr("存货编码") & "\'" Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter) dr("累计入仓数量") = Val1 Next End If End Select 请帮助:如何增加动态表达式条件(本人试图修改\'and & parent.项目名称 = \'" & Tables("入仓主表").current("项目名称") & ",但不成功),实现如下功能:当在入仓明细表中修改(含增行、删行)任意行,仅修改该行对应入仓主表的项目名称同一材料的材料累计入仓数量,不是该项目名称的同一材料的累计入仓数量不变。
|
||||
-- 作者:有点甜 -- 发布时间:2014/2/24 22:36: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("存货编码") & "\'" drs = e.DataTable.Select(Filter) For Each dr As DataRow In drs Filter = "[_SortKey] <= " & dr("_SortKey") & " And [存货编码] = \'" & dr("存货编码") & "\' and [入库单号] = \'" & e.DataRow("入库单号") & "\'" Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter) dr("累计入仓数量") = Val1 Next If e.DataCol.Name = "存货编码" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [存货编码] = \'" & e.OldValue & "\'" drs = e.DataTable.Select(Filter) For Each dr As DataRow In drs Filter = "[_SortKey] <= " & dr("_SortKey") & " And [存货编码] = \'" & dr("存货编码") & "\'" Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter) dr("累计入仓数量") = Val1 Next End If End Select [此贴子已经被作者于2014-2-24 22:38:22编辑过]
|
||||
-- 作者:xh2207 -- 发布时间:2014/2/24 22:39:00 -- 试试,先谢谢有点甜老师。 |
||||
-- 作者:xh2207 -- 发布时间:2014/2/24 22:43:00 -- 试了,行。谢谢有点甜。 |