Select e.DataCol.Name
Case "地级市"
If e.DataRow.IsNull("地级市") Then
e.DataRow("客户ID") = Nothing
ElseIf e.DataRow.Isnull("客户ID") Then
Dim lb As String = e.DataRow("地级市")
Dim max As String = e.DataTable.Compute("Max(客户ID)","地级市 = \'" & lb & "\' And _Identify<> \'" & e.DataRow("_Identify") & "\'") \'取得该类别的最大编号
If max > "" Then
e.DataRow("客户ID") = GetPy(lb, True).SubString(0, 1) & format(cint(max.SubString(1))+1, "000")
Else
e.DataRow("客户ID") = GetPy(lb, True).SubString(0, 1) & format(1, "000")
If e.DataRow("客户ID").StartsWith(lb) = False \'如果单据编号前缀不符
End If
End If
End If
End Select