以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  _identify的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=105993)

--  作者:mirochain1980
--  发布时间:2017/8/30 17:08:00
--  _identify的问题

用表达式设计了自动编号:\'RJZ\' + SubString(\'00000000\', 1, 8 - Len(Convert([_Identify],\'System.String\'))) + Convert([_Identify], \'System.String\')

增加行然后再删除,再新增行后编号仍然计算了第一次删除的行,也就是行删除了,主键值仍然存在是吗?


--  作者:有点甜
--  发布时间:2017/8/30 17:11:00
--  

_Identify列是不断递增的,不会恢复删除的编号的。

 

生成编号,可以参考这里 http://www.foxtable.com/webhelp/scr/2403.htm

 


--  作者:mirochain1980
--  发布时间:2017/9/4 14:23:00
--  

有个新问题,找不到原因

If e.DataCol.Name =  "日期" Then
    If e.DataRow.IsNull("日期") Then
        e.DataRow("记账编号") = Nothing
    Else
        Dim d As Date = e.DataRow("日期")
         Dim y As Integer = d.Year
        Dim m As Integer = d.Month
        Dim  Days As  Integer = Date.DaysInMonth(y,m)
         Dim fd As Date = New Date(y,m,1)  \'获得该月的第一天
        Dim ld As Date = New Date(y,m,Days)  \'获得该月的最后一天
          Dim bh As String = Format(d,"yyyyMM") \'生成编号的前6位,4位年,2位月.
        If e.DataRow("记账编号").StartsWith(bh) = False \'如果编号的前6位不符
            Dim  max As String
            Dim  idx As  Integer
            max = e.DataTable.Compute("Max(记账编号)","日期 >= #" & fd & "# And 日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该月的最大编号
            If  max > "" Then \'如果存在最大编号
                idx = CInt(max.Substring(7,3)) + 1  \'获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 \'否则顺序号等于1
            End  If
            e.DataRow("记账编号") = "RJZ" & bh & "-" & Format(idx,"000")
         End If
    End  If
 End  If

如上设置的编号代码,为什么结果显示如附件
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20170904141959.jpg
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2017/9/4 16:19:00
--  
If e.DataCol.Name =  "日期" Then
    If e.DataRow.IsNull("日期") Then
        e.DataRow("记账编号") = Nothing
    Else
        Dim d As Date = e.DataRow("日期")
        Dim y As Integer = d.Year
        Dim m As Integer = d.Month
        Dim  Days As  Integer = Date.DaysInMonth(y,m)
        Dim fd As Date = New Date(y,m,1)  \'获得该月的第一天
        Dim ld As Date = New Date(y,m,Days)  \'获得该月的最后一天
        Dim bh As String = "RJZ" & Format(d,"yyyyMM") & "-" \'生成编号的前6位,4位年,2位月.
        If e.DataRow("记账编号").StartsWith(bh) = False \'如果编号的前6位不符
            Dim  max As String
            Dim  idx As  Integer
            max = e.DataTable.Compute("Max(记账编号)","日期 >= #" & fd & "# And 日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该月的最大编号
            If  max > "" Then \'如果存在最大编号
                idx = CInt(max.Substring(10,3)) + 1  \'获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 \'否则顺序号等于1
            End  If
            e.DataRow("记账编号") = "RJZ" & bh & "-" & Format(idx,"000")
        End If
    End  If
End  If

--  作者:mirochain1980
--  发布时间:2017/9/4 17:07:00
--  

谢谢,明白了,加了三个字符