这是一个自定义函数,用同步和异步出现的结果不一样,不解?
此主题相关图片如下:jietu2021.png
'编号自动生成 用在最后地方
Dim d As Date = Functions.Execute("服务器时间").now
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim Days As Integer = d.DaysInMonth(y,m)
Dim fd As Date = New Date(y,m,1) '获得该月的第一天
Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天
Dim max As String
Dim bh As String = Format(d,"yyyyMM") '生成编号的前6位,4位年,2位月.
Dim fxbh As String=Args(0)
Dim idx As Integer
Dim cmd As new sqlcommand
cmd.Conne cti
cmd.CommandText="Sel-ect Max(缴费编号) from {报名缴费} where 分校编号 = '" & fxbh & "' and 缴费日期 >= '" & fd & "' And 缴费日期 <= '" & ld & "'"
max = cmd.ExecuteScalar
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(11,4)) + 1 '从第七位开始,向查四位,获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
max=bh & "-" & fxbh & format(idx,"0000")
Dim drr As DataRow =DataTables("报名缴费").SQLFind("缴费编号='" & max & "'")
If drr Is Nothing Then
Return max
Else
Return Nothing
End If
'编号自动生成完毕
[此贴子已经被作者于2021/1/21 8:32:44编辑过]