以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  table 定位行的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=91286)

--  作者:yancheng
--  发布时间:2016/10/6 19:58:00
--  table 定位行的问题
导入材料明细,表事件,CurrentChanged中写入:

If Forms("导入材料").Opened AndAlso Forms.ActiveForm.Name = "导入材料"  Then
    Dim dr As Row = Tables("导入材料.导入材料明细").Current
    If dr IsNot Nothing AndAlso dr.IsNull("定额编码")=False Then
        Dim i As Integer= Tables("材料").FindRow("定额编码 = \'" & dr("定额编码") & "\'")
        If i >= 0 Then
            SystemReady = False
            \'Tables("材料").Filter = ""
            Tables("材料").Position = i
            SystemReady = True
        End If
    End If
End If

现在的问题是,table 材料,表,并列窗口中,已经进行了筛选.
我发现在上面的代码不执行。或者说是:找不到,这个:定额编码了。

刚才开始想我在代码里面,把: \'Tables("材料").Filter = ""  , 这一句用上,但是也不起作用。且我在改变:导入材料明细,当前行时,运行变慢,改变一行,要1秒左右。好慢。

我需要怎么处理上面的代码呢?
[此贴子已经被作者于2016/10/6 19:59:31编辑过]

--  作者:有点蓝
--  发布时间:2016/10/7 8:55:00
--  
If Forms("导入材料").Opened AndAlso Forms.ActiveForm.Name = "导入材料"  Then
    Dim dr As Row = Tables("导入材料.导入材料明细").Current
    If dr IsNot Nothing AndAlso dr.IsNull("定额编码")=False Then
        Tables("材料").Filter = Tables("材料").Filter & " or 定额编码 = \'" & dr("定额编码") & "\'"
        Dim i As Integer= Tables("材料").FindRow("定额编码 = \'" & dr("定额编码") & "\'")
        If i >= 0 Then
            SystemReady = False
            Tables("材料").Position = i
            SystemReady = True
        End If
    End If
End If

--  作者:yancheng
--  发布时间:2016/10/7 11:33:00
--  
.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2016.7.29.1
错误所在事件:
详细错误信息:
语法错误:“Or”运算符前缺少操作数。

  Tables("材料").Filter = Tables("材料").Filter & " or 定额编码 = \'" & dr("定额编码") & "\'"
这个代码是什么意思 ?

我现在的问题是, 当table 材料表,进行了filter后,  导入材料明细表,的当前行事件,不能找到这个:定额编码,材料行。无法定位。
[此贴子已经被作者于2016/10/7 11:38:04编辑过]

--  作者:有点蓝
--  发布时间:2016/10/7 11:49:00
--  
If Forms("导入材料").Opened AndAlso Forms.ActiveForm.Name = "导入材料"  Then
    Dim dr As Row = Tables("导入材料.导入材料明细").Current
    If dr IsNot Nothing AndAlso dr.IsNull("定额编码")=False Then
        Dim filter As String = "定额编码 = \'" & dr("定额编码") & "\'"
        Dim dr2 As DataRow = DataTables("材料").Find(filter)
        If dr2 Is Nothing Then
            Dim drs As List(of DataRow) = DataTables("材料").AppendLoad(filter, False)
            If drs.Count > 0 Then
                dr2 = drs(0)
            Else
                msgbox("不存在这个定额编码")
                Return
            End If
        End If
        If Tables("材料").Filter > 0 Then
            Tables("材料").Filter = Tables("材料").Filter & " or 定额编码 = \'" & dr("定额编码") & "\'"
        End If
        Dim i As Integer= Tables("材料").FindRow(dr2)
        If i >= 0 Then
            SystemReady = False
            Tables("材料").Position = i
            SystemReady = True
        End If
    End If
End If

再不行就上例子测试

--  作者:yancheng
--  发布时间:2016/10/7 13:17:00
--  
弹错。


\'从字符串" Or 定额编码 = \'010043\' or 定额编码 = \'0"到类型"Double"的转换无效.
\'输入字符串的格式不正确.
\'

      If Tables("材料").Filter > 0 Then
            Tables("材料").Filter = Tables("材料").Filter & " or 定额编码 = \'" & dr("定额编码") & "\'"

 这个两段代码,怎么理解 ?
[此贴子已经被作者于2016/10/7 13:46:28编辑过]

--  作者:yancheng
--  发布时间:2016/10/7 13:54:00
--  
If Forms("导入材料").Opened AndAlso Forms.ActiveForm.Name = "导入材料"  Then
    Tables("材料").Filter = ""
    Dim dr As Row = Tables("导入材料.导入材料明细").Current
    If dr IsNot Nothing AndAlso dr.IsNull("定额编码")=False Then
        Dim i As Integer= Tables("材料").FindRow("定额编码 = \'" & dr("定额编码") & "\'")
        If i >= 0 Then
            SystemReady = False
            Tables("材料").Position = i
            SystemReady = True
        End If
    End If
End If

上面的代码,能满足我的需要。

只是上面的代码,在每一次:导入材料明细,表的当前行切换时,都 会把TABLE材料表,FILTER一遍。
这样,切换,导入材料明细表,当前行时,反应时间较长:1秒左右,影响,使用速度。
需要怎么改一下,这段代码呢?

我想的是,有没有一个代码。判断,TBALE表,是否作了:筛选。判断它?
[此贴子已经被作者于2016/10/7 13:54:47编辑过]

--  作者:有点蓝
--  发布时间:2016/10/7 14:21:00
--  
If Tables("材料").Filter > 0 Then

改为

If Tables("材料").Filter > ""  Then \'可以用这个判断是否有筛选条件

--  作者:yancheng
--  发布时间:2016/10/7 17:14:00
--  
OK 了。
If Tables("材料").Filter > ""  Then \'可以用这个判断是否有筛选条件
这个判断加上,可以的。


Tables("材料").Filter = Tables("材料").Filter & " or 定额编码 = \'" & dr("定额编码") & "\'"

我始终没有看懂这个代码,是怎么个意思 ?这个代码没错吗?

--  作者:有点蓝
--  发布时间:2016/10/7 17:18:00
--  
如果Filter不包含这个定额编码,就包含进来,这样就可以把指定的定额编码筛选出来