From 9431381dd74c397187f0215482b4e0d945c1713f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gabriel=2Ehuot-v=C3=A9zina?= Date: Wed, 18 Sep 2024 09:06:06 -0400 Subject: [PATCH] #359 fixed photo number calc failing with Ganfeld 2 digits photos. --- .../Services/DatabaseServices/DataIDCalculation.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs b/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs index b81571c9..e5eef9fc 100644 --- a/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs +++ b/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs @@ -719,7 +719,18 @@ public string CalculateDocumentAlias(int parentID, string parentAlias, int start { string lastAlias = docParent.ToList()[0].ToString(); //Select first element since the list has been sorted in descending order string lastNumberString = lastAlias.Substring(lastAlias.Length - 3); //Document only has three digits id in the alias - int newNumber = Convert.ToInt16(lastNumberString) + startingDocNumber; + string validLastNumber = string.Empty; + foreach (char c in lastNumberString) + { + if (char.IsNumber(c)) + { + //Rebuild number + validLastNumber = validLastNumber + c; + } + + } + + int newNumber = Convert.ToInt16(validLastNumber) + startingDocNumber; bool breaker = true; while (breaker)