老师,帮我看看哪里需要改一下,现在是不加1.所有编号都是001
Select e.DataCol.Name
Case "商品类别"
If e.DataRow.IsNull("商品类别") Then
e.DataRow("商品编号").save
Else
Dim lb As String
If e.DataRow("商品类别") = "成品" Then
lb = "CP-"
ElseIf e.DataRow("商品类别") = "半成品"
lb = "BCP-"
ElseIf e.DataRow("商品类别") = "原材料"
lb = "YCL-"
ElseIf e.DataRow("商品类别") = "配件"
lb = "PJ-"
End If
If e.DataRow("商品编号").StartsWith(lb) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(商品编号)","商品类别 = '" & lb & "' 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("商品编号") = lb & Format(idx,"000")
End If
End If
End Select