Restructuration

This commit is contained in:
Valentin Verdier 2020-11-30 00:19:37 +01:00
parent 1bcaa3c841
commit c3b67ca667
28 changed files with 1082 additions and 452 deletions

View File

@ -1,6 +1,78 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact"/>
</providers>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0"/>
</parameters>
</defaultConnectionFactory>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Caching.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0"/>
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data></configuration>

View File

@ -2,9 +2,5 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Hermes"
StartupUri="MainWindow.xaml"
Exit="Application_Exit">
<Application.Resources>
</Application.Resources>
StartupUri="MainWindow.xaml">
</Application>

View File

@ -13,8 +13,5 @@ namespace Hermes
/// </summary>
public partial class App : Application
{
private void Application_Exit(object sender, ExitEventArgs e) {
DataAccess.CloseConnection();
}
}
}

View File

@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hermes
{
public class Citoyen
{
public int Id { get; set; }
public string Nom { get; set; }
public string Prenom { get; set; }
public DateTime DateNaissance { get; set; }
public string Adresse { get; set; }
public string Profession { get; set; }
public int TypeResidence { get; set; }
public string Mail { get; set; }
public string Tel { get; set; }
public string TypeResidenceLabel {
get
{
return TypeResidence == 0 ? "Principale" : "Secondaire";
}
}
public int Age {
get
{
return DateTime.Now.Year - DateNaissance.Year;
}
set
{
DateNaissance = new DateTime(DateTime.Now.Year - value, 1, 1);
}
}
public Citoyen() {}
public Citoyen(int id, string nom, string prenom, DateTime dateNaissance, string adresse, string profession, int typeResidence, string mail, string tel) {
Id = id;
Nom = nom;
Prenom = prenom;
DateNaissance = dateNaissance;
Adresse = adresse;
Profession = profession;
TypeResidence = typeResidence;
Mail = mail;
Tel = tel;
}
}
}

View File

@ -1,153 +0,0 @@
using Microsoft.Data.Sqlite;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hermes
{
public static class CitoyenDAO
{
private static Citoyen ReadCitoyen(SqliteDataReader reader) {
Citoyen citoyen = new Citoyen(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), DateTime.Now, reader.GetString(4), reader.GetString(5), reader.GetInt32(6), reader.GetString(7), reader.GetString(8));
citoyen.DateNaissance = DateTime.ParseExact(reader.GetString(3), "yyyy", CultureInfo.InvariantCulture);
return citoyen;
}
private static List<Citoyen> ReadCitoyens(SqliteDataReader reader) {
List<Citoyen> citoyens = new List<Citoyen>();
while (reader.Read())
{
citoyens.Add(ReadCitoyen(reader));
}
return citoyens;
}
public static List<Citoyen> FetchAll() {
SqliteConnection db = DataAccess.GetConnection();
SqliteCommand selectCmd = new SqliteCommand("SELECT id, nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel FROM citoyen", db);
SqliteDataReader reader = selectCmd.ExecuteReader();
return ReadCitoyens(reader);
}
public static List<Citoyen> FetchByAgeSup(int age) {
SqliteConnection db = DataAccess.GetConnection();
int year = DateTime.Now.Year - age;
SqliteCommand selectCmd = new SqliteCommand("SELECT id, nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel FROM citoyen WHERE date_naissance < $year", db);
selectCmd.Parameters.AddWithValue("$year", year.ToString());
SqliteDataReader reader = selectCmd.ExecuteReader();
return ReadCitoyens(reader);
}
public static List<Citoyen> FetchByAgeEquals(int age)
{
SqliteConnection db = DataAccess.GetConnection();
int year = DateTime.Now.Year - age;
SqliteCommand selectCmd = new SqliteCommand("SELECT id, nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel FROM citoyen WHERE date_naissance = $year", db);
selectCmd.Parameters.AddWithValue("$year", year.ToString());
SqliteDataReader reader = selectCmd.ExecuteReader();
return ReadCitoyens(reader);
}
public static List<Citoyen> FetchByAgeInf(int age)
{
SqliteConnection db = DataAccess.GetConnection();
int year = DateTime.Now.Year - age;
SqliteCommand selectCmd = new SqliteCommand("SELECT id, nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel FROM citoyen WHERE date_naissance > $year", db);
selectCmd.Parameters.AddWithValue("$year", year.ToString());
SqliteDataReader reader = selectCmd.ExecuteReader();
return ReadCitoyens(reader);
}
public static List<Citoyen> FetchByProfession(string pattern)
{
SqliteConnection db = DataAccess.GetConnection();
SqliteCommand selectCmd = new SqliteCommand("SELECT id, nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel FROM citoyen WHERE LOWER(date_naissance) LIKE $pattern", db);
selectCmd.Parameters.AddWithValue("$pattern", "%" + pattern.ToLower() + "%");
SqliteDataReader reader = selectCmd.ExecuteReader();
return ReadCitoyens(reader);
}
public static List<Citoyen> FetchByAdresse(string pattern)
{
SqliteConnection db = DataAccess.GetConnection();
SqliteCommand selectCmd = new SqliteCommand("SELECT id, nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel FROM citoyen WHERE LOWER(adresse) LIKE $pattern", db);
selectCmd.Parameters.AddWithValue("$pattern", "%" + pattern.ToLower() + "%");
SqliteDataReader reader = selectCmd.ExecuteReader();
return ReadCitoyens(reader);
}
public static List<Citoyen> FetchByTypeResidence(int type)
{
SqliteConnection db = DataAccess.GetConnection();
SqliteCommand selectCmd = new SqliteCommand("SELECT id, nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel FROM citoyen WHERE type_residence = $type", db);
selectCmd.Parameters.AddWithValue("$type", type);
SqliteDataReader reader = selectCmd.ExecuteReader();
return ReadCitoyens(reader);
}
public static void Add(Citoyen citoyen) {
SqliteConnection db = DataAccess.GetConnection();
SqliteCommand insertCmd = new SqliteCommand("INSERT INTO citoyen (nom, prenom, date_naissance, adresse, profession, type_residence, mail, tel) VALUES ($nom, $prenom, $date_naissance, $adresse, $profession, $type_residence, $mail, $tel)", db);
insertCmd.Parameters.AddWithValue("$nom", citoyen.Nom);
insertCmd.Parameters.AddWithValue("$prenom", citoyen.Prenom);
insertCmd.Parameters.AddWithValue("$date_naissance", citoyen.DateNaissance.ToString("yyyy"));
insertCmd.Parameters.AddWithValue("$adresse", citoyen.Adresse);
insertCmd.Parameters.AddWithValue("$profession", citoyen.Profession);
insertCmd.Parameters.AddWithValue("$type_residence", citoyen.TypeResidence);
insertCmd.Parameters.AddWithValue("$mail", citoyen.Mail);
insertCmd.Parameters.AddWithValue("$tel", citoyen.Tel);
insertCmd.ExecuteNonQuery();
}
public static void Update(Citoyen citoyen) {
SqliteConnection db = DataAccess.GetConnection();
SqliteCommand insertCmd = new SqliteCommand("UPDATE citoyen SET nom = $nom, prenom = $prenom, date_naissance = $date_naissance, adresse = $adresse, profession = $profession, type_residence = $type_residence, mail = $mail, tel = $tel WHERE id = $id", db);
insertCmd.Parameters.AddWithValue("$id", citoyen.Id);
insertCmd.Parameters.AddWithValue("$nom", citoyen.Nom);
insertCmd.Parameters.AddWithValue("$prenom", citoyen.Prenom);
insertCmd.Parameters.AddWithValue("$date_naissance", citoyen.DateNaissance.ToString("yyyyMMdd"));
insertCmd.Parameters.AddWithValue("$adresse", citoyen.Adresse);
insertCmd.Parameters.AddWithValue("$profession", citoyen.Profession);
insertCmd.Parameters.AddWithValue("$type_residence", citoyen.TypeResidence);
insertCmd.Parameters.AddWithValue("$mail", citoyen.Mail);
insertCmd.Parameters.AddWithValue("$tel", citoyen.Tel);
insertCmd.ExecuteNonQuery();
}
public static void Remove(Citoyen citoyen) {
SqliteConnection db = DataAccess.GetConnection();
SqliteCommand insertCmd = new SqliteCommand("DELETE FROM citoyen WHERE id = $id", db);
insertCmd.Parameters.AddWithValue("$id", citoyen.Id);
insertCmd.ExecuteNonQuery();
}
}
}

