MS
This commit is contained in:
@@ -9,6 +9,7 @@ Public Class frmSearchStart
|
||||
Private DTSearchProfiles As DataTable
|
||||
Private TabSelected As XtraTabPage
|
||||
Private PSEARCH_ID As Integer = 0
|
||||
Private PSEARCH_BASE_RESULT_SQL As String
|
||||
Public FormShown As Boolean = False
|
||||
Private Const DEFAULT_X As Integer = 10
|
||||
Private Const DEFAULT_Y As Integer = 10
|
||||
@@ -34,8 +35,14 @@ Public Class frmSearchStart
|
||||
|
||||
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()
|
||||
End If
|
||||
Next
|
||||
DTSearchTerms.Rows.Add(pAttrID, pAttrTitle, pCriteria, pSearchTerm)
|
||||
DTSearchTerms.AcceptChanges()
|
||||
AddToken(pAttrTitle & " " & pCriteria & " '" & pSearchTerm & "'")
|
||||
|
||||
End Sub
|
||||
Public Sub SearchAttribute(pAttrID As String, pAttrTitle As String, pSearchTerm As String, Optional pCriteria As String = "=")
|
||||
@@ -63,6 +70,7 @@ Public Class frmSearchStart
|
||||
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")
|
||||
TabSelected.Text = DTSearchProfiles.Rows(0).Item("TITLE")
|
||||
Load_Search_Attributes()
|
||||
BarButtonItemNewSearch.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
||||
@@ -77,64 +85,102 @@ Public Class frmSearchStart
|
||||
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)
|
||||
Dim oXPosition As Integer = 10
|
||||
Dim oYPosition As Integer = 10
|
||||
Dim oControlXPosition As Integer = 33
|
||||
|
||||
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 = 3 Or oControlCount = 5 Then
|
||||
'linke Spalte
|
||||
If oControlCount = 1 Or oControlCount = 5 Or oControlCount = 9 Then
|
||||
oControlRow += 1
|
||||
End If
|
||||
Select Case oControlCount
|
||||
Case 2
|
||||
oXPosition = oXPosition + 150 + 15
|
||||
End Select
|
||||
Select Case oControlRow
|
||||
Case 1
|
||||
oYPosition = DEFAULT_Y
|
||||
If oControlCount > 1 Then
|
||||
oXPosition = DEFAULT_X + 170
|
||||
End If
|
||||
Case 2
|
||||
oYPosition = DEFAULT_Y + 150 + 20
|
||||
If oControlCount = 4 Then
|
||||
oXPosition = DEFAULT_X + 170
|
||||
End If
|
||||
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 Select
|
||||
End If
|
||||
ElseIf oControlRow = 3 Then
|
||||
If oControlCount = 9 Then
|
||||
oXPosition = 10
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim oControlHeight As Integer = CInt(oAttributeRow.Item("HEIGHT"))
|
||||
Dim oControlWidth As Integer = CInt(oAttributeRow.Item("WIDTH"))
|
||||
|
||||
|
||||
addLabel(oAttriTitle, oXPosition, oYPosition)
|
||||
'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
|
||||
Select Case oAttriTYPE
|
||||
Case "VARCHAR"
|
||||
oMyControl = oControls.CreateExistingGridControl(oAttributeRow, oXPosition, oYPosition + 20)
|
||||
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)
|
||||
End If
|
||||
Case "DATE"
|
||||
oMyControl = oControls.CreateExistingDatepicker(oAttributeRow, oXPosition, oYPosition + 20)
|
||||
Dim myDTP As DateEdit = CType(oMyControl, DateEdit)
|
||||
AddHandler myDTP.DisableCalendarDate, AddressOf DisableCalendarDate
|
||||
End Select
|
||||
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)
|
||||
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
|
||||
End Sub
|
||||
@@ -185,7 +231,14 @@ Public Class frmSearchStart
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CheckBox_CheckedChanged(sender As Object, e As EventArgs)
|
||||
If FormShown = False Then Exit Sub
|
||||
Dim oCurrentCB As CheckBox = DirectCast(sender, CheckBox)
|
||||
Dim oChecked = oCurrentCB.Checked
|
||||
Dim oAttrID = DirectCast(oCurrentCB.Tag, ClassControlCreator.ControlMetadata).AttrID
|
||||
Dim oAttrTitle = DirectCast(oCurrentCB.Tag, ClassControlCreator.ControlMetadata).AttrTitle
|
||||
AddSearchAttribute(oAttrID, oAttrTitle, oChecked.ToString)
|
||||
End Sub
|
||||
Private Sub frmSearchStart_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
FormShown = True
|
||||
End Sub
|
||||
@@ -214,18 +267,81 @@ 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
|
||||
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||
Try
|
||||
Clear_token()
|
||||
DTSearchTerms.Clear()
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in Clearing Search Items: " & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
For Each oControl As Control In TabSelected.Controls
|
||||
Select Case oControl.GetType.ToString
|
||||
Case ""
|
||||
End Select
|
||||
Next
|
||||
TabSelected.Controls.Clear()
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
||||
|
||||
TokenEdit1.Properties.BeginUpdate()
|
||||
'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()
|
||||
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
|
||||
|
||||
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 Class
|
||||
Reference in New Issue
Block a user