以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- test (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=166148) |
||||
-- 作者:sanny -- 发布时间:2021/5/20 21:09:00 -- test [此贴子已经被作者于2021/7/22 12:20:46编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2021/5/20 22:01:00 -- 问过了:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=164267&skin=0 |
||||
-- 作者:sanny -- 发布时间:2021/5/21 12:21:00 -- 是 [此贴子已经被作者于2021/7/22 12:20:58编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2021/5/21 13:31:00 -- 什么地方不对?请使用数据截图举例说明 |
||||
-- 作者:sanny -- 发布时间:2021/5/21 15:25:00 -- Dim con As Integer = DataTables.Compute("sum(数量)","产品名称=\'" & current("产品名称") & "\' and _sortkey < " & current("_sortkey")) Dim s As String Dim drs As List(Of DataRow) = DataTables("表B").Select("产品名称= \'" & current("产品名称") & "\'","出货日期") Dim dr As DataRow Dim sl As Integer = current("数量") Do While drs.Count > 0 dr = drs(0) If con >= dr("数量") Then con = con - dr("数量") Else Dim c1 As Integer = dr("数量") - con con = 0 If s > "" Then s = s & " + " If c1 >= sl Then s = s & dr("出货日期") & " /" & sl & "pc" & IIF(s.Contains("+"),"s","") Exit Do Else s = s & dr("出货日期") & " /" & c1 & "pcs" sl = sl - c1 End If End If drs.RemoveAt(0) Loop current("出货日期备注") = s |
||||
-- 作者:有点蓝 -- 发布时间:2021/5/21 15:33:00 -- 参考:http://www.foxtable.com/webhelp/topics/0445.htm Tables("表A").current("产品名称") Tables("表A").current("xx列")
|
||||
-- 作者:sanny -- 发布时间:2021/5/21 18:23:00 -- Dim con As Integer = DataTables.Compute("sum(数量)","产品名称=\'" & DataTables("表A").current("产品名称") & "\' and _sortkey < " & DataTables("表A").current("_sortkey")) Dim s As String Dim drs As List(Of DataRow) = DataTables("表B").Select("产品名称= \'" & DataTables("表A").current("产品名称") & "\'","出货日期") Dim dr As DataRow Dim sl As Integer = DataTables("表A").current("数量") Do While drs.Count > 0 dr = drs(0) If con >= dr("数量") Then con = con - dr("数量") Else Dim c1 As Integer = dr("数量") - con con = 0 If s > "" Then s = s & " + " If c1 >= sl Then s = s & dr("出货日期") & " /" & sl & "pc" & IIF(s.Contains("+"),"s","") Exit Do Else s = s & dr("出货日期") & " /" & c1 & "pcs" sl = sl - c1 End If End If drs.RemoveAt(0) Loop DataTables("表A").current("出货日期备注") = s |
||||
-- 作者:有点蓝 -- 发布时间:2021/5/22 9:04:00 -- DataTables("xx表").Compute...... |
||||
-- 作者:sanny -- 发布时间:2021/5/22 12:06:00 -- 老师,已经把代码加进去了,可是结果不对呀 结果就是这样的: 产品名称 数量 出货日期备注 A
4
2021-05-01 :4pcs A
7
2021-05-01 :5pcs + 2021-06-01 :2pcs A
1
2021-06-01 :1pcs A
5
2021-06-01 :2pcs
[此贴子已经被作者于2021/5/22 12:10:53编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2021/5/22 13:43:00 -- Dim s As String 改为 Dim s As String = ""
|