简体   繁体   中英

How to set filter for GridView in EditValue changed ? Winforms Devexpress

I need to filter the gridview when user select some item from dropdown. So I write this query code in edit value change event but my query is error

SELECT InvoiceId, InvoiceNumber, InvoiceDate, 
(Select CustomerId from Customer Where Customer.CustomerId=NewInvoice_1.CustomerName) AS CustomerId, 
(Select CustomerName from Customer where Customer.CustomerId = NewInvoice_1.CustomerName) AS CustomerName, 
DueDate, Tax, GrandTotal, CompanyId
FROM NewInvoice_1
Where InvoiceDate < 06-04-2014; // error in where condition

I have 6 conditions here to filter this invoice date

1) InvoiceDate before 01-04-2014

2) InvoiceDate startfrom 01-03-2014 endon 31-0302014

3) InvoiceDate thisweek that is last 7 days from now

4) InvoiceDate lastweek that is now(Today) - 14 days to +7 days

5) InvoiceDate ThisMonth that is last 30 days from now

6) InvoiceDate LastMonth that is now(today) - 60 days to +30 days

Help me to how to form query for this

I think there is an issue in how you pass the date.

 SELECT InvoiceId, InvoiceNumber, InvoiceDate, 
 (Select CustomerId from Customer Where Customer.CustomerId=NewInvoice_1.CustomerName) AS CustomerId, 
 (Select CustomerName from Customer where Customer.CustomerId = NewInvoice_1.CustomerName) AS CustomerName, 
 DueDate, Tax, GrandTotal, CompanyId
 FROM NewInvoice_1
 Where InvoiceDate < '06-04-2014';

This might work or pass the date as CDate('06-04-2014')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM