BoxDetails.Presenter.BoxDetailsPresenter.GetSearchResults C# (CSharp) Метод

GetSearchResults() публичный Метод

GetSearchResults Uses the BaseDal helper class to retrieve search results based on the paramater list sent to u_SearchRecords_s . The search logic is contained in the SQL of that stored procedure. Updates the view with the results dataset.
public GetSearchResults ( ) : bool
Результат bool
        public bool GetSearchResults()
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.Text;
            DataSet searchresults = new DataSet();

            string sql = "SELECT * FROM BoxDetails WHERE ClientName LIKE '%";
            if (!string.IsNullOrEmpty(_searchView.ClientName))
            {
                sql += _searchView.ClientName;
            }
            sql += "%'";
            sql += " AND ClientNumber LIKE '%";
            if (!string.IsNullOrEmpty(_searchView.ClientNumber))
            {
                sql += _searchView.ClientNumber;
            }
            sql += "%'";
            sql += " AND ClientLeader LIKE '%";
            if (!string.IsNullOrEmpty(_searchView.ClientPrincipal))
            {
                sql += _searchView.ClientPrincipal;
            }
            sql += "%'";
            sql += " AND (FileLocation LIKE '%";
            if (!string.IsNullOrEmpty(_searchView.location))
            {
                sql += _searchView.location;
            }
            sql += "%' OR";
            sql += " FileLocation2 LIKE '%";
            if(! string.IsNullOrEmpty(_searchView.location))
            {
                sql += _searchView.location;
            }
            sql += "%'";
            sql += ")";

            command.CommandText = sql;

            SqlDataAdapter adapter = new SqlDataAdapter(command);
            adapter.Fill(searchresults);

            _searchView.searchResults = searchresults;

            return true;
        }