Dim bh As String = Format(e.DataRow("日期"),"QCyyyyMMdd-") '取得出库编号的8位前缀
If e.DataRow("出库编号").StartsWith(bh) = False '如果出库编号的前8位不符
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(bh.Length - 3,3)) + 1 '获得最大出库编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("出库编号") = bh & Format(idx,"000")
End If
如果不需要日期,放到daterowadding
Dim bh As String = Format(e.DataRow("日期"),"QCyyyyMMdd-")
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(出库编号)","出库编号 like '" & bh & "%'") '查询此前缀的不好的最大值
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(bh.Length - 3,3)) + 1
Else
idx = 1
End If
e.DataRow("出库编号") = bh & Format(idx,"000")