MS Search

This commit is contained in:
SchreiberM 2020-12-01 17:27:20 +01:00
parent 1638fdc173
commit 73944f1545
2 changed files with 348 additions and 67 deletions

View File

@ -84,6 +84,7 @@ Public Class ClassControlCreator
oSourceSQL = oSourceSQL.Replace("@USER_LANGUAGE", My.Application.User.Language)
oSourceSQL = oSourceSQL.Replace("@pUSER_ID", My.Application.User.UserId)
oSourceSQL = oSourceSQL.Replace("@RESULT_TITLE", pAttributeRow.Item("ATTRIBUTE_TITLE").ToString)
'oSourceSQL = oSourceSQL & " ORDER BY T.TERM_VALUE"
Dim oDTSource As DataTable
'If pAttributeRow.Item("DEPENDING_ATTRIBUTE1") = 0 Then
If Utils.NotNull(oSourceSQL, String.Empty) <> String.Empty Then
@ -95,6 +96,8 @@ Public Class ClassControlCreator
Dim oMaxValue As String = ""
If Not IsNothing(oDTSource) Then
oDTSource.DefaultView.Sort = pAttributeRow.Item("ATTRIBUTE_TITLE").ToString '"ColumnName ASC"
oDTSource = oDTSource.DefaultView.ToTable
oMinValue = oDTSource.Rows(0).Item(0)
oMaxValue = oDTSource.Rows(oDTSource.Rows.Count - 1).Item(0)
End If
@ -181,7 +184,7 @@ Public Class ClassControlCreator
'oMyNewGridControl.Size = New Size(CInt(pAttributeRow.Item("WIDTH")), CInt(pAttributeRow.Item("HEIGHT")))
oView = CType(oMyNewGridControl.MainView, GridView)
oView.Appearance.EvenRow.BackColor = Color.PaleTurquoise
oView.Appearance.EvenRow.BackColor = Color.FromArgb(255, 214, 49)
oView.OptionsBehavior.Editable = False
oView.OptionsBehavior.ReadOnly = True
oView.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.False

View File

