If e.DataCol.Name = "送达日期" Then
If e.DataRow.Isnull("送达日期") Then
e.DataRow("送达编号") = Nothing
Else
Dim d As Date = e.DataRow("送达日期")
Dim y As Integer = d.Year
Dim fd As Date = New Date(y,1,1)
Dim ld As Date = fd.addyears(1)
Dim bh As String = Format(d,"yyyy")
If e.DataRow("送达编号").StartWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(送达编号)","送达日期 >= #" & fd & "# And 送达日期 < #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify"))
If max > "" Then
idx = CInt(max.Substring(4,4)) + 1
Else
idx = 1
End If
e.DataRow("送达编号") = bh & Format(idx,"0000")
End If
End If
End If