From 56a0eb794ed1492e5882441d11881623695c91f7 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Fri, 1 Sep 2023 12:57:09 +0200 Subject: [PATCH] AdministrationWindow: Fix default value change check --- Elwig/Helpers/AppDbContext.cs | 8 ++++---- Elwig/Helpers/ControlUtils.cs | 4 ++-- Elwig/Windows/AdministrationWindow.cs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Elwig/Helpers/AppDbContext.cs b/Elwig/Helpers/AppDbContext.cs index 42d403c..c96a053 100644 --- a/Elwig/Helpers/AppDbContext.cs +++ b/Elwig/Helpers/AppDbContext.cs @@ -119,7 +119,7 @@ namespace Elwig.Helpers { public async Task NextMgNr() { int c = await Members.Select(m => m.MgNr).MinAsync(); (await Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync()) - .ForEach(a => { if (a <= c + 100) c = a; }); + .ForEach(a => { if (a <= c + 1000) c = a; }); return c + 1; } @@ -134,21 +134,21 @@ namespace Elwig.Helpers { var dateStr = date.ToString("yyyy-MM-dd"); int c = 0; (await Deliveries.Where(d => d.DateString == dateStr).Select(d => d.LNr).ToListAsync()) - .ForEach(a => { if (a <= c + 10) c = a; }); + .ForEach(a => { if (a <= c + 100) c = a; }); return c + 1; } public async Task NextDId(int year) { int c = 0; (await Deliveries.Where(d => d.Year == year).Select(d => d.DId).ToListAsync()) - .ForEach(a => { if (a <= c + 10) c = a; }); + .ForEach(a => { if (a <= c + 100) c = a; }); return c + 1; } public async Task NextDPNr(int year, int did) { int c = 0; (await DeliveryParts.Where(p => p.Year == year && p.DId == did).Select(d => d.DPNr).ToListAsync()) - .ForEach(a => { if (a <= c + 10) c = a; }); + .ForEach(a => { if (a <= c + 100) c = a; }); return c + 1; } diff --git a/Elwig/Helpers/ControlUtils.cs b/Elwig/Helpers/ControlUtils.cs index b9f2659..5593238 100644 --- a/Elwig/Helpers/ControlUtils.cs +++ b/Elwig/Helpers/ControlUtils.cs @@ -212,9 +212,9 @@ namespace Elwig.Helpers { } else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) { return ccb.SelectedItems.Cast().ToArray(); } else if (input is CheckBox cb) { - return cb.IsChecked; + return (cb.IsChecked != null ? (cb.IsChecked == true ? bool.TrueString : bool.FalseString) : null); } else if (input is RadioButton rb) { - return rb.IsChecked; + return (rb.IsChecked != null ? (rb.IsChecked == true ? bool.TrueString : bool.FalseString) : null); } else { return null; } diff --git a/Elwig/Windows/AdministrationWindow.cs b/Elwig/Windows/AdministrationWindow.cs index 33a9b09..f944366 100644 --- a/Elwig/Windows/AdministrationWindow.cs +++ b/Elwig/Windows/AdministrationWindow.cs @@ -279,9 +279,9 @@ namespace Elwig.Windows { } else if (input is CheckComboBox ccb) { return !ccb.SelectedItems.Cast().ToArray().SequenceEqual(((object[]?)DefaultValues[ccb]) ?? Array.Empty()); } else if (input is CheckBox cb) { - return DefaultValues[cb] != (object?)cb.IsChecked; + return (string?)DefaultValues[cb] != (cb.IsChecked != null ? (cb.IsChecked == true ? bool.TrueString : bool.FalseString) : null); } else if (input is RadioButton rb) { - return DefaultValues[rb] != (object?)rb.IsChecked; + return (string?)DefaultValues[rb] != (rb.IsChecked != null ? (rb.IsChecked == true ? bool.TrueString : bool.FalseString) : null); } else { return false; }