以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]前面4列一样,第五列自动一样  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=122748)

--  作者:湛江智
--  发布时间:2018/8/1 15:13:00
--  [求助]前面4列一样,第五列自动一样
 前面4列一样,第五列自动一样 下面代码怎么修改呢?
Select Case e.DataCol.Name
    Case "第一列","第二列","第三列","第四列","第五列"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("第一列") = False AndAlso dr.IsNull("第二列") =False AndAlso dr.IsNull("第三列") =False AndAlso dr.IsNull("第四列") =False Then
            If e.DataTable.Select("第一列 = \'" & dr("第一列") & "\' And 第二列 = \'" & dr("第二列") & "\' And 第三列 = \'" & dr("第三列") & "\' And  第四列 = \'" & dr("第四列") & "\'") .Count > 1 Then
                  dr("第五列") = e.DataRow("第五列")                
MessageBox.Show("前面4列一样,第五列自动一样了!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        End If
End Select
[此贴子已经被作者于2018/8/1 15:13:06编辑过]

--  作者:有点甜
--  发布时间:2018/8/1 15:16:00
--  

Select Case e.DataCol.Name
    Case "第一列","第二列","第三列","第四列","第五列"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("第一列") = False AndAlso dr.IsNull("第二列") =False AndAlso dr.IsNull("第三列") =False AndAlso dr.IsNull("第四列") =False Then
            Dim fdr = e.DataTable.find("第一列 = \'" & dr("第一列") & "\' And 第二列 = \'" & dr("第二列") & "\' And 第三列 = \'" & dr("第三列") & "\' And  第四列 = \'" & dr("第四列") & "\' and _Identify <> " & dr("_Identify"))
            If fdr IsNot Nothing Then
                dr("第五列") = fdr("第五列")
                MessageBox.Show("前面4列一样,第五列自动一样了!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        End If
End Select

--  作者:湛江智
--  发布时间:2018/8/1 16:02:00
--  回复:(有点甜)Select Case e.DataCol.Name?&n...
 如果修改1-4列不同了,第5列值自动为空,怎么修改呢?
Select Case e.DataCol.Name
    Case "第一列","第二列","第三列","第四列","第五列"
        Dim dr As DataRow = e.DataRow
        \'If dr.IsNull("第一列") = False AndAlso dr.IsNull("第二列") =False AndAlso dr.IsNull("第三列") =False AndAlso dr.IsNull("第四列") =False AndAlso dr.IsNull("第五列") =False  Then
        If dr.IsNull("第五列") =False  Then
            Dim fdr = e.DataTable.find("第一列 = \'" & dr("第一列") & "\' And 第二列 = \'" & dr("第二列") & "\' And 第三列 = \'" & dr("第三列") & "\' And  第四列 = \'" & dr("第四列") & "\' and _Identify <> " & dr("_Identify"))

                If dr("第一列") <> fdr("第一列") Or dr("第二列") <> fdr("第二列") Or dr("第三列") <> fdr("第三列") Or dr("第四列") <> fdr("第四列") Then
                dr("第五列") = " "

                MessageBox.Show("前面4列不一样,第五列<layer highlight="term-5" class="searchwp-term searchwp-highlight-searchwp-highlighting">删除</layer>字符后为空值!", "提示")
            End If      
        End If
End Select
[此贴子已经被作者于2018/8/1 16:02:12编辑过]

--  作者:有点甜
--  发布时间:2018/8/1 16:09:00
--  

Select Case e.DataCol.Name
    Case "第一列","第二列","第三列","第四列","第五列"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("第一列") = False AndAlso dr.IsNull("第二列") =False AndAlso dr.IsNull("第三列") =False AndAlso dr.IsNull("第四列") =False Then
            Dim fdr = e.DataTable.find("第一列 = \'" & dr("第一列") & "\' And 第二列 = \'" & dr("第二列") & "\' And 第三列 = \'" & dr("第三列") & "\' And  第四列 = \'" & dr("第四列") & "\' and _Identify <> " & dr("_Identify"))
            If fdr IsNot Nothing Then
                dr("第五列") = fdr("第五列")
                MessageBox.Show("前面4列一样,第五列自动一样了!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)

            else

                dr("第五列") = Nothing
            End If
        End If
End Select


--  作者:湛江智
--  发布时间:2018/8/1 17:03:00
--  回复:(有点甜)Select Case e.DataCol.Name &n...
 1、上面代码有点问题:
      输入前面4列后,第5列不能输入字符串
      提示窗口提示确认2次

2、四列重复的行都显示出来,下面代码怎修改呢?
Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列,第三列,第四列"
For Each dr As DataRow In DataTables("表A").Select("", "第一列,第二列,第三列,第四列")
  
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag OrElse pdr Is Nothing Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
  
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify in (" & idx.trim(",") & ")"


--  作者:有点甜
--  发布时间:2018/8/1 17:09:00
--  

Select Case e.DataCol.Name
    Case "第一列","第二列","第三列","第四列"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("第一列") = False AndAlso dr.IsNull("第二列") =False AndAlso dr.IsNull("第三列") =False AndAlso dr.IsNull("第四列") =False Then
            Dim fdr = e.DataTable.find("第一列 = \'" & dr("第一列") & "\' And 第二列 = \'" & dr("第二列") & "\' And 第三列 = \'" & dr("第三列") & "\' And  第四列 = \'" & dr("第四列") & "\' and _Identify <> " & dr("_Identify"))
            If fdr IsNot Nothing Then
                dr("第五列") = fdr("第五列")
                MessageBox.Show("前面4列一样,第五列自动一样了!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)

            else

                dr("第五列") = Nothing
            End If
        End If
End Select


--  作者:有点甜
--  发布时间:2018/8/1 17:10:00
--  

2、筛选代码没问题,就是这样改。


--  作者:湛江智
--  发布时间:2018/8/1 17:18:00
--  回复:(有点甜)2、筛选代码没问题,就是这样改。
 上面的代码筛选结果是:1-4列重复的多行,只显示1行
想实现筛选结果是:要显示1-4列重复的所有行
代码怎么修改呢?
[此贴子已经被作者于2018/8/1 17:26:39编辑过]

--  作者:有点甜
--  发布时间:2018/8/1 17:43:00
--  

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列,第三列,第四列"
Dim t As Table = Tables("表A")
For Each dr As DataRow In t.DataTable.Select("", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
        idx_temp &= dr("_Identify") & ","
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

t.filter = "_Identify in (" & idx.trim(",") & ")"


--  作者:湛江智
--  发布时间:2018/8/1 18:24:00
--  回复:(有点甜)Dim idx As String = "-1,"Dim idx_t...
标设置标注列后,还报错,什么原因呢?
 列“_Identify”不属于表 物料表。