以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  代码问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=64469)

--  作者:爱相随
--  发布时间:2015/2/14 14:18:00
--  代码问题

老师,下面代码是自动编号,格式为:园别简码-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


--  作者:Bin
--  发布时间:2015/2/14 14:25:00
--  
 flt = "园别简码 = \'" & e.DataRow("园别简码") & "\' AND LBBH = \'" & e.DataRow("LBBH") & "\' And [_Identify] <> " & e.DataRow("_Identify")