数据筛选显示

本节的任务使设计一个筛选页面,输入输入条件,单击确定后,能从后台筛选出符合条件的行显示:

HttpRequest事件代码:

Dim wb As New WeUI
Select
Case e.Path
    Case "filter.htm"
        wb.AddForm("","form1","list.htm")
        With wb.AddInputGroup("form1","ipg1","
数据筛选")
            .AddSelect("product","
产品","PD01|PD02|PD03|PD04|PD05")
            .AddInput("startdate","
开始日期","date")
            .AddInput("enddate","
结束时间","date")
        End With
        With wb.AddButtonGroup("form1","btg1",True)
            .Add("btn1", "
确定", "submit")
        End With
    Case "list.htm"
        Dim flt As String
        If e.PostValues.ContainsKey("product") Then
            flt = "
产品 = '" & e.PostValues("product") & "'"
        End If
        If e.PostValues.ContainsKey("startdate") Then
            If flt > "" Then
                flt = flt & " and "
            End If
            flt = flt & "
日期 >= '" & e.PostValues("startdate") & "'"
        End If
        If e.PostValues.ContainsKey("enddate") Then
            If flt > "" Then
                flt = flt & " and "
            End If
            flt = flt & "
日期 <= '" & e.PostValues("enddate") & "'"
        End If
        Dim cmd As new SQLCommand
        cmd.ConnectionName = "orders"
        cmd.CommandText= "select
产品,客户,数量,单价,[日期] From 订单"
        If flt > "" Then
            cmd.CommandText = cmd.CommandText & " where " & flt
        End If
        With wb.AddTable("","Table1")
            .CreateFromDataTable(cmd.ExecuteReader)
        End With
        With wb.AddButtonGroup("","btg1",True)
           
.Add("btn1", "重新筛选", "","filter.htm")
        End With

End
Select
e
.WriteString(wb.Build)


本页地址:http://www.foxtable.com/mobilehelp/topics/0115.htm