'序列号
Dim tb As String = args(0) '表名称
Dim lb As String = args(1) '类别
Dim ws As Integer = 0 '位数
Dim rq As String = Format(Date.Today,"yyyyMMdd")
Dim xlh As String '序列号
Dim cmd As New SQLCommand
Dim sql As String =""
Dim dt As DataTable
cmd.ConnectionName = "chiplinksys"
sql="select top 1 * fr om " & tb & " where isdeleted = 0 order by _identify desc"
cmd.CommandText = sql
dt = cmd.ExecuteReader()
Dim rtval As String =""
If dt.DataRows.Count > 0 Then
xlh = dt.DataRows(0)("订单编号")
If rq = xlh.SubString(lb.length, 8)
ws = lb.Length + 8
xlh = xlh.SubString(ws)
rtval = lb & rq & format(CInt(xlh) + 1, "0000")
Else
rtval = lb & rq & "0001"
End If
Else
rtval = lb & rq & "0001"
End If
Return rtval