MS Push
This commit is contained in:
@@ -9,12 +9,15 @@ Public Class frmSearchStart
|
||||
Private DTSearchProfiles As DataTable
|
||||
Private TabSelectedIndex As Integer
|
||||
Private TabSelected As XtraTabPage
|
||||
Private CURR_CTRL_OBJ As Object
|
||||
Private PSEARCH_ID As Integer = 0
|
||||
Private PSEARCH_BASE_RESULT_SQL As String
|
||||
Public FormShown As Boolean = False
|
||||
Private SEARCH_SQL As String
|
||||
Private SEARCH_TITLE As String
|
||||
Public DataLoaded As Boolean = False
|
||||
Private Const DEFAULT_X As Integer = 10
|
||||
Private Const DEFAULT_Y As Integer = 10
|
||||
Private DTSearchTerms As DataTable
|
||||
Private oDTAttributes As DataTable
|
||||
Private SEARCH_COUNT As Integer = 0
|
||||
|
||||
Public Sub New(pDTSearchProfiles As DataTable)
|
||||
@@ -27,27 +30,74 @@ Public Class frmSearchStart
|
||||
Dim oSearchTerms As New DataTable
|
||||
|
||||
' Create four typed columns in the DataTable.
|
||||
oSearchTerms.Columns.Add("BracketLeft", GetType(String))
|
||||
oSearchTerms.Columns.Add("AttrID", GetType(Integer))
|
||||
oSearchTerms.Columns.Add("AttrTitle", GetType(String))
|
||||
oSearchTerms.Columns.Add("Criteria", GetType(String))
|
||||
oSearchTerms.Columns.Add("SearchTerm", GetType(String))
|
||||
oSearchTerms.Columns.Add("BracketRight", GetType(String))
|
||||
oSearchTerms.Columns.Add("Operator", GetType(String))
|
||||
DTSearchTerms = oSearchTerms
|
||||
|
||||
|
||||
End Sub
|
||||
Public Sub AddSearchAttribute(pAttrID As String, pAttrTitle As String, pSearchTerm As String, Optional pCriteria As String = "=")
|
||||
For Each oSearchTerm As DataRow In DTSearchTerms.Rows
|
||||
If oSearchTerm.Item("AttrID") = pAttrID Then 'And oSearchTerm.Item("Criteria") = pCriteria And oSearchTerm.Item("SearchTerm") = pSearchTerm
|
||||
oSearchTerm.Delete()
|
||||
GridControlSerchTerms.DataSource = Nothing
|
||||
Dim oMultiselect As Boolean = False
|
||||
For Each oROW As DataRow In oDTAttributes.Rows
|
||||
If oROW.Item("ATTRIBUTE_ID") = pAttrID Then
|
||||
oMultiselect = CBool(oROW.Item("MULTISELECT"))
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
DTSearchTerms.Rows.Add(pAttrID, pAttrTitle, pCriteria, pSearchTerm)
|
||||
DTSearchTerms.AcceptChanges()
|
||||
AddToken(pAttrTitle & " " & pCriteria & " '" & pSearchTerm & "'")
|
||||
If oMultiselect = False Then
|
||||
For Each oSearchTerm As DataRow In DTSearchTerms.Rows
|
||||
If oSearchTerm.Item("AttrID") = pAttrID Then 'And oSearchTerm.Item("Criteria") = pCriteria And oSearchTerm.Item("SearchTerm") = pSearchTerm
|
||||
oSearchTerm.Delete()
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
DTSearchTerms.Rows.Add("", pAttrID, pAttrTitle, pCriteria, pSearchTerm, "", "and")
|
||||
RenewBinding_DTSearchTerms()
|
||||
|
||||
If SplitContainerControlSearch.Collapsed = True Then
|
||||
SplitContainerControlSearch.Collapsed = False
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Sub RenewBinding_DTSearchTerms()
|
||||
DTSearchTerms.AcceptChanges()
|
||||
GridControlSerchTerms.DataSource = Nothing
|
||||
GridControlSerchTerms.DataSource = DTSearchTerms
|
||||
'"BracketLeft"
|
||||
'"AttrID", GetType(Integer))
|
||||
'"AttrTitle"
|
||||
'"Criteria"
|
||||
'"SearchTerm"
|
||||
'"BracketRight"
|
||||
'"Operator"
|
||||
GridViewSearchTerms.Columns("BracketLeft").Caption = "("
|
||||
GridViewSearchTerms.Columns("BracketRight").Caption = ")"
|
||||
If My.Application.User.Language <> "de-DE" Then
|
||||
GridViewSearchTerms.Columns("AttrTitle").Caption = "Attribute"
|
||||
GridViewSearchTerms.Columns("Criteria").Caption = "Criteria"
|
||||
Else
|
||||
GridViewSearchTerms.Columns("AttrTitle").Caption = "Attribut"
|
||||
GridViewSearchTerms.Columns("Criteria").Caption = "Bedingung"
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SearchAttribute(pAttrID As String, pAttrTitle As String, pSearchTerm As String, Optional pCriteria As String = "=")
|
||||
DTSearchTerms.Rows.Add(pAttrID, pAttrTitle, pCriteria, pSearchTerm)
|
||||
'"BracketLeft"
|
||||
'"AttrID", GetType(Integer))
|
||||
'"AttrTitle"
|
||||
'"Criteria"
|
||||
'"SearchTerm"
|
||||
'"BracketRight"
|
||||
'"Operator"
|
||||
DTSearchTerms.Rows.Add("", pAttrID, pAttrTitle, pCriteria, pSearchTerm, "", "And")
|
||||
DTSearchTerms.AcceptChanges()
|
||||
|
||||
End Sub
|
||||
@@ -69,17 +119,28 @@ Public Class frmSearchStart
|
||||
TabSelectedIndex = -1
|
||||
|
||||
Me.Panel1.Visible = True
|
||||
For Each orow As DataRow In DTSearchProfiles.Rows
|
||||
RepositoryItemComboBox1.Items.Add(orow.Item("TITLE"))
|
||||
Next
|
||||
|
||||
Else
|
||||
TabSelectedIndex = 0
|
||||
TabSelected = XtraTabControl1.TabPages(0)
|
||||
TabSelected.PageVisible = True
|
||||
PSEARCH_ID = DTSearchProfiles.Rows(0).Item("SEARCH_PROFILE_ID")
|
||||
PSEARCH_BASE_RESULT_SQL = DTSearchProfiles.Rows(0).Item("RESULT_SQL")
|
||||
SEARCH_SQL = DTSearchProfiles.Rows(0).Item("RESULT_SQL")
|
||||
SEARCH_TITLE = DTSearchProfiles.Rows(0).Item("TITLE")
|
||||
TabSelected.Text = DTSearchProfiles.Rows(0).Item("TITLE")
|
||||
Load_Search_Attributes()
|
||||
BarButtonItemNewSearch.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
||||
End If
|
||||
SEARCH_COUNT = DTSearchProfiles.Rows.Count
|
||||
SplitContainerControlSearch.Collapsed = True
|
||||
RibbonControl1.ColorScheme = DevExpress.XtraBars.Ribbon.RibbonControlColorScheme.Red
|
||||
If My.UIConfig.SearchForm.Location.X > 0 And My.UIConfig.SearchForm.Location.Y > 0 Then
|
||||
Me.Location = My.UIConfig.SearchForm.Location
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex.Message)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error while loading ProfileSearches:")
|
||||
@@ -87,106 +148,123 @@ Public Class frmSearchStart
|
||||
|
||||
End Sub
|
||||
Sub Load_Search_Attributes()
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_SEARCH_PROFILE_ATTRIBUTES WHERE SEARCH_PROFIL_ID = {PSEARCH_ID} ORDER BY [SEQUENCE]"
|
||||
Dim oDT As DataTable = My.Database_IDB.GetDatatable(oSQL)
|
||||
Try
|
||||
DataLoaded = False
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_SEARCH_PROFILE_ATTRIBUTES WHERE SEARCH_PROFIL_ID = {PSEARCH_ID} ORDER BY [SEQUENCE]"
|
||||
Dim oDT As DataTable = My.Database_IDB.GetDatatable(oSQL)
|
||||
oDTAttributes = Nothing
|
||||
oDTAttributes = oDT.Clone()
|
||||
oDT.Select("", "SEQUENCE").CopyToDataTable(oDTAttributes, LoadOption.PreserveChanges)
|
||||
oDTAttributes.Columns.Add("MULTISELECT", GetType(Boolean))
|
||||
oDTAttributes.AcceptChanges()
|
||||
For Each oAttributeRow As DataRow In oDTAttributes.Rows
|
||||
oAttributeRow.Item("MULTISELECT") = False
|
||||
Next
|
||||
Dim oControlCount As Integer = 1
|
||||
Dim oControlRow As Integer = 0
|
||||
Dim oControls As New ClassControlCreator(TabSelected, Me)
|
||||
Dim YMax As Integer = 0
|
||||
Dim YActControlHeight As Integer = 0
|
||||
Dim XActControlWidth As Integer = 0
|
||||
Dim iList As New List(Of Integer)()
|
||||
iList.Add(2)
|
||||
iList.Add(3)
|
||||
iList.Add(5)
|
||||
iList.Add(6)
|
||||
iList.Add(8)
|
||||
iList.Add(9)
|
||||
For Each oAttributeRow As DataRow In oDT.Rows
|
||||
Dim oXPosition As Integer
|
||||
Dim oYPositionControl As Integer
|
||||
Dim oYPositionLabel As Integer
|
||||
|
||||
Dim oControlCount As Integer = 1
|
||||
Dim oControlRow As Integer = 0
|
||||
Dim oControls As New ClassControlCreator(TabSelected, Me)
|
||||
Dim YMax As Integer = 0
|
||||
Dim YActControlHeight As Integer = 0
|
||||
Dim XActControlWidth As Integer = 0
|
||||
Dim iList As New List(Of Integer)()
|
||||
iList.Add(2)
|
||||
iList.Add(3)
|
||||
iList.Add(5)
|
||||
iList.Add(6)
|
||||
iList.Add(8)
|
||||
iList.Add(9)
|
||||
For Each oAttributeRow As DataRow In oDT.Rows
|
||||
Dim oXPosition As Integer
|
||||
Dim oYPositionControl As Integer
|
||||
Dim oYPositionLabel As Integer
|
||||
|
||||
Dim oSingleResult As Boolean = False
|
||||
Dim oAttriTitle As String = oAttributeRow.Item("ATTRIBUTE_TITLE").ToString
|
||||
Dim oAttriID As String = oAttributeRow.Item("ATTRIBUTE_ID").ToString
|
||||
Dim oAttriTYPE As String = oAttributeRow.Item("ATTRIBUTE_TYPE").ToString
|
||||
If oControlCount = 1 Or oControlCount = 5 Or oControlCount = 9 Then
|
||||
oControlRow += 1
|
||||
End If
|
||||
If oControlRow = 1 Then
|
||||
If oControlCount = 1 Then
|
||||
oXPosition = 10
|
||||
oYPositionLabel = 10
|
||||
oYPositionControl = oYPositionLabel + 20
|
||||
Dim oSingleResult As Boolean = False
|
||||
Dim oAttriTitle As String = oAttributeRow.Item("ATTRIBUTE_TITLE").ToString
|
||||
Dim oAttriID As String = oAttributeRow.Item("ATTRIBUTE_ID").ToString
|
||||
Dim oAttriTYPE As String = oAttributeRow.Item("ATTRIBUTE_TYPE").ToString
|
||||
If oControlCount = 1 Or oControlCount = 5 Or oControlCount = 9 Then
|
||||
oControlRow += 1
|
||||
End If
|
||||
ElseIf oControlRow = 2 Then
|
||||
If oControlCount = 5 Then
|
||||
oXPosition = 10
|
||||
oYPositionLabel = YActControlHeight + 10
|
||||
oYPositionControl = oYPositionLabel + 20
|
||||
If oControlRow = 1 Then
|
||||
If oControlCount = 1 Then
|
||||
oXPosition = 10
|
||||
oYPositionLabel = 10
|
||||
oYPositionControl = oYPositionLabel + 20
|
||||
End If
|
||||
ElseIf oControlRow = 2 Then
|
||||
If oControlCount = 5 Then
|
||||
oXPosition = 10
|
||||
oYPositionLabel = YActControlHeight + 10
|
||||
oYPositionControl = oYPositionLabel + 20
|
||||
|
||||
End If
|
||||
ElseIf oControlRow = 3 Then
|
||||
If oControlCount = 9 Then
|
||||
oXPosition = 10
|
||||
End If
|
||||
End If
|
||||
ElseIf oControlRow = 3 Then
|
||||
If oControlCount = 9 Then
|
||||
oXPosition = 10
|
||||
|
||||
Dim oControlHeight As Integer = CInt(oAttributeRow.Item("HEIGHT"))
|
||||
Dim oControlWidth As Integer = CInt(oAttributeRow.Item("WIDTH"))
|
||||
|
||||
|
||||
'Erst mal das Label hinzufügen
|
||||
'If oAttriTYPE <> "BIT" Then
|
||||
addLabel(oAttriTitle, oXPosition, oYPositionLabel)
|
||||
'End If
|
||||
|
||||
'Nun das Control mit dem entsprechenden Abstand und der Größe
|
||||
Dim oXDistance As Integer, oYDistance As Integer
|
||||
Dim oCalcHeight As Integer
|
||||
Dim oCalcWidth As Integer
|
||||
If oAttriTYPE = "VARCHAR" Or oAttriTYPE = "BIG INTEGER" Then
|
||||
oCalcHeight = oControlHeight + oYPositionControl
|
||||
oCalcWidth = oControlWidth
|
||||
ElseIf (oAttriTYPE = "DATE" Or oAttriTYPE = "BIT") Then
|
||||
oCalcHeight = 20 + oYPositionControl
|
||||
oCalcWidth = 100
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim oControlHeight As Integer = CInt(oAttributeRow.Item("HEIGHT"))
|
||||
Dim oControlWidth As Integer = CInt(oAttributeRow.Item("WIDTH"))
|
||||
|
||||
|
||||
'Erst mal das Label hinzufügen
|
||||
'If oAttriTYPE <> "BIT" Then
|
||||
addLabel(oAttriTitle, oXPosition, oYPositionLabel)
|
||||
'End If
|
||||
|
||||
'Nun das Control mit dem entsprechenden Abstand und der Größe
|
||||
Dim oXDistance As Integer, oYDistance As Integer
|
||||
Dim oCalcHeight As Integer
|
||||
Dim oCalcWidth As Integer
|
||||
If oAttriTYPE = "VARCHAR" Or oAttriTYPE = "BIG INTEGER" Then
|
||||
oCalcHeight = oControlHeight + oYPositionControl
|
||||
oCalcWidth = oControlWidth
|
||||
ElseIf (oAttriTYPE = "DATE" Or oAttriTYPE = "BIT") Then
|
||||
oCalcHeight = 20 + oYPositionControl
|
||||
oCalcWidth = 100
|
||||
End If
|
||||
If oCalcHeight > YActControlHeight Then
|
||||
YActControlHeight = oCalcHeight
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim oMyControl As Control
|
||||
If oAttriTYPE = "VARCHAR" Or oAttriTYPE = "BIG INTEGER" Then
|
||||
oMyControl = oControls.CreateExistingGridControl(oAttributeRow, oXPosition, oYPositionControl)
|
||||
Dim myDGV As GridControl = CType(oMyControl, GridControl)
|
||||
Dim omyDTSource As DataTable = CType(myDGV.DataSource, DataTable)
|
||||
Dim oView As DevExpress.XtraGrid.Views.Grid.GridView
|
||||
oView = CType(myDGV.MainView, GridView)
|
||||
AddHandler oView.FocusedRowChanged, AddressOf FocusedRowChanged
|
||||
If omyDTSource.Rows.Count = 1 Then
|
||||
oSingleResult = True
|
||||
AddSearchAttribute(oAttriID, oAttriTitle, omyDTSource.Rows(0).Item(oAttriTitle).ToString)
|
||||
If oCalcHeight > YActControlHeight Then
|
||||
YActControlHeight = oCalcHeight
|
||||
End If
|
||||
ElseIf oAttriTYPE = "DATE" Then
|
||||
oMyControl = oControls.CreateExistingDatepicker(oAttributeRow, oXPosition, oYPositionControl)
|
||||
Dim myDTP As DateEdit = CType(oMyControl, DateEdit)
|
||||
AddHandler myDTP.DisableCalendarDate, AddressOf DisableCalendarDate
|
||||
ElseIf oAttriTYPE = "BIT" Then
|
||||
oMyControl = oControls.CreateExistingCheckbox(oAttributeRow, oXPosition, oYPositionControl)
|
||||
Dim myCheckBox As CheckBox = CType(oMyControl, CheckBox)
|
||||
AddHandler myCheckBox.CheckedChanged, AddressOf CheckBox_CheckedChanged
|
||||
End If
|
||||
|
||||
oControlCount += 1
|
||||
TabSelected.Controls.Add(oMyControl)
|
||||
oXPosition += oControlWidth + 20
|
||||
|
||||
Next
|
||||
|
||||
Dim oMyControl As Control
|
||||
If oAttriTYPE = "VARCHAR" Or oAttriTYPE = "BIG INTEGER" Then
|
||||
oMyControl = oControls.CreateExistingGridControl(oAttributeRow, oXPosition, oYPositionControl)
|
||||
Dim myDGV As GridControl = CType(oMyControl, GridControl)
|
||||
myDGV.ContextMenuStrip = ContextMenuStripMultiselect
|
||||
Dim omyDTSource As DataTable = CType(myDGV.DataSource, DataTable)
|
||||
Dim oView As DevExpress.XtraGrid.Views.Grid.GridView
|
||||
oView = CType(myDGV.MainView, GridView)
|
||||
AddHandler oView.FocusedRowChanged, AddressOf FocusedRowChanged
|
||||
If omyDTSource.Rows.Count = 1 Then
|
||||
oSingleResult = True
|
||||
AddSearchAttribute(oAttriID, oAttriTitle, omyDTSource.Rows(0).Item(oAttriTitle).ToString)
|
||||
End If
|
||||
ElseIf oAttriTYPE = "DATE" Then
|
||||
oMyControl = oControls.CreateExistingDatepicker(oAttributeRow, oXPosition, oYPositionControl)
|
||||
Dim myDTP As DateEdit = CType(oMyControl, DateEdit)
|
||||
AddHandler myDTP.DisableCalendarDate, AddressOf DisableCalendarDate
|
||||
ElseIf oAttriTYPE = "BIT" Then
|
||||
oMyControl = oControls.CreateExistingCheckbox(oAttributeRow, oXPosition, oYPositionControl)
|
||||
Dim myCheckBox As CheckBox = CType(oMyControl, CheckBox)
|
||||
AddHandler myCheckBox.CheckedChanged, AddressOf CheckBox_CheckedChanged
|
||||
End If
|
||||
|
||||
oControlCount += 1
|
||||
TabSelected.Controls.Add(oMyControl)
|
||||
oXPosition += oControlWidth + 20
|
||||
|
||||
Next
|
||||
DataLoaded = True
|
||||
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:")
|
||||
DataLoaded = True
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
Sub addLabel(pAttrName As String, pXPos As Integer, ylbl As Integer)
|
||||
Dim lbl As New Label With {
|
||||
@@ -198,7 +276,7 @@ Public Class frmSearchStart
|
||||
|
||||
TabSelected.Controls.Add(lbl)
|
||||
End Sub
|
||||
Private Sub WindowsUIButtonPanel1_ButtonClick(sender As Object, e As DevExpress.XtraBars.Docking2010.ButtonEventArgs) Handles WindowsUIButtonPanel1.ButtonClick
|
||||
Private Sub WindowsUIButtonPanel1_ButtonClick(sender As Object, e As DevExpress.XtraBars.Docking2010.ButtonEventArgs)
|
||||
Select Case e.Button.Properties.Tag.ToString
|
||||
Case "Run"
|
||||
RunSearch()
|
||||
@@ -218,7 +296,7 @@ Public Class frmSearchStart
|
||||
TabSelected = XtraTabControl1.SelectedTabPage
|
||||
End Sub
|
||||
Private Sub FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs)
|
||||
If FormShown = False Then Exit Sub
|
||||
If DataLoaded = False Then Exit Sub
|
||||
Dim oCurrentView As GridView = DirectCast(sender, GridView)
|
||||
Dim oCurrentControl As GridControl = oCurrentView.GridControl
|
||||
|
||||
@@ -236,7 +314,7 @@ Public Class frmSearchStart
|
||||
|
||||
End Sub
|
||||
Private Sub CheckBox_CheckedChanged(sender As Object, e As EventArgs)
|
||||
If FormShown = False Then Exit Sub
|
||||
If DataLoaded = False Then Exit Sub
|
||||
Dim oCurrentCB As CheckBox = DirectCast(sender, CheckBox)
|
||||
Dim oChecked = oCurrentCB.Checked
|
||||
Dim oAttrID = DirectCast(oCurrentCB.Tag, ClassControlCreator.ControlMetadata).AttrID
|
||||
@@ -244,7 +322,7 @@ Public Class frmSearchStart
|
||||
AddSearchAttribute(oAttrID, oAttrTitle, oChecked.ToString)
|
||||
End Sub
|
||||
Private Sub frmSearchStart_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
FormShown = True
|
||||
DataLoaded = True
|
||||
End Sub
|
||||
|
||||
Private Sub DisableCalendarDate(sender As Object, e As DevExpress.XtraEditors.Calendar.DisableCalendarDateEventArgs)
|
||||
@@ -271,23 +349,23 @@ Public Class frmSearchStart
|
||||
Next
|
||||
Return oIsValid
|
||||
End Function
|
||||
Private Sub Clear_token()
|
||||
Try
|
||||
TokenEdit1.Properties.BeginUpdate()
|
||||
Dim oCount As Int16 = 1
|
||||
For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
TokenEdit1.RemoveItem($"criteria{oCount}")
|
||||
oCount += 1
|
||||
Next
|
||||
TokenEdit1.Properties.EndUpdate()
|
||||
Catch ex As Exception
|
||||
'Private Sub Clear_token()
|
||||
' Try
|
||||
' TokenEdit1.Properties.BeginUpdate()
|
||||
' Dim oCount As Int16 = 1
|
||||
' For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
' TokenEdit1.RemoveItem($"criteria{oCount}")
|
||||
' oCount += 1
|
||||
' Next
|
||||
' TokenEdit1.Properties.EndUpdate()
|
||||
' Catch ex As Exception
|
||||
|
||||
End Try
|
||||
' End Try
|
||||
|
||||
End Sub
|
||||
'End Sub
|
||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||
Try
|
||||
Clear_token()
|
||||
'Clear_token()
|
||||
DTSearchTerms.Clear()
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -298,58 +376,58 @@ Public Class frmSearchStart
|
||||
|
||||
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
||||
|
||||
TokenEdit1.Properties.BeginUpdate()
|
||||
'TokenEdit1.Properties.BeginUpdate()
|
||||
''TokenEdit1.Properties.Tokens.AddToken("Column1 = 'Value1'", "criteria1")
|
||||
|
||||
'TokenEdit1.Properties.Tokens.AddToken("Column1 = 'Value1'", "criteria1")
|
||||
|
||||
TokenEdit1.Properties.Tokens.AddToken("Column1 = 'Value1'", "criteria1")
|
||||
TokenEdit1.Properties.Tokens.AddToken("Column2 > 20", "criteria2")
|
||||
TokenEdit1.Properties.Tokens.AddToken("Column3 <> 'Harry'", "criteria3")
|
||||
TokenEdit1.EditValue = "criteria1, criteria2, criteria3"
|
||||
' ... add more tokens
|
||||
TokenEdit1.Properties.EndUpdate()
|
||||
'TokenEdit1.Properties.Tokens.AddToken("Column2 > 20", "criteria2")
|
||||
'TokenEdit1.Properties.Tokens.AddToken("Column3 <> 'Harry'", "criteria3")
|
||||
'TokenEdit1.EditValue = "criteria1, criteria2, criteria3"
|
||||
'' ... add more tokens
|
||||
'TokenEdit1.Properties.EndUpdate()
|
||||
End Sub
|
||||
Private Sub AddToken(CriteriaString As String)
|
||||
Try
|
||||
Clear_token()
|
||||
TokenEdit1.Properties.BeginUpdate()
|
||||
''oRow.Item("AttrTitle") & " " & oRow.Item("Criteria") & " '" & oRow.Item("SearchTerm") & "'"
|
||||
Dim oCount As Int16 = 1
|
||||
For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
Try
|
||||
Dim oCriteriaString = oRow.Item("AttrTitle") & " " & oRow.Item("Criteria") & " '" & oRow.Item("SearchTerm") & "'"
|
||||
TokenEdit1.Properties.Tokens.AddToken(CriteriaString, "criteria" + oCount.ToString)
|
||||
Catch ex As Exception
|
||||
'Private Sub AddToken(CriteriaString As String)
|
||||
' Try
|
||||
' Clear_token()
|
||||
' TokenEdit1.Properties.BeginUpdate()
|
||||
' ''oRow.Item("AttrTitle") & " " & oRow.Item("Criteria") & " '" & oRow.Item("SearchTerm") & "'"
|
||||
' Dim oCount As Int16 = 1
|
||||
' For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
' Try
|
||||
' Dim oCriteriaString = oRow.Item("AttrTitle") & " " & oRow.Item("Criteria") & " '" & oRow.Item("SearchTerm") & "'"
|
||||
' TokenEdit1.Properties.Tokens.AddToken(CriteriaString, "criteria" + oCount.ToString)
|
||||
' Catch ex As Exception
|
||||
|
||||
End Try
|
||||
' End Try
|
||||
|
||||
oCount += 1
|
||||
Next
|
||||
' Dim oTokenCount = DTSearchTerms.Rows.Count
|
||||
'TokenEdit1.Properties.BeginUpdate()
|
||||
'TokenEdit1.Properties.Tokens.AddToken(CriteriaString, "criteria" + oCount.ToString)
|
||||
Dim otokenEditString = ""
|
||||
oCount = 1
|
||||
For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
If oCount = 1 Then
|
||||
otokenEditString = "criteria1"
|
||||
Else
|
||||
otokenEditString &= $", criteria{oCount}"
|
||||
End If
|
||||
oCount += 1
|
||||
Next
|
||||
TokenEdit1.EditValue = otokenEditString
|
||||
' ... add more tokens
|
||||
TokenEdit1.Properties.EndUpdate()
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in AddToken: " & ex.Message, MsgBoxStyle.Critical)
|
||||
Logger.Warn("Unexpected Error in AddToken: " & ex.Message)
|
||||
End Try
|
||||
' oCount += 1
|
||||
' Next
|
||||
' ' Dim oTokenCount = DTSearchTerms.Rows.Count
|
||||
' 'TokenEdit1.Properties.BeginUpdate()
|
||||
' 'TokenEdit1.Properties.Tokens.AddToken(CriteriaString, "criteria" + oCount.ToString)
|
||||
' Dim otokenEditString = ""
|
||||
' oCount = 1
|
||||
' For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
' If oCount = 1 Then
|
||||
' otokenEditString = "criteria1"
|
||||
' Else
|
||||
' otokenEditString &= $", criteria{oCount}"
|
||||
' End If
|
||||
' oCount += 1
|
||||
' Next
|
||||
' TokenEdit1.EditValue = otokenEditString
|
||||
' ' ... add more tokens
|
||||
' TokenEdit1.Properties.EndUpdate()
|
||||
' Catch ex As Exception
|
||||
' MsgBox("Unexpected Error in AddToken: " & ex.Message, MsgBoxStyle.Critical)
|
||||
' Logger.Warn("Unexpected Error in AddToken: " & ex.Message)
|
||||
' End Try
|
||||
|
||||
|
||||
End Sub
|
||||
'End Sub
|
||||
|
||||
Private Sub cmbProfile_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbProfile.SelectedIndexChanged
|
||||
If FormShown = False Then Exit Sub
|
||||
If DataLoaded = False Then Exit Sub
|
||||
If cmbProfile.SelectedIndex <> -1 Then
|
||||
If TabSelectedIndex = -1 Then
|
||||
TabSelectedIndex = 0
|
||||
@@ -359,11 +437,226 @@ Public Class frmSearchStart
|
||||
TabSelected = XtraTabControl1.TabPages(TabSelectedIndex)
|
||||
TabSelected.PageVisible = True
|
||||
PSEARCH_ID = cmbProfile.SelectedValue
|
||||
TabSelected.Text = cmbProfile.Text
|
||||
|
||||
Dim oDT As New DataTable
|
||||
Dim oFilter As String = $"SEARCH_PROFILE_ID = {PSEARCH_ID}"
|
||||
Dim oFilteredRows() As DataRow = DTSearchProfiles.Select(oFilter)
|
||||
oDT = DTSearchProfiles.Clone
|
||||
For Each oRow As DataRow In oFilteredRows
|
||||
SEARCH_SQL = oRow.Item("RESULT_SQL").ToString
|
||||
SEARCH_TITLE = cmbProfile.Text
|
||||
Next
|
||||
TabSelected.Text = SEARCH_TITLE
|
||||
Load_Search_Attributes()
|
||||
BarButtonItemNewSearch.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
XtraTabControl1.SelectedTabPageIndex = TabSelectedIndex
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BarEditItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarEditItem2.ItemClick
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItemNewSearch_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemNewSearch.ItemClick
|
||||
Display_InfoItem("New Search not integrated", Color.Yellow)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
||||
Display_InfoItem("Search Save not integrated", Color.Yellow)
|
||||
End Sub
|
||||
Sub Display_InfoItem(pText As String, pColor As Color)
|
||||
BarStaticItemInfo.Caption = pText
|
||||
BarStaticItemInfo.ItemAppearance.Normal.BackColor = pColor
|
||||
End Sub
|
||||
|
||||
Private Sub MehrfachauswahlAktivierenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MehrfachauswahlAktivierenToolStripMenuItem.Click
|
||||
If DataLoaded = False Then Exit Sub
|
||||
Dim oCurrentControl As GridControl = DirectCast(CURR_CTRL_OBJ, GridControl)
|
||||
Dim oAttrID = DirectCast(oCurrentControl.Tag, ClassControlCreator.ControlMetadata).AttrID
|
||||
Dim oAttrTitle = DirectCast(oCurrentControl.Tag, ClassControlCreator.ControlMetadata).AttrTitle
|
||||
|
||||
For Each oROW As DataRow In oDTAttributes.Rows
|
||||
If oROW.Item("ATTRIBUTE_ID") = oAttrID Then
|
||||
oROW.Item("MULTISELECT") = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub ContextMenuStripMultiselect_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStripMultiselect.Opening
|
||||
DataLoaded = False
|
||||
CURR_CTRL_OBJ = ContextMenuStripMultiselect.SourceControl
|
||||
End Sub
|
||||
|
||||
Private Sub MehrfachauswahlInaktivierenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MehrfachauswahlInaktivierenToolStripMenuItem.Click
|
||||
If DataLoaded = False Then Exit Sub
|
||||
Dim oCurrentControl As GridControl = DirectCast(CURR_CTRL_OBJ, GridControl)
|
||||
Dim oAttrID = DirectCast(oCurrentControl.Tag, ClassControlCreator.ControlMetadata).AttrID
|
||||
Dim oAttrTitle = DirectCast(oCurrentControl.Tag, ClassControlCreator.ControlMetadata).AttrTitle
|
||||
|
||||
For Each oROW As DataRow In oDTAttributes.Rows
|
||||
If oROW.Item("ATTRIBUTE_ID") = oAttrID Then
|
||||
oROW.Item("MULTISELECT") = False
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub ContextMenuStripMultiselect_Closed(sender As Object, e As ToolStripDropDownClosedEventArgs) Handles ContextMenuStripMultiselect.Closed
|
||||
DataLoaded = True
|
||||
End Sub
|
||||
|
||||
Private Sub ContextMenuStripMultiselect_Closing(sender As Object, e As ToolStripDropDownClosingEventArgs) Handles ContextMenuStripMultiselect.Closing
|
||||
DataLoaded = True
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewSearchTerms_RowDeleted(sender As Object, e As DevExpress.Data.RowDeletedEventArgs) Handles GridViewSearchTerms.RowDeleted
|
||||
If DataLoaded = False Then Exit Sub
|
||||
Dim oCurrentView As GridView = DirectCast(sender, GridView)
|
||||
Dim oCurrentControl As GridControl = oCurrentView.GridControl
|
||||
|
||||
Dim rowView As DataRowView = CType(oCurrentView.GetFocusedRow(), DataRowView)
|
||||
|
||||
If IsNothing(rowView) = False Then
|
||||
Dim oResult As String = CType(rowView.Item(0), String)
|
||||
Dim oAttrID = DirectCast(oCurrentControl.Tag, ClassControlCreator.ControlMetadata).AttrID
|
||||
Dim oAttrTitle = DirectCast(oCurrentControl.Tag, ClassControlCreator.ControlMetadata).AttrTitle
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewSearchTerms_KeyUp(sender As Object, e As KeyEventArgs) Handles GridViewSearchTerms.KeyUp
|
||||
If e.KeyValue = Keys.Delete Then
|
||||
Dim oSelectedRows As Integer() = GridViewSearchTerms.GetSelectedRows()
|
||||
Dim oAttrID = GridViewSearchTerms.GetRowCellValue(oSelectedRows.Last(), GridViewSearchTerms.Columns("AttrID"))
|
||||
Dim oSearchTerm = GridViewSearchTerms.GetRowCellValue(oSelectedRows.Last(), GridViewSearchTerms.Columns("SearchTerm"))
|
||||
For Each dr As DataRow In DTSearchTerms.Rows
|
||||
If dr.Item("AttrID") = oAttrID And dr.Item("SearchTerm") = oSearchTerm Then
|
||||
dr.Delete()
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
RenewBinding_DTSearchTerms()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ContextMenuStripSearchTerms_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStripSearchTerms.Opening
|
||||
Dim rowView As DataRowView = GridViewSearchTerms.GetFocusedRow()
|
||||
'"BracketLeft"
|
||||
'"AttrID", GetType(Integer))
|
||||
'"AttrTitle"
|
||||
'"Criteria"
|
||||
'"SearchTerm"
|
||||
'"BracketRight"
|
||||
'"Operator"
|
||||
If IsNothing(rowView) = False Then
|
||||
Dim oOperator As String = rowView.Item("Operator")
|
||||
If oOperator = "and" Then
|
||||
If My.Application.User.Language = "de-De" Then
|
||||
tsmOperator.Text = "Operator = oder"
|
||||
Else
|
||||
tsmOperator.Text = "Operator = or"
|
||||
End If
|
||||
Else
|
||||
If My.Application.User.Language = "de-De" Then
|
||||
tsmOperator.Text = "Operator = und"
|
||||
Else
|
||||
tsmOperator.Text = "Operator = and"
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub tsmOperator_Click(sender As Object, e As EventArgs) Handles tsmOperator.Click
|
||||
Dim rowView As DataRowView = GridViewSearchTerms.GetFocusedRow()
|
||||
If IsNothing(rowView) = False Then
|
||||
Dim oAttrID As String = rowView.Item("AttrID")
|
||||
Dim oSearchTerm As String = rowView.Item("SearchTerm")
|
||||
Dim oREPLACEOperator As String
|
||||
If tsmOperator.Text.EndsWith("und") Or tsmOperator.Text.EndsWith("and") Then
|
||||
oREPLACEOperator = "and"
|
||||
Else
|
||||
oREPLACEOperator = "or"
|
||||
End If
|
||||
For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
If oRow.Item("AttrID") = oAttrID And oRow.Item("SearchTerm") = oSearchTerm Then
|
||||
oRow.Item("Operator") = oREPLACEOperator
|
||||
DTSearchTerms.AcceptChanges()
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub frmSearchStart_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
|
||||
My.UIConfig.SearchForm.Location = Me.Location
|
||||
My.UIConfigManager.Save()
|
||||
End Sub
|
||||
|
||||
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
|
||||
Try
|
||||
Dim oSEARCH_SQL = SEARCH_SQL
|
||||
Dim oOperator As String
|
||||
Dim oCount As Integer = 1
|
||||
For Each oRow As DataRow In DTSearchTerms.Rows
|
||||
'"BracketLeft"
|
||||
'"AttrID", GetType(Integer))
|
||||
'"AttrTitle"
|
||||
'"Criteria"
|
||||
'"SearchTerm"
|
||||
'"BracketRight"
|
||||
'"Operator"
|
||||
oOperator = oRow.Item("Operator").ToString
|
||||
Dim oSearchTerm = GetSearchTerm_for_Type(oRow.Item("AttrID"), oRow.Item("AttrTitle").ToString, oRow.Item("Criteria").ToString, oRow.Item("SearchTerm").ToString)
|
||||
|
||||
oSEARCH_SQL &= IIf(oCount = 0, " ", "") + $"{oRow.Item("BracketLeft").ToString}{oSearchTerm}{oRow.Item("BracketLeft").ToString}"
|
||||
If DTSearchTerms.Rows.Count > oCount Then
|
||||
oSEARCH_SQL &= $" {oOperator} {Chr(13)}"
|
||||
End If
|
||||
oCount += 1
|
||||
Next
|
||||
MsgBox(oSEARCH_SQL)
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function GetSearchTerm_for_Type(pAttrID As Int16, pAttrTitle As String, pCriteria As String, pTERM As String) As String
|
||||
Dim oRETURN As String = ""
|
||||
|
||||
Dim oDT As New DataTable
|
||||
Dim oFilter As String = $"GUID = {pAttrID}"
|
||||
Dim oFilteredRows() As DataRow = My.DTAttributes.Select(oFilter)
|
||||
If oFilteredRows.Length = 1 Then
|
||||
For Each oRow As DataRow In oFilteredRows
|
||||
Dim oType As Integer = CInt(oRow.Item("TYP_ID"))
|
||||
If oType = 1 Or oType = 8 Then
|
||||
oRETURN = $"{pAttrTitle} {pCriteria} '{pTERM.Replace("'", "''")}'"
|
||||
ElseIf oType = 2 Or oType = 9 Then
|
||||
oRETURN = $"{pAttrTitle} {pCriteria} {pTERM}"
|
||||
ElseIf oType = 3 Then 'Float
|
||||
oRETURN = $"{pAttrTitle} {pCriteria} Convert(float,'{pTERM.Replace(",", ".")}')"
|
||||
ElseIf oType = 4 Then 'Decimal
|
||||
oRETURN = $"{pAttrTitle} {pCriteria} Convert(decimal(19,2),'{pTERM.Replace(",", ".")}')"
|
||||
ElseIf oType = 5 Then 'DATE
|
||||
oRETURN = $"{pAttrTitle} {pCriteria} Convert(date,'{pTERM}')"
|
||||
ElseIf oType = 7 Then
|
||||
Dim oBit As Int16
|
||||
If CBool(pTERM) = True Then
|
||||
oBit = 1
|
||||
Else
|
||||
oBit = 0
|
||||
End If
|
||||
oRETURN = $"{pAttrTitle} {pCriteria} '{oBit.ToString}'"
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
Return oRETURN
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user