之前做了一个自动编号的功能,因为当时是一个人测试的,没有发现什么问题,后来几个人在使用自动编号这个功能的时候却发现自动编号存在相同的单据编号,这个BUG该如何处理:以下是部分自动编号的代码:
e.DataRow("日期") = Date.Today()
'Dim bh As String = Format(e.DataRow("日期"),"yyMMdd") '取得编号的8位前缀
'If e.DataRow("单据编号").StartsWith(bh) = False '如果编号的前8位不符
'Dim max As String
'Dim idx As Integer
'max = e.DataTable.Compute("Max(单据编号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
'If max > "" Then '如果存在最大编号
'idx = CInt(max.Substring(6,4)) + 1 '获得最大编号的后三位顺序号,并加1
'Else
'idx = 1 '否则顺序号等于1
'End If
'e.DataRow("单据编号") = bh & "" & Format(idx,"0000")
'End If