自动编号代码
Select e.DataCol.Name
Case "类别代号"
If e.DataRow.IsNull("类别代号") Then
e.DataRow("产品编号") = Nothing
Else
Dim lb As String = e.DataRow("类别代号")
If e.DataRow("产品编号").StartsWith(lb) = False '如果单据产品编号前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(产品编号)","类别代号 = '" & lb & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该类别代号的最大产品编号
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
-------------------------------------------------------------------------------------------------------
错误提示!!!!
.NET Framework 版本:2.0.50727.3649
Foxtable 版本:2013.10.14.1
错误所在事件:表,产品表,DataColChanged
详细错误信息:
Exception has been thrown by the target of an invocation.
Index and length must refer to a location within the string.
Parameter name: length