我的需求是:
1、产品类型和产品名称有一个为空时,级别为空
2、产品类型、产品名称和规格都不为空时,级别为“明细”
3、产品类型、产品名称不为空,并且在同表中有相同行时,级别为“大类”
4、产品类型、产品名称不为空,并且在同表中没有相同行时,级别为“小类”
下面代码如何调整?
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "产品类型","产品名称","规格"
' If e.NewValue IsNot Nothing Then
If dr.IsNull("产品类型") OrElse dr.IsNull("产品名称") Then
dr("级别") = Nothing
Else
If dr.IsNull("规格") = False Then
dr("级别") = "明细"
Else
Dim fdr As DataRow = e.DataTable.Find("产品名称 = '" & dr("产品名称") & "' And 产品类型 = '" & dr("产品类型") & "' And 规格 Is Null")
If fdr IsNot Nothing Then
fdr("级别") = "大类"
dr("级别") = "单个"
Else
dr("级别") = "单个"
End If
End If
'Dim fil As String
'Dim fdr1 As DataRow = e.DataTable.Find("产品名称 = '" & e.OldValue & "' or 产品类型 = '" & e.OldValue & "'") ' And 规格 Is Null")
Dim fdr1 As DataRow = e.DataTable.Find("产品类型 = '" & e.OldValue & "' or 产品名称 = '" & e.OldValue & "' And 规格 Is Null")
If fdr1 IsNot Nothing AndAlso e.DataTable.Compute("Count([_Identify])","产品类型 = '" & e.OldValue & "' or 产品名称 = '" & e.OldValue & "'") = 1 Then
fdr1("级别") = "单个"
End If
End If
' End If
End Select
[此贴子已经被作者于2018/9/2 20:49:36编辑过]