-- 作者:青丘狐
-- 发布时间:2023/2/26 13:54:00
-- 怎样改代码定义到外部数据库
\'编号生成\' Public _BizCodeBuilder As BizCodeBuilder
\'不重复编号上传用,这里的用法比较简单,没有做复杂的编号规则处理\' Public Class BizCodeBuilder Private _bizcode As DataTable \'直接把编号表取出到内存\' Private _codelock As New Object Public Sub New(sjy As String) Dim cmd1 As New SQLCommand cmd1.C \' 外部数据库
cmd1.commandText = "Selec t * From {网络编号} " Dim sql = cmd1.commandText
\' Dim sql = "Selec t * From {网络编号} " \' 内部数据库
_bizcode = Functions.Execute("Cmd_GetDataTable", sjy, sql, True) End Sub Public Function GetNextCode(s_name As String,Optional s_prefix As String = Nothing) As String SyncLock _codelock \'使用锁处理并发 Dim dr As DataRow = _bizcode.Find(CExp("BizName=\'{0}\'", s_name)) If dr Is Nothing Then \'建议先在编号表中维护好需要产生编号的表,不用默认生成的编号规则\' dr = _bizcode.AddNew() dr("BizName") = s_name dr("MaxValue") = 1 If String.IsNullOrEmpty(s_prefix) Then s_prefix = Date.now.ToString("mmss") & "BH" dr("Prefix") = s_prefix dr("Mark") = "yyyyMMdd" dr("MarkValue") = Date.Today.ToString("yyyyMMdd") dr("Length") = 4 Else \'这里的处理规则是按时间进行重新编号,至于是按年,月还是日,在掩码中体现\' If dr("MarkValue") <> Date.Today.ToString(dr("Mark")) Then dr("MaxValue") = 1 dr("MarkValue") = Date.Today.ToString(dr("Mark")) Else dr("MaxValue") = dr("MaxValue") + 1 End If End If dr.Save() Return dr("Prefix") & dr("MarkValue") & "-" & Format(dr("MaxValue"),"0000") \'顺序号只取4位\' End SyncLock End Function End Class
请问怎样修改代码定义到外部数据库
[此贴子已经被作者于2023/2/26 13:55:34编辑过]
|