以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求助  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=98236)

--  作者:jackyfashion
--  发布时间:2017/3/27 0:20:00
--  求助
您好!大师:
这是表的筛选代码,请您帮我帮我优化.谢谢!!!
e.Form.StopRedraw
Dim Filter As String
With e.Form.Controls("款号")
    If .Value IsNot Nothing Then
        Filter = "vdmh = 1 and ffikgn = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("xqsufjya")
    If .Value IsNot Nothing Then
        Filter = "vdmh = 1 and xqsufjya = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("设计师")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "vdmh = 1 and ymyfjgm = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "vdmhjjad >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "vdmhjjad <= \'" & .Value & "\'"
    End If
End With
If e.Form.Controls("已审核").Checked = True   \' 如果付款状态选择了"已付"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "pjsy = 1"
End If
If e.Form.Controls("未审核").Checked = True \'
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "vdmh = 1 and pjsy = 0"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("fixqsu").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If   
    Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] <> (\'纸样已完成\')"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("nnxqsu").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] = (\'纸样已完成\')"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("filgsr").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If   
    Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] <> (\'车板已完成\')"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("nnlgsr").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] = (\'车板已完成\')"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("thnn").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "pjsy = 0 and xqsujgm = \'" & User.Name & "\'"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("g").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "vdmhjjad = \'" & Date.Today & "\'"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("f").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Dim dt As Date = Date.Today.AddDays(-3)
    Filter = Filter & "vdmhjjad > \'" & dt & "\'"
    If Filter > "" Then
    End If
End If
If e.Form.Controls("d").Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Dim dt As Date = Date.Today.AddDays(-7)
    Filter = Filter & "vdmhjjad > \'" & dt & "\'"
    If Filter > "" Then
    End If
End If
Tables("qrymyf").Filter = Filter
DataTables("qrymyf").LoadFilter = Filter
DataTables("qrymyf").Load()
谢谢!

--  作者:有点色
--  发布时间:2017/3/27 1:06:00
--  
你的逻辑是这样,这个是无法优化的了。
--  作者:jackyfashion
--  发布时间:2017/3/27 23:28:00
--  
谢谢!