没有人这样设计修通的,数据冗余,维护困难,编码难度大幅增加。
同样的数据,应该只出现在一个地方。
还有你原来的公式,完全重复了,有一段是多余的,应该:
If e.DataCol.Name = "选择" Then
If e.DataRow("选择") = True Then
Dim nma() As String = {"单位","商品类别","商品代码","商品名称","仓库名称","仓位","日期","进库_折扣","进库_数量","进库_单价","进库_金额","规格","等级"} 'A表数据来源列
Dim nmb() As String = {"单位","商品类别","商品代码","商品名称","仓库名称","仓位","日期","进库_折扣","进库_数量","进库_单价","进库_金额","规格","等级"} 'B表数据来源列 Dim dr As DataRow = DataTables("库存表").AddNew
Dim dr As DataRow = DataTables("库存表").AddNew
For i As Integer = 0 To nma.Length - 1
dr(nmb(i)) = e.DataRow(nma(i))
Next
dr("id") =e.DataRow("_identify")
Else
Dim tr As DataRow =DataTables("库存表").find("id ="& e.DataRow("id"))
If tr IsNot Nothing Then
tr.delete()
End If
End If
End If