以文本方式查看主题

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

--  作者:xusuyang
--  发布时间:2018/10/17 18:57:00
--  编码请教

老师:您好!

我设计了一个表格:第一列“订货日期”,第二列“订货日期序码”,第三列“出库单序码”,第四列“客户编码”,第五列“产品名称”。假设我同一天在第一列“订货日期”输入多次相同的日期,如:2018-10-16,2018-10-16,2018-10-16,2018-10-16,2018-10-16,2018-10-16;而第二列“订货日期序码”显示为:20181016-001,20181016-002,20181016-003,20181016-004,20181016-005,20181016-006;在第四列“客户编码”输入:装饰公司,装饰公司,广东公司,广东公司,天津公司,天津公司;在第五列“产品名称”依次输入:钢笔,铅笔;语文,数学;毛笔,墨水。请问如何实现 第三列“出库单序码”分别为:20181016-装饰公司-001,20181016-装饰公司-001,20181016-广东公司-002,20181016-广东公司-002,20181016-天津公司-003,20181016-天津公司-003。谢谢!!!


--  作者:有点甜
--  发布时间:2018/10/17 19:15:00
--  

参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=120973&skin=0

 

不会做请上传具体实例

 

 


--  作者:有点甜
--  发布时间:2018/10/17 21:00: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