老师,以下代码是自动生成编号的代码,是根据登录单位+年度+月份+000三位数组成的代码,修改后不得行,提示标注红色的代码有错,请老师帮助一下,谢谢!!
Select e.DataCol.Name
Case "DWJM","ND","ZJY"
If e.DataRow.IsNull("DWJM") OrElse e.DataRow.IsNull("ND") OrElse e.DataRow.IsNull("ZJY") Then
e.DataRow("JHBH") = Nothing
Else
Dim bh As String = e.DataRow("DWJM") & "-" & e.DataRow("ND") & "-" & e.DataRow("ZJY") & "-" '生成编号的前缀
If e.DataRow("JHBH").StartsWith(bh) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "DWJM = '"& e.DataRow("DWJM") & "'" And "ND = '"& e.DataRow("ND") & "'" And "ZJY = '"& e.DataRow("ZJY") & "'" And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(JHBH)",flt) '取得该月的相同工程代码的最大单据编号
If max > "" Then '如果存在最大单据编号
idx = CInt(max.Substring(12,3)) + 1 '获得最大单据编号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("JHBH") = bh & Format(idx,"000")
End If
End If
End Select