diff --git a/Elwig/Dialogs/AbwertenDialog.xaml b/Elwig/Dialogs/AbwertenDialog.xaml
new file mode 100644
index 0000000..cf81046
--- /dev/null
+++ b/Elwig/Dialogs/AbwertenDialog.xaml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Elwig/Dialogs/AbwertenDialog.xaml.cs b/Elwig/Dialogs/AbwertenDialog.xaml.cs
new file mode 100644
index 0000000..34086d2
--- /dev/null
+++ b/Elwig/Dialogs/AbwertenDialog.xaml.cs
@@ -0,0 +1,40 @@
+using Elwig.Helpers;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+
+namespace Elwig.Dialogs {
+ public partial class AbwertenDialog : Window {
+
+ public int Weight;
+
+ public AbwertenDialog(string lsnr, string name, int weight) {
+ Weight = weight;
+ InitializeComponent();
+ Text.Inlines.Clear();
+ Text.Inlines.Add("Welche Menge der Teillieferung ");
+ Text.Inlines.Add(new Run(lsnr) { FontWeight = FontWeights.Bold });
+ Text.Inlines.Add("\nvon ");
+ Text.Inlines.Add(new Run(name) { FontWeight = FontWeights.Bold });
+ Text.Inlines.Add("\nmit ");
+ Text.Inlines.Add(new Run($"{weight:N0}\u202fkg") { FontWeight = FontWeights.Bold });
+ Text.Inlines.Add(" soll abgewertet werden?");
+ }
+
+ private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
+ DialogResult = true;
+ Weight = int.Parse(WeightInput.Text);
+ Close();
+ }
+
+ private void UpdateButtons() {
+ ConfirmButton.IsEnabled = int.TryParse(WeightInput.Text, out var w) && w > 0 && w <= Weight;
+ }
+
+ private void WeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
+ Validator.CheckInteger(WeightInput, true, 5);
+ UpdateButtons();
+ }
+ }
+}
diff --git a/Elwig/Dialogs/ManualWeighingDialog.xaml.cs b/Elwig/Dialogs/ManualWeighingDialog.xaml.cs
index 9c33f6d..a567b5c 100644
--- a/Elwig/Dialogs/ManualWeighingDialog.xaml.cs
+++ b/Elwig/Dialogs/ManualWeighingDialog.xaml.cs
@@ -15,7 +15,7 @@ namespace Elwig.Dialogs {
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
DialogResult = true;
- Weight = int.Parse(WeightInput.Text.Replace("\u202f", ""));
+ Weight = int.Parse(WeightInput.Text);
Reason = Regex.Replace(ReasonInput.Text, @"\s+", "").Trim();
if (Reason == "") {
Reason = null;
diff --git a/Elwig/Helpers/AppDbContext.cs b/Elwig/Helpers/AppDbContext.cs
index 728cddf..a9dc8b0 100644
--- a/Elwig/Helpers/AppDbContext.cs
+++ b/Elwig/Helpers/AppDbContext.cs
@@ -8,6 +8,7 @@ using System.Windows;
using Microsoft.Extensions.Logging;
using Microsoft.Data.Sqlite;
using System.Text.RegularExpressions;
+using System.Collections.Generic;
namespace Elwig.Helpers {
public class AppDbContext : DbContext {
@@ -157,5 +158,49 @@ namespace Elwig.Helpers {
.OrderBy(q => q.MinKmw)
.LastOrDefaultAsync();
}
+
+ public async Task UpdateDeliveryPartAttributes(DeliveryPart part, IEnumerable attributes) {
+ foreach (var a in attributes) {
+ var attr = part.PartAttributes.Where(pa => pa.AttrId == a.AttrId).FirstOrDefault();
+ if (attributes.Contains(a)) {
+ DeliveryPartAttr dpa = attr ?? this.CreateProxy();
+ dpa.Year = part.Year;
+ dpa.DId = part.DId;
+ dpa.DPNr = part.DPNr;
+ dpa.AttrId = a.AttrId;
+ if (attr == null) {
+ await AddAsync(dpa);
+ } else {
+ Update(dpa);
+ }
+ } else {
+ if (attr != null) {
+ Remove(attr);
+ }
+ }
+ }
+ }
+
+ public async Task UpdateDeliveryPartModifiers(DeliveryPart part, IEnumerable modifiers) {
+ foreach (var m in modifiers) {
+ var mod = part.PartModifiers.Where(pa => pa.ModId == m.ModId).FirstOrDefault();
+ if (modifiers.Contains(m)) {
+ DeliveryPartModifier dpm = mod ?? this.CreateProxy();
+ dpm.Year = part.Year;
+ dpm.DId = part.DId;
+ dpm.DPNr = part.DPNr;
+ dpm.ModId = m.ModId;
+ if (mod == null) {
+ await AddAsync(dpm);
+ } else {
+ Update(dpm);
+ }
+ } else {
+ if (mod != null) {
+ Remove(mod);
+ }
+ }
+ }
+ }
}
}
diff --git a/Elwig/Helpers/ControlUtils.cs b/Elwig/Helpers/ControlUtils.cs
index ee66310..c74190b 100644
--- a/Elwig/Helpers/ControlUtils.cs
+++ b/Elwig/Helpers/ControlUtils.cs
@@ -106,6 +106,7 @@ namespace Elwig.Helpers {
var selectedIds = selector.SelectedItems.Cast