@ -36,8 +36,12 @@ Public Class frmSearchStart
Private DatatableAttributeLinks As DataTable
Private DatatableSearchProfiles As DataTable
Private DatatableStartSearchResult As DataTable
Private DatatableSearchResultSoFar As DataTable
Private LastSearchForm As frmDocumentResultList
Private ChangedDateControls As List(Of String)
Private clsControls As ClassControlCreator
Private StopWatch As Watch
@ -155,7 +159,7 @@ Public Class frmSearchStart
Dim oControlCount As Integer = 1
Dim oControlRow As Integer = 0
Dim oControls As New ClassControlCreator(SelectedTab, Me)
clsControls = New ClassControlCreator(SelectedTab, Me)
Dim YActControlHeight As Integer = 0
Dim XActControlWidth As Integer = 0
@ -230,7 +234,7 @@ Public Class frmSearchStart
Dim oMyControl As Control = Nothing
If oAttributeType = ATTR_TYPE_STRING Or oAttributeType = ATTR_TYPE_INTEGER Then
oMyControl = oControls.CreateExistingGridControl(oAttributeRow, oXPosition, oYPositionControl)
oMyControl = clsControls.CreateExistingGridControl(oAttributeRow, oXPosition, oYPositionControl)
Dim oGrid As GridControl = CType(oMyControl, GridControl)
Dim oDataSource As DataTable = CType(oGrid.DataSource, DataTable)
@ -245,17 +249,23 @@ Public Class frmSearchStart
'Prüfen ob für dieses Grid eine Abhängigkeit definiert ist?
For Each oROW As DataRow In DatatableAttributeLinks.Rows
If CInt(oROW.Item("LINKED_ATTR_ID")) = oAttriID Then
AddHandler oView.FocusedRowChanged, AddressOf FocusedRowChanged
If CBool(oAttributeRow.Item("MULTISELECT")) = True Then
AddHandler oView.SelectionChanged, AddressOf SelectionChanged
Else
AddHandler oView.FocusedRowChanged, AddressOf FocusedRowChanged
End If
End If
Next
ElseIf oAttributeType = ATTR_TYPE_DATE Then
oMyControl = oControls.CreateExistingDatepicker(oAttributeRow, oXPosition, oYPositionControl)
oMyControl = clsControls.CreateExistingDatepicker(oAttributeRow, oXPosition, oYPositionControl)
Dim myDTP As DateEdit = CType(oMyControl, DateEdit)
AddHandler myDTP.DisableCalendarDate, AddressOf DisableCalendarDate
AddHandler myDTP.DateTimeChanged, AddressOf CalendarChanged 'CalendarChanged
ElseIf oAttributeType = ATTR_TYPE_BOOLEAN Then
oMyControl = oControls.CreateExistingCheckbox(oAttributeRow, oXPosition, oYPositionControl)
oMyControl = clsControls.CreateExistingCheckbox(oAttributeRow, oXPosition, oYPositionControl)
Dim myCheckBox As CheckBox = CType(oMyControl, CheckBox)
AddHandler myCheckBox.CheckedChanged, AddressOf CheckBox_CheckedChanged
End If
@ -269,7 +279,7 @@ Public Class frmSearchStart
SelectedTab.Controls.Add(oMyControl)
If oAttributeType = ATTR_TYPE_STRING Or oAttributeType = ATTR_TYPE_INTEGER Then
oControls.DeselectGridControl(oMyControl)
clsControls.DeselectGridControl(oMyControl)
End If
End If
@ -278,6 +288,14 @@ Public Class frmSearchStart
oWatch4.Stop()
oWatch3.Stop()
Next
oSQL = $"SELECT [dbo].[FNIDB_SEARCH_GET_FILTER_SQL] ({SEARCH_ID},{My.Application.User.UserId},'{My.Application.User.Language}')"
Dim oREsult = My.DatabaseIDB.GetScalarValue(oSQL)
If Not IsNothing(oREsult) Then
DatatableStartSearchResult = My.DatabaseIDB.GetDatatable(oREsult)
End If
Catch ex As Exception
Logger.Warn("Unexpected error in Load_Search_Attributes - Error: " & ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Load_Search_Attributes:")
@ -285,6 +303,35 @@ Public Class frmSearchStart
DataLoaded = True
End Try
End Function
Private Function FilterbyAttribute(Attribute2Filter As String, pFilter As String, TermColumn As String) As DataTable
Try
Dim oDV As DataView = New DataView(DatatableStartSearchResult, pFilter, "", DataViewRowState.OriginalRows)
Dim oDT As DataTable = oDV.ToTable(True, TermColumn)
Return oDT
Catch ex As Exception
Logger.Error(ex.Message)
Return Nothing
End Try
End Function
Private Function RenewResultSoFar(pFilter As String) As DataTable
Try
Dim oDT2Filter As DataTable
' If DatatableSearchResultSoFar Is Nothing Then
oDT2Filter = DatatableStartSearchResult.Copy()
' Else
'oDT2Filter = DatatableSearchResultSoFar
' End If
Dim oDV As DataView = New DataView(oDT2Filter, pFilter, "", DataViewRowState.OriginalRows)
Dim oDT As DataTable = oDV.ToTable(True)
DatatableSearchResultSoFar = oDT
Display_InfoItem("FindResusult so far: " & DatatableSearchResultSoFar.Rows.Count.ToString, Color.Yellow)
Return DatatableSearchResultSoFar
Catch ex As Exception
Logger.Error(ex.Message)
Return Nothing
End Try
End Function
Sub addLabel(pAttrName As String, pXPos As Integer, ylbl As Integer)
Dim lbl As New Label With {
.Name = "lbl" & pAttrName,
@ -310,9 +357,20 @@ Public Class frmSearchStart
Private Sub ClearSelectedControls()
ChangedDateControls = Nothing
End Sub
Private Sub ClearAllRestrictedData()
Dim osql = $"DELETE FROM TBIDB_SEARCH_RESTRICTIONS_INPUT WHERE SEARCH_ID = {SEARCH_ID} and USR_ID = {My.Application.User.UserId}"
My.DatabaseIDB.ExecuteNonQuery(osql)
osql = $"DELETE FROM TBIDB_SEARCH_RESTRICTIONS_OBJECTS WHERE SEARCH_ID = {SEARCH_ID} AND USR_ID = {My.Application.User.UserId}"
My.DatabaseIDB.ExecuteNonQuery(osql)
End Sub
Private Sub ClearRestrictedDataAttr(pAttrID As Integer)
Dim osql = $"DELETE FROM TBIDB_SEARCH_RESTRICTIONS_INPUT WHERE SEARCH_ID = {SEARCH_ID} and USR_ID = {My.Application.User.UserId} AND RESTR_ATTR_ID = {pAttrID}"
My.DatabaseIDB.ExecuteNonQuery(osql)
End Sub
Private Sub RenewSearchAttributes()
ClearSearchCriteria()
ClearAllRestrictedData()
For Each oControl As Control In SelectedTab.Controls
Dim octrlType = oControl.GetType.ToString
@ -385,76 +443,295 @@ Public Class frmSearchStart
End Select
Next
End Sub
Private Sub Link2ControlActivated(pAttributeID)
Private Sub Relation2ControlActivated(pToAttributeID As Integer, pAttribute2Filter As String, pFilter As String, pTermColumn As String)
Try
For Each oControl As Control In SelectedTab.Controls
Dim octrlType = oControl.GetType.ToString
Dim oAttrID As Integer
Dim oAttrTitle As String
If octrlType = "System.Windows.Forms.Label" Then
Continue For
End If
oAttrID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
Select Case oControl.GetType.FullName
Case GetType(GridControl).FullName
Dim oMyGridControl As GridControl = CType(oControl, GridControl)
Dim oMyGridView As GridView = CType(oMyGridControl.MainView, GridView)
If pToAttributeID = oAttrID Then
Dim oDTSource As DataTable = FilterbyAttribute(pAttribute2Filter, pFilter, pTermColumn)
If Not IsNothing(oDTSource) Then
oDTSource.DefaultView.Sort = oAttrTitle '"ColumnName ASC"
oDTSource = oDTSource.DefaultView.ToTable
oMyGridControl.DataSource = oDTSource
oMyGridView.PopulateColumns()
oMyGridView.FocusInvalidRow()
End If
'MsgBox("Attribute" & oAttrTitle & " is linked" & vbNewLine & oinString)
Continue For
End If
For Each oControl As Control In SelectedTab.Controls
Dim octrlType = oControl.GetType.ToString
Case GetType(DateEdit).FullName
' MsgBox("Date")
Dim oDateEdit As DateEdit = CType(oControl, DateEdit)
If pToAttributeID = oAttrID Then
Continue For
End If
Case GetType(CheckBox).FullName
Dim myCheckBox As CheckBox = CType(oControl, CheckBox)
Case Else
'MsgBox(oControl.GetType.ToString)
End Select
Next
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Function ReplacePatterns(pInput As String, pAttrTitle As String) As String
Try
Dim oReturn = pInput
oReturn = oReturn.Replace("@USER_LANGUAGE", My.Application.User.Language)
oReturn = oReturn.Replace("@pUSER_ID", My.Application.User.UserId)
oReturn = oReturn.Replace("@RESULT_TITLE", pAttrTitle)
Return oReturn
Catch ex As Exception
Return pInput
Logger.Error(ex)
End Try
End Function
Private Sub RenewDatasourceControl(pToAttributeID As Integer, pSourceSQL As String)
Try
For Each oControl As Control In SelectedTab.Controls
Dim octrlType = oControl.GetType.ToString
Dim oAttrID As Integer
Dim oAttrTitle As String
If octrlType = "System.Windows.Forms.Label" Then
Continue For
End If
oAttrID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
If pToAttributeID = oAttrID Then
Dim oSourceSQL As String = ReplacePatterns(pSourceSQL, oAttrTitle)
Dim oDTSource As DataTable = My.DatabaseIDB.GetDatatable(oSourceSQL)
If Not IsNothing(oDTSource) Then
oDTSource.DefaultView.Sort = oAttrTitle '"ColumnName ASC"
oDTSource = oDTSource.DefaultView.ToTable
Select Case oControl.GetType.FullName
Case GetType(GridControl).FullName
Dim oMyGridControl As GridControl = CType(oControl, GridControl)
Dim oMyGridView As GridView = CType(oMyGridControl.MainView, GridView)
oMyGridControl.DataSource = oDTSource
oMyGridView.PopulateColumns()
oMyGridView.FocusInvalidRow()
Case GetType(DateEdit).FullName
' MsgBox("Date")
Dim oDateEdit As DateEdit = CType(oControl, DateEdit)
Case GetType(CheckBox).FullName
Dim myCheckBox As CheckBox = CType(oControl, CheckBox)
Case Else
'MsgBox(oControl.GetType.ToString)
End Select
End If
End If
Next
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub Link2ControlActivated(pFromAttributeID As Integer, pToAttributeID As Integer, pListSelected As List(Of String), pSourceSQL As String)
Try
For Each oControl As Control In SelectedTab.Controls
Dim octrlType = oControl.GetType.ToString
Dim oAttrID As Integer
Dim oAttrTitle As String
If octrlType = "System.Windows.Forms.Label" Then
Continue For
End If
oAttrID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
Select Case oControl.GetType.FullName
Case GetType(GridControl).FullName
Dim oMyGridControl As GridControl = CType(oControl, GridControl)
Dim oMyGridView As GridView = CType(oMyGridControl.MainView, GridView)
If pToAttributeID = oAttrID Then
ClearRestrictedDataAttr(pToAttributeID)
Dim i As Integer = 0
Dim oinString As String = " in ("
For Each oOBJ_ID As String In pListSelected
Dim oinsert As String = $"INSERT INTO [dbo].[TBIDB_SEARCH_RESTRICTIONS_INPUT] ([SEARCH_ID],[RESTR_ATTR_ID],[SOURCE_ATTR_ID] ,[TERM],[USR_ID]) VALUES ({SEARCH_ID},{pToAttributeID},{pFromAttributeID},'{oOBJ_ID}',{My.Application.User.UserId})"
My.DatabaseIDB.ExecuteNonQuery(oinsert)
If i = 0 Then
oinString += "'" + oOBJ_ID.ToString + "'"
Else
oinString = oinString + ",'" + oOBJ_ID.ToString + "'"
End If
i += 1
Next
oinString += ")"
Dim oSourceSQL As String = pSourceSQL
oSourceSQL = oSourceSQL.Replace("@USER_LANGUAGE", My.Application.User.Language)
oSourceSQL = oSourceSQL.Replace("@pUSER_ID", My.Application.User.UserId)
oSourceSQL = oSourceSQL.Replace("@RESULT_TITLE", oAttrTitle)
oSourceSQL &= $" Inner Join TBIDB_SEARCH_RESTRICTIONS_OBJECTS T1 ON T.IDB_OBJECT_ID = T1.IDB_OBJ_ID " &
$"WHERE RESTR_ATTR_ID = {pToAttributeID} And SEARCH_ID = {SEARCH_ID} And USR_ID = {My.Application.User.UserId} "
'oSourceSQL &= " ORDER BY T.TERM_VALUE"
Dim oDTSource As DataTable
If Utils.NotNull(oSourceSQL, String.Empty) <> String.Empty Then
oDTSource = My.DatabaseIDB.GetDatatable(oSourceSQL)
If Not IsNothing(oDTSource) Then
oDTSource.DefaultView.Sort = oAttrTitle '"ColumnName ASC"
oDTSource = oDTSource.DefaultView.ToTable
oMyGridControl.DataSource = oDTSource
oMyGridView.PopulateColumns()
oMyGridView.FocusInvalidRow()
End If
End If
'MsgBox("Attribute" & oAttrTitle & " is linked" & vbNewLine & oinString)
Continue For
End If
Case GetType(DateEdit).FullName
' MsgBox("Date")
Dim oDateEdit As DateEdit = CType(oControl, DateEdit)
If pToAttributeID = oAttrID Then
Continue For
End If
Case GetType(CheckBox).FullName
Dim myCheckBox As CheckBox = CType(oControl, CheckBox)
Case Else
'MsgBox(oControl.GetType.ToString)
End Select
Next
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub SelectionChanged(sender As Object, e As DevExpress.Data.SelectionChangedEventArgs)
Try
If DataLoaded = False Then Exit Sub
Dim oMyGridView As GridView = DirectCast(sender, GridView)
Dim oMyGridControl As GridControl = oMyGridView.GridControl
Dim oAttrID As Integer
Dim oAttrTitle As String
Select Case oControl.GetType.FullName
Case GetType(GridControl).FullName
Dim oMyGridControl As GridControl = CType(oControl, GridControl)
Dim oMyGridView As GridView = CType(oMyGridControl.MainView, GridView)
oAttrID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
If pAttributeID = oAttrID Then
MsgBox("Attribute" & oAttrTitle & " is linked")
Continue For
oAttrID = DirectCast(oMyGridControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oMyGridControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
Dim oSelectedRows As Integer() = oMyGridView.GetSelectedRows()
If oSelectedRows.Count = 0 Then
ClearRestrictedDataAttr(oAttrID)
For Each orow As DataRow In DatatableAttributeLinks.Rows
If CInt(orow.Item("LINKED_ATTR_ID")) = oAttrID Then
' Nun die Controls durchlaufen
RenewDatasourceControl(CInt(orow.Item("DEP_ATTR_ID")), orow.Item("DEP_SOURCE_SQL").ToString)
End If
Case GetType(DateEdit).FullName
' MsgBox("Date")
Dim oDateEdit As DateEdit = CType(oControl, DateEdit)
oAttrID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
If pAttributeID = oAttrID Then
Continue For
End If
Case GetType(CheckBox).FullName
Dim myCheckBox As CheckBox = CType(oControl, CheckBox)
oAttrID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
Case Else
'MsgBox(oControl.GetType.ToString)
End Select
Next
End Sub
Private Sub FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs)
If DataLoaded = False Then Exit Sub
Dim oMyGridView As GridView = DirectCast(sender, GridView)
Dim oMyGridControl As GridControl = oMyGridView.GridControl
Dim oSelectedRows As Integer() = oMyGridView.GetSelectedRows()
If oSelectedRows.Count = 0 Then
Exit Sub
End If
Dim oAttrID As Integer
Dim oAttrTitle As String
oAttrID = DirectCast(oMyGridControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oMyGridControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
For Each orow As DataRow In DatatableAttributeLinks.Rows
If CInt(orow.Item("LINKED_ATTR_ID")) = oAttrID Then
' Nun die Controls durchlaufen
Link2ControlActivated(CInt(orow.Item("DEP_ATTR_ID")))
Next
Exit Sub
End If
Next
Dim oList As New List(Of String)
For Each oRowHandle As Integer In oSelectedRows
Dim oSelectedItem As String = oMyGridView.GetRowCellValue(oRowHandle, oMyGridView.Columns(0).FieldName)
oList.Add("'" + oSelectedItem + "'")
Next
Dim oFilter As String = oAttrTitle + " in (" + String.Join(",", oList) + ")"
RenewResultSoFar(oFilter)
For Each orow As DataRow In DatatableAttributeLinks.Rows
If CInt(orow.Item("LINKED_ATTR_ID")) = oAttrID Then
' Nun die Controls durchlaufen
Relation2ControlActivated(CInt(orow.Item("DEP_ATTR_ID")), oAttrTitle, oFilter, orow.Item("DEP_ATTRIBUTE_TITLE").ToString)
'Link2ControlActivated(oAttrID, CInt(orow.Item("DEP_ATTR_ID")), oList, orow.Item("DEP_SOURCE_SQL"))
End If
Next
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs)
Try
If DataLoaded = False Then Exit Sub
Dim oMyGridView As GridView = DirectCast(sender, GridView)
Dim oMyGridControl As GridControl = oMyGridView.GridControl
Dim oSelectedRows As Integer() = oMyGridView.GetSelectedRows()
If oSelectedRows.Count = 0 Then
Exit Sub
End If
Dim oList As New List(Of String)
For Each oRowHandle As Integer In oSelectedRows
Dim oSelectedItem As String = oMyGridView.GetRowCellValue(oRowHandle, oMyGridView.Columns(0).FieldName)
oList.Add(oSelectedItem)
Next
Dim oAttrID As Integer
Dim oAttrTitle As String
oAttrID = DirectCast(oMyGridControl.Tag, ClassControlCreator.ControlMetadata).AttributeID
oAttrTitle = DirectCast(oMyGridControl.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
Dim oFilter As String = oAttrTitle + " = (" + String.Join(",", oList) + ")"
RenewResultSoFar(oFilter)
For Each orow As DataRow In DatatableAttributeLinks.Rows
If CInt(orow.Item("LINKED_ATTR_ID")) = oAttrID Then
' Nun die Controls durchlaufen
Relation2ControlActivated(CInt(orow.Item("DEP_ATTR_ID")), oAttrTitle, oFilter, orow.Item("DEP_ATTRIBUTE_TITLE").ToString)
' Link2ControlActivated(oAttrID, CInt(orow.Item("DEP_ATTR_ID")), oList, orow.Item("DEP_SOURCE_SQL"))
End If
Next
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub CheckBox_CheckedChanged(sender As Object, e As EventArgs)
If DataLoaded = False Then Exit Sub
Dim oCurrentCB As CheckBox = DirectCast(sender, CheckBox)
Dim oChecked = oCurrentCB.Checked
Dim oAttrID = DirectCast(oCurrentCB.Tag, ClassControlCreator.ControlMetadata).AttributeID
Dim oAttrTitle = DirectCast(oCurrentCB.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
'RenewSearchAttributes()
' AddSearchAttribute(oAttrID, oAttrTitle, oChecked.ToString)
Try
If DataLoaded = False Then Exit Sub
Dim oCurrentCB As CheckBox = DirectCast(sender, CheckBox)
Dim oChecked = oCurrentCB.Checked
Dim oAttrID = DirectCast(oCurrentCB.Tag, ClassControlCreator.ControlMetadata).AttributeID
Dim oAttrTitle = DirectCast(oCurrentCB.Tag, ClassControlCreator.ControlMetadata).AttributeTitle
'RenewSearchAttributes()
' AddSearchAttribute(oAttrID, oAttrTitle, oChecked.ToString)
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub frmSearchStart_Shown(sender As Object, e As EventArgs) Handles Me.Shown
DataLoaded = True
@ -507,6 +784,7 @@ Public Class frmSearchStart
Try
ClearSearchCriteria()
ClearSelectedControls()
ClearAllRestrictedData()
Catch ex As Exception
MsgBox("Unexpected Error in Clearing Search Items: " & ex.Message, MsgBoxStyle.Critical)
End Try