Foxtable(狐表)用户栏目专家坐堂 → [求助]自动生成编号


  共有2199人关注过本帖平板打印复制链接

主题:[求助]自动生成编号

美女呀,离线,留言给我吧!
winlikong
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:3 积分:80 威望:0 精华:0 注册:2014/9/16 14:08:00
[求助]自动生成编号  发帖心情 Post By:2014/9/16 14:15:00 [只看该作者]

请查看附件:

我需要把201406到201409的日期的自动生成编号 :

是否直接把http://www.foxtable.com/help/index.html?n=2403.htm这个教程上的一些字改一下就可以?

请指教

If e.DataCol.Name = "遞交日期" Then

    If e.DataRow.IsNull("遞交日期") Then

        e.DataRow("日期編號") = Nothing

    Else

        Dim d As Date = e.DataRow("遞交日期")

        Dim y As Integer = d.Year

        Dim m As Integer = d.Month

        Dim Days As Integer = Date.DaysInMonth(y,m)

        Dim fd As Date = New Date(y,m,1) '获得该月的第一天

        Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天

        Dim bh As String = Format(d,"yyyyMM") '生成编号的前6位,4位年,2位月.

        If e.DataRow("日期編號").StartsWith(bh) = False '如果编号的前6位不符

            Dim max As String

            Dim idx As Integer

            max = e.DataTable.Compute("Max(日期編號)","遞交日期 >= #" & fd & "# And 遞交日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大编号

            If max > "" Then '如果存在最大编号

                idx = CInt(max.Substring(7,3)) + 1 '获得最大编号的后三位顺序号,并加1

            Else

                idx = 1 '否则顺序号等于1

            End If

            e.DataRow("日期編號") = bh & "-" & Format(idx,"000")

        End If

    End If

End If

<!--EndFragment-->


 回到顶部