Foxtable(狐表)用户栏目专家坐堂 → 超出索引范围的问题


  共有5284人关注过本帖树形打印复制链接

主题:超出索引范围的问题

帅哥哟,离线,有人找我吗?
Bin
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2013/6/14 16:58:00 [显示全部帖子]

Case "取货方案_1","产品条码"                                                                             '错误代码起始
        Dim drs As List (Of DataRow)
        Dim dr As DataRow
        Dim dr1 As DataRow
        Dim Int As Integer = e.DataRow("取货方案_1")
        Dim Int1 As Integer
        Dim filter As String = "库存_库房号 ='1'  And 产品条码 = '" & e.DataRow("产品条码") & "'"
        Dim id As String = "And [_identify] <> -1"
        If e.DataRow.IsNull("取货方案_1") = False Then
            Do While Int > 0
                drs = DataTables("库存表").Select(filter & id & "And 库存数量 >= " & Int)
                Int1 = Math.Abs(drs(0)("库存数量") - Int)    如果Select出来的行数为0的话.你就无法获得第一行 那么就报错
                For i As Integer = 1 To drs.count - 1
                    Int1 = Math.Min(Int1,Math.Abs(drs(i)("库存数量") - Int))
                Next
                dr = DataTables("库存表").Find(filter & id & "And 库存数量 = " & Int + Int1)
                If dr IsNot Nothing
                    dr1 = DataTables("取货明细").AddNew()
                    dr1("取货_数量") = Int
                    dr1("取货_箱号") = dr("库存_装箱号")
                    Int = 0
                Else
                    drs = DataTables("库存表").Select(filter & id & "And 库存数量 < " & Int)
                    Int1 =Int - drs(0)("库存数量")
                    For i As Integer = 1 To drs.count - 1
                        Int1 = Math.Min(Int1,Int-drs(i)("库存数量"))
                    Next
                    dr = DataTables("库存表").Find(filter &  id & " And 库存数量 = " & Int - Int1)
                    If dr IsNot Nothing Then
                        dr1 = DataTables("取货明细").AddNew()
                        dr1("取货_数量") = dr("库存数量")
                        dr1("取货_箱号") = dr("库存_装箱号")
                        Int = Int1                        
                        If id = "And [_identify] <> -1" Then
                            id = "And [_identify] <> " & dr("_identify")
                        Else
                            id = id & "And [_identify] <> " & dr("_identify")
                        End If
                    End If
                End If
            Loop
        End If  

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2013/6/14 17:18:00 [显示全部帖子]

判断一下 drs  是否为NOthing  只要不是空就说明肯定有至少一行  那么drs(0)就不会报错

 回到顶部