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) & format(cint(max.SubString(lb.length))+1, "00000")
Else
e.DataRow("商品ID") = GetPy(lb, True) & format(1, "00000")
If e.DataRow("商品ID").StartsWith(lb) = False \'如果单据编号前缀不符
End If
End If
End If
End Select