尝试在窗口使用"代号"和"到货时间"自动生产编号,但是实际使用中发现有重复编号的情况出现,请大大帮忙看看问题出现在哪里呢
'自动填充订单号
Select e.DataCol.name
Case "到货时间","件号"
If e.DataRow.IsNull("到货时间") OrElse e.DataRow.IsNull("件号") Then
e.DataRow("订单号") = Nothing
Else
Dim bh As String = e.DataRow("代号") & Format(e.DataRow("到货时间"),"yyMMdd")
If e.DataRow("订单号").startsWith(bh) = False
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(8,2)) + 1
Else
idx = 1
End If
e.DataRow("订单号") = bh & Format(idx,"00")
End If
End If
End Select