Select Case e.DataCol.name
Case "时间","委托部门代码"
If dr.Isnull("时间") And dr.Isnull("委托部门代码")
dr.("项目代码") = Nothing
Else
Dim d As Date = dr.("时间")
Dim y As Integer =d.year
Dim wtbmdm As String =dr.("委托部门代码")
Dim bh As String = Format(d,"yyyy") & "-" & dr.("委托部门代码")
If dr.("项目代码").startswith(bh)= False
Dim max As String
Dim idx As Integer
max= e.DataTable.compute("max(项目代码)","时间 = # " & y & "# and 委托部门代码 = '"& wtbmdm &"' And [_Identify] <>" & dr.("_Identify"))
If max > "" Then
idx = CInt(max.Substring(bh.length,3)) + 1
Else idx= 1
End If
dr.("项目代码")= bh & "-" & Format(idx,"000")
End If
End If
End If
End Select