请教工程师,您看下下面代码,生成的编号格式为:20111228-001
我需要在这个编号前加前缀,比如生成 YP20111228-001,编号统一以“YP”开头,请教代码该怎么写?
多谢多谢!!!!!
If e.DataCol.Name = "日期" Then
If e.DataRow.IsNull("日期") Then
e.DataRow("编号") = Nothing
Else
Dim bh As String = 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("日期") & "#")
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(9,3)) + 1
Else
idx = 1
End If
e.DataRow("编号") = bh & "-" & Format(idx,"000")
End If
End If
End If