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


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

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

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


加好友 发短信
等级:一尾狐 帖子:492 积分:4243 威望:0 精华:0 注册:2008/9/1 20:47:00
  发帖心情 Post By:2011/6/9 21:47: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" & format(e.NewValue,"yyMMdd")    '可替换
            e.DataRow("编号") ="AA" & CStr(e.NewValue).Remove(0,2).Remove(2,1).Remove(4,1)
            Dim dr As DataRow
            Dim mr As DataRow = e.DataRow
            Dim drs As List(of DataRow)
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & "  And [日期] = #" & d & "#", "[_SortKey] Desc")
            If dr Is Nothing Then
                mr("编号") = mr("编号") & format(1,"000")
                dr = mr
            End If
            drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [日期] = '" & d & "'", "[_SortKey]")
            For i As Integer = 1 To drs.Count - 1
                drs(i)("编号") ="AA" & drs(i-1)("编号").SubString(drs(i-1)("编号").Length - 9) + 1
            Next
        End If
    End If
End If

 

说明:如果要求编号确立后不允许修改的,将[_SortKey] 替换为[_Identify]

[此贴子已经被作者于2011-6-9 23:11:14编辑过]

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