以文本方式查看主题

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

--  作者:bashanren
--  发布时间:2019/7/15 9:34:00
--  [求助]关于编号问题
各位老师上午好!!
以下是我在项目中的自动编号代码,总觉得太复杂,且“年月日”未能按“4位年2位月2位日”和格式,请老师帮忙修改,谢谢!!
If e.DataCol.Name = "Begin" Then
    If e.DataRow.Isnull("Begin") Then
        e.DataRow("SYBH") = Nothing
    Else
        Dim d As Date = e.DataRow("Begin")
        Dim y As Integer = d.Year
        Dim m As Integer = d.Month
        Dim Days As Integer = d.day

Dim bh0 As Integer = e.DataRow("_Identify")
Dim bh1 As String = y & m & days
Dim bh2 As String = Format(bh0,"000")
        e.DataRow("SYBH")=bh1 & "-" & bh2
    End If
End If

--  作者:有点蓝
--  发布时间:2019/7/15 10:21:00
--  
If e.DataCol.Name = "Begin" Then
    If e.DataRow.Isnull("Begin") Then
        e.DataRow("SYBH") = Nothing
    Else
        Dim d As Date = e.DataRow("Begin")
        Dim bh0 As Integer = e.DataRow("_Identify")
        e.DataRow("SYBH") = Format(d,"yyyyMMdd") & "-" & Format(bh0,"000")
    End If
End If