以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  代码优化  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=70002)

--  作者:qingwuzu
--  发布时间:2015/6/14 14:47:00
--  代码优化

此主题相关图片如下:111.png
按此在新窗口浏览图片

此主题相关图片如下:222.png
按此在新窗口浏览图片
这个条件加载的思路是怎么样做的
Dim kh As String = e.Form.Controls("ComboBox1").Value
Dim hp As String = e.Form.Controls("ComboBox2").Value
Dim ywy As String = e.Form.Controls("ComboBox3").Value
Dim b As New SQLJoinTableBuilder("查询表1","O_Sale1Detail")
b.C
b.AddTable("O_Sale1Detail","GoodsId","B_Goods","GoodsId") \'添加统计表
b.AddTable("O_Sale1Detail","BillNo","O_Sale1","BillNo") \'添加统计表
b.AddTable("B_Goods","TypeCode","B_GoodsType","Code") \'添加统计表
b.AddTable("O_Sale1","ClientID","B_Client","ClientId")
b.AddTable("O_Sale1","ExeManID","B_Employ","EmployID")
b.AddExp("单据编号","{O_Sale1Detail}.BillNo")
b.AddExp("客户代码","{B_Client}.Code")
b.AddExp("客户名称","{B_Client}.Name")
b.AddExp("货品代码","{B_Goods}.Code")
If kh IsNot Nothing And hp IsNot Nothing And ywy IsNot Nothing Then
    b.filter = "{B_Employ}.Name = \'" & ywy & "\' and {B_Client}.Name = \'" & kh & "\' and {O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \' and {B_Goods}.Name = \'" & hp & "\' "
Else
    If kh IsNot Nothing And ywy IsNot Nothing Then
        b.filter = "{B_Employ}.Name = \'" & ywy & "\' and {B_Client}.Name = \'" & kh & "\' and {O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \' "
    Else
        If ywy IsNot Nothing And hp IsNot Nothing Then
            b.filter = "{B_Employ}.Name = \'" & ywy & "\' and {O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \' and {B_Goods}.Name = \'" & hp & "\' "
        Else
            If kh IsNot Nothing And hp IsNot Nothing Then
                b.filter = "{B_Client}.Name = \'" & kh & "\' and {O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \' and {B_Goods}.Name = \'" & hp & "\' "
            Else
                If ywy IsNot Nothing Then
                    b.filter = "{B_Employ}.Name = \'" & ywy & "\' and {O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \'"
                Else
                    If hp IsNot Nothing Then
                        b.filter = "{B_Goods}.Name = \'" & hp & "\' and {O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \'"
                    Else
                        If kh IsNot Nothing Then
                            b.filter = "{B_Client}.Name = \'" & kh & "\' and {O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \'"
                        Else
                            b.Filter = "{O_Sale1}.BillDate >= \'" & A & "\' And {O_Sale1}.BillDate <= \'" & C & " \' "
                        End If
                    End If
                End If
            End If
        End If
    End If
End If
这个代码怎么优化
[此贴子已经被作者于2015/6/14 14:48:11编辑过]

--  作者:大红袍
--  发布时间:2015/6/14 15:58:00
--  

 参考这里

 

http://www.foxtable.com/help/topics/1058.htm

 


--  作者:qingwuzu
--  发布时间:2015/6/14 16:31:00
--  
图片点击可在新窗口打开查看
--  作者:大红袍
--  发布时间:2015/6/14 17:00:00
--  
http://www.foxtable.com/help/topics/1058.htm