Select e.DataCol.Name
Case "年份"
If e.DataRow.IsNull("年份") Then
e.DataRow("内部合同编号") = Nothing
Else
Dim nf As String = e.DataRow("年份")
If e.DataRow("内部合同编号").StartsWith(nf) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(内部合同编号)","年份 = '" & nf & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该类别的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(8,4)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("内部合同编号") = nf & "-FA-" & Format(idx,"0000")
End If
End If
End Select
以开发者身份登录可看到全部表格内容时,增加行后自动编号没问题,但是一旦以其他用户身份登录(设置了权限,只能看到登录用户所涉及的合同),增加行后自动编号生成就有问题了,不能根据总表的编号顺延,怎么破?