Finalisation de la fonction de filtrage
This commit is contained in:
@@ -83,6 +83,12 @@ namespace Hermes {
|
||||
citoyenCollectionViewSource.Filter -= new FilterEventHandler(CitoyenFilter);
|
||||
isEnabledFilter = false;
|
||||
}
|
||||
ageOperationFilterComboBox.SelectedIndex = 0;
|
||||
ageFilterTextBox.Text = null;
|
||||
professionFilterTextBox.Text = null;
|
||||
quartierFilterTextBox.Text = null;
|
||||
adresseFilterTextBox.Text = null;
|
||||
residenceFilterComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e) {
|
||||
@@ -95,11 +101,45 @@ namespace Hermes {
|
||||
Citoyen citoyen = (Citoyen) e.Item;
|
||||
e.Accepted = true;
|
||||
if(citoyen != null) {
|
||||
if(!String.IsNullOrWhiteSpace(professionFilterTextBox.Text)) {
|
||||
if(!citoyen.Profession.ToLower().Contains(professionFilterTextBox.Text.ToLower())) {
|
||||
if(!String.IsNullOrEmpty(professionFilterTextBox.Text)) {
|
||||
if(citoyen.Profession == null || !citoyen.Profession.ToLower().Contains(professionFilterTextBox.Text.ToLower())) {
|
||||
e.Accepted = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
int ageFilter = Int32.Parse(ageFilterTextBox.Text);
|
||||
if(!citoyen.AgeInt.HasValue
|
||||
|| (ageOperationFilterComboBox.SelectedIndex == 0 && ageFilter != citoyen.AgeInt)
|
||||
|| (ageOperationFilterComboBox.SelectedIndex == 1 && ageFilter >= citoyen.AgeInt)
|
||||
|| (ageOperationFilterComboBox.SelectedIndex == 2 && ageFilter <= citoyen.AgeInt)) {
|
||||
e.Accepted = false;
|
||||
return;
|
||||
}
|
||||
} catch(Exception) { }
|
||||
|
||||
if(!String.IsNullOrEmpty(quartierFilterTextBox.Text)) {
|
||||
if(citoyen.Quartier == null || !citoyen.Quartier.ToLower().Contains(quartierFilterTextBox.Text.ToLower())) {
|
||||
e.Accepted = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string addrBat = citoyen.AdresseBatiment == null ? "" : citoyen.AdresseBatiment;
|
||||
string addr = $"{citoyen.AdresseNumero} {citoyen.AdresseRue} {addrBat}".ToLower();
|
||||
if(!String.IsNullOrEmpty(adresseFilterTextBox.Text)) {
|
||||
if(!addr.Contains(adresseFilterTextBox.Text.ToLower())) {
|
||||
e.Accepted = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if((residenceFilterComboBox.SelectedIndex == 1 && citoyen.TypeResidence != false)
|
||||
|| (residenceFilterComboBox.SelectedIndex == 2 && citoyen.TypeResidence != true)) {
|
||||
e.Accepted = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user