예제 #1
0
        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;
        }
예제 #2
0
        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());
        }