標籤:
前端頁面(源):
<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寫條件查詢,且不用調用預存程序