-- 分组内排序(分组内有重复的编号一致)
要求在饰品类别分组,按件数进行排序且件数相等,序号相同
以下代码执行后无法实现,求老师解答
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "饰品类别","件数"
If e.DataCol.Name = "饰品类别" Then
If e.DataRow.IsNull("饰品类别") Then
e.DataRow("序号") = Nothing
Else
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(序号)","饰品类别 = \'" & e.DataRow("饰品类别") & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大序号
If max > "" Then \'如果存在最大序号
If e.DataTable.Compute("Count([_Identify])","饰品类别 = \'" & dr("饰品类别") & "\' And 件数 = \'" & dr("件数") & "\'") > 1 Then
e.DataRow("序号") = Format(max,"00000")
Else
idx = CInt(max.Substring(0,5)) + 1 \'获得最大序号的后三位顺序号,并加1
End If
Else
idx = idx \'否则顺序号等于1
End If
e.DataRow("序号") = Format(idx,"00000")
End If
End If
End Select