在DataRowAdded事件中写了如下代码后,批量入库后,自动编号怎么不起作用呢?
Dim dt As DataTable = DataTables("库存资料")
Dim max As String
Dim idx As Integer
max = dt.Compute("Max(机具ID)","机具ID like 'JJ%'")
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(2)) + 1
Else
idx = 1
End If
For Each dr As DataRow In dt.Select("机具ID is null")
Dim str As String = "JJ" & Format(idx,"000000")
Dim fdr As DataRow = dt.find("机具ID = '" & str & "'")
If fdr Is Nothing
dr("机具ID") = str
End If
idx += 1
Next