Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:如何实现按年度自动编号

1楼
bigpeng 发表于:2025/2/4 15:23:00
帮助里只看到按月编号和按日编号的,尝试了在按日编号基础上修正后进行按年自动编号出现错误,麻烦老师帮忙指正


If e.DataCol.Name = "录入时间" Then
    If e.DataRow.IsNull("录入时间") Then
        e.DataRow("年度编号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("录入时间"), "yyyy") 
        If e.DataRow("年度编号").StartsWith(bh) = False Then
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(年度编号)", "录入时间 = #" & e.DataRow("录入时间") & "# And [_Identify] <> " & e.DataRow("_Identify")) 
            If max > "" Then
                idx = CInt(max.Substring(9, 3)) + 1
            Else
                idx = 1
            End If
            e.DataRow("年度编号") = bh & "-" & Format(idx, "000")
        End If
    End If
End If
2楼
有点蓝 发表于:2025/2/5 9:53:00
参考按月的用法

        If e.DataRow("年度编号").StartsWith(bh) = False Then
            Dim max As String
            Dim idx As Integer
            Dim fd As Date = New Date(y,1,1'获得该年的第一天
            Dim ld As Date = 
fd.addyears(1) '
获得下年的第一天
            max = e.DataTable.Compute("Max(年度编号)", "录入时间 >= #" & fd  & "# and 录入时间 < #" & ld  & "# And [_Identify] <> " & e.DataRow("_Identify")) 


3楼
bigpeng 发表于:2025/2/5 10:43:00
非常感谢!
共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03320 s, 2 queries.