PaymentVariantsWindow: Add possibility to switch options on/off
This commit is contained in:
@ -65,6 +65,12 @@
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.RowSpan="2"
|
||||
Click="DeleteButton_Click"/>
|
||||
|
||||
<TextBox x:Name="DataInput" Margin="10,200,35,10" Grid.Column="0" Grid.RowSpan="2"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="auto"
|
||||
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto"
|
||||
FontFamily="Cascadia Code Light" FontSize="13"
|
||||
TextChanged="DataInput_TextChanged"/>
|
||||
|
||||
<Label Content="Name:" Margin="10,10,0,0" Grid.Column="1"/>
|
||||
<TextBox x:Name="NameInput" Width="200" Grid.Column="2" HorizontalAlignment="Left" Margin="0,10,0,0"
|
||||
TextChanged="NameInput_TextChanged"/>
|
||||
@ -80,11 +86,20 @@
|
||||
<TextBox x:Name="TransferDateInput" Grid.Column="2" Width="77" HorizontalAlignment="Left" Margin="0,100,10,0"
|
||||
TextChanged="TransferDateInput_TextChanged"/>
|
||||
|
||||
<TextBox x:Name="DataInput" Margin="82,70,10,74" Grid.Column="2"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="auto"
|
||||
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto"
|
||||
FontFamily="Cascadia Code Light" FontSize="13"
|
||||
TextChanged="DataInput_TextChanged"/>
|
||||
<Label Content="Berücksichtigen:" Margin="90,70,10,10" Grid.Column="2"/>
|
||||
<CheckBox x:Name="ConsiderModifiersInput" Content="Zu-/Abschläge bei Lieferungen"
|
||||
Margin="110,95,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="ConsiderModifiersInput_Changed" Unchecked="ConsiderModifiersInput_Changed"/>
|
||||
<CheckBox x:Name="ConsiderPenaltiesInput" Content="Pönalen bei Unterlieferungen (FB)"
|
||||
Margin="110,115,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="ConsiderPenaltiesInput_Changed" Unchecked="ConsiderPenaltiesInput_Changed"/>
|
||||
<CheckBox x:Name="ConsiderPenaltyInput" Content="Strafen bei Unterlieferungen (GA)"
|
||||
Margin="110,135,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="ConsiderPenaltyInput_Changed" Unchecked="ConsiderPenaltyInput_Changed"/>
|
||||
<CheckBox x:Name="ConsiderAutoInput" Content="Automatische Nachzeichnungen der GA"
|
||||
Margin="110,155,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="ConsiderAutoInput_Changed" Unchecked="ConsiderAutoInput_Changed"/>
|
||||
<Label Content="" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="0" Grid.Column="2" Margin="108,175,10,10"/>
|
||||
|
||||
<Grid Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10,10,10,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -21,6 +21,7 @@ namespace Elwig.Windows {
|
||||
public readonly int Year;
|
||||
public readonly bool SeasonLocked;
|
||||
private bool DataValid, DataChanged, NameChanged, CommentChanged, TransferDateValid, TransferDateChanged;
|
||||
private BillingData? BillingData;
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOpt = new() { WriteIndented = true };
|
||||
|
||||
@ -56,16 +57,37 @@ namespace Elwig.Windows {
|
||||
ExportButton.IsEnabled = locked;
|
||||
|
||||
NameInput.Text = v.Name;
|
||||
NameInput.IsReadOnly = false;
|
||||
CommentInput.Text = v.Comment;
|
||||
CommentInput.IsReadOnly = false;
|
||||
DateInput.Text = $"{v.Date:dd.MM.yyyy}";
|
||||
DateInput.IsReadOnly = false;
|
||||
TransferDateInput.Text = $"{v.TransferDate:dd.MM.yyyy}";
|
||||
if (App.Config.Debug) {
|
||||
try {
|
||||
var json = BillingData.ParseJson(v.Data);
|
||||
DataInput.Text = JsonSerializer.Serialize(json, JsonOpt);
|
||||
} catch {
|
||||
DataInput.Text = v.Data;
|
||||
}
|
||||
TransferDateInput.IsReadOnly = false;
|
||||
try {
|
||||
BillingData = BillingData.FromJson(v.Data);
|
||||
ConsiderModifiersInput.IsChecked = BillingData.ConsiderDelieryModifiers;
|
||||
ConsiderModifiersInput.IsEnabled = !locked;
|
||||
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
|
||||
ConsiderPenaltiesInput.IsEnabled = !locked;
|
||||
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
|
||||
ConsiderPenaltyInput.IsEnabled = !locked;
|
||||
ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares;
|
||||
ConsiderAutoInput.IsEnabled = !locked;
|
||||
DataInput.Text = JsonSerializer.Serialize(BillingData.Data, JsonOpt);
|
||||
DataInput.IsReadOnly = locked;
|
||||
} catch {
|
||||
BillingData = null;
|
||||
ConsiderModifiersInput.IsChecked = false;
|
||||
ConsiderModifiersInput.IsEnabled = false;
|
||||
ConsiderPenaltiesInput.IsChecked = false;
|
||||
ConsiderPenaltiesInput.IsEnabled = false;
|
||||
ConsiderPenaltyInput.IsChecked = false;
|
||||
ConsiderPenaltyInput.IsEnabled = false;
|
||||
ConsiderAutoInput.IsChecked = false;
|
||||
ConsiderAutoInput.IsEnabled = false;
|
||||
DataInput.Text = v.Data;
|
||||
DataInput.IsEnabled = false;
|
||||
}
|
||||
} else {
|
||||
EditButton.Content = "Bearbeiten";
|
||||
@ -81,11 +103,25 @@ namespace Elwig.Windows {
|
||||
PrintButton.IsEnabled = false;
|
||||
ExportButton.IsEnabled = false;
|
||||
|
||||
BillingData = null;
|
||||
NameInput.Text = "";
|
||||
NameInput.IsReadOnly = true;
|
||||
CommentInput.Text = "";
|
||||
CommentInput.IsReadOnly = true;
|
||||
DateInput.Text = "";
|
||||
DateInput.IsReadOnly = true;
|
||||
TransferDateInput.Text = "";
|
||||
TransferDateInput.IsReadOnly = true;
|
||||
ConsiderModifiersInput.IsChecked = false;
|
||||
ConsiderModifiersInput.IsEnabled = false;
|
||||
ConsiderPenaltiesInput.IsChecked = false;
|
||||
ConsiderPenaltiesInput.IsEnabled = false;
|
||||
ConsiderPenaltyInput.IsChecked = false;
|
||||
ConsiderPenaltyInput.IsEnabled = false;
|
||||
ConsiderAutoInput.IsChecked = false;
|
||||
ConsiderAutoInput.IsEnabled = false;
|
||||
DataInput.Text = "";
|
||||
DataInput.IsReadOnly = true;
|
||||
}
|
||||
UpdateSums();
|
||||
UpdateSaveButton();
|
||||
@ -94,7 +130,11 @@ namespace Elwig.Windows {
|
||||
private void UpdateSaveButton() {
|
||||
SaveButton.IsEnabled = PaymentVariantList.SelectedItem != null &&
|
||||
((DataChanged && DataValid) || NameChanged || CommentChanged ||
|
||||
(TransferDateChanged && TransferDateValid));
|
||||
(TransferDateChanged && TransferDateValid)) ||
|
||||
(ConsiderModifiersInput.IsChecked != BillingData?.ConsiderDelieryModifiers) ||
|
||||
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
|
||||
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
|
||||
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares);
|
||||
}
|
||||
|
||||
private void UpdateSums() {
|
||||
@ -268,15 +308,25 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||
if (PaymentVariantList.SelectedItem is not PaymentVar v) return;
|
||||
if (PaymentVariantList.SelectedItem is not PaymentVar v || BillingData == null) return;
|
||||
try {
|
||||
v.Name = NameInput.Text;
|
||||
v.Comment = (CommentInput.Text != "") ? CommentInput.Text : null;
|
||||
v.TransferDateString = (TransferDateInput.Text != "") ? string.Join("-", TransferDateInput.Text.Split(".").Reverse()) : null;
|
||||
if (App.Config.Debug) v.Data = JsonSerializer.Serialize(BillingData.ParseJson(DataInput.Text));
|
||||
var d = App.Config.Debug ? BillingData.FromJson(DataInput.Text) : BillingData;
|
||||
d.ConsiderDelieryModifiers = ConsiderModifiersInput.IsChecked ?? false;
|
||||
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
|
||||
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
|
||||
d.ConsiderAutoBusinessShares = ConsiderAutoInput.IsChecked ?? false;
|
||||
v.Data = JsonSerializer.Serialize(d.Data);
|
||||
Context.Update(v);
|
||||
await Context.SaveChangesAsync();
|
||||
await App.HintContextChange();
|
||||
CommentInput_TextChanged(null, null);
|
||||
ConsiderModifiersInput_Changed(null, null);
|
||||
ConsiderPenaltiesInput_Changed(null, null);
|
||||
ConsiderPenaltyInput_Changed(null, null);
|
||||
ConsiderAutoInput_Changed(null, null);
|
||||
} catch (Exception exc) {
|
||||
await HintContextChange();
|
||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||
@ -304,7 +354,7 @@ namespace Elwig.Windows {
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private void CommentInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
private void CommentInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
|
||||
if (PaymentVariantList.SelectedItem is not PaymentVar v) {
|
||||
ControlUtils.ClearInputState(CommentInput);
|
||||
return;
|
||||
@ -366,6 +416,58 @@ namespace Elwig.Windows {
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private void ConsiderModifiersInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||
if (BillingData == null) {
|
||||
ControlUtils.ClearInputState(ConsiderModifiersInput);
|
||||
return;
|
||||
}
|
||||
if (BillingData.ConsiderDelieryModifiers != ConsiderModifiersInput.IsChecked) {
|
||||
ControlUtils.SetInputChanged(ConsiderModifiersInput);
|
||||
} else {
|
||||
ControlUtils.ClearInputState(ConsiderModifiersInput);
|
||||
}
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private void ConsiderPenaltiesInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||
if (BillingData == null) {
|
||||
ControlUtils.ClearInputState(ConsiderPenaltiesInput);
|
||||
return;
|
||||
}
|
||||
if (BillingData.ConsiderContractPenalties != ConsiderPenaltiesInput.IsChecked) {
|
||||
ControlUtils.SetInputChanged(ConsiderPenaltiesInput);
|
||||
} else {
|
||||
ControlUtils.ClearInputState(ConsiderPenaltiesInput);
|
||||
}
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private void ConsiderPenaltyInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||
if (BillingData == null) {
|
||||
ControlUtils.ClearInputState(ConsiderPenaltyInput);
|
||||
return;
|
||||
}
|
||||
if (BillingData.ConsiderTotalPenalty != ConsiderPenaltyInput.IsChecked) {
|
||||
ControlUtils.SetInputChanged(ConsiderPenaltyInput);
|
||||
} else {
|
||||
ControlUtils.ClearInputState(ConsiderPenaltyInput);
|
||||
}
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private void ConsiderAutoInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||
if (BillingData == null) {
|
||||
ControlUtils.ClearInputState(ConsiderAutoInput);
|
||||
return;
|
||||
}
|
||||
if (BillingData.ConsiderAutoBusinessShares != ConsiderAutoInput.IsChecked) {
|
||||
ControlUtils.SetInputChanged(ConsiderAutoInput);
|
||||
} else {
|
||||
ControlUtils.ClearInputState(ConsiderAutoInput);
|
||||
}
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private async Task Generate(int mode) {
|
||||
if (PaymentVariantList.SelectedItem is not PaymentVar v)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user