以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  采购申请号规则  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=137066)

--  作者:有点甜
--  发布时间:2019/6/27 14:45:00
--  


If e.DataCol.Name = "申请日期"  Then
    If e.DataRow.IsNull("申请日期")  Then
        e.DataRow("采购申请号") = Nothing
    Else
        e.DataRow.save
        Dim bh As String  =  Format(e.DataRow("申请日期"),"yyMMdd")  \' 取得编号的8位前缀
        If e.DataRow("申请类别") = "辅料采购" Then
            bh = "CGSQ" & bh
        Else
            bh = "PJCG" & bh
        End If
        If e.DataRow("采购申请号").StartsWith(bh) = False \'如果编号的前8位不符
            Dim dt2 As DataTable = DataTables("采购申请明细")
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.SQLCompute("Max(采购申请号)","采购申请号 like \'" & bh & "%\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大编号
            If max > "" Then \'如果存在最大编号
                idx = CInt(max.Substring(bh.length,3)) + 1 \'获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 \'否则顺序号等于1
            End If
            e.DataRow("采购申请号") = bh  & Format(idx,"000")
            e.DataRow.save
        End If
    End If
End If

 


--  作者:有点蓝
--  发布时间:2019/8/5 8:51:00
--  
idx = CInt(max.Substring(bg.Length)) + 1