老师,我的下面代码也实现自动编号了,不过不能累加,每次顺序号都是“01”,编号的例子:ty2015010101-01
Select e.DataCol.Name
Case "部门名称"
If e.DataRow.IsNull("部门名称") Then
e.DataRow("员工编号") = Nothing
Else
dim dr as datarow = datatables("部门").find("部门名称='" & e.datarow("部门名称") & "'")
if dr isnot nothing then
Dim lb As String = dr("部门编号")
If e.DataRow("员工编号").StartsWith(bh) = False '如果单据地块编号前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.SQLCompute("Max(员工编号)","部门名称 = '" & bh & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该所属园区的最大地块编号
If max > "" Then '如果存在最大地块编号
idx = CInt(max.Substring(13,2)) + 1 '获得最大地块编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("地块编号") = bh & Format(idx,"00")
End If
End If
End Select
[此贴子已经被作者于2015/5/19 19:05:33编辑过]