Dim bh As String = "wd-" & e.DataRow("客户") & "-" & Format(d,"yyyyMMdd") & "-" '生成编号的前缀
If e.DataRow("编号").StartsWith(bh) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
max = e.DataTable.SQLCompute("Max(Right(编号,4))")
If max > "" Then
idx=cint(max)+1
Else
idx = 1
End If
e.DataRow("编号") = bh & Format(idx,"0000")
e.DataRow.save
End If