MailWindow: Make more user safe
All checks were successful
Test / Run tests (push) Successful in 1m50s
All checks were successful
Test / Run tests (push) Successful in 1m50s
This commit is contained in:
@ -86,14 +86,16 @@
|
|||||||
<Label x:Name="DocumentFooterLabel" Content="Fußtext:" Margin="10,40,0,10"/>
|
<Label x:Name="DocumentFooterLabel" Content="Fußtext:" Margin="10,40,0,10"/>
|
||||||
<TextBox x:Name="DeliveryConfirmationFooterInput" Grid.Column="1"
|
<TextBox x:Name="DeliveryConfirmationFooterInput" Grid.Column="1"
|
||||||
Margin="0,40,10,10" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
|
Margin="0,40,10,10" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
|
||||||
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap"/>
|
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap"
|
||||||
|
TextChanged="DocumentInput_TextChanged"/>
|
||||||
<TextBox x:Name="CreditNoteFooterInput" Grid.Column="1"
|
<TextBox x:Name="CreditNoteFooterInput" Grid.Column="1"
|
||||||
Margin="0,10,10,10" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
|
Margin="0,10,10,10" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
|
||||||
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap"/>
|
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap"
|
||||||
|
TextChanged="DocumentInput_TextChanged"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<TextBox x:Name="PostalLocation" Grid.Column="1"
|
<TextBox x:Name="PostalLocation" Grid.Column="1" TextChanged="PostalLocation_TextChanged"
|
||||||
Margin="10,30,10,10" Width="120" HorizontalAlignment="Left"/>
|
Margin="10,30,10,10" Width="120" HorizontalAlignment="Left"/>
|
||||||
<Label Content=", am" Margin="130,30,10,10" FontSize="14" Grid.Column="1"/>
|
<Label Content=", am" Margin="130,30,10,10" FontSize="14" Grid.Column="1"/>
|
||||||
<TextBox x:Name="PostalDate" Grid.Column="1" Text="01.01.2020"
|
<TextBox x:Name="PostalDate" Grid.Column="1" Text="01.01.2020"
|
||||||
@ -195,41 +197,42 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<GroupBox Header="Zusenden an..." Margin="10,10,10,10" Height="150" Width="220" VerticalAlignment="Top" HorizontalAlignment="Left">
|
<GroupBox Header="Zusenden an..." Margin="10,10,10,10" Height="150" Width="220" VerticalAlignment="Top" HorizontalAlignment="Left">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<RadioButton x:Name="PostalAllInput" Margin="10,10,10,2.5">
|
<RadioButton x:Name="PostalAllInput" Margin="10,10,10,2.5" Click="PostalInput_Changed">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
... alle (<Run Text="{Binding Path=PostalAllCount, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MailWindow}}}"/>)
|
...alle (<Run Text="{Binding Path=PostalAllCount, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MailWindow}}}"/>)
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton x:Name="PostalWishInput" Margin="10,2.5,10,2.5" IsChecked="True">
|
<RadioButton x:Name="PostalWishInput" Margin="10,2.5,10,2.5" Click="PostalInput_Changed" IsChecked="True">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
...Mitglieder, die Zusendung<LineBreak/>
|
...Mitglieder, die Zusendung<LineBreak/>
|
||||||
per Post wünschen (<Run Text="{Binding Path=PostalWishCount, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MailWindow}}}"/>)
|
per Post wünschen (<Run Text="{Binding Path=PostalWishCount, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MailWindow}}}"/>)
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton x:Name="PostalNoEmailInput" Margin="10,2.5,10,2.5">
|
<RadioButton x:Name="PostalNoEmailInput" Margin="10,2.5,10,2.5" Click="PostalInput_Changed">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
...Mitglieder, die keine<LineBreak/>
|
...Mitglieder, die keine<LineBreak/>
|
||||||
E-Mail erhalten würden (<Run Text="{Binding Path=PostalNoEmailCount, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MailWindow}}}"/>)
|
E-Mail erhalten würden (<Run Text="{Binding Path=PostalNoEmailCount, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MailWindow}}}"/>)
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton x:Name="PostalNobodyInput" Margin="10,2.5,10,10" Content="...niemanden (0)"/>
|
<RadioButton x:Name="PostalNobodyInput" Margin="10,2.5,10,10" Content="...niemanden (0)" Click="PostalInput_Changed"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<GroupBox Header="Sortieren nach" Margin="10,180,10,10" Width="180" Height="80" VerticalAlignment="Top" HorizontalAlignment="Left">
|
<GroupBox Header="Sortieren nach" Margin="10,180,10,10" Width="180" Height="80" VerticalAlignment="Top" HorizontalAlignment="Left">
|
||||||
<StackPanel Margin="5,5,0,5">
|
<StackPanel Margin="5,5,0,5">
|
||||||
<RadioButton GroupName="Order" x:Name="OrderMgNrInput" Content="Mitgliedsnummer" IsChecked="True"/>
|
<RadioButton GroupName="Order" x:Name="OrderMgNrInput" Content="Mitgliedsnummer" Click="OrderInput_Changed" IsChecked="True"/>
|
||||||
<RadioButton GroupName="Order" x:Name="OrderNameInput" Content="Name"/>
|
<RadioButton GroupName="Order" x:Name="OrderNameInput" Content="Name" Click="OrderInput_Changed"/>
|
||||||
<RadioButton GroupName="Order" x:Name="OrderPlzInput" Content="PLZ, Ort, Name"/>
|
<RadioButton GroupName="Order" x:Name="OrderPlzInput" Content="PLZ, Ort, Name" Click="OrderInput_Changed"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<CheckBox x:Name="DoublePagedInput" Margin="20,270,10,10" Content="Doppelseitig drucken"
|
<CheckBox x:Name="DoublePagedInput" Margin="20,270,10,10" Content="Doppelseitig drucken"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||||
|
Checked="DoublePagedInput_Changed" Unchecked="DoublePagedInput_Changed"/>
|
||||||
|
|
||||||
<TextBox x:Name="PostalSender1" IsEnabled="False"
|
<TextBox x:Name="PostalSender1" TextChanged="PostalSender_TextChanged" IsEnabled="False"
|
||||||
Margin="10,300,10,10"/>
|
Margin="10,300,10,10"/>
|
||||||
<TextBox x:Name="PostalSender2"
|
<TextBox x:Name="PostalSender2" TextChanged="PostalSender_TextChanged"
|
||||||
Margin="10,330,10,10"/>
|
Margin="10,330,10,10"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
@ -200,6 +200,48 @@ namespace Elwig.Windows {
|
|||||||
await UpdateRecipients(ctx);
|
await UpdateRecipients(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ResetDocuments() {
|
||||||
|
DisposeDocs();
|
||||||
|
if (IsLoaded) {
|
||||||
|
PreviewButton.IsEnabled = false;
|
||||||
|
PrintButton.IsEnabled = false;
|
||||||
|
EmailButton.IsEnabled = false;
|
||||||
|
ProgressBar.Value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LockInputs() {
|
||||||
|
DocumentAddButton.IsEnabled = false;
|
||||||
|
DocumentRemoveButton.IsEnabled = false;
|
||||||
|
SelectDocumentButton.IsEnabled = false;
|
||||||
|
foreach (var tb in ControlUtils.FindAllChildren<TextBox>(this, []))
|
||||||
|
tb.IsReadOnly = true;
|
||||||
|
foreach (var cb in ControlUtils.FindAllChildren<ComboBox>(this, []))
|
||||||
|
cb.IsEnabled = false;
|
||||||
|
foreach (var cb in ControlUtils.FindAllChildren<CheckBox>(this, []))
|
||||||
|
cb.IsEnabled = false;
|
||||||
|
foreach (var lb in ControlUtils.FindAllChildren<ListBox>(this, []))
|
||||||
|
lb.IsEnabled = false;
|
||||||
|
foreach (var rb in ControlUtils.FindAllChildren<RadioButton>(this, []))
|
||||||
|
rb.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnlockInputs() {
|
||||||
|
DocumentAddButton.IsEnabled = true;
|
||||||
|
DocumentRemoveButton.IsEnabled = true;
|
||||||
|
SelectDocumentButton.IsEnabled = true;
|
||||||
|
foreach (var tb in ControlUtils.FindAllChildren<TextBox>(this, []))
|
||||||
|
tb.IsReadOnly = false;
|
||||||
|
foreach (var cb in ControlUtils.FindAllChildren<ComboBox>(this, []))
|
||||||
|
cb.IsEnabled = true;
|
||||||
|
foreach (var cb in ControlUtils.FindAllChildren<CheckBox>(this, []))
|
||||||
|
cb.IsEnabled = true;
|
||||||
|
foreach (var lb in ControlUtils.FindAllChildren<ListBox>(this, []))
|
||||||
|
lb.IsEnabled = true;
|
||||||
|
foreach (var rb in ControlUtils.FindAllChildren<RadioButton>(this, []))
|
||||||
|
rb.IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void ContinueButton_Click(object sender, RoutedEventArgs evt) {
|
private void ContinueButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
TabControl.SelectedIndex = 1;
|
TabControl.SelectedIndex = 1;
|
||||||
TabControl.AllowDrop = false;
|
TabControl.AllowDrop = false;
|
||||||
@ -210,7 +252,7 @@ namespace Elwig.Windows {
|
|||||||
TabControl.AllowDrop = true;
|
TabControl.AllowDrop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Document_Drop(object sender, DragEventArgs evt) {
|
private async void Document_Drop(object sender, DragEventArgs evt) {
|
||||||
if (evt.Data.GetDataPresent(DataFormats.FileDrop)) {
|
if (evt.Data.GetDataPresent(DataFormats.FileDrop)) {
|
||||||
var files = (string[])evt.Data.GetData(DataFormats.FileDrop);
|
var files = (string[])evt.Data.GetData(DataFormats.FileDrop);
|
||||||
foreach (var file in files) {
|
foreach (var file in files) {
|
||||||
@ -218,6 +260,8 @@ namespace Elwig.Windows {
|
|||||||
SelectedDocs.Add(new(DocType.Custom, Path.GetFileName(file), file));
|
SelectedDocs.Add(new(DocType.Custom, Path.GetFileName(file), file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
using var ctx = new AppDbContext();
|
||||||
|
await UpdateRecipients(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,8 +304,9 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DocumentAddButton_Click(object sender, RoutedEventArgs evt) {
|
private async void DocumentAddButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var idx = AvaiableDocumentsList.SelectedIndex;
|
var idx = AvaiableDocumentsList.SelectedIndex;
|
||||||
|
using var ctx = new AppDbContext();
|
||||||
if (AvaiableDocumentsList.SelectedItem is not string s)
|
if (AvaiableDocumentsList.SelectedItem is not string s)
|
||||||
return;
|
return;
|
||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
@ -270,20 +315,22 @@ namespace Elwig.Windows {
|
|||||||
SelectedDocs.Add(new(DocType.DeliveryConfirmation, s, (Year, DocumentNonDeliverersInput.IsChecked == true)));
|
SelectedDocs.Add(new(DocType.DeliveryConfirmation, s, (Year, DocumentNonDeliverersInput.IsChecked == true)));
|
||||||
RecipientsDeliveryMembersInput.IsChecked = true;
|
RecipientsDeliveryMembersInput.IsChecked = true;
|
||||||
} else if (idx >= 2) {
|
} else if (idx >= 2) {
|
||||||
using var ctx = new AppDbContext();
|
|
||||||
var name = s.Split(" – ")[^1];
|
var name = s.Split(" – ")[^1];
|
||||||
var pv = ctx.PaymentVariants.Single(v => v.Year == Year && v.Name == name)!;
|
var pv = await ctx.PaymentVariants.SingleAsync(v => v.Year == Year && v.Name == name)!;
|
||||||
SelectedDocs.Add(new(DocType.CreditNote, s, (pv.Year, pv.AvNr)));
|
SelectedDocs.Add(new(DocType.CreditNote, s, (pv.Year, pv.AvNr)));
|
||||||
RecipientsDeliveryMembersInput.IsChecked = true;
|
RecipientsDeliveryMembersInput.IsChecked = true;
|
||||||
}
|
}
|
||||||
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
||||||
|
await UpdateRecipients(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DocumentRemoveButton_Click(object sender, RoutedEventArgs evt) {
|
private async void DocumentRemoveButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
DeleteCommand.Execute(null);
|
DeleteCommand.Execute(null);
|
||||||
|
using var ctx = new AppDbContext();
|
||||||
|
await UpdateRecipients(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectDocumentButton_Click(object sender, RoutedEventArgs evt) {
|
private async void SelectDocumentButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var d = new OpenFileDialog() {
|
var d = new OpenFileDialog() {
|
||||||
Title = "Dokument auswählen - Elwig",
|
Title = "Dokument auswählen - Elwig",
|
||||||
DefaultExt = "pdf",
|
DefaultExt = "pdf",
|
||||||
@ -296,6 +343,8 @@ namespace Elwig.Windows {
|
|||||||
SelectedDocs.Add(new(DocType.Custom, Path.GetFileName(file), file));
|
SelectedDocs.Add(new(DocType.Custom, Path.GetFileName(file), file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
using var ctx = new AppDbContext();
|
||||||
|
await UpdateRecipients(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,6 +383,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void Date_TextChanged(object sender, RoutedEventArgs evt) {
|
private void Date_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
Validator.CheckDate((TextBox)sender, true);
|
Validator.CheckDate((TextBox)sender, true);
|
||||||
|
ResetDocuments();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Date_LostFocus(object sender, RoutedEventArgs evt) {
|
private void Date_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
@ -375,6 +425,8 @@ namespace Elwig.Windows {
|
|||||||
query = query.Where(m => m.Deliveries.Any(d => d.Year == Year));
|
query = query.Where(m => m.Deliveries.Any(d => d.Year == Year));
|
||||||
} else if (RecipientsNonDeliveryMembersInput.IsChecked == true) {
|
} else if (RecipientsNonDeliveryMembersInput.IsChecked == true) {
|
||||||
query = query.Where(m => m.IsActive && !m.Deliveries.Any(d => d.Year == Year));
|
query = query.Where(m => m.IsActive && !m.Deliveries.Any(d => d.Year == Year));
|
||||||
|
} else if (RecipientsActiveMembersInput.IsChecked == true && SelectedDocs.Any(d => d.Type == DocType.DeliveryConfirmation || d.Type == DocType.CreditNote)) {
|
||||||
|
query = query.Where(m => m.IsActive || m.Deliveries.Any(d => d.Year == Year));
|
||||||
} else {
|
} else {
|
||||||
query = query.Where(m => m.IsActive);
|
query = query.Where(m => m.IsActive);
|
||||||
}
|
}
|
||||||
@ -403,6 +455,7 @@ namespace Elwig.Windows {
|
|||||||
PostalWishCount = Recipients.Count(m => m.ContactViaPost);
|
PostalWishCount = Recipients.Count(m => m.ContactViaPost);
|
||||||
var m = EmailAllInput.IsChecked == true ? 3 : EmailWishInput.IsChecked == true ? 2 : 1;
|
var m = EmailAllInput.IsChecked == true ? 3 : EmailWishInput.IsChecked == true ? 2 : 1;
|
||||||
PostalNoEmailCount = PostalAllCount - (m == 3 ? EmailAllCount : m == 2 ? EmailWishCount : 0);
|
PostalNoEmailCount = PostalAllCount - (m == 3 ? EmailAllCount : m == 2 ? EmailWishCount : 0);
|
||||||
|
ResetDocuments();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateTextParameters() {
|
private async Task UpdateTextParameters() {
|
||||||
@ -458,6 +511,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void GenerateButton_Click(object sender, RoutedEventArgs evt) {
|
private async void GenerateButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
LockInputs();
|
||||||
PreviewButton.IsEnabled = false;
|
PreviewButton.IsEnabled = false;
|
||||||
PrintButton.IsEnabled = false;
|
PrintButton.IsEnabled = false;
|
||||||
EmailButton.IsEnabled = false;
|
EmailButton.IsEnabled = false;
|
||||||
@ -520,6 +574,7 @@ namespace Elwig.Windows {
|
|||||||
dcData[year] = await DeliveryConfirmationDeliveryData.ForSeason(ctx.DeliveryParts, year);
|
dcData[year] = await DeliveryConfirmationDeliveryData.ForSeason(ctx.DeliveryParts, year);
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
UnlockInputs();
|
||||||
GenerateButton.IsEnabled = true;
|
GenerateButton.IsEnabled = true;
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
return;
|
return;
|
||||||
@ -536,6 +591,7 @@ namespace Elwig.Windows {
|
|||||||
);
|
);
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
UnlockInputs();
|
||||||
GenerateButton.IsEnabled = true;
|
GenerateButton.IsEnabled = true;
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
return;
|
return;
|
||||||
@ -626,6 +682,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
UnlockInputs();
|
||||||
GenerateButton.IsEnabled = true;
|
GenerateButton.IsEnabled = true;
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
return;
|
return;
|
||||||
@ -665,6 +722,7 @@ namespace Elwig.Windows {
|
|||||||
PrintDocument = print;
|
PrintDocument = print;
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
UnlockInputs();
|
||||||
GenerateButton.IsEnabled = true;
|
GenerateButton.IsEnabled = true;
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
return;
|
return;
|
||||||
@ -672,6 +730,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
ProgressBar.Value = 100.0;
|
ProgressBar.Value = 100.0;
|
||||||
|
|
||||||
|
UnlockInputs();
|
||||||
GenerateButton.IsEnabled = true;
|
GenerateButton.IsEnabled = true;
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
PreviewButton.IsEnabled = true;
|
PreviewButton.IsEnabled = true;
|
||||||
@ -705,7 +764,11 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private async void PrintButton_Click(object sender, RoutedEventArgs evt) {
|
private async void PrintButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (PrintDocument == null) return;
|
if (PrintDocument == null) return;
|
||||||
|
|
||||||
PrintButton.IsEnabled = false;
|
PrintButton.IsEnabled = false;
|
||||||
|
GenerateButton.IsEnabled = false;
|
||||||
|
LockInputs();
|
||||||
|
|
||||||
var res = MessageBox.Show($"Sollen {PrintDocument.Pages} Blätter ({PrintDocument.TotalPages} Seiten) gedruckt werden?",
|
var res = MessageBox.Show($"Sollen {PrintDocument.Pages} Blätter ({PrintDocument.TotalPages} Seiten) gedruckt werden?",
|
||||||
"Rundschreiben drucken", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
|
"Rundschreiben drucken", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
|
||||||
if (res == MessageBoxResult.Yes) {
|
if (res == MessageBoxResult.Yes) {
|
||||||
@ -717,13 +780,19 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintButton.IsEnabled = true;
|
PrintButton.IsEnabled = true;
|
||||||
|
GenerateButton.IsEnabled = true;
|
||||||
|
UnlockInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void EmailButton_Click(object sender, RoutedEventArgs evt) {
|
private async void EmailButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (App.Config.Smtp == null || EmailDocuments == null) return;
|
if (App.Config.Smtp == null || EmailDocuments == null) return;
|
||||||
|
|
||||||
EmailButton.IsEnabled = false;
|
EmailButton.IsEnabled = false;
|
||||||
|
GenerateButton.IsEnabled = false;
|
||||||
|
LockInputs();
|
||||||
|
|
||||||
SmtpClient? client = null;
|
SmtpClient? client = null;
|
||||||
try {
|
try {
|
||||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||||
@ -754,6 +823,8 @@ namespace Elwig.Windows {
|
|||||||
msg.Body = body;
|
msg.Body = body;
|
||||||
await client!.SendAsync(msg);
|
await client!.SendAsync(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Erfolgreich alle E-Mails verschickt!", "Rundschreiben verschicken", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -761,11 +832,14 @@ namespace Elwig.Windows {
|
|||||||
await client.DisconnectAsync(true);
|
await client.DisconnectAsync(true);
|
||||||
client?.Dispose();
|
client?.Dispose();
|
||||||
EmailButton.IsEnabled = true;
|
EmailButton.IsEnabled = true;
|
||||||
|
GenerateButton.IsEnabled = true;
|
||||||
|
UnlockInputs();
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddDeliveryConfirmation() {
|
public void AddDeliveryConfirmation() {
|
||||||
|
if (!GenerateButton.IsEnabled) return;
|
||||||
AvaiableDocumentsList.SelectedIndex = 1;
|
AvaiableDocumentsList.SelectedIndex = 1;
|
||||||
if (AvaiableDocumentsList.SelectedItem is not string s || SelectedDocs.Any(d => d.Type == DocType.DeliveryConfirmation))
|
if (AvaiableDocumentsList.SelectedItem is not string s || SelectedDocs.Any(d => d.Type == DocType.DeliveryConfirmation))
|
||||||
return;
|
return;
|
||||||
@ -775,6 +849,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AddCreditNote(int index) {
|
public void AddCreditNote(int index) {
|
||||||
|
if (!GenerateButton.IsEnabled) return;
|
||||||
AvaiableDocumentsList.SelectedIndex = 2 + index;
|
AvaiableDocumentsList.SelectedIndex = 2 + index;
|
||||||
if (AvaiableDocumentsList.SelectedItem is not string s || SelectedDocs.Any(d => d.Type == DocType.CreditNote))
|
if (AvaiableDocumentsList.SelectedItem is not string s || SelectedDocs.Any(d => d.Type == DocType.CreditNote))
|
||||||
return;
|
return;
|
||||||
@ -785,5 +860,29 @@ namespace Elwig.Windows {
|
|||||||
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
||||||
RecipientsDeliveryMembersInput.IsChecked = true;
|
RecipientsDeliveryMembersInput.IsChecked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DocumentInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
ResetDocuments();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PostalLocation_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
ResetDocuments();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PostalInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
ResetDocuments();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OrderInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
ResetDocuments();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoublePagedInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
ResetDocuments();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PostalSender_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
ResetDocuments();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user