编号一定要符合规范,不能不一致。否则就会出错
If e.DataCol.Name = "订购日期" Then
If e.DataRow.IsNull("订购日期") Then
e.DataRow("订单号") = Nothing
Else
Dim bh As String = "DG" & 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 > "" AndAlso max.Length >= bh.Length +3 Then
idx = CInt(max.Substring(bh.Length+1,2)) + 1
Else
idx = 1
End If
e.DataRow("订单号") = bh & "-" & Format(idx,"00")
End If
End If
End If