以下是引用风声在2014-6-11 15:36:00的发言:
Select Case e.DataCol.Name
Case "入库单编号"
End Select
If e.DataRow.IsNull("入库单编号") Then
e.DataRow("入库单编号明细") = Nothing
Else
Dim bh As String = e.DataRow("入库单编号")
If e.DataRow("入库单编号明细").StartsWith(bh) = False '如果入库单编号明细前缀不符
Dim max As String
Dim idx As Integer
Dim count As Integer = e.DataTable.Compute("Count(_Identify)","入库单编号 = '" & bh & "' And [_Identify] <> " & e.DataRow("_Identify"))
If count > 0 Then
max = e.DataTable.Compute("Max(入库单编号明细)","入库单编号 = '" & bh & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该类别的最大入库单编号
If max > "" Then '如果存在最大入库单编号
Dim l As Integer = bh.Length
idx = CInt(max.Substring(l,3)) + 1 '获得最大入库单编号的后两位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("入库单编号明细") = bh & Format(idx,"000")
End If
End If
End If
此主题相关图片如下:编号明细.png

入库单编号明细列的第一行没有自动添加编号
兄弟,你的Select Case 的语句有点奇怪,早早的End 了,是否应该放到下面来。