以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 关于流水账 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=63135) |
-- 作者:信达 -- 发布时间:2015/1/14 16:05:00 -- 关于流水账 老师,关于流水账的设计,如果要给库存设定一个初始值,而这个初始值来自于A表的B列,怎么改啊? Case "产品","入库","出库" Dim dr As DataRow Dim mr As DataRow = e.DataRow Dim drs As List(of DataRow) dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [产品] = \'" & mr("产品") & "\'", "[_SortKey] Desc") If dr Is Nothing Then mr("库存") = mr("入库") - mr("出库") dr = mr End If drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [产品] = \'" & dr("产品") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库") Next If e.DataCol.Name = "产品" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [产品] = \'" & e.OldValue & "\'", "[_SortKey] Desc") If dr Is Nothing Then dr = e.DataTable.Find("[产品] = \'" & e.OldValue & "\'", "[_SortKey]") If dr IsNot Nothing Then dr("库存") = dr("入库") - dr("出库") End If End If If dr IsNot Nothing Then drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [产品] = \'" & dr("产品") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库") Next End If End If End Select |
-- 作者:Bin -- 发布时间:2015/1/14 16:12:00 -- dim drr as datarow = datatables("A表").find("产品=\'" & dr("产品") & "\'") if drr isnot nothing then drs(0)("库存")= drr("B列") end if For i As Integer = 1 To drs.Count - 1
drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库") Next [此贴子已经被作者于2015-1-14 16:13:32编辑过]
|
-- 作者:信达 -- 发布时间:2015/1/14 16:41:00 -- 试了一下,数值修改后没变化。 |
-- 作者:Bin -- 发布时间:2015/1/14 16:44:00 -- 修改A表的数值希望 这个表变化? 那你要到A表的DataColChanged里面写代码 .参考帮助的跨表引用自动更新 |