Select Case e.DataCol.Name
Case "设备名称","入库数量","出库数量","入库地点"
If e.DataCol.Name = "设备名称" Then
If e.NewValue Is Nothing Then
e.DataRow("设备品牌") = Nothing
e.DataRow("设备版本") = Nothing
e.DataRow("设备型号") = Nothing
e.DataRow("设备颜色") = Nothing
e.DataRow("设备内存") = Nothing
Else
Dim dr1 As DataRow
dr1 = DataTables("设备信息").Find("[设备名称] = '" & e.NewValue & "'")
If dr1 IsNot Nothing
e.DataRow("设备品牌") = dr1("设备品牌")
e.DataRow("设备版本") = dr1("设备版本")
e.DataRow("设备型号") = dr1("设备型号")
e.DataRow("设备颜色") = dr1("设备颜色")
e.DataRow("设备内存") = dr1("设备内存")
End If
End If
End If
Dim dr As DataRow
Dim mr As DataRow = e.DataRow
Dim drs As List(of DataRow)
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [设备名称] = '" & mr("设备名称") & "' and 入库地点 = '" & e.DataRow("入库地点") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
mr("当前库存") = mr("入库数量") - mr("出库数量")
dr = mr
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [设备名称] = '" & dr("设备名称") & "' and 入库地点 = '" & e.DataRow("入库地点") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("当前库存") = drs(i-1)("当前库存") + drs(i)("入库数量") - drs(i)("出库数量")
Next
If e.DataCol.Name = "设备名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [设备名称] = '" & e.OldValue & "' and 入库地点 = '" & e.DataRow("入库地点") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
dr = e.DataTable.Find("[设备名称] = '" & e.OldValue & "'", "[_SortKey]")
If dr IsNot Nothing Then
dr("当前库存") = dr("入库数量") - dr("出库数量")
End If
End If
If dr IsNot Nothing Then
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [设备名称] = '" & dr("设备名称") & "' and 入库地点 = '" & e.DataRow("入库地点") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("当前库存") = drs(i-1)("当前库存") + drs(i)("入库数量") - drs(i)("出库数量")
Next
End If
End If
If e.DataCol.Name = "入库地点" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [设备名称] = '" & e.DataRow("设备名称") & "' and 入库地点 = '" & e.OldValue & "'", "[_SortKey] Desc")
If dr Is Nothing Then
dr = e.DataTable.Find("[入库地点] = '" & e.OldValue & "'", "[_SortKey]")
If dr IsNot Nothing Then
dr("当前库存") = dr("入库数量") - dr("出库数量")
End If
End If
If dr IsNot Nothing Then
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [设备名称] = '" & dr("设备名称") & "' and 入库地点 = '" & e.DataRow("入库地点") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("当前库存") = drs(i-1)("当前库存") + drs(i)("入库数量") - drs(i)("出库数量")
Next
End If
End If
End Select