建议:
1、两个表通过入库单号建立关联,固定资产入库表为父表,固定资产库存表为子表。
2、固定资产库存表的名称、规格改为表达式列,用表达式引用父表数据:
http://www.foxtable.com/help/topics/0106.htm
3、自动增加删除行的代码改为:
If e.DataCol.Name = "数量" OrElse e.DataCol.name = "入库单号" Then
If e.DataRow.Isnull("数量") = False Then
Dim n As Integer = e.DataRow("数量")
Dim drs As List(of DataRow) = e.DataRow.GetChildRows("固定资产库存表")
If drs.count > n Then
For i As Integer = n To drs.count - 1
drs(i).delete
Next
Else
For i As Integer = 0 To drs.count - 1
Dim dr As DataRow = DataTables("固定资产库存").AddNew
dr("入库单号") = e.DataRow("入库单号")
Next
End If
End If
End If