View File

@ -5,38 +5,144 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Hermes"
mc:Ignorable="d"
Title="Informations" Height="279" Width="640"
Title="Informations" Height="390" Width="750"
Icon="hermes.png"
ResizeMode="NoResize"
xmlns:Validation="clr-namespace:Hermes.Validation"
xmlns:Converter="clr-namespace:Hermes.Converter"
Loaded="Window_Loaded"
WindowStartupLocation="CenterOwner"
Closing="Window_Closing">
<Window.Resources>
<Converter:NegateBoolean x:Key="NegateBoolean"/>
</Window.Resources>
<Grid>
<WrapPanel>
<StackPanel Margin="10,10,0,0" VerticalAlignment="Top">
<Label>Nom :</Label>
<TextBox HorizontalAlignment="Left" Width="150"/>
<Label>Prénom :</Label>
<TextBox HorizontalAlignment="Left" Width="150"/>
<Label>Age :</Label>
<TextBox HorizontalAlignment="Left" Width="30"/>
<Label>Adresse :</Label>
<TextBox Width="250"/>
<Label>Profession :</Label>
<TextBox HorizontalAlignment="Left" Width="150"/>
</StackPanel>
<GroupBox Header="Résidence" Margin="10,10,0,0" VerticalAlignment="Top">
<StackPanel>
<RadioButton Margin="5,5,5,0">Principale</RadioButton>
<RadioButton Margin="5,5,5,5">Secondaire</RadioButton>
<StackPanel>
<WrapPanel>
<StackPanel Margin="10,10,0,0" VerticalAlignment="Top">
<Label>Civilité:</Label>
<ComboBox Name="civiliteComboBox" SelectedItem="{Binding Civilite}" Height="23" Width="150"/>
<Label>Nom :</Label>
<TextBox Name="nomTextBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Validation.Error="ValidationError" Binding.TargetUpdated="BindingTargetUpdated" Binding.SourceUpdated="BindingSourceUpdated" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150">
<TextBox.Text>
<Binding Path="Nom" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="true" NotifyOnValidationError="true">
<Binding.ValidationRules>
<Validation:MandatoryString/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<Label>Nom de naissance :</Label>
<TextBox Name="nomNaissanceTextBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Validation.Error="ValidationError" Binding.TargetUpdated="BindingTargetUpdated" Binding.SourceUpdated="BindingSourceUpdated" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150">
<TextBox.Text>
<Binding Path="NomNaissance" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="true" NotifyOnValidationError="true">
<Binding.ValidationRules>
<Validation:MandatoryString/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<Label>Prénom :</Label>
<TextBox Name="prenomTextBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Validation.Error="ValidationError" Binding.TargetUpdated="BindingTargetUpdated" Binding.SourceUpdated="BindingSourceUpdated" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150">
<TextBox.Text>
<Binding Path="Prenom" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="true" NotifyOnValidationError="true">
<Binding.ValidationRules>
<Validation:MandatoryString/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<Label>Age :</Label>
<TextBox Name="ageTextBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Validation.Error="ValidationError" Binding.TargetUpdated="BindingTargetUpdated" Binding.SourceUpdated="BindingSourceUpdated" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="30">
<TextBox.Text>
<Binding Path="Age" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="true" NotifyOnValidationError="true">
<Binding.ValidationRules>
<Validation:Age/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<Label>Profession :</Label>
<TextBox Name="professionTextBox" Text="{Binding Path=Profession}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Contact" Margin="10,10,0,0" VerticalAlignment="Top">
<StackPanel>
<Label>E-Mail :</Label>
<TextBox HorizontalAlignment="Left" Width="200"/>
<Label>Téléphone :</Label>
<TextBox HorizontalAlignment="Left" Width="150"/>
<GroupBox Header="Résidence" Margin="10,10,0,0" VerticalAlignment="Top">
<StackPanel>
<RadioButton Name="principaleResCheckBox" IsChecked="{Binding Path=TypeResidence, Converter={StaticResource NegateBoolean}}" Margin="5,5,5,0">Principale</RadioButton>
<RadioButton Name="secondResCheckBox" IsChecked="{Binding Path=TypeResidence}" Margin="5,5,5,5">Secondaire</RadioButton>
</StackPanel>
</GroupBox>
<GroupBox Header="Adresse Locale" Margin="10,10,0,0" VerticalAlignment="Top">
<StackPanel>
<Label>Numéro :</Label>
<TextBox Name="adresseNumeroTextBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Validation.Error="ValidationError" Binding.TargetUpdated="BindingTargetUpdated" Binding.SourceUpdated="BindingSourceUpdated" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="50">
<TextBox.Text>
<Binding Path="AdresseNumero" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="true" NotifyOnValidationError="true">
<Binding.ValidationRules>
<Validation:MandatoryString/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<Label>Rue:</Label>
<TextBox Name="adresseRueTextBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Validation.Error="ValidationError" Binding.TargetUpdated="BindingTargetUpdated" Binding.SourceUpdated="BindingSourceUpdated" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150">
<TextBox.Text>
<Binding Path="AdresseRue" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="true" NotifyOnValidationError="true">
<Binding.ValidationRules>
<Validation:MandatoryString/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<Label>Bâtiment :</Label>
<TextBox Name="adresseBatimentTextBox" Text="{Binding Path=AdresseBatiment}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
<Label>Quartier :</Label>
<TextBox Name="quartierTextBox" Text="{Binding Path=Quartier}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
</StackPanel>
</GroupBox>
</StackPanel>
</GroupBox>
</WrapPanel>
<Button Margin="516,212,10,10">OK</Button>
<StackPanel>
<GroupBox IsEnabled="{Binding IsChecked, ElementName=secondResCheckBox}" x:Name="mainAddrGroupBox" Header="Adresse" Margin="10,10,0,0" VerticalAlignment="Top" >
<GroupBox.Style>
<Style>
<Style.Triggers>
<Trigger Property="Control.IsEnabled" Value="False">
<Setter Property="Control.Foreground" Value ="#FF6D6D6D" />
</Trigger>
</Style.Triggers>
</Style>
</GroupBox.Style>
<StackPanel>
<Label IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}">Numéro :</Label>
<TextBox Name="adresseExtNumeroTextBox" Text="{Binding Path=AdresseExtNumero}" IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="50"/>
<Label IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}">Rue :</Label>
<TextBox Name="adresseExtRueTextBox" Text="{Binding Path=AdresseExtRue}" IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
<Label IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}">Code postal :</Label>
<TextBox Name="adresseExtCPTextBox" Text="{Binding Path=AdresseExtCP}" IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="80"/>
<Label IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}">Ville :</Label>
<TextBox Name="adresseExtVilleTextBox" Text="{Binding Path=AdresseExtVille}" IsEnabled="{Binding IsEnabled, ElementName=mainAddrGroupBox}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel>
<GroupBox Header="Contact" Margin="10,10,0,0" VerticalAlignment="Top">
<StackPanel>
<Label>E-Mail :</Label>
<TextBox Name="mailTextBox" Text="{Binding Path=Mail}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="200"/>
<Label>Téléphone :</Label>
<TextBox Name="telTextBox" Text="{Binding Path=Tel}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
<Label>Mobile :</Label>
<TextBox Name="telPortTextBox" Text="{Binding Path=TelPort}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
</StackPanel>
</GroupBox>
</StackPanel>
</WrapPanel>
<WrapPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10,10,10,10">
<Button Height="25" Margin="0,0,10,0" Width="100" Click="Save_Click">Enregister</Button>
<Button Height="25" Width="100" Click="Cancel_Click">Annuler</Button>
</WrapPanel>
</StackPanel>
</Grid>
</Window>

