'产品码
Select e.DataCol.Name
Case "合同编号"
If e.DataRow.IsNull("合同编号") Then '如果合同编号为空,则产品码为空
e.DataRow("产品码") = Nothing
Else
Dim lb As String = e.DataRow("合同编号") & "-" '产产品码前缀
If e.DataRow("产品码").StartsWith(lb) = False Then '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "合同编号 = '" & lb & "' And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(产品码)", flt) '取得该类别的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(11, 2)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("产品码") = lb & Format(idx, "00")
End If
End If
End Select
当合同编号是:2022000027出现2次的时候,为什么产品码都是2022000027-01 ?上面代码哪里不对么