From cca69b619d282f6974f6b1443991c357bcb1a9b4 Mon Sep 17 00:00:00 2001 From: Marcus Date: Thu, 28 Aug 2025 14:12:42 +0200 Subject: [PATCH] =?UTF-8?q?5.1.0.6:=20Asp=20verwalten=20entfernt=20jetzt?= =?UTF-8?q?=20f=C3=BCr=20die=20SQL=20Query=20die=20Zwischeninitiale=20des?= =?UTF-8?q?=20Username?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZKuP/MainWindow.xaml.cs | 2 +- ZKuP/ManageAsp.xaml.cs | 6 +++++- ZKuP/StringExtensions.cs | 43 ++++++++++++++++++++++++++++++++++++++++ ZKuP/ZKuP.csproj | 1 + 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 ZKuP/StringExtensions.cs diff --git a/ZKuP/MainWindow.xaml.cs b/ZKuP/MainWindow.xaml.cs index e0b71bb..ffe782b 100644 --- a/ZKuP/MainWindow.xaml.cs +++ b/ZKuP/MainWindow.xaml.cs @@ -43,7 +43,7 @@ namespace ZKuP PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - public const string Version = "5.1.0.5"; + public const string Version = "5.1.0.6"; public static Roles LoggedInRole { get; private set; } = Roles.None; diff --git a/ZKuP/ManageAsp.xaml.cs b/ZKuP/ManageAsp.xaml.cs index 817f724..6dfbb9a 100644 --- a/ZKuP/ManageAsp.xaml.cs +++ b/ZKuP/ManageAsp.xaml.cs @@ -54,7 +54,11 @@ namespace ZKuP } else { - asp = SQL.ReadSQL($"SELECT * FROM {MainWindow.table}.ansprechpartner WHERE Name LIKE '%{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}%' OR Vertreter LIKE '%{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}%' OR Vorgesetzter LIKE '%{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}%' OR CreatorID = '{UserID}' ORDER BY Name ASC", asp).Result; + asp = SQL.ReadSQL($"SELECT * FROM {MainWindow.table}.ansprechpartner WHERE " + + $"Name LIKE '%{Helper.InsertSpaceBeforeUpperCase(Environment.UserName.ReplaceMiddleInitialWithSpace()).ReplaceUmlaute()}%' OR " + + $"Vertreter LIKE '%{Helper.InsertSpaceBeforeUpperCase(Environment.UserName.ReplaceMiddleInitialWithSpace()).ReplaceUmlaute()}%' OR " + + $"Vorgesetzter LIKE '%{Helper.InsertSpaceBeforeUpperCase(Environment.UserName.ReplaceMiddleInitialWithSpace()).ReplaceUmlaute()}%' OR " + + $"CreatorID = '{UserID}' ORDER BY Name ASC", asp).Result; } //aspView = Asp.DataTableToAsp(asp); diff --git a/ZKuP/StringExtensions.cs b/ZKuP/StringExtensions.cs new file mode 100644 index 0000000..72b2a01 --- /dev/null +++ b/ZKuP/StringExtensions.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace ZKuP +{ + public static class StringExtensions + { + public static string ReplaceUmlaute(this string input) + { + if (string.IsNullOrEmpty(input)) + return input; + + return input + .Replace("ä", "ae") + .Replace("ö", "oe") + .Replace("ü", "ue") + .Replace("Ä", "Ae") + .Replace("Ö", "Oe") + .Replace("Ü", "Ue") + .Replace("ß", "ss"); + } + + public static string ReplaceMiddleInitialWithSpace(this string input) + { + if (string.IsNullOrEmpty(input)) + return input; + + var pattern = @"^([A-Za-z]{2,})([A-Z][a-z]?)([A-Z][A-Za-z]+)$"; + var match = Regex.Match(input, pattern); + + if (match.Success) + { + return match.Groups[1].Value + " " + match.Groups[3].Value; + } + + return input; + } + } +} diff --git a/ZKuP/ZKuP.csproj b/ZKuP/ZKuP.csproj index d50f146..70b6cd8 100644 --- a/ZKuP/ZKuP.csproj +++ b/ZKuP/ZKuP.csproj @@ -323,6 +323,7 @@ + ucSpinnerPiston.xaml