这样吧,大同小异的
Dim d As Date = e.DataRow("日期")
Dim StartDate As Date
Dim EndDate As Date
Dim Month As Integer = d.Month
Dim Year As Integer = d.Year
StartDate = New Date(Year,Month,1)
EndDate = New Date(Year,Month,Date.DaysInMonth(Year,Month))
If e.DataCol.Name = "日期" Then
If e.DataRow.IsNull("日期") Then
e.DataRow("编号") = Nothing
Else
If e.NewValue <> Nothing And e.DataRow("编号") = Nothing Then
e.DataRow("编号") ="AA" & CStr(e.NewValue).Remove(0,2).Remove(2,1).Remove(4,1)
Dim drs As List(of DataRow) = e.DataTable.Select("日期 >= #" & StartDate & "# And 日期 <= #" & EndDate & "# And 日期 = #" & d & "#")
For i As Integer = 0 To drs.Count - 1
If drs(i)("编号").Length = 8 Then
drs(i)("编号") = e.DataRow("编号") & format(i+1,"000")
End If
Next
End If
End If
End If
个人倾向于将红字部分去掉,这样即能将一月的编号连续,又能区分不同日期。
[此贴子已经被作者于2011-6-6 19:31:10编辑过]