First Version with Template Config from Database

This commit is contained in:
Jonathan Jenne
2021-11-16 15:00:58 +01:00
parent 510a08c1ed
commit 964f2ee60c
26 changed files with 6234 additions and 444 deletions

View File

@@ -1,9 +1,6 @@
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraVerticalGrid.Rows
Imports DevExpress.XtraGrid.Views.Grid
Imports MultiTool.Shared.Documents
Imports MultiTool.Shared.Documents.DocumentRow
Imports MultiTool.Shared
Imports DevExpress.XtraEditors.Repository
Imports MultiTool.Shared.Winline
Imports DigitalData.Modules.Language
@@ -11,13 +8,14 @@ Imports DevExpress.XtraEditors.Controls
Imports System.Globalization
Imports DevExpress.XtraEditors
Imports DigitalData.Modules.Logging
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports MultiTool.Shared.Schemas
Public Class frmRowEditor
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private ReadOnly FormHelper As FormHelper
Private ReadOnly _Table As Schema.Table
Private ReadOnly _Columns As List(Of String)
Private ReadOnly _DataTable As New DataTable
Private ReadOnly _Accounts As List(Of Account)
@@ -46,7 +44,7 @@ Public Class frmRowEditor
End Get
End Property
Public Sub New(pLogConfig As LogConfig, pColumns As List(Of String), pDocumentRow As DocumentRow, pMandator As Mandator, pWinline As WinlineData)
Public Sub New(pLogConfig As LogConfig, pColumns As List(Of String), pDocumentRow As DocumentRow, pMandator As Mandator, pWinline As WinlineData, pTable As Schema.Table)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
@@ -59,6 +57,7 @@ Public Class frmRowEditor
_Articles = pWinline.Articles.Where(Function(a) a.Mandator.Id = pMandator.Id).ToList()
_DocumentKinds = pWinline.DocumentKinds.Where(Function(k) k.Mandator.Id = pMandator.Id).ToList()
_DocumentRow = pDocumentRow
_Table = pTable
AccountPicker.DataSource = _Accounts
AccountPicker.DisplayMember = "Name"
@@ -102,15 +101,23 @@ Public Class frmRowEditor
Private Sub frmRowEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim oDict = New Dictionary(Of String, FieldValue)
For Each oColumn As String In _Columns
For Each oColumnName As String In _Columns
Dim oField = _DocumentRow.Fields.
Where(Function(f) f.Key = oColumn).
Where(Function(f) f.Key = oColumnName).
SingleOrDefault()
Dim oColumn = _Table.Columns.
Where(Function(c) c.Name = oColumnName).
SingleOrDefault()
' Only Show Columns that are set to visible true
If oColumn?.Config?.IsVisible = False Then
Continue For
End If
If oField.Value Is Nothing Then
oDict.Add(oColumn, New FieldValue())
oDict.Add(oColumnName, New FieldValue())
Else
oDict.Add(oColumn, oField.Value)
oDict.Add(oColumnName, oField.Value)
End If
Next
@@ -202,6 +209,7 @@ Public Class frmRowEditor
Private Sub GridView1_CustomRowCellEdit(sender As Object, e As CustomRowCellEditEventArgs) Handles GridView1.CustomRowCellEdit
Dim oDataRow As DataRow = GridView1.GetDataRow(e.RowHandle)
Dim oKey As String = oDataRow.Item(COL_KEY)
If e.Column.FieldName = COL_VALUE_ORIGINAL Or e.Column.FieldName = COL_VALUE_FINAL Then
If e.CellValue.ToString.Length > 100 Then
@@ -210,46 +218,52 @@ Public Class frmRowEditor
End If
If e.Column.FieldName = COL_VALUE_FINAL Then
Dim oReadOnlyFields As New List(Of String) From {
"BELEGKEY"
}
Dim oColumn = _Table.Columns.
Where(Function(c) c.Name = oKey).
SingleOrDefault()
If oReadOnlyFields.Contains(oDataRow.Item(COL_KEY)) Then
e.RepositoryItem = ReadOnlyEditor
If oColumn Is Nothing Then
Exit Sub
End If
ElseIf oDataRow.Item(COL_KEY) = "Datum_Auftrag-Bestellung" Then
'e.RepositoryItem = DatePicker
'e.RepositoryItem = MaskDateEditor
ElseIf e.CellValue.ToString.Length > 30 Then
e.RepositoryItem = MultilineEditor
ElseIf oDataRow.Item(COL_KEY) = "Fakt_Kontonummer" Or oDataRow.Item(COL_KEY) = "Lief_Kontonummer" Then
If oColumn.Config?.Function.Name = "GLN" Then
e.RepositoryItem = AccountPicker
ElseIf oDataRow.Item(COL_KEY) = "Artikelnummer" Then
End If
If oColumn.Config?.Function.Name = "EAN" Then
e.RepositoryItem = ArticlePicker
ElseIf oDataRow.Item(COL_KEY) = "Belegart" Then
e.RepositoryItem = DocumentKindPicker
End If
If e.CellValue.ToString.Length > 30 Then
e.RepositoryItem = MultilineEditor
End If
If oColumn.Config?.IsReadOnly Then
e.RepositoryItem = ReadOnlyEditor
End If
End If
End Sub
Private Sub GridView1_CustomDrawCell(sender As Object, e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles GridView1.CustomDrawCell
Dim oDataRow As DataRow = GridView1.GetDataRow(e.RowHandle)
Dim oKey As String = oDataRow.Item(COL_KEY)
If e.Column.FieldName = COL_VALUE_FINAL Then
Dim oReadOnlyFields As New List(Of String) From {
"BELEGKEY"
}
Dim oColumn = _Table.Columns.
Where(Function(c) c.Name = oKey).
SingleOrDefault()
If oReadOnlyFields.Contains(oDataRow.Item(COL_KEY)) Then
If oColumn Is Nothing Then
Exit Sub
End If
If oColumn.Config?.IsReadOnly Then
e.Appearance.BackColor = Color.LightGray
End If
End If
If oDataRow.Item(COL_VALUE_FINAL) = "" Then
e.Appearance.BackColor = Color.LightCoral
If (oColumn.IsRequired Or oColumn.Config?.IsRequired) AndAlso e.CellValue.ToString.Length = 0 Then
e.Appearance.BackColor = Color.LightCoral
End If
End If
End Sub
End Class