/// <summary> /// Makes a query to BookColletction based on filled search fields and copies query to BookCollection. If all search fields are empty, then all books in current BookCollection are return by query. /// </summary> private void Search() { GetBooks(); ObservableCollection <Book> bufferList = new ObservableCollection <Book>(); var SearchQuery = BookCollection.ToList().Where(p => !SearchTitle.Equals(string.Empty) ? p.BookTitle.ToLower().Contains(SearchTitle.Trim()) : true && !SearchFirstName.Equals(string.Empty) ? p.Author.AuthorFirstName.ToLower().Contains(SearchFirstName.Trim().ToLower()) : true && !SearchLastName.Equals(string.Empty) ? p.Author.AuthorLastName.ToLower().Contains(SearchLastName.Trim().ToLower()) : true).Select(p => (Book)p); foreach (Book b in SearchQuery) { bufferList.Add(b); } if (bufferList != null) { BookCollection.Clear(); foreach (Book b in bufferList) { BookCollection.Add(b); } } }
public DataSet MoveInRevenueSearchGet() { DataSet dsRevenue = new DataSet(); using (SqlConnection Connection = new SqlConnection(ConfigurationManager.AppSettings["WebApplication"])) { using (SqlCommand Command = new SqlCommand("BonusPlan.MoveInRevenueSearchGet", Connection)) { Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Add("@CustomerID", SqlDbType.Int); Command.Parameters["@CustomerID"].Value = SearchCustomerID.NullIfEmpty(); Command.Parameters.Add("@FirstName", SqlDbType.VarChar); Command.Parameters["@FirstName"].Value = SearchFirstName.NullIfEmpty(); Command.Parameters.Add("@LastName", SqlDbType.VarChar); Command.Parameters["@LastName"].Value = SearchLastName.NullIfEmpty(); Command.Parameters.Add("@CommunityNumber", SqlDbType.VarChar); Command.Parameters["@CommunityNumber"].Value = SearchCommunityNumber.NullIfEmpty(); Command.Parameters.Add("@BeginEffectiveDt", SqlDbType.DateTime); Command.Parameters["@BeginEffectiveDt"].Value = SearchBeginEffectiveDt.NullIfEmpty(); Command.Parameters.Add("@EndEffectiveDt", SqlDbType.DateTime); Command.Parameters["@EndEffectiveDt"].Value = SearchEndEffectiveDt.NullIfEmpty(); using (SqlDataAdapter DataAdapter = new SqlDataAdapter(Command)) { DataAdapter.Fill(dsRevenue); } } } return(dsRevenue); }