Foxtable(狐表)用户栏目专家坐堂 → 编号问题!求助


  共有5119人关注过本帖树形打印复制链接

主题:编号问题!求助

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


加好友 发短信
等级:八尾狐 帖子:1812 积分:12999 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2013/6/7 10:30:00 [显示全部帖子]

If e.DataCol.Name = "日期" Then
    If e.DataRow.IsNull(
"
日期"Then
        e.DataRow(
"
编号") = Nothing
    Else
        e.DataRow("编号") = Nothing
        Dim d As Date = e.DataRow(
"
日期")
        Dim y As Integer = d.Year

        Dim fd As Date = New Date(y,1,1
'
获得该年的第一天
        Dim ld As Date = New Date(y,12,31) 
'
获得该年的最后一天
        
Dim bh As String = y  '生成编号的4位年
        If e.DataRow("编号").StartsWith(bh) = False '如果编号的前6位不符
            Dim max,flt As String
            Dim idx As Integer
            flt ="日期 >= #" & fd & "# And 日期 <= #" & ld & "#"
            flt=flt & " And [_Identify] <> " & e.DataRow("_Identify")
            max = e.DataTable.Compute("Max(编号)",flt'取得该年的最大编号
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(5,3)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            e.DataRow("编号") = bh & "-" & Format(idx,"000")
        End If
    End 
If

End
 If
[此贴子已经被作者于2013-6-7 10:38:26编辑过]

 回到顶部