Traitement des tickets : #2 , #6 , #7 , #8

This commit is contained in:
Valentin Verdier 2020-12-06 21:54:59 +01:00
parent c945890625
commit 3efd7948a0
14 changed files with 320 additions and 111 deletions

View File

@ -1,4 +1,4 @@
<Window x:Class="Hermes.CitoyenModal"
<Window x:Class="Hermes.CitoyenWindow"
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"
@ -9,9 +9,7 @@
ResizeMode="NoResize"
xmlns:Validation="clr-namespace:Hermes.Validation"
xmlns:Converter="clr-namespace:Hermes.Converter"
Loaded="Window_Loaded"
WindowStartupLocation="CenterOwner"
Closing="Window_Closing">
WindowStartupLocation="CenterOwner">
<Window.Resources>
<Converter:NegateBoolean x:Key="NegateBoolean"/>

View File

@ -6,30 +6,27 @@ using System.Windows.Controls;
using System.Windows.Data;
namespace Hermes {
public partial class CitoyenModal : Window {
private ModelContext dbContext = null;
private Citoyen citoyen = null;
public partial class CitoyenWindow : Window {
private Citoyen editRef = 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");
public CitoyenWindow(Window parent, Citoyen context = null) {
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
civiliteComboBox.ItemsSource = Civilites;
}
DataContext = new Citoyen();
Owner = parent;
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
this.Hide();
if(context != null) {
editRef = context;
editRef.Copyto((Citoyen) DataContext);
} else {
((Citoyen) DataContext).Civilite = "Monsieur";
}
List<string> civilites = new List<string>();
civilites.Add("Monsieur");
civilites.Add("Madame");
civiliteComboBox.ItemsSource = civilites;
}
private void ValidationError(object sender, ValidationErrorEventArgs e) {
@ -50,20 +47,6 @@ namespace Hermes {
}
}
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();
@ -71,25 +54,22 @@ namespace Hermes {
ageTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
adresseTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if(_isInvalidElements.Count == 0) {
if(_modeCreate) {
ModelContext dbContext = ModelContext.Getinstance();
if(editRef == null) {
((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;
Citoyen context = (Citoyen) DataContext;
context.Copyto(editRef);
editRef.DateModification = DateTime.Now;
}
DataContext = null;
dbContext.SaveChanges();
Close();
}
}
public void Cancel_Click(object sender, RoutedEventArgs e) {
DataContext = null;
citoyen = null;
Close();
}
}

View File

@ -110,6 +110,9 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converter\NegateBoolean.cs" />
<Compile Include="InputWindow.xaml.cs">
<DependentUpon>InputWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Migrations\202012051414539_V1.cs" />
<Compile Include="Migrations\202012051414539_V1.designer.cs">
<DependentUpon>202012051414539_V1.cs</DependentUpon>
@ -118,8 +121,8 @@
<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 Include="PreferencesWindow.xaml.cs">
<DependentUpon>PreferencesWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SmsSendingStatus.cs" />
<Compile Include="SmsWindow.xaml.cs">
@ -127,7 +130,11 @@
</Compile>
<Compile Include="Validation\Age.cs" />
<Compile Include="Validation\MandatoryString.cs" />
<Page Include="CitoyenModal.xaml">
<Page Include="CitoyenWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="InputWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@ -139,14 +146,14 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="CitoyenModal.xaml.cs">
<DependentUpon>CitoyenModal.xaml</DependentUpon>
<Compile Include="CitoyenWindow.xaml.cs">
<DependentUpon>CitoyenWindow.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="PreferencesModal.xaml">
<Page Include="PreferencesWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>

View File

@ -18,7 +18,9 @@ Global
{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
{F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Debug|Any CPU.ActiveCfg = Debug
{F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Debug|Any CPU.Build.0 = Debug
{F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Release|Any CPU.ActiveCfg = Release
{F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Release|Any CPU.Build.0 = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

25
InputWindow.xaml Normal file
View File

@ -0,0 +1,25 @@
<Window x:Class="Hermes.InputWindow"
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"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
Title="" Height="140" Width="250">
<Grid Background="WhiteSmoke">
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="10" VerticalAlignment="Center">
<TextBlock Name="msgTextBlock" Margin="0,0,0,10"/>
<TextBox Name="inputTextBox" Height="23" HorizontalAlignment="Left" Width="200"/>
</StackPanel>
<WrapPanel Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0">
<Button Margin="0,0,10,0" Height="25" Width="80" IsDefault="True" Click="Valider_Click">Valider</Button>
<Button Height="25" Width="80" Click="Annuler_Click">Annuler</Button>
</WrapPanel>
</Grid>
</Window>

26
InputWindow.xaml.cs Normal file
View File

@ -0,0 +1,26 @@
using System.Windows;
namespace Hermes {
public partial class InputWindow : Window {
private string inputText = null;
public InputWindow(string title, string message, Window parent) {
InitializeComponent();
msgTextBlock.Text = message;
Title = title;
Owner = parent;
}
private void Valider_Click(object sender, RoutedEventArgs e) {
inputText = inputTextBox.Text;
DialogResult = true;
Close();
}
private void Annuler_Click(object sender, RoutedEventArgs e) {
Close();
}
public string InputText => inputText;
}
}

View File

@ -99,12 +99,30 @@
}
"Entry"
{
"MsmKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65"
"OwnerKey" = "8:_C4AD2B19587A5D3179211CF729B66A33"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65"
"OwnerKey" = "8:_EDA497A114444E23814EEE023731C727"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_A3A39C8B97A947A09D3B1660AC88FF5E"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_C4AD2B19587A5D3179211CF729B66A33"
"OwnerKey" = "8:_EDA497A114444E23814EEE023731C727"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_C767BE5A43214C2C9E31CD47DB92AA96"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@ -147,6 +165,24 @@
}
"Entry"
{
"MsmKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4"
"OwnerKey" = "8:_C4AD2B19587A5D3179211CF729B66A33"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4"
"OwnerKey" = "8:_EDA497A114444E23814EEE023731C727"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4"
"OwnerKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_EDA497A114444E23814EEE023731C727"
"MsmSig" = "8:_UNDEFINED"
@ -154,6 +190,24 @@
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_C4AD2B19587A5D3179211CF729B66A33"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_F0A5B43231BDF6E8358EE22CD3E2D5F2"
"MsmSig" = "8:_UNDEFINED"
}
@ -208,10 +262,10 @@
"ComponentsUrl" = "8:"
"Items"
{
"{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.7.2"
"{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.8"
{
"Name" = "8:Microsoft .NET Framework 4.7.2 (x86 and x64)"
"ProductCode" = "8:.NETFramework,Version=v4.7.2"
"Name" = "8:Microsoft .NET Framework 4.8 (x86 et x64)"
"ProductCode" = "8:.NETFramework,Version=v4.8"
}
}
}
@ -549,6 +603,37 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A0F83BCCDBA77804851DAAE18F54AC65"
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:RestSharp.Net2, Version=102.7.0.0, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_A0F83BCCDBA77804851DAAE18F54AC65"
{
"Name" = "8:RestSharp.Net2.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:RestSharp.Net2.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A3A39C8B97A947A09D3B1660AC88FF5E"
{
"SourcePath" = "8:..\\bin\\Release\\amd64\\sqlcecompact40.dll"
@ -569,6 +654,37 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_C4AD2B19587A5D3179211CF729B66A33"
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:isendpro, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_C4AD2B19587A5D3179211CF729B66A33"
{
"Name" = "8:isendpro.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:isendpro.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C767BE5A43214C2C9E31CD47DB92AA96"
{
"SourcePath" = "8:..\\bin\\Release\\amd64\\sqlceqp40.dll"
@ -691,6 +807,37 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_F434633E0B073F068C7E19B9E5AB2EC4"
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_F434633E0B073F068C7E19B9E5AB2EC4"
{
"Name" = "8:Newtonsoft.Json.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:Newtonsoft.Json.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
}
"FileType"
{
@ -769,15 +916,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Hermes"
"ProductCode" = "8:{458A9AC9-956F-44DC-86F1-6C59FCEC0001}"
"PackageCode" = "8:{C3692850-4A0E-43FE-B6D1-0FFE749C3562}"
"ProductCode" = "8:{D2CA66FB-020C-41EF-BD0D-991FFC306669}"
"PackageCode" = "8:{89CBF16D-49D3-4DE5-9CEE-4CE55ADD05AE}"
"UpgradeCode" = "8:{A8FB75F3-57A5-4B7D-A0AE-9E87F69529B0}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:0.9.0"
"ProductVersion" = "8:0.9.1"
"Manufacturer" = "8:Aztrom"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
@ -1319,7 +1466,7 @@
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_EDA497A114444E23814EEE023731C727"
{
"SourcePath" = "8:..\\obj\\Release\\Hermes.exe"
"SourcePath" = "8:..\\obj\\Debug\\Hermes.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0"

View File

@ -22,8 +22,12 @@
<MenuItem Header="Fichier">
<MenuItem Header="Quitter" Click="Quitter_Click"/>
</MenuItem>
<MenuItem Header="Edition">
<MenuItem Header="Édition">
<MenuItem Header="Ajouter..." Click="Ajouter_Click"/>
<MenuItem Header="Édition groupée">
<MenuItem Header="Quartier" Click="GroupEdit_Quartier"/>
<MenuItem Header="Bâtiment" Click="GroupEdit_Batiment"/>
</MenuItem>
<MenuItem Header="Supprimer" Click="Supprimer_Click"/>
</MenuItem>
<MenuItem Header="Affichage">

View File

@ -12,9 +12,6 @@ using Microsoft.Win32;
namespace Hermes {
public partial class MainWindow : Window {
private ModelContext dbContext = null;
private CitoyenModal citoyenModal = new CitoyenModal();
private PreferencesModal preferencesModal = new PreferencesModal();
private SmsWindow smsModal = new SmsWindow();
private CollectionViewSource citoyenCollectionViewSource = null;
private bool isEnabledFilter = false;
@ -27,9 +24,6 @@ namespace Hermes {
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
citoyenModal.Owner = this;
preferencesModal.Owner = this;
smsModal.Owner = this;
dbContext.CitoyenSet.Load();
dbContext.Preferences.Load();
citoyenCollectionViewSource = (CollectionViewSource) this.FindResource("citoyenCollectionViewSource");
@ -37,19 +31,51 @@ namespace Hermes {
if(dbContext.Preferences.Local.Count == 0) {
MessageBox.Show("Il s'agit du premier lancement de Hermes. Veuillez renseigner les informations sur votre commune.", "Premier lancement", MessageBoxButton.OK, MessageBoxImage.None);
preferencesModal.LoadPreferences();
preferencesModal.ShowDialog();
PreferencesWindow preferencesWindow = new PreferencesWindow(this);
preferencesWindow.ShowDialog();
}
}
private void Options_Click(object sender, RoutedEventArgs e) {
preferencesModal.LoadPreferences();
preferencesModal.ShowDialog();
PreferencesWindow preferencesWindow = new PreferencesWindow(this);
preferencesWindow.ShowDialog();
}
private void Ajouter_Click(object sender, RoutedEventArgs e) {
citoyenModal.EnableCreateMode();
citoyenModal.ShowDialog();
CitoyenWindow citoyenWindow = new CitoyenWindow(this);
citoyenWindow.ShowDialog();
}
private void GroupEdit_Batiment(object sender, RoutedEventArgs e) {
if(dgCitoyens.SelectedItems.Count == 0) {
MessageBox.Show("Aucun citoyen sélectionné", "Édition groupée", MessageBoxButton.OK, MessageBoxImage.Exclamation);
return;
}
InputWindow inputBox = new InputWindow("Associer un bâtiment :", "Entrez le nom d'un bâtiment :", this);
if(inputBox.ShowDialog() == true) {
foreach(Citoyen citoyen in dgCitoyens.SelectedItems) {
citoyen.AdresseBatiment = inputBox.InputText;
citoyen.DateModification = DateTime.Now;
}
dbContext.SaveChanges();
}
}
private void GroupEdit_Quartier(object sender, RoutedEventArgs e) {
if(dgCitoyens.SelectedItems.Count == 0) {
MessageBox.Show("Aucun citoyen sélectionné", "Édition groupée", MessageBoxButton.OK, MessageBoxImage.Exclamation);
return;
}
InputWindow inputBox = new InputWindow("Associer un quartier :", "Entrez le nom d'un quartier :", this);
if(inputBox.ShowDialog() == true) {
foreach(Citoyen citoyen in dgCitoyens.SelectedItems) {
citoyen.Quartier = inputBox.InputText;
citoyen.DateModification = DateTime.Now;
}
dbContext.SaveChanges();
}
}
private void Supprimer_Click(object sender, RoutedEventArgs e) {
@ -87,8 +113,8 @@ namespace Hermes {
if(noTel) {
MessageBox.Show("Certains des citoyens sélectionnés ne disposent pas d'un numéro de mobile", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
smsModal.LoadCitoyens(rcps);
smsModal.ShowDialog();
SmsWindow smsWindow = new SmsWindow(this, rcps);
smsWindow.ShowDialog();
} else {
MessageBox.Show("Aucun des citoyens sélectionnés ne disposent d'un numéro de mobile", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
@ -183,8 +209,8 @@ namespace Hermes {
private void DgCitoyen_DoubleClick(object sender, MouseButtonEventArgs e) {
if(dgCitoyens.SelectedItem != null) {
citoyenModal.EnableEditMode((Citoyen) dgCitoyens.SelectedItem);
citoyenModal.ShowDialog();
CitoyenWindow citoyenWindow = new CitoyenWindow(this, (Citoyen) dgCitoyens.SelectedItem);
citoyenWindow.ShowDialog();
}
}

View File

@ -1,4 +1,4 @@
<Window x:Class="Hermes.PreferencesModal"
<Window x:Class="Hermes.PreferencesWindow"
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"

View File

@ -3,20 +3,15 @@ using System;
using System.Windows;
namespace Hermes {
public partial class PreferencesModal : Window {
public partial class PreferencesWindow : Window {
private ModelContext dbContext = null;
public PreferencesModal() {
dbContext = ModelContext.Getinstance();
public PreferencesWindow(Window parent) {
InitializeComponent();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
this.Hide();
}
Owner = parent;
dbContext = ModelContext.Getinstance();
public void LoadPreferences() {
if(dbContext.Preferences.Local.Count > 0) {
Preferences pref = dbContext.Preferences.Local[0];
villeTextBox.Text = pref.Ville;
@ -25,6 +20,13 @@ namespace Hermes {
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
if(dbContext.Preferences.Local.Count == 0) {
MessageBox.Show("La saisie d'information sur la commune est obligatoire.", "Saisie obligatoire", MessageBoxButton.OK, MessageBoxImage.Warning);
e.Cancel = true;
}
}
public void Enregistrer_Click(object sender, RoutedEventArgs e) {
if(String.IsNullOrWhiteSpace(villeCPTextBox.Text) || String.IsNullOrWhiteSpace(villeTextBox.Text)) {
MessageBox.Show("La saisie d'information sur la commune est obligatoire.", "Saisie obligatoire", MessageBoxButton.OK, MessageBoxImage.Warning);

View File

@ -51,6 +51,6 @@ using System.Windows;
// 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("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]
[assembly: AssemblyVersion("0.9.1.0")]
[assembly: AssemblyFileVersion("0.9.1.0")]
[assembly: NeutralResourcesLanguage("fr-FR")]

View File

@ -8,7 +8,6 @@
ResizeMode="NoResize"
Title="Envoi de SMS" Height="490" Width="700"
WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"
Closing="Window_Closing">
<Grid Background="WhiteSmoke">
<Grid.RowDefinitions>

View File

@ -12,43 +12,33 @@ using System.Windows.Documents;
namespace Hermes {
public partial class SmsWindow : Window {
private ObservableCollection<SmsSendingStatus> status = new ObservableCollection<SmsSendingStatus>();
private ModelContext dbContext = null;
private ApiClient apiClient = new ApiClient();
private SmsApi smsApi = null;
private bool sending = false;
public SmsWindow() {
dbContext = ModelContext.Getinstance();
smsApi = new SmsApi(apiClient);
public SmsWindow(Window parent, List<Citoyen> rcps) {
InitializeComponent();
}
Owner = parent;
foreach(Citoyen rcp in rcps) {
SmsSendingStatus s = new SmsSendingStatus();
s.Nom = rcp.Nom;
s.Prenom = rcp.Prenom;
s.Mobile = rcp.TelPort.Replace(" ", "");
s.Status = "En attente";
status.Add(s);
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
lvLog.ItemsSource = status;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
if(sending) {
e.Cancel = true;
return;
}
messageTextBox.Document.Blocks.Clear();
status.Clear();
this.Hide();
}
public void LoadCitoyens(List<Citoyen> citoyens) {
foreach(Citoyen citoyen in citoyens) {
SmsSendingStatus s = new SmsSendingStatus();
s.Nom = citoyen.Nom;
s.Prenom = citoyen.Prenom;
s.Mobile = citoyen.TelPort.Replace(" ", "");
s.Status = "En attente";
status.Add(s);
}
}
public void Envoyer_Click(object sender, RoutedEventArgs e) {
ModelContext dbContext = ModelContext.Getinstance();
bool error = false;
string message = new TextRange(messageTextBox.Document.ContentStart, messageTextBox.Document.ContentEnd).Text;
string apiKey = dbContext.Preferences.Local[0].SmsApiKey;
@ -68,6 +58,9 @@ namespace Hermes {
messageTextBox.IsEnabled = false;
sending = true;
ApiClient apiClient = new ApiClient();
SmsApi smsApi = new SmsApi(apiClient);
foreach(SmsSendingStatus stat in status) {
if(!stat.Status.Equals("Envoyé")) {
SmsUniqueRequest req = new SmsUniqueRequest();