asp.net(c#)中如何在前端用js写条件查询,且不用调用存储过程

前端页面(源):

<dx:ASPxButton ID="ASPxButton_Select" runat="server" Text="查询" AutoPostBack="false">
<ClientSideEvents Click="bt_select" />
</dx:ASPxButton>

 

js部分:

        function bt_select() {

            //alert(cb_goodstype.GetValue());

            updateGrid();

        };

       

        function updateGrid() {

            var filterCondition = " 1=1 ";

            //业务员

            if (cb_buyuser.GetSelectedIndex() != -1)

                filterCondition += " and ([sureuser] = '" + cb_buyuser.GetValue() + "') ";

            //供应商名称

            if (cb_supplers.GetSelectedIndex() != -1)

                filterCondition += " and ([peoid]= '" + cb_supplers.GetValue() + "') ";

            //是否审核

            if (cb_audflag.GetSelectedIndex() != -1)

                filterCondition += " and ([AUDFLAG] = '" + cb_audflag.GetValue() + "') ";

            // alert(filterCondition);

            //是否付款

            if (cb_iscollflag.GetSelectedIndex() != -1)

                filterCondition += " and ([ISCOLLFLAG] = '" + cb_iscollflag.GetValue() + "') ";

            //制订日期

            var myDate = new Date();

            var theDate = myDate.toLocaleDateString();  //获取今天的日期

            //获取控件选择的日期并进行转换

            var s = ASPxDateEdit1.GetValue();

            var y = new Date(s).getFullYear();

            var m = new Date(s).getMonth() + 1;

            // m = m < 10 ? ('0' + m) : m;

            var d = new Date(s).getDate();

           // d = d < 10 ? ('0' + d) : d;

            var h = new Date(s).getHours();

            var minute = new Date(s).getMinutes();

            // minute = minute < 10 ? ('0' + minute) : minute;

            var dt = y + '/' + m + '/' + d + ' ' + h + ':' + minute;

            if (ASPxDateEdit1.GetValue())

                //filterCondition += " and [PAYDATE] >='" + dt + "' and [PAYDATE]<='" + theDate + "'";

                filterCondition += " and [PAYDATE] >= # " + dt + "# and [PAYDATE]<= #" + theDate + "#";

            //alert(filterCondition);

            ASPxGridView1.ApplyFilter(filterCondition);  //采购商品

            ASPxGridView2.ApplyFilter(filterCondition); //采购服务及费用

        };

   注:以上查询只适用于ASPxGridView中的数据条件查询,其他则不知。

posted @ 2015-12-27 15:00  小鹿的无名书  阅读(320)  评论(0编辑  收藏  举报