EditForm Tweaks, Other Tweaks
This commit is contained in:
@@ -4,9 +4,17 @@ Imports DevExpress.XtraLayout
|
||||
|
||||
Public Class frmEdit
|
||||
Private ReadOnly _Datatable As DataTable
|
||||
Private _BindingSource As BindingSource
|
||||
|
||||
Private _LanguageDatatable As DataTable
|
||||
Private _AttributeId As Integer
|
||||
|
||||
Private Class ControlMetadata
|
||||
Public AttributeId As Integer
|
||||
Public DataType As Type
|
||||
Public ColumnName As String
|
||||
End Class
|
||||
|
||||
Public Sub New(AttributeId As Integer, Datatable As DataTable)
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
@@ -22,8 +30,11 @@ Public Class frmEdit
|
||||
ProcessContainer(AddressOf ClassGridControl.DefaultGridSettings).
|
||||
ProcessContainer(AddressOf ClassGridControl.ReadOnlyGridSettings)
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
GridList.DataSource = _Datatable
|
||||
labelParentAttributeId.Caption = $"Attribut-ID: {_AttributeId}"
|
||||
|
||||
_BindingSource = New BindingSource()
|
||||
_BindingSource.DataSource = _Datatable
|
||||
GridList.DataSource = _BindingSource
|
||||
|
||||
SplitContainerControl1.SplitterPosition = My.UIConfig.FrmEdit_Splitter
|
||||
|
||||
@@ -47,17 +58,28 @@ Public Class frmEdit
|
||||
|
||||
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
|
||||
Dim oIntegerEdit = New TextEdit()
|
||||
oIntegerEdit.Name = Column.ColumnName
|
||||
oIntegerEdit.Properties.Mask.MaskType = Mask.MaskType.Numeric
|
||||
oIntegerEdit.Properties.Mask.EditMask = "n"
|
||||
oEditor = oIntegerEdit
|
||||
Case Else
|
||||
oEditor = New TextEdit() With {.Name = Column.ColumnName}
|
||||
End Select
|
||||
|
||||
' Set EditControl Metadata
|
||||
If AttributeId > 0 Then
|
||||
oEditor.Tag = AttributeId
|
||||
oEditor.Tag = New ControlMetadata() With {
|
||||
.AttributeId = AttributeId,
|
||||
.DataType = Column.DataType,
|
||||
.ColumnName = Column.ColumnName
|
||||
}
|
||||
Else
|
||||
oEditor.Tag = New ControlMetadata() With {
|
||||
.AttributeId = Nothing,
|
||||
.DataType = Column.DataType,
|
||||
.ColumnName = Column.ColumnName
|
||||
}
|
||||
End If
|
||||
|
||||
Return oEditor
|
||||
@@ -94,22 +116,45 @@ Public Class frmEdit
|
||||
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))
|
||||
oEditor.DataBindings.Add(New Binding("Text", _BindingSource, oColumn.ColumnName))
|
||||
|
||||
' Add Control to Layout
|
||||
LayoutControlGroup1.AddItem(oCaption, oEditor)
|
||||
LayoutGroup.AddItem(oCaption, oEditor)
|
||||
|
||||
' Set Column Captions
|
||||
ViewList.Columns.Item(oColumn.ColumnName).Caption = oCaption
|
||||
|
||||
oCounter = oCounter + 1
|
||||
Next
|
||||
|
||||
' General Layout Tweaks
|
||||
LayoutControlGroup1.AddItem(New EmptySpaceItem())
|
||||
LayoutControlGroup1.LayoutMode = Utils.LayoutMode.Flow
|
||||
LayoutGroup.AddItem(New EmptySpaceItem())
|
||||
LayoutGroup.LayoutMode = Utils.LayoutMode.Flow
|
||||
End Sub
|
||||
|
||||
Public Sub SaveRecord()
|
||||
_BindingSource.EndEdit()
|
||||
|
||||
Dim oChanges As DataTable = _Datatable.GetChanges()
|
||||
Dim oChangedRow As DataRow = oChanges.Rows.Item(0)
|
||||
|
||||
For Each oColumn As DataColumn In oChanges.Columns
|
||||
Dim oAttributeId = (From oItem As LayoutControlItem In LayoutGroup.Items
|
||||
Where oItem.Control.Name = oColumn.ColumnName
|
||||
Select DirectCast(oItem.Control.Tag, ControlMetadata).AttributeId).FirstOrDefault()
|
||||
|
||||
Dim oValue = oChangedRow.Item(oColumn.ColumnName)
|
||||
MsgBox($"Saving Value {oValue} for Attribute {oAttributeId}")
|
||||
Next
|
||||
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
|
||||
|
||||
Private Sub BarButtonSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonSave.ItemClick
|
||||
SaveRecord()
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user