以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]自动生成编号 为什么会出现这个错误  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=17726)

--  作者:jolon
--  发布时间:2012/3/22 14:00:00
--  [求助]自动生成编号 为什么会出现这个错误
If e.DataCol.Name = "入库日期" Then
    If e.DataRow.IsNull("入库日期") Then
        e.DataRow("票号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("入库日期"),"yyMMdd") \'取得编号的8位前缀
        If e.DataRow("票号").StartsWith(bh) = False \'如果编号的前8位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(票号)","入库日期 = #" & e.DataRow("入库日期") & "#") \'取得该天的最大编号
            If max > "" Then \'如果存在最大编号
                idx = CInt(max.Substring(9,3)) + 1 \'获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 \'否则顺序号等于1
            End If
            e.DataRow("票号") = "RK" & bh & Format(idx,"000")
        End If
    End If
End If

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:申磊库存设计.table


图片点击可在新窗口打开查看此主题相关图片如下:1.jpg
图片点击可在新窗口打开查看


--  作者:狐狸爸爸
--  发布时间:2012/3/22 14:35:00
--  
If e.DataCol.Name = "入库日期" Then
    If e.DataRow.IsNull("入库日期") Then
        e.DataRow("票号") = Nothing
    Else
        Dim bh As String = "RK" & Format(e.DataRow("入库日期"),"yyMMdd") \'取得编号的8位前缀
        If e.DataRow("票号").StartsWith(bh) = False \'如果编号的前8位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(票号)","入库日期 = #" & e.DataRow("入库日期") & "#") \'取得该天的最大编号
            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 If