Foxtable(狐表)用户栏目专家坐堂 → 求编号的自动生成代码


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

主题:求编号的自动生成代码

帅哥哟,离线,有人找我吗?
lkqing
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:492 积分:4243 威望:0 精华:0 注册:2008/9/1 20:47:00
  发帖心情 Post By:2011/6/6 19:31:00 [只看该作者]

这样吧,大同小异的

 

Dim d As Date = e.DataRow("日期")
Dim StartDate As Date
Dim EndDate As Date
Dim Month As Integer  = d.Month
Dim Year As Integer = d.Year
StartDate = New Date(Year,Month,1)
EndDate = New Date(Year,Month,Date.DaysInMonth(Year,Month))
If e.DataCol.Name = "日期" Then
    If e.DataRow.IsNull("日期") Then
        e.DataRow("编号") = Nothing
    Else
        If e.NewValue <> Nothing And e.DataRow("编号") = Nothing Then
            e.DataRow("编号") ="AA" & CStr(e.NewValue).Remove(0,2).Remove(2,1).Remove(4,1)
            Dim drs As List(of DataRow) = e.DataTable.Select("日期 >= #" & StartDate & "# And 日期 <= #" & EndDate & "# And 日期 = #" & d & "#")
            For i As Integer = 0 To drs.Count - 1
                If drs(i)("编号").Length = 8 Then
                    drs(i)("编号")  = e.DataRow("编号") & format(i+1,"000")
                End If
            Next
        End If
    End If
End If

 

个人倾向于将红字部分去掉,这样即能将一月的编号连续,又能区分不同日期。

[此贴子已经被作者于2011-6-6 19:31:10编辑过]

 回到顶部
总数 45 1 2 3 4 5 下一页