private void button_Search_Click(object sender, EventArgs e) { SearchingEmployee srchEmployee = new SearchingEmployee(); srchEmployee.SearchName = textBox_Name.Text; srchEmployee.SearchLastname = textBox_Surname.Text; srchEmployee.SearchIsWorking = isWorkingSearch; searchRsltEmps = frm1Service.Search(srchEmployee); dataGridView_employee.DataSource = searchRsltEmps; }
public List <Employee> Search(SearchingEmployee srchEmp) { IEnumerable <Employee> result = employees; if (!string.IsNullOrEmpty(srchEmp.SearchName)) { result = result.Where(w => w.Name.Contains(srchEmp.SearchName)); } if (!string.IsNullOrEmpty(srchEmp.SearchLastname)) { result = result.Where(w => w.Surname.Contains(srchEmp.SearchLastname)); } if (srchEmp.SearchIsWorking.HasValue) { result = result.Where(w => w.IsWorking == srchEmp.SearchIsWorking.Value); } return(result.ToList()); }