If e.DataRow.IsNull("日期") Then
e.DataRow("日期") = Date.Now()
End If
Dim str As String = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim d As Date = e.DataRow("日期")
Dim y As Integer = d.Year - 2001
Dim m As Integer = d.Month - 1
Dim bh As String = str.Substring(y,1) & str.Substring(m,1)
If e.DataRow("编号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("max(编号)","编号 like '" & bh & "%'")
If max > "" Then
idx = CInt(max.Substring(bh.length+1,3)) + 1
Else
idx = 1
End If
e.DataRow("编号") = bh & "-" & Format(idx,"000")
End If