Load Dynamic Form for frmEdit, Save Application Skin, add UIConfig
This commit is contained in:
@@ -1,11 +1,104 @@
|
||||
Public Class frmEdit
|
||||
Public Property Datatable As DataTable
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraLayout
|
||||
|
||||
Private Sub frmEdit_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
GridList = ClassUIUtils.ConfigureGridControlDefaults(GridList)
|
||||
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
|
||||
GridList.DataSource = DataTable
|
||||
_Datatable = Datatable
|
||||
_AttributeId = AttributeId
|
||||
End Sub
|
||||
|
||||
Private Async Sub frmEdit_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
GridList = ClassUIUtils.ConfigureGridControlDefaults(GridList, [ReadOnly]:=True)
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
GridList.DataSource = _Datatable
|
||||
|
||||
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
|
||||
End Class
|
||||
Reference in New Issue
Block a user