From 05815eff9e267196243969417ca7a81457b2ba1f Mon Sep 17 00:00:00 2001 From: "m.ilhan" Date: Wed, 9 Oct 2024 16:23:25 +0200 Subject: [PATCH] Ma Suche verbessert --- UID/Mitarbeiter/usrCntlMitarbeiter.vb | 100 +++++++++++++------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/UID/Mitarbeiter/usrCntlMitarbeiter.vb b/UID/Mitarbeiter/usrCntlMitarbeiter.vb index af4c1df..35678ff 100644 --- a/UID/Mitarbeiter/usrCntlMitarbeiter.vb +++ b/UID/Mitarbeiter/usrCntlMitarbeiter.vb @@ -28,6 +28,7 @@ Public Class usrCntlMitarbeiter Try ' Me.Size = My.Settings.frmMainSize ' Me.Location = My.Settings.frmMainPosition + Catch ex As Exception Catch ex As Exception 'nix tun - Standardgröße wird somit automatisch gesetzt End Try @@ -37,58 +38,57 @@ Public Class usrCntlMitarbeiter txtSuche.Focus() End Sub - - - Public Sub Tabelle_anzeigen() Dim startIndex As Integer = TabControl1.SelectedIndex Dim firmaGefunden As Boolean = False Dim tabCount As Integer = TabControl1.TabCount + If TabControl1.SelectedIndex <> 7 Then + For offset As Integer = 0 To tabCount - 1 + Dim i As Integer = (startIndex + offset) Mod tabCount + Dim firma As String = "" - Dim checkedTabs As Integer = 0 - Dim i As Integer = startIndex + Select Case i + Case 0 + firma = "VERAG" + Case 1 + firma = "ATILLA" + Case 2 + firma = "IMEX" + Case 3 + firma = "UNISPED" + Case 4 + firma = "AMBAR" + Case 5 + firma = "FRONTOFFICE" + Case 6 + firma = "VERIMEX" + End Select - Do While checkedTabs < tabCount - Dim firma As String = "" - Select Case i - Case 0 - firma = "VERAG" - Case 1 - firma = "ATILLA" - Case 2 - firma = "IMEX" - Case 3 - firma = "UNISPED" - Case 4 - firma = "AMBAR" - Case 5 - firma = "FRONTOFFICE" - Case 6 - firma = "VERIMEX" - Case 7 - If dgvTimasNew IsNot Nothing Then - showTIMAS(False) + + If firma <> "" Then + If showVERAGATILLA(firma) Then + ' Wechsel zum Tab der gefundenen Firma + TabControl1.SelectedIndex = i firmaGefunden = True - Exit Do + Exit For End If - End Select - - If firma <> "" Then - If showVERAGATILLA(firma) Then - ' Wechsel zum Tab der gefundenen Firma - TabControl1.SelectedIndex = i - firmaGefunden = True - Exit Do End If - End If - checkedTabs += 1 - i = (i + 1) Mod tabCount ' Modulo-Operation für zyklisches Durchlaufen - Loop - - If Not firmaGefunden Then - MsgBox("Keine Daten für die ausgewählten Kriterien gefunden.", MsgBoxStyle.Information) + Next End If + + If TabControl1.SelectedIndex = 7 Then + If dgvTimasNew IsNot Nothing Then + showTIMAS(False) + End If + End If + + If txtSuche.Text <> "" AndAlso TabControl1.SelectedIndex <> 7 Then + If Not firmaGefunden Then + MsgBox("Keine Daten für die ausgewählten Kriterien gefunden.", MsgBoxStyle.Information) + End If + End If + End Sub @@ -97,10 +97,14 @@ Public Class usrCntlMitarbeiter locZeilen = -1 If Not Grid_aktiv Then Return False - ' Ihre ursprüngliche SQL-Abfrage hier, angepasst für die aktuelle Firma - Dim sql As String = "SELECT mit_id, mit_username, mit_vname, mit_nname, mit_niederlassung, mit_abteilung, mit_email, cast(case when mit_timasId is null then 0 else 1 end as bit) mit_ze, cast(case when isnull([mit_DAKOSY_SB],'')<> '' and isnull([mit_DAKOSY_SBFull],'')<>'' then 1 else 0 end as bit) mit_DAKOSY, mit_durchwahl, mit_gekuendigt, isnull(mit_foto_DocId,'') as mit_foto_DocId FROM tblMitarbeiter WHERE (mit_firma='" & firma & "' OR (mit_firma='ALL' AND mit_FirmaHaupt='" & firma & "'))" + ' SQL-Abfrage erstellen + Dim sql As String = "SELECT mit_id, mit_username, mit_vname, mit_nname, mit_niederlassung, mit_abteilung, mit_email, " & + "CAST(CASE WHEN mit_timasId IS NULL THEN 0 ELSE 1 END AS BIT) mit_ze, " & + "CAST(CASE WHEN ISNULL([mit_DAKOSY_SB],'')<> '' AND ISNULL([mit_DAKOSY_SBFull],'')<>'' THEN 1 ELSE 0 END AS BIT) mit_DAKOSY, " & + "mit_durchwahl, mit_gekuendigt, ISNULL(mit_foto_DocId,'') AS mit_foto_DocId " & + "FROM tblMitarbeiter WHERE (mit_firma='" & firma & "' OR (mit_firma='ALL' AND mit_FirmaHaupt='" & firma & "'))" - ' Rest Ihrer Filterbedingungen... + ' Filter hinzufügen If txtSuche.Text <> "" Then sql &= " AND (mit_username LIKE '%" & txtSuche.Text & "%' OR mit_nname LIKE '%" & txtSuche.Text & "%' OR mit_vname LIKE '%" & txtSuche.Text & "%')" End If @@ -110,11 +114,11 @@ Public Class usrCntlMitarbeiter End If If cbxZE.CheckState <> CheckState.Indeterminate Then - sql &= If(cbxZE.Checked, " AND mit_timasId is not null", " AND mit_timasId is null") + sql &= If(cbxZE.Checked, " AND mit_timasId IS NOT NULL", " AND mit_timasId IS NULL") End If If cbxDakosy.CheckState <> CheckState.Indeterminate Then - sql &= If(cbxDakosy.Checked, " AND (isnull([mit_DAKOSY_SB],'')<> '' AND isnull([mit_DAKOSY_SBFull],'')<>'')", " AND (isnull([mit_DAKOSY_SB],'')= '' OR isnull([mit_DAKOSY_SBFull],'')='')") + sql &= If(cbxDakosy.Checked, " AND (ISNULL([mit_DAKOSY_SB],'')<> '' AND ISNULL([mit_DAKOSY_SBFull],'')<>'')", " AND (ISNULL([mit_DAKOSY_SB],'')= '' OR ISNULL([mit_DAKOSY_SBFull],'')='')") End If ' Daten laden und prüfen @@ -175,7 +179,6 @@ Public Class usrCntlMitarbeiter dgvVERIMEX.Sort(dgvVERIMEX.Columns(3), ListSortDirection.Ascending) Return True End If - ' Fügen Sie weitere Fälle hinzu, falls erforderlich End Select Return False @@ -183,9 +186,6 @@ Public Class usrCntlMitarbeiter - - - Public Sub showTIMAS(refresh As Boolean) locZeilen = -1 If Not Grid_aktiv Then Exit Sub