From d0c52190cbac9b232d6014619677b0f4060e2a6b Mon Sep 17 00:00:00 2001 From: "m.ilhan" Date: Wed, 9 Oct 2024 11:17:24 +0200 Subject: [PATCH] Telefonnummer From AD to Admin Tool --- UID/Mitarbeiter/frmMitarbDetails.vb | 32 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/UID/Mitarbeiter/frmMitarbDetails.vb b/UID/Mitarbeiter/frmMitarbDetails.vb index 3d05b87..9d7247b 100644 --- a/UID/Mitarbeiter/frmMitarbDetails.vb +++ b/UID/Mitarbeiter/frmMitarbDetails.vb @@ -1121,15 +1121,35 @@ Public Class frmMitarbDetails If txtDurchwahl.Text = "" Then txtDurchwahl.Text = de.Properties("otherTelephone").Value If txtALIASUser.Text = "" Then txtALIASUser.Text = de.Properties("sAMAccountName").Value If txtEmailExtension.Text = "" Then txtEmailExtension.Text = de.Properties("extensionAttribute7").Value - Dim phoneNr = de.Properties("telephoneNumber").Value + + + Dim phoneNr As String = de.Properties("telephoneNumber").Value If phoneNr <> "" Then + Dim digitsOnly As String = Regex.Replace(phoneNr, "\D", "") - Dim pattern = "-.*" 'enfernt alle zeichen nach - - Dim myString = Regex.Replace(phoneNr, pattern, "") - pattern = "DW.*" 'enfernt alle zeichen nach DW - myString = Regex.Replace(myString, pattern, "") - If txtTelNr.Text = "" Then txtTelNr.Text = myString.Trim() + If digitsOnly.Length > 10 Then + Dim digitCount As Integer = 0 + Dim splitIndex As Integer = -1 + For i As Integer = 0 To phoneNr.Length - 1 + If Char.IsDigit(phoneNr(i)) Then + digitCount += 1 + If digitCount = 10 Then + splitIndex = i + Exit For + End If + End If + Next + + If splitIndex <> -1 Then + If txtTelNr.Text = "" Then txtTelNr.Text = phoneNr.Substring(0, splitIndex + 1).Trim() + If txtDurchwahl.Text = "" Then txtDurchwahl.Text = phoneNr.Substring(splitIndex + 1).Trim() + Else + If txtTelNr.Text = "" Then txtTelNr.Text = phoneNr.Trim() + End If + Else + If txtTelNr.Text = "" Then txtTelNr.Text = phoneNr.Trim() + End If End If 'cboALIASDomain.changeItem(frmAD.activeDirectoryObj.domain)