public void SearchData() { Cursor.Current = Cursors.WaitCursor; DateTime dtFromDate, dtToDate; string strFromDate, strToDate; string strSearchCustomer; string strSearchPONumber; string strSearchItem; string strSearchStatus; gcHeader.DataSource = null; try { dtFromDate = Convert.ToDateTime(dtSearchDateFrom.EditValue); dtToDate = Convert.ToDateTime(dtSearchDateTo.EditValue).AddDays(1); strFromDate = Functions.FunctionDateToString(dtFromDate, 0); strToDate = Functions.FunctionDateToString(dtToDate, 0); dtFromDate = Convert.ToDateTime(strFromDate); dtToDate = Convert.ToDateTime(strToDate); strSearchCustomer = lueSearchCustomer.Properties.GetKeyValueByDisplayText(lueSearchCustomer.Text).ToString(); if (string.IsNullOrEmpty(strSearchCustomer)) { strSearchCustomer = "%"; } strSearchPONumber = lueSearchPO.Properties.GetKeyValueByDisplayText(lueSearchPO.Text).ToString(); if (string.IsNullOrEmpty(strSearchPONumber)) { strSearchPONumber = "%"; } strSearchItem = txtSearchItem.Text.ToString(); if (string.IsNullOrEmpty(strSearchItem)) { strSearchItem = "%"; } strSearchStatus = lueSearchStatus.Properties.GetKeyValueByDisplayText(lueSearchStatus.Text).ToString(); if (string.IsNullOrEmpty(strSearchStatus)) { strSearchStatus = "%"; } string strSearchPOtype = lueSearchPOType.Properties.GetKeyValueByDisplayText(lueSearchPOType.Text).ToString(); if (string.IsNullOrEmpty(strSearchPOtype)) { strSearchPOtype = "%"; } var qry = db.stp_POHeader_Select(dtFromDate, dtToDate, strSearchCustomer, strSearchPOtype, strSearchPONumber, strSearchStatus); if (qry != null) { gcHeader.DataSource = qry.ToList(); if (gvHeader.RowCount > 0) { gvHeader.FocusedRowHandle = -1; string[] arr = { "CustomerID", "POHeaderID" }; Functions.SetInvisible(ref gvHeader, arr); gvHeader.BestFitColumns(); gvHeader.OptionsBehavior.ReadOnly = true; gvHeader.FocusedRowHandle = 0; } } else { gcHeader.DataSource = null; MessageBox.Show("No Results", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("Couldn't Search Item List!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } }