以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求一代码连接 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=12182) |
||||
-- 作者:xxlzfd -- 发布时间:2011/8/25 10:05:00 -- 求一代码连接 三个表,{入库}{出库}{库存表}
{库存表}DataColChanged事件本来有这个代码 Dim dr As DataRow = e.DataRow
在{库存表}里如何加上下面的代码
Select
Case e.DataCol.Name
|
||||
-- 作者:狐狸爸爸 -- 发布时间:2011/8/25 10:17:00 -- Dim dr As DataRow = e.DataRow Dim dt1 As DataTable = DataTables("入库") Dim dt2 As DataTable = DataTables("出库") Select Case e.DataCol.Name Case "序号" dr("入库数量") = dt1.Compute("Sum(入库数量)","[序号] = \'" & dr("序号") & "\'") dr("入库额") = dt1.Compute("Sum(入库额)","[序号] = \'" & dr("序号") & "\'") dr("出库数量") = dt2.Compute("Sum(出库数量)","[序号] = \'" & dr("序号") & "\'") dr("出库额") = dt2.Compute("Sum(出库额)","[序号] = \'" & dr("序号") & "\'") Case "入库数量","出库数量" For Each dr As DataRow In e.DataTable.Select("[_SortKey] >= " & e.DataRow("_SortKey")) Dim Val1 As Double = e.DataTable.Compute("Sum(入库数量)","[_SortKey] <= " & dr("_SortKey")) Dim Val2 As Double = e.DataTable.Compute("Sum(出库数量)","[_SortKey] <= " & dr("_SortKey")) dr("库存量") = Val1 - Val2 Next End Select |
||||
-- 作者:xxlzfd -- 发布时间:2011/8/25 10:41:00 -- 谢谢你啦,狐爸爸 |
||||
-- 作者:xxlzfd -- 发布时间:2011/8/25 10:46:00 -- 提示出错,我把表传上了
|
||||
-- 作者:狐狸爸爸 -- 发布时间:2011/8/25 11:02:00 -- Dim dr As DataRow = e.DataRow Dim dt1 As DataTable = DataTables("入库") Dim dt2 As DataTable = DataTables("出库") Select Case e.DataCol.Name Case "序号" dr("入库数量") = dt1.Compute("Sum(入库数量)","[序号] = \'" & dr("序号") & "\'") dr("入库额") = dt1.Compute("Sum(入库额)","[序号] = \'" & dr("序号") & "\'") dr("出库数量") = dt2.Compute("Sum(出库数量)","[序号] = \'" & dr("序号") & "\'") dr("出库额") = dt2.Compute("Sum(出库额)","[序号] = \'" & dr("序号") & "\'") Case "入库数量","出库数量" For Each dr2 As DataRow In e.DataTable.Select("[_SortKey] >= " & e.DataRow("_SortKey")) Dim Val1 As Double = e.DataTable.Compute("Sum(入库数量)","[_SortKey] <= " & dr2("_SortKey")) Dim Val2 As Double = e.DataTable.Compute("Sum(出库数量)","[_SortKey] <= " & dr2("_SortKey")) dr2("库存量") = Val1 - Val2 Next End Select |
||||
-- 作者:xxlzfd -- 发布时间:2011/8/25 11:12:00 -- 还有小小问题,没入库的也自动计算了 |
||||
-- 作者:xxlzfd -- 发布时间:2011/8/25 11:26:00 -- 在等中 刷新一下 |
||||
-- 作者:狐狸爸爸 -- 发布时间:2011/8/25 11:29:00 --
|
||||
-- 作者:xxlzfd -- 发布时间:2011/8/25 11:45:00 -- 谢谢你,狐爸爸,可以了 |