以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  遍历取值问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=97084)

--  作者:xywl
--  发布时间:2017/3/6 7:13:00
--  遍历取值问题

.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2016.7.29.1
错误所在事件:表,当天出库, DataColChanged
详细错误信息:
调用的目标发生了异常。
从类型“String()”到类型“String”的转换无效。
代码:

DataColChanged

Case "数量"
If e.DataRow("数量") IsNot Nothing Then
         Dim r As DataRow = e.DataRow
        Dim d1 As DataRow = DataTables("商品库存明细").Find("货品编号 = \'" & r("商品编号") & "\'")
        If d1 IsNot Nothing Then
           If d1("实时库存") > r("数量") Then
r("库位") = d1("货格")
Else
Dim count As Integer = 0
   
    Dim drs As List(Of DataRow) = DataTables("商品库存明细").Select(" 货品编号 = \'" & r("商品编号") & "\'", "_Identify")
   
    For i As Integer = 0 To drs.count - 1
       
        Dim dr As DataRow = drs(i)
        count += dr("实时库存")
        Dim sy As Integer = count - r("数量")
        If sy >= 0 Then
r("库位") = dr("货格").split(",")
        End If
Next
End If
End If
End If
熬了一夜,头昏脑胀,看不出问题了,请各位帮帮忙,不胜感激

 

 


--  作者:有点蓝
--  发布时间:2017/3/6 9:00:00
--  

r("库位") = dr("货格").split(",")

这句代码得问题,split返回的是一个数组,应该这样使用:

 

 r("库位") = dr("货格").split(",")(0)

 


 


--  作者:xywl
--  发布时间:2017/3/6 9:13:00
--  

谢谢,那为什么还是没有取得这个数组中所有的货格呢,依然是单一货格满足出货量才有库位显示

 


--  作者:有点色
--  发布时间:2017/3/6 9:40:00
--  
If e.DataRow("数量") IsNot Nothing Then
    Dim r As DataRow = e.DataRow
    Dim d1 As DataRow = DataTables("商品库存明细").Find("货品编号 = \'" & r("商品编号") & "\' and 实时库存 > " & r("数量"))
    If d1 IsNot Nothing Then
        r("库位") = d1("货格")
    Else
        Dim count As Integer = 0
        Dim drs As List(Of DataRow) = DataTables("商品库存明细").Select("货品编号 = \'" & r("商品编号") & "\'", "_Identify")
        Dim s As String = ""
        For i As Integer = 0 To drs.count - 1
            Dim dr As DataRow = drs(i)
            count += dr("实时库存")
            Dim sy As Integer = count - r("数量")
            s = dr("货格") & ","
            If sy >= 0 Then
                r("库位") = s.trim(",")
                Exit For
            End If
        Next
    End If
End If

--  作者:xywl
--  发布时间:2017/3/6 13:52:00
--  
还是不行,DataTables("商品库存明细").Select("货品编号 = \'" & r("商品编号") & "\'", "_Identify") 不用主键 用入库日期怎样写代码 (先进先出)

--  作者:有点蓝
--  发布时间:2017/3/6 14:35:00
--  
没看懂,上例子说明
--  作者:有点色
--  发布时间:2017/3/6 14:51:00
--  
以下是引用xywl在2017/3/6 13:52:00的发言:
还是不行,DataTables("商品库存明细").Select("货品编号 = \'" & r("商品编号") & "\'", "_Identify") 不用主键 用入库日期怎样写代码 (先进先出)

 

Dim drs As List(Of DataRow) = DataTables("商品库存明细").Select("货品编号 = \'" & r("商品编号") & "\'", "_Identify")

 

改成

 

Dim drs As List(Of DataRow) = DataTables("商品库存明细").Select("货品编号 = \'" & r("商品编号") & "\'", "日期, _Identify")