以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 多列判断 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=124229) |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/9/2 19:00:00 -- 多列判断 我的需求是: 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编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2018/9/2 19:57:00 --
|
||||
-- 作者:ZJZK2018 -- 发布时间:2018/9/2 20:42:00 -- 还是有点问题: 1、我一重置后红色部分变成“小类”了,应为“大类” 2、当修改表的“产品类型”和“产品名称”时,如果当前表相同值只有一行时,大类返回为小类 [此贴子已经被作者于2018/9/2 20:49:06编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2018/9/2 21:02:00 -- 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 count = e.DataTable.compute("count(产品名称)", "产品名称 = \'" & dr("产品名称") & "\' And 产品类型 = \'" & dr("产品类型") & "\' And 规格 Is Null") If count >= 1 Then dr("级别") = "大类" Else dr("级别") = "小类" End If End If End If End Select |