115 lines
4.4 KiB
VB.net
115 lines
4.4 KiB
VB.net
Imports DevExpress.XtraEditors
|
|
Imports DevExpress.XtraGrid
|
|
Imports DevExpress.XtraLayout
|
|
|
|
Public Class frmEdit
|
|
Private ReadOnly _Datatable As DataTable
|
|
Private _LanguageDatatable As DataTable
|
|
Private _AttributeId As Integer
|
|
|
|
Public Sub New(AttributeId As Integer, Datatable As DataTable)
|
|
' Dieser Aufruf ist für den Designer erforderlich.
|
|
InitializeComponent()
|
|
|
|
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
|
_Datatable = Datatable
|
|
_AttributeId = AttributeId
|
|
End Sub
|
|
|
|
Private Async Sub frmEdit_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Dim oGridPatcher = New ClassControlPatcher(Of GridControl)(Me)
|
|
oGridPatcher.
|
|
ProcessContainer(AddressOf ClassGridControl.DefaultGridSettings).
|
|
ProcessContainer(AddressOf ClassGridControl.ReadOnlyGridSettings)
|
|
|
|
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
|
GridList.DataSource = _Datatable
|
|
|
|
SplitContainerControl1.SplitterPosition = My.UIConfig.FrmEdit_Splitter
|
|
|
|
Dim oUserLanguage = My.Application.User.Language
|
|
Await LoadLanguageTableAsync(oUserLanguage)
|
|
LoadFormLayout()
|
|
End Sub
|
|
|
|
Private Async Function LoadLanguageTableAsync(UserLanguage As String) As Task
|
|
Dim oSQL = $"SELECT * FROM VWICM_ATTRIBUTE_LANGUAGE WHERE LANGUAGE_CODE = '{UserLanguage}' AND PARENT_ATTRIBUTE_ID = '{_AttributeId}' ORDER BY ""SEQUENCE"";"
|
|
|
|
Await My.Channel.CreateDatabaseRequestAsync("Language Syskey", False)
|
|
Dim oResult = Await My.Channel.ReturnDatatableAsync(oSQL)
|
|
_LanguageDatatable = oResult.Table
|
|
|
|
Await My.Channel.CloseDatabaseRequestAsync()
|
|
End Function
|
|
|
|
Private Function GetColumnEditor(Column As DataColumn, AttributeId As Integer)
|
|
Dim oEditor As BaseEdit
|
|
|
|
Select Case Column.DataType
|
|
Case GetType(Int64)
|
|
Dim oTextEdit = New TextEdit()
|
|
oTextEdit.Name = Column.ColumnName
|
|
oTextEdit.Properties.Mask.MaskType = Mask.MaskType.Numeric
|
|
oTextEdit.Properties.Mask.EditMask = "n"
|
|
oEditor = oTextEdit
|
|
Case Else
|
|
oEditor = New TextEdit() With {.Name = Column.ColumnName}
|
|
End Select
|
|
|
|
If AttributeId > 0 Then
|
|
oEditor.Tag = AttributeId
|
|
End If
|
|
|
|
Return oEditor
|
|
End Function
|
|
|
|
Private Function GetColumnCaption(Column As DataColumn, SequenceId As Integer)
|
|
Dim oRow = GetRowBySequence(SequenceId)
|
|
Dim oCaption = Column.ColumnName
|
|
|
|
If oRow IsNot Nothing Then
|
|
oCaption = oRow.Item("LANGUAGE_TERM")
|
|
ElseIf oCaption = ClassConstants.ATTRIBUTE_ID_COLUMN Then
|
|
oCaption = "ID"
|
|
End If
|
|
|
|
Return oCaption
|
|
End Function
|
|
|
|
Private Function GetRowBySequence(SequenceId As Integer)
|
|
Return _LanguageDatatable.Select($"SEQUENCE = {SequenceId}").FirstOrDefault()
|
|
End Function
|
|
|
|
Private Function GetRowItemBySequence(SequenceId As Integer, ColumnName As String)
|
|
Dim oRow = _LanguageDatatable.Select($"SEQUENCE = {SequenceId}").FirstOrDefault()
|
|
Return oRow?.Item(ColumnName)
|
|
End Function
|
|
|
|
Private Sub LoadFormLayout()
|
|
' Counter is used to match SEQUENCE in Attributes
|
|
' to column order in the used View (eg. VWICM_USER)
|
|
Dim oCounter = 0
|
|
|
|
For Each oColumn As DataColumn In _Datatable.Columns
|
|
Dim oAttributeId As Integer = GetRowItemBySequence(oCounter, "ATTRIBUTE_ID")
|
|
Dim oCaption = GetColumnCaption(oColumn, oCounter)
|
|
Dim oEditor = GetColumnEditor(oColumn, oAttributeId)
|
|
oEditor.DataBindings.Add(New Binding("Text", _Datatable, oColumn.ColumnName))
|
|
|
|
' Add Control to Layout
|
|
LayoutControlGroup1.AddItem(oCaption, oEditor)
|
|
ViewList.Columns.Item(oColumn.ColumnName).Caption = oCaption
|
|
|
|
oCounter = oCounter + 1
|
|
Next
|
|
|
|
' General Layout Tweaks
|
|
LayoutControlGroup1.AddItem(New EmptySpaceItem())
|
|
LayoutControlGroup1.LayoutMode = Utils.LayoutMode.Flow
|
|
End Sub
|
|
|
|
Private Sub SplitContainerControl1_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl1.SplitterPositionChanged
|
|
My.UIConfig.FrmEdit_Splitter = SplitContainerControl1.SplitterPosition
|
|
My.UIConfigManager.Save()
|
|
End Sub
|
|
End Class |