以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  自动编号  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=115673)

--  作者:nxqtxwz
--  发布时间:2018/3/12 11:49:00
--  自动编号

请老师看看,我这个代码怎么不往上加呢,永远是第一个号。

 

 

Dim d As Date = Date.Today
Dim max As String
Dim idx As Integer
Dim flt As String
Dim bh As String =Format(d,"yyyy")
flt = "编号 like \'" & bh & "%\'"
\'Output.Show(flt)
max = e.DataTable.Compute("Max(编号)",flt)
If max > "" Then \'如果存在最大
idx = CInt(max.Substring(max.Length-3,3)) + 1
Else
    idx = 1 \'否则顺序号等于1
End If
e.DataRow("编号") ="CG" & bh & Format(idx,"000")


--  作者:有点甜
--  发布时间:2018/3/12 12:01:00
--  
Dim d As Date = Date.Today
Dim max As String
Dim idx As Integer
Dim flt As String
Dim bh As String = "CG" & Format(d,"yyyy")
flt = "编号 like \'" & bh & "%\'"
max = e.DataTable.Compute("Max(编号)",flt)
If max > "" Then \'如果存在最大
    idx = CInt(max.Substring(max.Length-3,3)) + 1
Else
    idx = 1 \'否则顺序号等于1
End If
e.DataRow("编号") = bh & Format(idx,"000")