Foxtable(狐表)用户栏目专家坐堂 → 代码有什么问题么?为什么 编号都是001 不自动增加呢?


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

主题:代码有什么问题么?为什么 编号都是001 不自动增加呢?

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


加好友 发短信
等级:五尾狐 帖子:1062 积分:9781 威望:0 精华:0 注册:2012/3/13 5:23:00
代码有什么问题么?为什么 编号都是001 不自动增加呢?  发帖心情 Post By:2016/5/24 14:26:00 [只看该作者]

If e.DataCol.Name = "time" Then
    If e.DataRow.IsNull("time") Then
        e.DataRow("danhao") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("time"),"yyyyMMdd") '取得danhao的8位前缀
        If e.DataRow("danhao").StartsWith(bh) = False '如果danhao的前8位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(danhao)","time = #" & e.DataRow("time") & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大danhao
            If max > "" Then '如果存在最大danhao
                idx = CInt(max.Substring(9,3)) + 1 '获得最大danhao的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            e.DataRow("danhao") = bh & "-" & Format(idx,"000")
        End If
    End If
End If

[此贴子已经被作者于2016/5/24 14:26:33编辑过]

 回到顶部
总数 19 1 2 下一页