以文本方式查看主题

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

--  作者:xusuyang
--  发布时间:2018/10/17 20:06:00
--  编码?
 

老师:您好!

我设计了一个表格:第一列“订货日期”,第二列“日期序码”,第三列“出库单序码”,第四列“客户编码”,第五列“产品名称”。 

请问如何实现 第三列出库单序码分别为20181016-装饰公司-00120181016-装饰公司-00120181016-装饰公司-00120181016-广东公司-00220181016-广东公司-00220181016-广东公司-00220181016-天津公司-00320181016-天津公司-003,20181016-天津公司-003。谢谢!!!

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:yyxx公司.foxdb

[此贴子已经被作者于2018/10/17 20:50:51编辑过]

--  作者:xusuyang
--  发布时间:2018/10/17 20:49:00
--  
老师???
--  作者:有点甜
--  发布时间:2018/10/17 21:01:00
--  
Select Case e.DataCol.name
    Case "日期", "客户编码"
        If e.DataRow("日期") = Nothing OrElse e.DataRow("客户编码") = Nothing Then
            e.DataRow("出库单序码") = Nothing
        Else
            Dim fdr As DataRow = e.DataTable.find("日期 = #" & e.DataRow("日期") & "# and 客户编码 =\'" & e.DataRow("客户编码") & "\' and 出库单序码 Is not null")
            If fdr IsNot Nothing Then
                e.DataRow("出库单序码") = fdr("出库单序码")
            Else
                Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") & "-" & e.DataRow("客户编码") & "-" \'取得编号的8位前缀
                If e.DataRow("出库单序码").StartsWith(bh) = False \'如果编号的前8位不符
                    Dim max As String
                    Dim idx As Integer = 0
                    For Each dr As DataRow In e.DataTable.Select("出库单序码 is not null and 日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify"))
                        If right(dr("出库单序码"), 3) > idx Then
                            idx = right(dr("出库单序码"), 3)
                        End If
                    Next
                    idx += 1
                    e.DataRow("出库单序码") = bh & Format(idx,"000")
                End If
            End If
        End If
End Select