asp.net(c#)中如何在前端用js寫條件查詢,且不用調用預存程序

來源:互聯網
上載者:User

標籤:

前端頁面(源):

<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中的資料條件查詢,其他則不知。

asp.net(c#)中如何在前端用js寫條件查詢,且不用調用預存程序

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.