Correction de la fonction de publipostage
This commit is contained in:
parent
9c368f4c44
commit
e860a03047
@ -112,6 +112,9 @@
|
||||
<Compile Include="PreferencesModal.xaml.cs">
|
||||
<DependentUpon>PreferencesModal.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SmsWindow.xaml.cs">
|
||||
<DependentUpon>SmsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Validation\Age.cs" />
|
||||
<Compile Include="Validation\MandatoryString.cs" />
|
||||
<Page Include="CitoyenModal.xaml">
|
||||
@ -137,6 +140,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SmsWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
|
@ -48,7 +48,7 @@
|
||||
</MenuItem>
|
||||
<MenuItem Header="Communication">
|
||||
<MenuItem Header="Courriel..." Click="Courriel_Click"/>
|
||||
<MenuItem Header="SMS..."/>
|
||||
<MenuItem Header="SMS..." Click="Sms_Click"/>
|
||||
<MenuItem Header="Publipostage..." Click="Publipostage_Click"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Outils">
|
||||
|
@ -14,6 +14,7 @@ namespace Hermes {
|
||||
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;
|
||||
|
||||
@ -28,6 +29,7 @@ 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");
|
||||
@ -68,17 +70,44 @@ namespace Hermes {
|
||||
}
|
||||
}
|
||||
|
||||
private void Sms_Click(object sender, RoutedEventArgs e) {
|
||||
if(dgCitoyens.SelectedItems.Count > 0) {
|
||||
MessageBoxResult result = MessageBox.Show("Voulez-vous envoyer un SMS à ces citoyens ?", "Envoi de SMS", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if(result == MessageBoxResult.Yes) {
|
||||
bool noTel = false;
|
||||
foreach(Citoyen citoyen in dgCitoyens.SelectedItems) {
|
||||
if(String.IsNullOrWhiteSpace(citoyen.TelPort)) {
|
||||
noTel = true;
|
||||
}
|
||||
}
|
||||
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.ShowDialog();
|
||||
}
|
||||
} else {
|
||||
MessageBox.Show("Aucun citoyen sélectionné", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Courriel_Click(object sender, RoutedEventArgs e) {
|
||||
if(dgCitoyens.SelectedItems.Count > 0) {
|
||||
MessageBoxResult result = MessageBox.Show("Voulez-vous envoyer un courriel à ces citoyens ?", "Envoi de courriel", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if(result == MessageBoxResult.Yes) {
|
||||
bool noMail = false;
|
||||
List<string> mails = new List<string>();
|
||||
foreach(Citoyen citoyen in dgCitoyens.SelectedItems) {
|
||||
if(!String.IsNullOrWhiteSpace(citoyen.Mail)) {
|
||||
mails.Add(citoyen.Mail);
|
||||
mails.Add(citoyen.Mail);
|
||||
} else {
|
||||
noMail = true;
|
||||
}
|
||||
}
|
||||
if(mails.Count > 0) {
|
||||
if(noMail) {
|
||||
MessageBox.Show("Certains des citoyens sélectionnés ne disposent pas d'une adresse E-Mail", "Envoi de courriel", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
|
||||
Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
|
||||
foreach(string mail in mails) {
|
||||
@ -93,7 +122,7 @@ namespace Hermes {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageBox.Show("Aucun citoyen sélectionné", "Suppression", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
MessageBox.Show("Aucun citoyen sélectionné", "Envoi de courriel", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
}
|
||||
|
||||
|
23
SmsWindow.xaml
Normal file
23
SmsWindow.xaml
Normal file
@ -0,0 +1,23 @@
|
||||
<Window x:Class="Hermes.SmsWindow"
|
||||
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"
|
||||
Title="Envoi de SMS" Height="370" Width="500"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closing="Window_Closing">
|
||||
<Grid Background="WhiteSmoke">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="290"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<RichTextBox Margin="5" Grid.Row="0" FontSize="15" Block.LineHeight="2" VerticalScrollBarVisibility="Visible"/>
|
||||
<WrapPanel Grid.Row="1" Margin="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||
<Button Margin="0,0,10,0" Height="25" Width="100" IsDefault="True" Click="Envoyer_Click">Envoyer</Button>
|
||||
<Button Height="25" Width="100" Click="Annuler_Click">Annuler</Button>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Window>
|
23
SmsWindow.xaml.cs
Normal file
23
SmsWindow.xaml.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Windows;
|
||||
|
||||
|
||||
namespace Hermes {
|
||||
public partial class SmsWindow : Window {
|
||||
public SmsWindow() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
e.Cancel = true;
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
public void Envoyer_Click(object sender, RoutedEventArgs e) {
|
||||
MessageBox.Show("Erreur lors de la tentative d'envoi : Clé IsendPro invalide", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
public void Annuler_Click(object sender, RoutedEventArgs e) {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user