Commit initial

This commit is contained in:
Valentin Verdier 2020-09-07 22:24:37 +02:00
parent 5d235a759c
commit 1bcaa3c841
20 changed files with 985 additions and 0 deletions

6
App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

10
App.xaml Normal file
View File

@ -0,0 +1,10 @@
<Application x:Class="Hermes.App"
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>
</Application>

20
App.xaml.cs Normal file
View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Hermes
{
/// <summary>
/// Logique d'interaction pour App.xaml
/// </summary>
public partial class App : Application
{
private void Application_Exit(object sender, ExitEventArgs e) {
DataAccess.CloseConnection();
}
}
}

53
Citoyen.cs Normal file
View File

@ -0,0 +1,53 @@
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;
}
}
}

153
CitoyenDAO.cs Normal file
View File

@ -0,0 +1,153 @@
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();
}
}
}

42
CitoyenModal.xaml Normal file
View File

@ -0,0 +1,42 @@
<Window x:Class="Hermes.CitoyenModal"
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="Informations" Height="279" Width="640"
ResizeMode="NoResize"
Closing="Window_Closing">
<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>
</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"/>
</StackPanel>
</GroupBox>
</WrapPanel>
<Button Margin="516,212,10,10">OK</Button>
</Grid>
</Window>

32
CitoyenModal.xaml.cs Normal file
View File

@ -0,0 +1,32 @@
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 CitoyenModal.xaml
/// </summary>
public partial class CitoyenModal : Window
{
public CitoyenModal()
{
InitializeComponent();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
this.Hide();
}
}
}

44
DataAccess.cs Normal file
View File

@ -0,0 +1,44 @@
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;
}
}
}
}

153
Hermes.csproj Normal file
View File

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2F7FDF03-5F05-438E-9C90-F926B40DCC6D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Hermes</RootNamespace>
<AssemblyName>Hermes</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<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>
<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>
<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>
<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.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>
<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.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="SearchModal.xaml.cs">
<DependentUpon>SearchModal.xaml</DependentUpon>
</Compile>
<Page Include="CitoyenModal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<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">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</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'))" />
</Target>
</Project>

25
Hermes.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30330.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hermes", "Hermes.csproj", "{2F7FDF03-5F05-438E-9C90-F926B40DCC6D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2F7FDF03-5F05-438E-9C90-F926B40DCC6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F7FDF03-5F05-438E-9C90-F926B40DCC6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F7FDF03-5F05-438E-9C90-F926B40DCC6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F7FDF03-5F05-438E-9C90-F926B40DCC6D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {883D0F2A-F831-488D-8896-1BE1A816E072}
EndGlobalSection
EndGlobal

36
MainWindow.xaml Normal file
View File

@ -0,0 +1,36 @@
<Window x:Class="Hermes.MainWindow"
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="Hermes" Height="450" Width="800">
<StackPanel>
<Menu>
<MenuItem Header="Fichier">
<MenuItem Header="Exporter..."/>
<MenuItem Header="Importer..."/>
</MenuItem>
<MenuItem Header="Outils">
<MenuItem Header="Ajouter..." Click="Ajouter_Click"/>
<MenuItem Header="Rechercher..." Click="Rechercher_Click"/>
<MenuItem Header="Actualiser"/>
</MenuItem>
</Menu>
<Grid>
<DataGrid Name="dgCitoyens" AutoGenerateColumns="False" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Nom" Binding="{Binding Nom}" 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="Résidence" Binding="{Binding TypeResidenceLabel}" Width="*"/>
<DataGridTextColumn Header="E-Mail" Binding="{Binding Mail}" Width="*"/>
<DataGridTextColumn Header="Téléphone" Binding="{Binding Tel}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</StackPanel>
</Window>

50
MainWindow.xaml.cs Normal file
View File

@ -0,0 +1,50 @@
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.Navigation;
using System.Windows.Shapes;
namespace Hermes
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private CitoyenModal citoyenModal = new CitoyenModal();
private SearchModal searchModal = new SearchModal();
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)
{
citoyenModal.ShowDialog();
}
private void Rechercher_Click(object sender, RoutedEventArgs e)
{
searchModal.ShowDialog();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
Application.Current.Shutdown();
}
}
}

View File

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Hermes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Hermes")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur True à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
//Pour commencer à générer des applications localisables, définissez
//<UICulture>CultureUtiliséePourCoder</UICulture> dans votre fichier .csproj
//dans <PropertyGroup>. Par exemple, si vous utilisez le français
//dans vos fichiers sources, définissez <UICulture> à fr-FR. Puis, supprimez les marques de commentaire de
//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
//(utilisé si une ressource est introuvable dans la page,
// ou dictionnaires de ressources de l'application)
ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
//(utilisé si une ressource est introuvable dans la page,
// dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
)]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

71
Properties/Resources.Designer.cs generated Normal file
View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Hermes.Properties
{
/// <summary>
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
/// </summary>
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
// avec l'option /str ou régénérez votre projet VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Hermes.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

117
Properties/Resources.resx Normal file
View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
Properties/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Hermes.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

36
SearchModal.xaml Normal file
View File

@ -0,0 +1,36 @@
<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>

32
SearchModal.xaml.cs Normal file
View File

@ -0,0 +1,32 @@
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();
}
}
}

13
packages.config Normal file
View File

@ -0,0 +1,13 @@
<?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" />
</packages>