以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  项目发布  (http://www.foxtable.com/bbs/list.asp?boardid=5)
----  [求助]控件Click下的自动编号问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=5&id=108174)

--  作者:cyh2017
--  发布时间:2017/10/17 18:04:00
--  [求助]控件Click下的自动编号问题
以下代码是DataColchanged下的自动编号代码,,请问如果要移到 按钮控件的click下,增加一行后,直接按条件给个编号,要怎么修改。。。。。。



Select e.DataCol.Name
    Case "公司名称"
        If e.DataRow.IsNull("公司名称")  Then
            e.DataRow("公司编号") = Nothing
        Else
                If e.DataRow("公司编号").StartsWith("C") = False \'如果编号前缀不符
                Dim max As String
                Dim idx As Integer
                max = e.DataTable.Compute("Max(公司编号)"," [_Identify] <> " & e.DataRow("_Identify")) \'取得最大编号
                If max > "" Then \'如果存在最大单据编号
                    idx = CInt(max.Substring(1,4)) + 1 \'获得最大单据编号的后四位顺序号,并加1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("公司编号") = "C" & Format(idx,"0000")
            End If
        End If
End Select