老师,下面代码是自动编号,格式为:园别简码-zCLB-数字序号组成,但提示红色代码部分有错,请老师帮我修改,谢谢!!
Select e.DataCol.Name
Case "LBBH","园别简码"
If e.DataRow.IsNull("LBBH") OrElse e.DataRow.IsNull("园别简码") Then
e.DataRow("ZCBH") = Nothing
Else
Dim bh As String = e.DataRow("园别简码") & "-" & e.DataRow("LBBH") & "-" '生成编号的前缀
If e.DataRow("ZCBH").StartsWith(bh) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "园别简码 = '"& e.DataRow("园别简码") & "' AND "LBBH = '"& e.DataRow("LBBH") & "' And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(ZCBH)",flt) '取得该相同工程代码的最大单据编号
If max > "" Then '如果存在最大单据编号
idx = CInt(max.Substring(bh.length,3)) + 1 '获得最大单据编号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("ZCBH") = bh & Format(idx,"000")
End If
End If
End Select