以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  数据添加  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=179962)

--  作者:asionwong
--  发布时间:2022/9/20 17:26:00
--  数据添加
                Dim drs As List(of DataRow)=DataTables("销售查询").Select("[客户编码]=\'" & e.DataRow("客户编码") &"\' And [产品编码]=\'" & e.dataRow("产品编码") &"\'")
                If drs.count>0
                    Dim Cols1() As String = {"出货日期","包装规格","出货方式","出货数量","包装单位","出货单价"}
                    Dim Cols2() As String = {"出货日期","包装规格","出货方式","出货数量","包装单位","出货单价"}
                    For Each dr1 As DataRow In drs
                        Dim dr2 As Row = Tables("预售单_table10").AddNew()
                        For i As Integer = 0 To Cols1.Length -1
                            dr2(Cols2(i)) = dr1(Cols1(i))
                        Next
                    Next
                    Tables("预售单_table10").sort="出货日期 DESC"
                End If

只想在Tables("预售单_table10")添加最近5条数据,而不是全部的数据,请问怎么做?谢谢

--  作者:有点蓝
--  发布时间:2022/9/20 17:39:00
--  
Dim drs As List(of DataRow)=DataTables("销售查询").Select("[客户编码]=\'" & e.DataRow("客户编码") &"\' And [产品编码]=\'" & e.dataRow("产品编码") &"\'","出货日期 desc")
                If drs.count>0
                    Dim Cols1() As String = {"出货日期","包装规格","出货方式","出货数量","包装单位","出货单价"}
                    Dim Cols2() As String = {"出货日期","包装规格","出货方式","出货数量","包装单位","出货单价"}
                    For i as integer = 0 to math.min(drs.count - 1,4)
dim dr1 as datarow = drs(i)
                        Dim dr2 As Row = Tables("预售单_table10").AddNew()
                        For i As Integer = 0 To Cols1.Length -1
                            dr2(Cols2(i)) = dr1(Cols1(i))
                        Next
                    Next
                    Tables("预售单_table10").sort="出货日期 DESC"
                End If