以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  批量添加数据后自动编号问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=129810)

--  作者:裴保民
--  发布时间:2019/1/7 0:57:00
--  批量添加数据后自动编号问题

在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


--  作者:有点甜
--  发布时间:2019/1/7 9:34:00
--  

你是不是写了 SystemReady = False 这样的代码批量入库的?

 

如果是,你需要删除这个代码,才会触发事件的。

 
--  作者:裴保民
--  发布时间:2019/1/7 9:48:00
--  
知道了写了
[此贴子已经被作者于2019/1/7 9:49:06编辑过]