Foxtable(狐表)用户栏目专家坐堂 → 自动编号跨年跟换代码后错误


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

主题:自动编号跨年跟换代码后错误

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


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

这样试试:

Select e.DataCol.Name
    Case "登记日期","类别"
        If e.DataRow.IsNull("登记日期") OrElse e.DataRow.IsNull("类别") Then
            e.DataRow("编号") = Nothing
        Else
            Dim d As Date = e.DataRow("登记日期")
            Dim y As Integer = d.Year
            Dim bh As String = e.DataRow("类别") & "[" & Format(d,"yyyy") & "]" '生成编号的前缀
            If e.DataRow("编号").StartsWith(bh) = False '如果立案编号前缀不符
                Dim idx As Integer
                Dim max,flt,s1 As String
                Dim d1,d2 As Date
                d1 = New Date(y,1,1)
                d2 = New Date(y,12,31)

                Dim v1 as string() ={e.DataRow("类别"),e.DataRow("_Identify"),d1,d2}
                s1 ="类别 ='{0}' and [_Identify] ={1} and 登记日期 >= #{2}# and 登记日期 <= #{3}#"
                flt = String.format(s1,V1(0),V1(1),v1(2),v1(3))
                
                max = e.DataTable.Compute("Max(编号)",flt) '取得区划机关行为简称的最大单据编号
                If max > "" Then '如果存在最大立案编号
                    idx = CInt(max.Substring(8,3)) + 1 '获得最大单据编号的后四位顺序号,并加1
                Else
                    idx = 1 '否则顺序号等于1
                End If
                e.DataRow("编号") = bh & Format(idx,"000") 
            End If
        End If
End Select

 回到顶部