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
|