This commit is contained in:
2020-11-05 10:37:14 +01:00
parent 7750fdf6a5
commit 10f660460f
16 changed files with 570 additions and 178 deletions

View File

@@ -182,7 +182,7 @@ Public Class frmSearchStart
Dim oXPosition As Integer
Dim oYPositionControl As Integer
Dim oYPositionLabel As Integer
Dim oMyLastGridView As DevExpress.XtraGrid.Views.Grid.GridView
Dim oSingleResult As Boolean = False
Dim oAttriTitle As String = oAttributeRow.Item("ATTRIBUTE_TITLE").ToString
Dim oAttriID As Integer = CInt(oAttributeRow.Item("ATTRIBUTE_ID"))
@@ -235,9 +235,6 @@ Public Class frmSearchStart
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)
@@ -253,7 +250,14 @@ Public Class frmSearchStart
Dim oView As DevExpress.XtraGrid.Views.Grid.GridView
oView = CType(myDGV.MainView, GridView)
AddHandler oView.FocusedRowChanged, AddressOf FocusedRowChanged
oMyLastGridView = oView
If CBool(oAttributeRow.Item("MULTISELECT")) = True Then
AddHandler oView.SelectionChanged, AddressOf RenewSearchAttributes
Else
AddHandler oView.FocusedRowChanged, AddressOf FocusedRowChanged
End If
oView.FocusInvalidRow()
ElseIf oAttriTYPE = "DATE" Then
oMyControl = oControls.CreateExistingDatepicker(oAttributeRow, oXPosition, oYPositionControl)
@@ -267,6 +271,10 @@ Public Class frmSearchStart
oControlCount += 1
TabSelected.Controls.Add(oMyControl)
If oAttriTYPE = "VARCHAR" Or oAttriTYPE = "BIG INTEGER" Then
oMyLastGridView.FocusInvalidRow()
End If
oXPosition += oControlWidth + 20
Next
@@ -307,6 +315,40 @@ Public Class frmSearchStart
Private Sub XtraTabControl1_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControl1.SelectedPageChanged
TabSelected = XtraTabControl1.SelectedTabPage
End Sub
Private Sub ClearSearchCriteria()
Dim oSQL = $"DELETE FROM TBIDB_USER_SEARCH_CRITERIA WHERE SEARCH_PROFIL_ID = {PSEARCH_ID} AND USERID = {My.Application.User.UserId}"
My.DatabaseIDB.ExecuteNonQuery(oSQL)
End Sub
Private Sub RenewSearchAttributes()
ClearSearchCriteria()
For Each oControl As Control In TabSelected.Controls
Dim octrlType = oControl.GetType.ToString
Select Case oControl.GetType.ToString
Case "DevExpress.XtraGrid.GridControl"
Dim oMyGridControl As GridControl = CType(oControl, GridControl)
Dim oMyGridView As DevExpress.XtraGrid.Views.Grid.GridView = CType(oMyGridControl.MainView, GridView)
Dim oSelectedRows As Integer() = oMyGridView.GetSelectedRows()
If oSelectedRows.Count = 0 Then
Continue For
End If
Dim oAttrID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttrID
Dim oAttrTitle = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).AttrTitle
For Each oRowHandle As Integer In oSelectedRows
Dim oResult = oMyGridView.GetRowCellValue(oRowHandle, oMyGridView.Columns(0).FieldName)
Dim oInsert = $"EXEC PRIDB_NEW_USER_SEARCH_CRITERIA {PSEARCH_ID.ToString},{My.Application.User.UserId.ToString},{oAttrID.ToString},'{oResult}','{My.Application.User.UserName}'"
My.DatabaseIDB.ExecuteNonQuery(oInsert)
Next
Case "DevExpress.XtraEditors.DateEdit"
' MsgBox("Date")
End Select
Next
End Sub
Private Sub FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs)
If DataLoaded = False Then Exit Sub
Dim oCurrentView As GridView = DirectCast(sender, GridView)
@@ -318,6 +360,7 @@ Public Class frmSearchStart
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
RenewSearchAttributes()
AddSearchAttribute(oAttrID, oAttrTitle, oResult)
'For Each oAttributeRow1 As DataRow In oDTAttributes.Rows
' If CInt(oAttributeRow1.Item("DEPENDING_ATTRIBUTE1")) = oAttrID Then
@@ -391,12 +434,14 @@ Public Class frmSearchStart
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
Try
'Clear_token()
ClearSearchCriteria()
DTSearchTerms.Clear()
Catch ex As Exception
MsgBox("Unexpected Error in Clearing Search Items: " & ex.Message, MsgBoxStyle.Critical)
End Try
TabSelected.Controls.Clear()
Load_Search_Attributes()
End Sub
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
@@ -666,8 +711,41 @@ Public Class frmSearchStart
My.UIConfig.SearchForm.Location = Me.Location
My.UIConfigManager.Save()
End Sub
Private Function GetSearchTermForType(pAttrID As Int16, pAttrTitle As String, pCriteria As String, pTERM As String) As String
Dim oRETURN As String = ""
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
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
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
Try
Dim oSEARCH_SQL = SEARCH_SQL
Dim oOperator As String
@@ -721,40 +799,5 @@ Public Class frmSearchStart
Catch ex As Exception
End Try
End Sub
Private Function GetSearchTermForType(pAttrID As Int16, pAttrTitle As String, pCriteria As String, pTERM As String) As String
Dim oRETURN As String = ""
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