以文本方式查看主题

-  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=133882)

--  作者:蓝蚂蚁
--  发布时间:2019/4/22 20:50:00
--  自动编号

图片点击可在新窗口打开查看此主题相关图片如下:图像 1.jpg
图片点击可在新窗口打开查看
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.zip


--  作者:有点蓝
--  发布时间:2019/4/22 21:17:00
--  
If e.DataCol.Name = "来货单日期" Then
    If e.DataRow.IsNull("来货单日期") Then
        e.DataRow("来货单号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("来货单日期"),"yyyyMMdd") \'取得编号的8位前缀
        Dim max As String
        Dim idx As Integer
        max =Tables("来货登记表").Compute("Max(来货单号)","来货单日期 = #" & e.DataRow("来货单日期") & "#") \'取得该天的最大编号
        If max > "" Then \'如果存在最大编号
            idx = CInt(max.Substring(9,3)) + 1 \'获得最大编号的后三位顺序号,并加1
        Else
            idx = 1 \'否则顺序号等于1
        End If
        e.DataRow("来货单号") = bh & "-" & Format(idx,"000")        
    End If
End If