public IEnumerable <Person> SearchItem(string searchItem, SearchStyleEnum searchStyle) { const string query = @"SELECT p.Id , [Lastname], [Firstname], [Middlename], [MiddleInitial], [NameExtension], [MaidenMiddlename], [BirthDate], [Gender] from person p where Replace(DBO.FULLNAME(LASTNAME, FIRSTNAME, MIDDLENAME, MiddleInitial, 0, NAMEEXTENSION),' ','') like @Criteria"; var results = Search.SearchData <dynamic>(searchItem, query, searchStyle); var itemCollection = new List <Person>(); foreach (var result in results) { var item = new Person(); item.DataMapper.Map(result); item.DataMapper.Map(result); item.RowStatus = RecordStatus.NoChanges; item.StartTrackingChanges(); itemCollection.Add(item); } return(itemCollection); }
public IEnumerable <Employee> SearchItem(string searchItem, SearchStyleEnum searchStyle) { const string query = @"SELECT e.Id, e.EmpNum , p.Id PersonId, [Lastname], [Firstname], [Middlename], [MiddleInitial], [NameExtension], [MaidenMiddlename], [Gender] from person p inner join Employee e on p.Id = e.PersonId where Replace(DBO.FULLNAME(LASTNAME, FIRSTNAME, MIDDLENAME, MiddleInitial, 0, NAMEEXTENSION),' ','') like @Criteria"; var results = Search.SearchData <dynamic>(searchItem, query, searchStyle); var itemCollection = new List <Employee>(); foreach (var result in results) { var item = new Employee(); item.DataMapper.Map(result); item.PersonClass.DataMapper.Map(result); item.PersonClass.Id = result.PersonId; item.StartTrackingChanges(); itemCollection.Add(item); } return(itemCollection); }
private void btnSearch_Click(object sender, EventArgs e) { try { FlexGrid.Rows.Count = 1; if (!DataSearchIsValid()) { return; } var searchStyle = new SearchStyleEnum(); switch (cboSearchType.Text) { case "Contains": searchStyle = SearchStyleEnum.Contains; break; case "Starts With": searchStyle = SearchStyleEnum.StartsWith; break; case "Ends With": searchStyle = SearchStyleEnum.EndsWith; break; } var reader = new DeductionDataReader(); var items = reader.SearchItem(txtSearch.Text, searchStyle); var deductions = items as IList <Deduction> ?? items.ToList(); if (!deductions.Any()) { MessageDialog.ShowValidationError(txtSearch, "No items match your search"); return; } FlexGrid.Rows.Count = deductions.Count() + 1; var row = 0; foreach (var item in deductions.OrderBy(_ => _.Description)) { row++; FlexGrid[row, "code"] = item.Code; FlexGrid[row, "description"] = item.Description; FlexGrid.Select(1, 0); } FlexGrid.Focus(); } catch (Exception ex) { MessageDialog.ShowError(ex, this); } }
private void btnSearch_Click(object sender, EventArgs e) { FlexGrid.Rows.Count = 1; if (!DataSearchIsValid()) { return; } var searchStyle = new SearchStyleEnum(); switch (cboSearchType.Text) { case "Contains": searchStyle = SearchStyleEnum.Contains; break; case "Starts With": searchStyle = SearchStyleEnum.StartsWith; break; case "Ends With": searchStyle = SearchStyleEnum.EndsWith; break; } var reader = new PersonDataReader(); var items = reader.SearchItem(txtSearch.Text, searchStyle); var enumerable = items as IList <Person> ?? items.ToList(); if (!enumerable.Any()) { MessageDialog.ShowValidationError(txtSearch, "No items match your search"); return; } FlexGrid.Rows.Count = enumerable.Count() + 1; var row = 0; foreach (var item in enumerable.OrderBy(_ => _.Name.Fullname)) { row++; FlexGrid[row, "contactid"] = item.Id; FlexGrid[row, "name"] = item.Name.Fullname; FlexGrid[row, "gender"] = item.Gender == GenderType.Male ? "Male" : "Female"; FlexGrid[row, "birthdate"] = item.BirthDate.ToString("yyyy MMM dd"); FlexGrid.Select(1, 0); } FlexGrid.Focus(); }
public IEnumerable <Deduction> SearchItem(string searchItem, SearchStyleEnum searchStyle) { const string query = @"SELECT * from Payroll_Deduction where Description like @Criteria"; var results = Search.SearchData <Dll.Payroll.Deduction>(searchItem, query, searchStyle); var deductions = results as IList <Deduction> ?? results.ToList(); foreach (var item in deductions) { item.StartTrackingChanges(); } return(deductions); }
public IEnumerable <BiometricUser> SearchItem(string searchItem, string category, SearchStyleEnum searchStyle) { var query = @"SELECT b.Id, b.BiometricId , p.Id PersonId, [Lastname], [Firstname], [Middlename], [MiddleInitial], [NameExtension], [MaidenMiddlename], [Gender], Category from person p inner join Biometric_User b on p.Id = b.PersonId where Category = '@Category' and Replace(DBO.FULLNAME(LASTNAME, FIRSTNAME, MIDDLENAME, MiddleInitial, 0, NAMEEXTENSION),' ','') like @Criteria"; query = query.Replace("@Category", category); var results = Search.SearchData <dynamic>(searchItem, query, searchStyle); var itemCollection = new List <BiometricUser>(); foreach (var result in results) { var item = new BiometricUser(); item.Map(result); item.PersonClass.DataMapper.Map(result); item.PersonClass.Id = result.PersonId; item.StartTrackingChanges(); itemCollection.Add(item); } return(itemCollection); }