--
Select e.DataCol.Name
Case "级码"
If e.DataRow.IsNull("级码") OrElse e.DataRow.IsNull("编号")=False Then
Else
Dim lb As String = e.DataRow("级码")
Dim max As String
Dim idx As Integer
If lb.contains(".") = False Then
max = e.DataTable.Compute("Max(编号)","len(编号) = 7 And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号
If max > "" Then \'如果存在最大编号
idx = CInt(max.Substring(max.Length - 3)) + 1 \'获得最大编号的后三位顺序号,并加1
Else
idx = 1 \'否则顺序号等于1
End If
e.DataRow("编号") = Date.Today.year & Format(idx,"000")
Else
Dim sr() As String = lb.split(".")
sr(sr.Length - 1) = ""
lb = String.join(".",sr).trim()
Dim len As Integer = 4 + sr.Length * 3
max = e.DataTable.Compute("Max(编号)","len(编号) = " & len & " And 级码 like \'" & lb & "%\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号
If max > "" Then \'如果存在最大编号
lb = max.Substring(0,max.Length - 3)
idx = CInt(max.Substring(max.Length - 3)) + 1 \'获得最大编号的后三位顺序号,并加1
Else
idx = 1 \'否则顺序号等于1
lb = Date.Today.year
For i As Integer = 0 To sr.Length - 2
lb = lb & sr(i).PadLeft(3,"0")
Next
End If
e.DataRow("编号") = lb & Format(idx,"000")
End If
End If
End Select