Foxtable(狐表)用户栏目专家坐堂 → 判断加自动编号?


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

主题:判断加自动编号?

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


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

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

 回到顶部