-- 作者:18310172639
-- 发布时间:2021/1/31 14:21:00
-- 求助:自动编号生成的连接符号有长有短
此主题相关图片如下:自动编号生成的连接符有长有短.png
 老师:我用自动编号代码生成的出库单编号,若是同一天的出库单编号,最后面的连接符有长有短,应该怎么改正代码?
代码如下:
Select e.DataCol.Name Case "出库日期","任务类型" If e.DataRow.IsNull("出库日期") OrElse e.DataRow.IsNull("任务类型") Then e.DataRow("出库单编号") = Nothing Else Dim d As Date = e.DataRow("出库日期") Dim y As Integer = d.Year Dim m As Integer = d.Month Dim bh As String = e.DataRow("任务类型") & "-" & Format(e.DataRow("出库日期"),"yyyyMMdd") & "-" \'生成编号的前缀 If e.DataRow("出库单编号").StartsWith(bh) = False \'如果单据编号前缀不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(出库单编号)","出库日期 = #" & e.DataRow("出库日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) If max > "" Then \'如果存在最大单据编号 idx = CInt(max.Substring(12,2)) + 1 \'获得最大单据编号的后2位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("出库单编号") = bh & Format(idx,"00") End If End If End Select
|