Select Case e.DataCol.name
Case "时间","委托部门代码"
If dr.Isnull("时间") And dr.Isnull("委托部门代码")
dr("项目代码") = Nothing
Else
Dim d As Date = dr("时间")
d = new Date(d.year, 1, 1)
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(项目代码)","时间 >= # " & d & "# and 时间 < #" & d.AddYears(1) & "# and 委托部门代码 = '"& wtbmdm &"' And [_Identify] <>" & dr("_Identify"))
If max > "" Then
idx = CInt(max.Substring(bh.length+1,3)) + 1
Else idx= 1
End If
dr("项目代码")= bh & "-" & Format(idx,"000")
End If
End If
End Select
[此贴子已经被作者于2019/5/28 10:56:15编辑过]