Select e.DataCol.Name
Case "制单日期"
If e.DataRow.IsNull("制单日期") Then
e.DataRow("送检单编号") = Nothing
Else
Dim d As Date = e.DataRow("制单日期")
Dim y As Integer = d.Year
Dim bh As String = Format(d,"yyyy")
d = new Date(y, 1, 1)
If e.DataRow("送检单编号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(送检单编号)","制单日期 >= #" & d & "# And 制单日期 < #" & d.addyears(1) & "# and [_Identify] <> " & e.DataRow("_Identify"))
If max > "" Then
idx = CInt(max.Substring(7)) + 1
Else
idx = 1
End If
e.DataRow("内部合同编号") = bh & "-F-" & Format(idx,"000")
e.DataRow.Save
End If
End If
End Select
[此贴子已经被作者于2018/6/27 11:54:16编辑过]