以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  自动编号  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=78475)

--  作者:xujie80
--  发布时间:2015/12/9 21:22:00
--  自动编号
我有一报价系统,每张报价单是一个单独表,办事处、姓名、日期、单号都是统一的,如何根据办事处、姓名、日期、当天的报价次数生成报单号?如长沙办的业务员王一20151209次报价是CSB-WY-20151209-001,第次报价是CSB-WY-20151209-002?
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:报价.rar


--  作者:大红袍
--  发布时间:2015/12/9 21:24:00
--  

参考

 

http://www.foxtable.com/help/topics/2403.htm

 


--  作者:大红袍
--  发布时间:2015/12/9 21:34:00
--  
Select e.DataCol.Name
    Case "办事处","姓名","日期"
        If e.DataRow.IsNull("姓名") OrElse e.DataRow.IsNull("办事处") OrElse e.DataRow.Isnull("日期") Then
            e.DataRow("报单号") = Nothing
        Else
            Dim d As Date = e.DataRow("日期")
            Dim bh As String = GetPy(e.DataRow("办事处"),True).ToUpper & "-" & GetPy(e.DataRow("姓名"),True).ToUpper & Format(d,"yyyyMMdd") & "-" \'生成报单号的前缀
            If e.DataRow("报单号").StartsWith(bh) = False \'如果单据报单号前缀不符
                Dim max As String
                Dim idx As Integer
                Dim flt As String
                flt = "办事处 = \'"& e.DataRow("办事处") & "\' and 姓名 = \'" & e.DataRow("姓名") & "\' And 日期 >= #" & d & "# And 日期 < #" & d.AddDays(1) & "# And [_Identify] <> " & e.DataRow("_Identify")
                max = e.DataTable.Compute("Max(报单号)",flt) \'取得该月的相同工程代码的最大单据报单号
                If max > "" Then \'如果存在最大单据报单号
                    idx = CInt(max.Substring(bh.length)) + 1 \'获得最大单据报单号的后四位顺序号,并加1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("报单号") = bh & Format(idx,"000")
            End If
        End If
End Select