Select e.DataCol.Name
Case "所属地区", "设备类型"
If e.DataRow.IsNull("所属地区") Then
e.DataRow("设备编号") = Nothing
Else
Dim lb As String = e.DataRow("所属地区") & e.DataRow("设备类型") & "-" '生成编号的前缀
If e.DataRow("设备编号").StartsWith(lb) = False '如果单据设备编号前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(设备编号)","所属地区 = '" & lb & "'") '取得该所属地区的最大设备编号
If max > "" Then '如果存在最大设备编号
idx = CInt(max.Substring(2,3)) + 1 '获得最大设备编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("设备编号") = lb & Format(idx,"000")
End If
End If
End Select
我这串代码,不能编号
[此贴子已经被作者于2013-2-20 21:53:22编辑过]