Select e.DataCol.Name Case "群组分类","客户供应商","企业税号" If e.DataRow.IsNull("群组分类") OrElse e.DataRow.Isnull("客户供应商") OrElse e.DataRow.Isnull("企业税号") Then e.DataRow("客户ID") = Nothing Else Dim xz As String = getpy(e.DataRow("群组分类"), True).toupper().PadRight(4,"A") Dim gys As String = e.DataRow("客户供应商").toupper() If gys.Length > 3 Then gys = gys.Substring(0,4) Dim sh As String = e.DataRow("企业税号") If sh.Length > 3 Then sh = sh.SubString(sh.Length - 4) Dim lb As String = xz & "-" & getpinyin(gys,1).Toupper & "-" & sh & "-" Dim max As String = e.DataTable.Compute("Max(客户ID)","群组分类 = '" & e.DataRow("群组分类") & "' And _Identify <> " & e.DataRow("_Identify") ) '取得该类别的最大编号 Dim idx = 1 If max > "" Then idx = cint(max.SubString(lb.length))+1 End If e.DataRow("客户ID") = lb & format(idx, "000") End If End Select
|