View File

@ -1,32 +1,100 @@
using System;
using Hermes.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Hermes
{
namespace Hermes {
/// <summary>
/// Logique d'interaction pour CitoyenModal.xaml
/// </summary>
public partial class CitoyenModal : Window
{
public CitoyenModal()
{
public partial class CitoyenModal : Window {
private ModelContext dbContext = null;
private Citoyen citoyen = null;
private List<object> _isInvalidElements = new List<object>();
private bool _modeCreate = true;
public static List<string> Civilites = new List<string>();
public CitoyenModal() {
dbContext = ModelContext.Getinstance();
DataContext = new Citoyen();
Civilites.Add("M");
Civilites.Add("Mme");
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
civiliteComboBox.ItemsSource = Civilites;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
this.Hide();
}
private void ValidationError(object sender, ValidationErrorEventArgs e) {
if(!_isInvalidElements.Contains(sender)) {
_isInvalidElements.Add(sender);
}
}
private void BindingTargetUpdated(object sender, DataTransferEventArgs e) {
if(_isInvalidElements.Contains(sender)) {
_isInvalidElements.Remove(sender);
}
}
private void BindingSourceUpdated(object sender, DataTransferEventArgs e) {
if(_isInvalidElements.Contains(sender)) {
_isInvalidElements.Remove(sender);
}
}
public void EnableCreateMode() {
DataContext = new Citoyen();
civiliteComboBox.SelectedIndex = 0;
_modeCreate = true;
}
public void EnableEditMode(Citoyen citoyen) {
this.citoyen = citoyen;
Citoyen citoyenContext = new Citoyen();
this.citoyen.Copyto(citoyenContext);
DataContext = citoyenContext;
_modeCreate = false;
}
public void Save_Click(object sender, RoutedEventArgs e) {
nomTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
nomNaissanceTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
prenomTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
ageTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
adresseNumeroTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
adresseRueTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if(_isInvalidElements.Count == 0) {
if(_modeCreate) {
((Citoyen) DataContext).DateCreation = DateTime.Now;
((Citoyen) DataContext).DateModification = DateTime.Now;
dbContext.CitoyenSet.Add((Citoyen) DataContext);
} else {
Citoyen citoyenContext = (Citoyen) DataContext;
citoyenContext.Copyto(citoyen);
citoyen.DateModification = DateTime.Now;
citoyen = null;
}
DataContext = null;
dbContext.SaveChanges();
Close();
}
}
public void Cancel_Click(object sender, RoutedEventArgs e) {
DataContext = null;
citoyen = null;
Close();
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace Hermes.Converter {
class NegateBoolean : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return !(bool) value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return !(bool) value;
}
}
}

View File

@ -1,44 +0,0 @@
using Microsoft.Data.Sqlite;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
namespace Hermes
{
public static class DataAccess
{
private static SqliteConnection db= null;
public static SqliteConnection GetConnection() {
if (db != null) {
return db;
}
var dbpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "hermes.db");
if (!System.IO.File.Exists(dbpath)) {
FileStream fs = File.Create(dbpath);
fs.Close();
}
db = new SqliteConnection($"Filename={dbpath}");
db.Open();
var createTableCmd = "CREATE TABLE IF NOT EXISTS citoyen (id INTEGER PRIMARY KEY, nom TEXT NOT NULL, prenom TEXT NOT NULL, date_naissance TEXT NOT NULL, adresse TEXT NOT NULL, profession TEXT, type_residence INTEGER NOT NULL, mail TEXT, tel TEXT)";
SqliteCommand createTable = new SqliteCommand(createTableCmd, db);
createTable.ExecuteReader();
return db;
}
public static void CloseConnection() {
if (db != null) {
db.Close();
db = null;
}
}
}
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -16,6 +17,21 @@
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -37,36 +53,24 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Data.Sqlite, Version=3.1.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Data.Sqlite.Core.3.1.7\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.2.669, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
<HintPath>packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.2\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.core, Version=2.0.2.669, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
<HintPath>packages\SQLitePCLRaw.core.2.0.2\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.nativelibrary, Version=2.0.2.669, Culture=neutral, PublicKeyToken=502ed628492ab262, processorArchitecture=MSIL">
<HintPath>packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.2\lib\net461\SQLitePCLRaw.nativelibrary.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.2.669, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
<HintPath>packages\SQLitePCLRaw.provider.dynamic_cdecl.2.0.2\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
<Reference Include="EntityFramework.SqlServerCompact, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.SqlServerCompact.6.4.4\lib\net45\EntityFramework.SqlServerCompact.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.SqlServer.Compact.4.0.8876.1\lib\net40\System.Data.SqlServerCe.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -85,9 +89,20 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="SearchModal.xaml.cs">
<DependentUpon>SearchModal.xaml</DependentUpon>
<Compile Include="Converter\NegateBoolean.cs" />
<Compile Include="Migrations\202011292109022_V1.cs" />
<Compile Include="Migrations\202011292109022_V1.designer.cs">
<DependentUpon>202011292109022_V1.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Model\Citoyen.cs" />
<Compile Include="Model\Preferences.cs" />
<Compile Include="Model\ModelContext.cs" />
<Compile Include="PreferencesModal.xaml.cs">
<DependentUpon>PreferencesModal.xaml</DependentUpon>
</Compile>
<Compile Include="Validation\Age.cs" />
<Compile Include="Validation\MandatoryString.cs" />
<Page Include="CitoyenModal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -100,17 +115,14 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Citoyen.cs" />
<Compile Include="CitoyenDAO.cs" />
<Compile Include="CitoyenModal.xaml.cs">
<DependentUpon>CitoyenModal.xaml</DependentUpon>
</Compile>
<Compile Include="DataAccess.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="SearchModal.xaml">
<Page Include="PreferencesModal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@ -129,11 +141,15 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Migrations\202011292109022_V1.resx">
<DependentUpon>202011292109022_V1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\DataSources\Hermes.Model.Citoyen.datasource" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -142,12 +158,38 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 et x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="hermes.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
<Error Condition="!Exists('packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
<Error Condition="!Exists('packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
</Target>
<Import Project="packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
<PropertyGroup>
<PostBuildEvent>
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\x86\*.*" "$(TargetDir)x86"
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -5,30 +5,56 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Hermes"
mc:Ignorable="d"
Title="Hermes" Height="450" Width="800">
Icon="hermes.png"
Loaded="Window_Loaded"
WindowStartupLocation="CenterScreen"
Title="Hermes" Height="512" Width="1024">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="Bool2VisibilityConv"/>
</Window.Resources>
<StackPanel>
<Menu>
<MenuItem Header="Fichier">
<MenuItem Header="Exporter..."/>
<MenuItem Header="Importer..."/>
</MenuItem>
<MenuItem Header="Outils">
<MenuItem Header="Edition">
<MenuItem Header="Ajouter..." Click="Ajouter_Click"/>
<MenuItem Header="Rechercher..." Click="Rechercher_Click"/>
<MenuItem Header="Actualiser"/>
<MenuItem Header="Supprimer" Click="Supprimer_Click"/>
</MenuItem>
<MenuItem Header="Affichage">
<MenuItem x:Name="completeViewCheckbox" Header="Vue détaillée" IsCheckable="true"/>
</MenuItem>
<MenuItem Header="Communication">
<MenuItem Header="Courriel..."/>
<MenuItem Header="SMS..."/>
<MenuItem Header="Publipostage..."/>
</MenuItem>
<MenuItem Header="Outils">
<MenuItem Header="Options..." Click="Options_Click"/>
</MenuItem>
</Menu>
<Grid>
<DataGrid Name="dgCitoyens" AutoGenerateColumns="False" IsReadOnly="True">
<DataGrid Name="dgCitoyens" AutoGenerateColumns="False" IsReadOnly="True" MouseDoubleClick="DgCitoyen_DoubleClick">
<DataGrid.Columns>
<DataGridTextColumn Header="Civilité" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Civilite}" Width="*"/>
<DataGridTextColumn Header="Nom" Binding="{Binding Nom}" Width="*"/>
<DataGridTextColumn Header="Nom de naissance" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding NomNaissance}" Width="*"/>
<DataGridTextColumn Header="Prénom" Binding="{Binding Prenom}" Width="*"/>
<DataGridTextColumn Header="Age" Binding="{Binding Age}" Width="*"/>
<DataGridTextColumn Header="Adresse" Binding="{Binding Adresse}" Width="200"/>
<DataGridTextColumn Header="Profession" Binding="{Binding Profession}" Width="*"/>
<DataGridTextColumn Header="Age" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Age}" Width="*"/>
<DataGridTextColumn Header="Profession" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Profession}" Width="*"/>
<DataGridTextColumn Header="Résidence" Binding="{Binding TypeResidenceLabel}" Width="*"/>
<DataGridTextColumn Header="E-Mail" Binding="{Binding Mail}" Width="*"/>
<DataGridTextColumn Header="Téléphone" Binding="{Binding Tel}" Width="*"/>
<DataGridTextColumn Header="Quartier" Binding="{Binding Quartier}" Width="*"/>
<DataGridTextColumn Header="Numéro de rue (locale)" Binding="{Binding AdresseNumero}" Width="*"/>
<DataGridTextColumn Header="Rue (locale)" Binding="{Binding AdresseRue}" Width="*"/>
<DataGridTextColumn Header="Bâtiment" Binding="{Binding AdresseBatiment}" Width="*"/>
<DataGridTextColumn Header="Numéro de rue" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding AdresseExtNumero}" Width="*"/>
<DataGridTextColumn Header="Rue" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding AdresseExtRue}" Width="*"/>
<DataGridTextColumn Header="Code postal" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding AdresseExtCP}" Width="*"/>
<DataGridTextColumn Header="Ville" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding AdresseExtVille}" Width="*"/>
<DataGridTextColumn Header="E-Mail" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Mail}" Width="*"/>
<DataGridTextColumn Header="Téléphone" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding Tel}" Width="*"/>
<DataGridTextColumn Header="Mobile" Visibility="{Binding Source={x:Reference completeViewCheckbox}, Path=IsChecked, Converter={StaticResource Bool2VisibilityConv}}" Binding="{Binding TelPort}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>

