Finalisation de la fonction de filtrage
This commit is contained in:
parent
b95e14a29f
commit
b56f785e3d
14
App.xaml.cs
14
App.xaml.cs
@ -1,17 +1,9 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace Hermes
|
namespace Hermes {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logique d'interaction pour App.xaml
|
/// Logique d'interaction pour App.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
Icon="hermes.png"
|
Icon="hermes.png"
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
Title="Hermes" Height="512" Width="1024">
|
Title="Hermes" Height="640" Width="1024">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<BooleanToVisibilityConverter x:Key="Bool2VisibilityConv"/>
|
<BooleanToVisibilityConverter x:Key="Bool2VisibilityConv"/>
|
||||||
<CollectionViewSource x:Key="citoyenCollectionViewSource"/>
|
<CollectionViewSource x:Key="citoyenCollectionViewSource"/>
|
||||||
@ -87,6 +87,7 @@
|
|||||||
<Label>Résidence :</Label>
|
<Label>Résidence :</Label>
|
||||||
<WrapPanel>
|
<WrapPanel>
|
||||||
<ComboBox Name="residenceFilterComboBox" Width="150" Margin="0,0,5,0">
|
<ComboBox Name="residenceFilterComboBox" Width="150" Margin="0,0,5,0">
|
||||||
|
<ComboBoxItem IsSelected="True" Height="20"/>
|
||||||
<ComboBoxItem>Principale</ComboBoxItem>
|
<ComboBoxItem>Principale</ComboBoxItem>
|
||||||
<ComboBoxItem>Secondaire</ComboBoxItem>
|
<ComboBoxItem>Secondaire</ComboBoxItem>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
@ -97,7 +98,7 @@
|
|||||||
<Button Margin="0,0,0,5" Height="25" Width="100" Click="Reinitialiser_Click">Réinitialiser</Button>
|
<Button Margin="0,0,0,5" Height="25" Width="100" Click="Reinitialiser_Click">Réinitialiser</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
<DataGrid ItemsSource="{Binding Source={StaticResource citoyenCollectionViewSource}}" Background="White" Grid.Row="2" VerticalScrollBarVisibility="Visible" GridLinesVisibility="All" Margin="10" Name="dgCitoyens" AutoGenerateColumns="False" IsReadOnly="True" MouseDoubleClick="DgCitoyen_DoubleClick">
|
<DataGrid AlternatingRowBackground="WhiteSmoke" VerticalGridLinesBrush="LightGray" HorizontalGridLinesBrush="LightGray" ItemsSource="{Binding Source={StaticResource citoyenCollectionViewSource}}" Background="White" Grid.Row="2" VerticalScrollBarVisibility="Visible" GridLinesVisibility="All" Margin="10" Name="dgCitoyens" AutoGenerateColumns="False" IsReadOnly="True" MouseDoubleClick="DgCitoyen_DoubleClick">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Civilité" Visibility="{Binding Source={x:Reference civiliteViewCheckBox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Civilite}" Width="*"/>
|
<DataGridTextColumn Header="Civilité" Visibility="{Binding Source={x:Reference civiliteViewCheckBox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Civilite}" Width="*"/>
|
||||||
<DataGridTextColumn Header="Nom" Visibility="{Binding Source={x:Reference nomViewCheckBox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Nom}" Width="*"/>
|
<DataGridTextColumn Header="Nom" Visibility="{Binding Source={x:Reference nomViewCheckBox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Nom}" Width="*"/>
|
||||||
|
@ -83,6 +83,12 @@ namespace Hermes {
|
|||||||
citoyenCollectionViewSource.Filter -= new FilterEventHandler(CitoyenFilter);
|
citoyenCollectionViewSource.Filter -= new FilterEventHandler(CitoyenFilter);
|
||||||
isEnabledFilter = false;
|
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) {
|
protected override void OnClosed(EventArgs e) {
|
||||||
@ -95,10 +101,44 @@ namespace Hermes {
|
|||||||
Citoyen citoyen = (Citoyen) e.Item;
|
Citoyen citoyen = (Citoyen) e.Item;
|
||||||
e.Accepted = true;
|
e.Accepted = true;
|
||||||
if(citoyen != null) {
|
if(citoyen != null) {
|
||||||
if(!String.IsNullOrWhiteSpace(professionFilterTextBox.Text)) {
|
if(!String.IsNullOrEmpty(professionFilterTextBox.Text)) {
|
||||||
if(!citoyen.Profession.ToLower().Contains(professionFilterTextBox.Text.ToLower())) {
|
if(citoyen.Profession == null || !citoyen.Profession.ToLower().Contains(professionFilterTextBox.Text.ToLower())) {
|
||||||
e.Accepted = false;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
namespace Hermes.Migrations {
|
using System.Data.Entity.Migrations;
|
||||||
using System;
|
|
||||||
using System.Data.Entity;
|
|
||||||
using System.Data.Entity.Migrations;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
|
namespace Hermes.Migrations {
|
||||||
internal sealed class Configuration : DbMigrationsConfiguration<Hermes.Model.ModelContext> {
|
internal sealed class Configuration : DbMigrationsConfiguration<Hermes.Model.ModelContext> {
|
||||||
public Configuration() {
|
public Configuration() {
|
||||||
AutomaticMigrationsEnabled = false;
|
AutomaticMigrationsEnabled = false;
|
||||||
|
@ -28,7 +28,9 @@ namespace Hermes.Model {
|
|||||||
private DateTime _dateCreation;
|
private DateTime _dateCreation;
|
||||||
private DateTime _dateModification;
|
private DateTime _dateModification;
|
||||||
|
|
||||||
public int Id { get => _id; set => _id = value; }
|
public int Id {
|
||||||
|
get => _id; set => _id = value;
|
||||||
|
}
|
||||||
public string Civilite {
|
public string Civilite {
|
||||||
get => _civilite;
|
get => _civilite;
|
||||||
set {
|
set {
|
||||||
@ -179,7 +181,9 @@ namespace Hermes.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string TypeResidenceLabel { get => TypeResidence == false ? "Principale" : "Secondaire"; }
|
public string TypeResidenceLabel {
|
||||||
|
get => TypeResidence == false ? "Principale" : "Secondaire";
|
||||||
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string Age {
|
public string Age {
|
||||||
@ -201,6 +205,16 @@ namespace Hermes.Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public int? AgeInt {
|
||||||
|
get {
|
||||||
|
if(DateNaissance.HasValue) {
|
||||||
|
return DateTime.Now.Year - DateNaissance.Value.Year;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string AdresseCP => ModelContext.Getinstance().Preferences.Local[0].VilleCP;
|
public string AdresseCP => ModelContext.Getinstance().Preferences.Local[0].VilleCP;
|
||||||
|
|
||||||
|
@ -19,7 +19,11 @@ namespace Hermes.Model {
|
|||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual DbSet<Citoyen> CitoyenSet { get; set; }
|
public virtual DbSet<Citoyen> CitoyenSet {
|
||||||
public virtual DbSet<Preferences> Preferences { get; set; }
|
get; set;
|
||||||
|
}
|
||||||
|
public virtual DbSet<Preferences> Preferences {
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,17 @@
|
|||||||
|
|
||||||
namespace Hermes.Model {
|
namespace Hermes.Model {
|
||||||
public class Preferences {
|
public class Preferences {
|
||||||
public int Id { get; set; }
|
public int Id {
|
||||||
public string VilleCP { get; set; }
|
get; set;
|
||||||
public string Ville { get; set; }
|
}
|
||||||
public string SmsApiKey { get; set; }
|
public string VilleCP {
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
public string Ville {
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
public string SmsApiKey {
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user