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