public IncidentSearch(MDIMainForm mdiForm) { InitializeComponent(); _bs = new BindingSource(); _mdiForm = mdiForm; _incidentType = Incident.IncidentTypeEnum.All; _lastSortedPropertyName = "IncidentDate"; }
private void rbOther_CheckedChanged(object sender, EventArgs e) { if (rbOther.Checked) { //_filteredIncidents = GetFilteredList(Incident.IncidentTypeEnum.Other); _incidentType = Incident.IncidentTypeEnum.Other; SetDataSource(false); } }
private void rbStaffAndStudent_CheckedChanged(object sender, EventArgs e) { if (rbStaffAndStudent.Checked) { //_filteredIncidents = GetFilteredList(Incident.IncidentTypeEnum.StaffAndStudent); _incidentType = Incident.IncidentTypeEnum.StaffAndStudent; SetDataSource(false); } }
private void rbAll_CheckedChanged(object sender, EventArgs e) { if (rbAll.Checked) { //_filteredIncidents=_allIncidents; //_incidentType = Incident.IncidentTypeEnum.All; _incidentType = Incident.IncidentTypeEnum.All; SetDataSource(false); } }
private List <Incident> GetFilteredList(Incident.IncidentTypeEnum incidentType, bool sort) { List <Incident> newList; if (incidentType == Incident.IncidentTypeEnum.All) { newList = _allIncidents; } else if (incidentType == Incident.IncidentTypeEnum.Student) { newList = _allIncidents.FindAll(x => x.IncidentType == Incident.IncidentTypeEnum.Student); } else if (incidentType == Incident.IncidentTypeEnum.Staff) { newList = _allIncidents.FindAll(x => x.IncidentType == Incident.IncidentTypeEnum.Staff); } else if (incidentType == Incident.IncidentTypeEnum.StaffAndStudent) { newList = _allIncidents.FindAll(x => x.IncidentType == Incident.IncidentTypeEnum.StaffAndStudent); } else { newList = _allIncidents.FindAll(x => x.IncidentType == Incident.IncidentTypeEnum.Other); } if (txtSearch.Text != string.Empty) { newList = _filteredIncidents = newList.FindAll(x => x.PersonFullName.ToUpper().Contains(txtSearch.Text.ToUpper()) || x.Description.ToUpper().Contains(txtSearch.Text.ToUpper())); } if (sort) { if (!_sorted) { newList = newList.OrderBy(p => p.GetType() .GetProperty(_lastSortedPropertyName) .GetValue(p, null)).ToList(); _sorted = true; } else { newList = newList.OrderByDescending(p => p.GetType() .GetProperty(_lastSortedPropertyName) .GetValue(p, null)).ToList(); _sorted = false; } } return(newList); }