View File

@ -1,48 +1,71 @@
using System;
using Hermes.Model;
using System;
using System.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Hermes
{
namespace Hermes {
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public partial class MainWindow : Window {
private ModelContext dbContext = null;
private CitoyenModal citoyenModal = new CitoyenModal();
private SearchModal searchModal = new SearchModal();
private PreferencesModal preferencesModal = new PreferencesModal();
public MainWindow() {
dbContext = ModelContext.Getinstance();
//dbContext.Database.Log = log => System.Console.WriteLine(log);
dbContext.Database.CreateIfNotExists();
public MainWindow()
{
InitializeComponent();
List<Citoyen> citoyens = new List<Citoyen>();
citoyens.Add(new Citoyen(0, "Dupont", "Jean", new DateTime(1994, 3, 24), "14 rue de la République, Lyon", "Jardinier", 0, "jean.dupont@test.fr", "04 00 00 00 00"));
dgCitoyens.ItemsSource = citoyens;
}
private void Ajouter_Click(object sender, RoutedEventArgs e)
{
private void Window_Loaded(object sender, RoutedEventArgs e) {
citoyenModal.Owner = this;
preferencesModal.Owner = this;
dbContext.CitoyenSet.Load();
dbContext.Preferences.Load();
dgCitoyens.ItemsSource = dbContext.CitoyenSet.Local;
}
private void Options_Click(object sender, RoutedEventArgs e) {
preferencesModal.ShowDialog();
}
private void Ajouter_Click(object sender, RoutedEventArgs e) {
citoyenModal.EnableCreateMode();
citoyenModal.ShowDialog();
}
private void Rechercher_Click(object sender, RoutedEventArgs e)
{
searchModal.ShowDialog();
private void Supprimer_Click(object sender, RoutedEventArgs e) {
if(dgCitoyens.SelectedItems.Count > 0) {
MessageBoxResult result = MessageBox.Show("Voulez-vous supprimer ces citoyens ?", "Suppression", MessageBoxButton.YesNo, MessageBoxImage.Question);
if(result == MessageBoxResult.Yes) {
List<Citoyen> clist = new List<Citoyen>();
foreach(Citoyen c in dgCitoyens.SelectedItems) {
clist.Add(c);
}
foreach(Citoyen c in clist) {
dbContext.CitoyenSet.Remove(c);
}
dbContext.SaveChanges();
}
} else {
MessageBox.Show("Aucun citoyen sélectionné", "Suppression", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
protected override void OnClosed(EventArgs e)
{
private void DgCitoyen_DoubleClick(object sender, MouseButtonEventArgs e) {
if(dgCitoyens.SelectedItem != null) {
citoyenModal.EnableEditMode((Citoyen) dgCitoyens.SelectedItem);
citoyenModal.ShowDialog();
}
}
protected override void OnClosed(EventArgs e) {
dbContext.Dispose();
base.OnClosed(e);
Application.Current.Shutdown();
}

View File

@ -0,0 +1,29 @@
// <auto-generated />
namespace Hermes.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.4.4")]
public sealed partial class V1 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(V1));
string IMigrationMetadata.Id
{
get { return "202011292109022_V1"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}

View File

@ -0,0 +1,57 @@
namespace Hermes.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class V1 : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.Citoyens",
c => new
{
Id = c.Int(nullable: false, identity: true),
Civilite = c.String(maxLength: 4000),
Nom = c.String(maxLength: 4000),
NomNaissance = c.String(maxLength: 4000),
Prenom = c.String(maxLength: 4000),
DateNaissance = c.DateTime(),
Profession = c.String(maxLength: 4000),
TypeResidence = c.Boolean(nullable: false),
Mail = c.String(maxLength: 4000),
Tel = c.String(maxLength: 4000),
TelPort = c.String(maxLength: 4000),
Quartier = c.String(maxLength: 4000),
AdresseNumero = c.String(maxLength: 4000),
AdresseRue = c.String(maxLength: 4000),
AdresseBatiment = c.String(maxLength: 4000),
AdresseExtNumero = c.String(maxLength: 4000),
AdresseExtRue = c.String(maxLength: 4000),
AdresseExtCP = c.String(maxLength: 4000),
AdresseExtVille = c.String(maxLength: 4000),
DateCreation = c.DateTime(nullable: false),
DateModification = c.DateTime(nullable: false),
})
.PrimaryKey(t => t.Id);
CreateTable(
"dbo.Preferences",
c => new
{
Id = c.Int(nullable: false, identity: true),
VilleCP = c.String(maxLength: 4000),
Ville = c.String(maxLength: 4000),
SmsApiKey = c.String(maxLength: 4000),
})
.PrimaryKey(t => t.Id);
}
public override void Down()
{
DropTable("dbo.Preferences");
DropTable("dbo.Citoyens");
}
}
}

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Target" xml:space="preserve">
<value>H4sIAAAAAAAEAO1azW7jNhC+F+g7CDpnrfzsoQ3sXWSdpA26+WmU3TstjR2iFOWSVGA/2x76SH2FDvVLUYojeWWhKIpcohnym+FwOJwZ+u9vf00/biLmvICQNOYz92Ry7DrAgzikfDVzE7V895P78cOPP0yvwmjjfC3GnelxOJPLmfus1Prc82TwDBGRk4gGIpbxUk2COPJIGHunx8c/eycnHiCEi1iOM31MuKIRpB/4OY95AGuVEHYbh8BkTkeOn6I6dyQCuSYBzNxfQeD/k3Sg61wwSlAHH9jSdQjnsSIKNTz/IsFXIuYrf40Ewp62a8BxS8Ik5JqfV8O7LuL4VC/CqyYWUEEiVRz1BDw5y63i2dP3sq1bWg3tdoX2VVu96tR2M3dOVbwFRLZlnc+Z0OPqlp3k44+cjHpU7j26iP47cuYJU4mAGYdECcKOnIdkwWjwG2yf4j+Az3jCmKkTaoW8GgFJDyJeg1DbR1jmmt6EruPV53n2xHKaMSdbxA1XZ6euc4fCyYJBueXGgn0VC/gFOAiiIHwgSoHgGgNSozWkW7Lm9IUyqqCQiH6Gh8V1bsnmM/CVep6574+P8Xxc0w2EBSlX4wuneLhwlhIJvCXpLo5GEXJHqJQEj+DhpT0I4GOs6hK3trEsTXzCsPO2kvESpEwP4qEV1fiPICk6X6XopzhmQHiLG+8GuyWUjaAyjCPkIRbq8IJ+T4hQFMThJV2EAr0K7pIIRDyauMdkhGOdy/pE9K3OR9i1XODVRo1sTpQ4pkVR3PxhTGlfKWMjLE+H4rmAPNuxw3PPsKcnYtZClzTYB3DqVdnSzhwKL68lCB2oZec8ypjzfy7VkJV62xgOPpJb+5G8WFO08NCidvso1k+KUNyEIg/QrqeJsFEtnorFUe6sMpdVX1QG6oOq1w5IcJ1KjazqmpSFhbcbpHZ4Gig1btvCyyVWtaGXFYdFEem9UkVOb8l6jZtgVJU5xfGzknL+zu9fcUUZhhfIlsKr1LaUhOeErMDiomjU9JoKqTBWkQXRXjAPo8aw2oa+YudCVGPP7DBRGb+Yov/PprXVgDZAZcBrXJO+79PlQalJVW02ZqYlPWFEtASdecySiL8WuHbNrkoyE6OidkdKSy4TJCX0mm+UHRaQwemOWFRMJlZB645i1UMmmMXqo1lVJtW1q+jd0axCyAS0WN0xs3rIhMooPbQCCyAl9JqflTEWRkbsjlNVKSZQRe2OZFUhJpzF6o2ZJsYtgI/Ni7MDWlVMtEBWzN64Rs3QAmxw90F+zQQFax9MnR+1Q2rOPoh5NtQOmjP7xZYql7dDS8Xph1hP6G3UOreJPPWsK8q+BL3GLWilyfa92unWNdOYva/dHSAdrt6dsw9z/ZZZvAlREnvitKD0wTAycBPHII/sLI0E1h5SSi8TWSthnebJ49tvI41sMhviOmikF7w+MZP0t1JBNNEDJv6fzAfxAmIOk/f6RacYdks4xStcZcWnm/JqLy3/nlcPT8qQdXv6GL1+pvp+erNC7tnssJ8f+AsRwTMRLTVmhdzztWFIzEYXfjDw+lvCYLCtTwchEpXVSuqmo/2UMJierS8HC6q+69VgOO3gIJjmm8BguPYTwGDArR3/odGNdvTQ0HY/f2j8Rvv+AAIOaJ5ac/4A4LWm5aDxzW69t4W372q9dwTcq/X+37jHrdb3YNt7GKdpNLb3RO7Xx252Rzs1qnd1qbOMGB10oYNOpmbOlA0jfEcPu03OEE3uZi0w9cxfU00vMSVYVRD6t1UcAn02K9BizA1fxsVG4ypNjYohdq4AiuDZJhd4YS5JoJAd6PxGv3F8JSzBIVfRAsIbfp+odaIuMJJFC1Yru6bebvlpJ7+u8/R+rb/kEEtANakOT/f8U0JZWOp93RKeXoHQfpmHAtTKVzokrLYl0l3MOwLl5ruENXAdSJ4gWjMEk/fcJy+wj25fJHyGFQm2RTH3OsjbG1E3+/SSkpUgkcwxqvn4iT4cRpsP/wCPZpf3VCgAAA==</value>
</data>
<data name="DefaultSchema" xml:space="preserve">
<value>dbo</value>
</data>
</root>

View File

@ -0,0 +1,20 @@
namespace Hermes.Migrations {
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<Hermes.Model.ModelContext> {
public Configuration() {
AutomaticMigrationsEnabled = false;
ContextKey = "Hermes";
}
protected override void Seed(Hermes.Model.ModelContext context) {
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data.
}
}
}

240
Model/Citoyen.cs Normal file
View File

@ -0,0 +1,240 @@
using System;
using Hermes.Model;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Hermes.Model {
public class Citoyen : INotifyPropertyChanged {
private int _id;
private string _civilite;
private string _nom;
private string _nomNaissance;
private string _prenom;
private DateTime? _dateNaissance = null;
private string _profession;
private bool _typeResidence = false;
private string _mail;
private string _tel;
private string _telPort;
private string _quartier;
private string _adresseNumero;
private string _adresseRue;
private string _adresseBatiment;
private string _adresseExtNumero;
private string _adresseExtRue;
private string _adresseExtCP;
private string _adresseExtVille;
private DateTime _dateCreation;
private DateTime _dateModification;
public int Id { get => _id; set => _id = value; }
public string Civilite {
get => _civilite;
set {
_civilite = value;
OnPropertyChanged();
}
}
public string Nom {
get => _nom;
set {
_nom = value;
OnPropertyChanged();
}
}
public string NomNaissance {
get => _nomNaissance;
set {
_nomNaissance = value;
OnPropertyChanged();
}
}
public string Prenom {
get => _prenom;
set {
_prenom = value;
OnPropertyChanged();
}
}
public DateTime? DateNaissance {
get => _dateNaissance;
set {
_dateNaissance = value;
OnPropertyChanged();
OnPropertyChanged("Age");
}
}
public string Profession {
get => _profession;
set {
_profession = value;
OnPropertyChanged();
}
}
public bool TypeResidence {
get => _typeResidence;
set {
_typeResidence = value;
if(_typeResidence == false) {
AdresseExtNumero = null;
AdresseExtRue = null;
AdresseExtCP = null;
AdresseExtVille = null;
}
OnPropertyChanged();
OnPropertyChanged("TypeResidenceLabel");
}
}
public string Mail {
get => _mail;
set {
_mail = value;
OnPropertyChanged();
}
}
public string Tel {
get => _tel;
set {
_tel = value;
OnPropertyChanged();
}
}
public string TelPort {
get => _telPort;
set {
_telPort = value;
OnPropertyChanged();
}
}
public string Quartier {
get => _quartier;
set {
_quartier = value;
OnPropertyChanged();
}
}
public string AdresseNumero {
get => _adresseNumero;
set {
_adresseNumero = value;
OnPropertyChanged();
}
}
public string AdresseRue {
get => _adresseRue;
set {
_adresseRue = value;
OnPropertyChanged();
}
}
public string AdresseBatiment {
get => _adresseBatiment;
set {
_adresseBatiment = value;
OnPropertyChanged();
}
}
public string AdresseExtNumero {
get => TypeResidence == false ? null : _adresseExtNumero;
set {
_adresseExtNumero = value;
OnPropertyChanged();
}
}
public string AdresseExtRue {
get => TypeResidence == false ? null : _adresseExtRue;
set {
_adresseExtRue = value;
OnPropertyChanged();
}
}
public string AdresseExtCP {
get => TypeResidence == false ? null : _adresseExtCP;
set {
_adresseExtCP = value;
OnPropertyChanged();
}
}
public string AdresseExtVille {
get => TypeResidence == false ? null : _adresseExtVille;
set {
_adresseExtVille = value;
OnPropertyChanged();
}
}
public DateTime DateCreation {
get => _dateCreation;
set {
_dateCreation = value;
OnPropertyChanged();
}
}
public DateTime DateModification {
get => _dateModification;
set {
_dateModification = value;
OnPropertyChanged();
}
}
[NotMapped]
public string TypeResidenceLabel { get => TypeResidence == false ? "Principale" : "Secondaire"; }
[NotMapped]
public string Age {
get {
if(DateNaissance.HasValue) {
return (DateTime.Now.Year - DateNaissance.Value.Year).ToString();
}
return "";
}
set {
if(String.IsNullOrWhiteSpace(value)) {
DateNaissance = null;
} else {
try {
DateNaissance = new DateTime(DateTime.Now.Year - Int32.Parse(value), 1, 1);
} catch(Exception) {}
}
}
}
[NotMapped]
public string AdresseCP => ModelContext.Getinstance().Preferences.Local[0].VilleCP;
[NotMapped]
public string AdresseVille => ModelContext.Getinstance().Preferences.Local[0].Ville;
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
public void Copyto(Citoyen citoyen) {
citoyen.Id = Id;
citoyen.Civilite = Civilite;
citoyen.Nom = Nom;
citoyen.NomNaissance = NomNaissance;
citoyen.Prenom = Prenom;
citoyen.DateNaissance = DateNaissance;
citoyen.Profession = Profession;
citoyen.TypeResidence = TypeResidence;
citoyen.Mail = Mail;
citoyen.Tel = Tel;
citoyen.TelPort = TelPort;
citoyen.Quartier = Quartier;
citoyen.AdresseNumero = AdresseNumero;
citoyen.AdresseRue = AdresseRue;
citoyen.AdresseBatiment = AdresseBatiment;
citoyen.AdresseExtNumero = AdresseExtNumero;
citoyen.AdresseExtRue = AdresseExtRue;
citoyen.AdresseExtCP = AdresseExtCP;
citoyen.AdresseExtVille = AdresseExtVille;
citoyen.DateCreation = DateCreation;
citoyen.DateModification = DateModification;
}
}
}

25
Model/ModelContext.cs Normal file
View File

@ -0,0 +1,25 @@
using System;
using System.Data.Entity;
using System.IO;
namespace Hermes.Model {
public class ModelContext : DbContext {
private static ModelContext instance = new ModelContext();
public static ModelContext Getinstance() {
return instance;
}
public ModelContext()
: base("Data Source=" + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "hermes.sdf")) {
Database.SetInitializer(new MigrateDatabaseToLatestVersion<ModelContext, Migrations.Configuration>());
}
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
base.OnModelCreating(modelBuilder);
}
public virtual DbSet<Citoyen> CitoyenSet { get; set; }
public virtual DbSet<Preferences> Preferences { get; set; }
}
}

10
Model/Preferences.cs Normal file
View File

@ -0,0 +1,10 @@
using System;
namespace Hermes.Model {
public class Preferences {
public int Id { get; set; }
public string VilleCP { get; set; }
public string Ville { get; set; }
public string SmsApiKey { get; set; }
}
}

37
PreferencesModal.xaml Normal file
View File

@ -0,0 +1,37 @@
<Window x:Class="Hermes.PreferencesModal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Hermes"
mc:Ignorable="d"
Title="Options" Height="250" Width="300"
Icon="hermes.png"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
Closing="Window_Closing">
<Grid>
<StackPanel>
<TabControl Margin="5,5,5,5" MinHeight="160">
<TabItem Header="Général">
<StackPanel Margin="5,5,5,5" VerticalAlignment="Top">
<Label>Code postal :</Label>
<TextBox HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="80"/>
<Label>Ville :</Label>
<TextBox HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="150"/>
</StackPanel>
</TabItem>
<TabItem Header="Envoi de SMS">
<StackPanel Margin="5,5,5,5" VerticalAlignment="Top">
<Label>Clé API ISendPro :</Label>
<TextBox HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="200"/>
</StackPanel>
</TabItem>
</TabControl>
</StackPanel>
<WrapPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10,10,10,10">
<Button Height="25" Margin="0,0,10,0" Width="100">Enregister</Button>
<Button Height="25" Width="100">Annuler</Button>
</WrapPanel>
</Grid>
</Window>

21
PreferencesModal.xaml.cs Normal file
View File

@ -0,0 +1,21 @@
using Hermes.Model;
using System.Windows;
namespace Hermes {
/// <summary>
/// Logique d'interaction pour PreferencesModal.xaml
/// </summary>
public partial class PreferencesModal : Window {
private ModelContext dbContext = null;
public PreferencesModal() {
dbContext = ModelContext.Getinstance();
InitializeComponent();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
this.Hide();
}
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="Citoyen" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>Hermes.Model.Citoyen, Hermes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -1,36 +0,0 @@
<Window x:Class="Hermes.SearchModal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Hermes"
mc:Ignorable="d"
Title="Rechercher" Height="250" Width="370"
ResizeMode="NoResize"
Closing="Window_Closing">
<Grid>
<WrapPanel>
<GroupBox Header="Age" Margin="10,10,0,0" Width="130">
<StackPanel>
<RadioButton Margin="5,5,5,0">Supérieur à</RadioButton>
<RadioButton Margin="5,5,5,0">Inférieur à</RadioButton>
<RadioButton Margin="5,5,5,0">Egal à</RadioButton>
<TextBox Margin="5,5,5,5"/>
</StackPanel>
</GroupBox>
<StackPanel Margin="10,10,0,0">
<Label>Profession :</Label>
<TextBox HorizontalAlignment="Left" Width="130"/>
<Label>Adresse :</Label>
<TextBox Width="200"/>
</StackPanel>
<GroupBox Header="Résidence" Margin="10,10,0,0">
<StackPanel>
<RadioButton Margin="5,5,5,0">Principale</RadioButton>
<RadioButton Margin="5,5,5,5">Secondaire</RadioButton>
</StackPanel>
</GroupBox>
</WrapPanel>
<Button Margin="246,183,10,10">Rechercher</Button>
</Grid>
</Window>

View File

@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Hermes
{
/// <summary>
/// Logique d'interaction pour SearchModal.xaml
/// </summary>
public partial class SearchModal : Window
{
public SearchModal()
{
InitializeComponent();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
this.Hide();
}
}
}

22
Validation/Age.cs Normal file
View File

@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Windows.Controls;
namespace Hermes.Validation {
class Age : ValidationRule {
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
if(string.IsNullOrEmpty((string) value)) {
return ValidationResult.ValidResult;
}
try {
if(Int32.Parse((string) value) <= 0) {
throw new ArgumentException();
}
} catch(Exception) {
return new ValidationResult(false, "Ce champ doit contenir un age au format numérique");
}
return ValidationResult.ValidResult;
}
}
}

View File

@ -0,0 +1,13 @@
using System.Globalization;
using System.Windows.Controls;
namespace Hermes.Validation {
class MandatoryString : ValidationRule {
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
if(string.IsNullOrWhiteSpace((string) value)) {
return new ValidationResult(false, "Ce champ est obligatoire");
}
return ValidationResult.ValidResult;
}
}
}

BIN
hermes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -1,13 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Data.Sqlite" version="3.1.7" targetFramework="net48" />
<package id="Microsoft.Data.Sqlite.Core" version="3.1.7" targetFramework="net48" />
<package id="SQLitePCLRaw.bundle_e_sqlite3" version="2.0.2" targetFramework="net48" />
<package id="SQLitePCLRaw.core" version="2.0.2" targetFramework="net48" />
<package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.2" targetFramework="net48" />
<package id="SQLitePCLRaw.provider.dynamic_cdecl" version="2.0.2" targetFramework="net48" />
<package id="System.Buffers" version="4.4.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.3" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net48" />
<package id="EntityFramework" version="6.4.4" targetFramework="net48" />
<package id="EntityFramework.SqlServerCompact" version="6.4.4" targetFramework="net48" />
<package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework="net48" />
</packages>