285 lines
12 KiB
VB.net
285 lines
12 KiB
VB.net
Imports DevExpress.Utils
|
|
Imports DevExpress.XtraGrid
|
|
Imports DevExpress.XtraGrid.Columns
|
|
Imports DevExpress.XtraGrid.Views.Grid
|
|
Imports DevExpress.XtraEditors
|
|
Imports DevExpress.XtraEditors.Repository
|
|
|
|
Public Class ClassWindreamDocGrid
|
|
Public Shared RESULT_DOC_PATH As String
|
|
Public Shared RESULT_OBJECTTYPE As String
|
|
Public Shared RESULT_INWORK As Boolean
|
|
Public Shared RESULT_DOC_ID As Integer
|
|
Public Shared RESULT_DISPLAYNAME As String
|
|
|
|
Private Shared _dropdownValueChangedHandler As EventHandler
|
|
|
|
Public Shared Sub GetDocItems(gridView As GridView)
|
|
Try
|
|
RESULT_DOC_PATH = gridView.GetFocusedRowCellValue(gridView.Columns("FULLPATH"))
|
|
Catch ex As Exception
|
|
ClassLogger.Add(">> Attention: Could not set DocVariable RESULT_DOC_PATH: " & ex.Message, False)
|
|
RESULT_DOC_PATH = Nothing
|
|
End Try
|
|
Try
|
|
RESULT_OBJECTTYPE = gridView.GetFocusedRowCellValue(gridView.Columns("OBJECTTYPE"))
|
|
Catch ex As Exception
|
|
ClassLogger.Add(">> Attention: Could not set DocVariable RESULT_OBJECTTYPE: " & ex.Message, False)
|
|
RESULT_OBJECTTYPE = ""
|
|
End Try
|
|
Try
|
|
RESULT_INWORK = gridView.GetFocusedRowCellValue(gridView.Columns("in work?"))
|
|
Catch ex As Exception
|
|
ClassLogger.Add(">> Attention: Could not set DocVariable RESULT_INWORK: " & ex.Message, False)
|
|
RESULT_INWORK = ""
|
|
End Try
|
|
Try
|
|
RESULT_DOC_ID = gridView.GetFocusedRowCellValue(gridView.Columns("DocID"))
|
|
Catch ex As Exception
|
|
ClassLogger.Add(">> Attention: Could not set DocVariable RESULT_DOC_ID: " & ex.Message, False)
|
|
RESULT_DOC_ID = Nothing
|
|
End Try
|
|
Try
|
|
RESULT_DISPLAYNAME = gridView.GetFocusedRowCellValue(gridView.Columns("Displayname"))
|
|
Catch ex As Exception
|
|
ClassLogger.Add(">> Attention: Could not set DocVariable RESULT_DISPLAYNAME: " & ex.Message, False)
|
|
RESULT_DISPLAYNAME = ""
|
|
End Try
|
|
End Sub
|
|
|
|
Public Shared Sub FormatColumns(gridView As GridView, DT_RESULT As DataTable, DT_WINDREAM_RESULTLIST As DataTable, DT_DOCRESULT_DROPDOWN_ITEMS As DataTable, DropdownValueChangedHandler As EventHandler)
|
|
Dim dateColumns As New List(Of String)
|
|
Dim checkboxColumns As New List(Of String)
|
|
Dim dropdownTable As New DataTable()
|
|
dropdownTable.TableName = "DROPDOWN_TABLE"
|
|
dropdownTable.Columns.Add("ID", GetType(Integer))
|
|
dropdownTable.Columns.Add("COLUMN_VIEW", GetType(String))
|
|
|
|
_dropdownValueChangedHandler = DropdownValueChangedHandler
|
|
|
|
For Each row As DataRow In DT_WINDREAM_RESULTLIST.Rows
|
|
Dim guid As Integer = row.Item("GUID")
|
|
Dim width As Integer = row.Item("WIDTH")
|
|
Dim typeID As Integer = row.Item("TYPE_ID")
|
|
Dim isVisible As Boolean = row.Item("VISIBLE")
|
|
Dim columnTitle As String = row.Item("HEADER_CAPTION")
|
|
|
|
' Liste aller Datumsspalten erstellen
|
|
If typeID = 3 And isVisible = True Then
|
|
dateColumns.Add(columnTitle)
|
|
End If
|
|
|
|
' Liste aller Checkboxspalten erstellen
|
|
If typeID = 2 And isVisible = True Then
|
|
checkboxColumns.Add(columnTitle)
|
|
End If
|
|
|
|
If typeID = 4 And isVisible = True Then
|
|
Dim dropdownRow As DataRow = dropdownTable.NewRow()
|
|
dropdownRow.Item("ID") = guid
|
|
dropdownRow.Item("COLUMN_VIEW") = columnTitle
|
|
dropdownTable.Rows.Add(dropdownRow)
|
|
dropdownTable.AcceptChanges()
|
|
End If
|
|
Next
|
|
|
|
Dim clonedTable As DataTable = DT_RESULT.Clone()
|
|
' In DataTable die DateSpalten mit dem Type Date belegen
|
|
For Each dateColumnTitle As String In dateColumns
|
|
Dim dateColumn As DataColumn = clonedTable.Columns(dateColumnTitle)
|
|
If Not IsNothing(dateColumn) Then
|
|
dateColumn.DataType = GetType(Date)
|
|
End If
|
|
Next
|
|
' In DataTable die CheckboxSpalten mit dem Typ Boolean belegen
|
|
For Each checkboxColunmTitle As String In checkboxColumns
|
|
Dim checkboxColumn As DataColumn = clonedTable.Columns(checkboxColunmTitle)
|
|
If Not IsNothing(checkboxColumn) Then
|
|
checkboxColumn.DataType = GetType(Boolean)
|
|
End If
|
|
Next
|
|
|
|
Try
|
|
clonedTable.Load(DT_RESULT.CreateDataReader())
|
|
DT_RESULT = clonedTable
|
|
Catch ex As Exception
|
|
ClassLogger.Add(">> Attention: Could not load converted datatable DocSearch: " & ex.Message, False)
|
|
End Try
|
|
|
|
gridView.GridControl.DataSource = DT_RESULT
|
|
|
|
' Breite der Spalten anpassen
|
|
For Each row As DataRow In DT_WINDREAM_RESULTLIST.Rows
|
|
Dim Width = row.Item("WIDTH")
|
|
If Not IsNothing(Width) And Not IsDBNull(Width) Then
|
|
Dim column = DirectCast(gridView.Columns.Item(row.Item("HEADER_CAPTION")), DevExpress.XtraGrid.Columns.GridColumn)
|
|
If Not IsNothing(column) Then
|
|
column.Width = Width
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
' Dropdown/Combobox Editor für passende Spalten anwenden
|
|
For Each dropdownRow As DataRow In dropdownTable.Rows
|
|
Dim dropdown As New RepositoryItemComboBox()
|
|
Dim columnTitle As String = dropdownRow.Item("COLUMN_VIEW")
|
|
Dim guid As Integer = dropdownRow.Item("ID")
|
|
|
|
Dim expression As String = String.Format("CONFIG_ID = {0}", guid.ToString())
|
|
Dim matchingRows() As DataRow = DT_DOCRESULT_DROPDOWN_ITEMS.Select(expression, "SEQUENCE")
|
|
|
|
' Dropdown füllen
|
|
For Each matchingRow As DataRow In matchingRows
|
|
Dim item As New WindreamDocGridComboboxItem()
|
|
item.ConfigID = matchingRow.Item("CONFIG_ID")
|
|
item.Value = matchingRow.Item("VALUE")
|
|
|
|
dropdown.Items.Add(item)
|
|
Next
|
|
|
|
gridView.GridControl.RepositoryItems.Add(dropdown)
|
|
|
|
If Not IsNothing(gridView.Columns(columnTitle)) Then
|
|
gridView.Columns(columnTitle).ColumnEdit = dropdown
|
|
End If
|
|
AddHandler dropdown.SelectedValueChanged, _dropdownValueChangedHandler
|
|
Next
|
|
|
|
' Eigenschaften der Spalten anpassen
|
|
|
|
gridView.Columns.Item("ICON").MaxWidth = 24
|
|
gridView.Columns.Item("ICON").MinWidth = 24
|
|
gridView.Columns.Item("FULLPATH").Visible = False
|
|
gridView.Columns.Item("OBJECTTYPE").Visible = False
|
|
gridView.Columns.Item("DocID").Visible = False
|
|
|
|
' Changed & Created Spalten anpassen
|
|
|
|
Dim created, changed As String
|
|
If USER_LANGUAGE <> "de-DE" Then
|
|
changed = "Changed"
|
|
created = "Created"
|
|
Else
|
|
changed = "Geändert"
|
|
created = "Erstellt"
|
|
End If
|
|
|
|
Dim createdColumn = gridView.Columns(created)
|
|
If Not IsNothing(createdColumn) Then
|
|
createdColumn.DisplayFormat.FormatType = FormatType.DateTime
|
|
createdColumn.DisplayFormat.FormatString = CURRENT_DATE_FORMAT & " HH:MM:ss"
|
|
End If
|
|
|
|
Dim changedColumn = gridView.Columns(changed)
|
|
If Not IsNothing(changedColumn) Then
|
|
changedColumn.DisplayFormat.FormatType = FormatType.DateTime
|
|
changedColumn.DisplayFormat.FormatString = CURRENT_DATE_FORMAT & " HH:MM:ss"
|
|
End If
|
|
|
|
' Für die Dropdown Spalte Änderungen zulassen
|
|
For Each column As GridColumn In gridView.Columns
|
|
Dim _AllowEdit As Boolean = False
|
|
For Each dropdownrow As DataRow In dropdownTable.Rows
|
|
Dim columnTitle = dropdownrow.Item("COLUMN_VIEW")
|
|
If columnTitle = column.FieldName Then
|
|
_AllowEdit = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
column.OptionsColumn.AllowEdit = _AllowEdit
|
|
Next
|
|
|
|
Dim CheckBoxEditorForDisplay = New RepositoryItemCheckEdit()
|
|
CheckBoxEditorForDisplay.ValueChecked = "True"
|
|
CheckBoxEditorForDisplay.ValueUnchecked = "False"
|
|
'Alle Checkbox Spalten durchgehen und CheckBoxEditor zuweisen
|
|
For Each columnTitle As String In checkboxColumns
|
|
gridView.GridControl.RepositoryItems.Add(CheckBoxEditorForDisplay)
|
|
If Not IsNothing(gridView.Columns(columnTitle)) Then
|
|
gridView.Columns(columnTitle).ColumnEdit = CheckBoxEditorForDisplay
|
|
End If
|
|
Next
|
|
|
|
End Sub
|
|
|
|
Public Class WindreamDocGridComboboxItem
|
|
Implements IConvertible
|
|
|
|
Public ConfigID As Integer
|
|
Public Value As String
|
|
|
|
Public Overrides Function ToString() As String
|
|
Return Me.Value
|
|
End Function
|
|
|
|
Public Function ToString1(provider As IFormatProvider) As String Implements IConvertible.ToString
|
|
Return Me.Value
|
|
End Function
|
|
|
|
Public Function GetTypeCode() As TypeCode Implements IConvertible.GetTypeCode
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToBoolean(provider As IFormatProvider) As Boolean Implements IConvertible.ToBoolean
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToByte(provider As IFormatProvider) As Byte Implements IConvertible.ToByte
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToChar(provider As IFormatProvider) As Char Implements IConvertible.ToChar
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToDateTime(provider As IFormatProvider) As Date Implements IConvertible.ToDateTime
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToDecimal(provider As IFormatProvider) As Decimal Implements IConvertible.ToDecimal
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToDouble(provider As IFormatProvider) As Double Implements IConvertible.ToDouble
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToInt16(provider As IFormatProvider) As Short Implements IConvertible.ToInt16
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToInt32(provider As IFormatProvider) As Integer Implements IConvertible.ToInt32
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToInt64(provider As IFormatProvider) As Long Implements IConvertible.ToInt64
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToSByte(provider As IFormatProvider) As SByte Implements IConvertible.ToSByte
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToSingle(provider As IFormatProvider) As Single Implements IConvertible.ToSingle
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToType(conversionType As Type, provider As IFormatProvider) As Object Implements IConvertible.ToType
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToUInt16(provider As IFormatProvider) As UShort Implements IConvertible.ToUInt16
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToUInt32(provider As IFormatProvider) As UInteger Implements IConvertible.ToUInt32
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
Public Function ToUInt64(provider As IFormatProvider) As ULong Implements IConvertible.ToUInt64
|
|
Throw New NotImplementedException
|
|
End Function
|
|
End Class
|
|
|
|
End Class
|