Improve Validation, Report, Transfer document with selected mandator

This commit is contained in:
Jonathan Jenne
2021-11-17 16:25:00 +01:00
parent 47c22e9361
commit 1366343cdf
7 changed files with 119 additions and 44 deletions

View File

@@ -1,14 +1,15 @@
Imports DevExpress.XtraGrid.Views.Grid
Imports System.Globalization
Imports MultiTool.Shared.Documents
Imports MultiTool.Shared.Documents.DocumentRow
Imports DevExpress.XtraEditors.Repository
Imports MultiTool.Shared.Winline
Imports DigitalData.Modules.Language
Imports DevExpress.XtraEditors.Controls
Imports System.Globalization
Imports DevExpress.XtraEditors
Imports DigitalData.Modules.Logging
Imports MultiTool.Shared.Schemas
Imports MultiTool.Shared.Constants
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Logging
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraGrid.Views.Grid
Public Class frmRowEditor
Private ReadOnly LogConfig As LogConfig
@@ -29,10 +30,6 @@ Public Class frmRowEditor
Private ReadOnly DocumentKindPicker As New RepositoryItemSearchLookUpEdit
Private ReadOnly ReadOnlyEditor As New RepositoryItemTextEdit
'Private ReadOnly MaskDateEditor As New RepositoryItemTextEdit
'Private ReadOnly DatePicker As New RepositoryItemDateEdit
Private Const COL_KEY = "KEY"
Private Const COL_VALUE_ORIGINAL = "VALUE_ORIGINAL"
Private Const COL_VALUE_EXTERNAL = "VALUE_EXTERNAL"
@@ -45,7 +42,6 @@ Public Class frmRowEditor
End Property
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()
LogConfig = pLogConfig
@@ -105,11 +101,12 @@ Public Class frmRowEditor
Dim oField = _DocumentRow.Fields.
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
' Only Show Columns that are set to visible
If oColumn?.Config?.IsVisible = False Then
Continue For
End If
@@ -160,6 +157,13 @@ Public Class frmRowEditor
If Not oFieldValue.Final.Equals(oGridValue) Then
Dim oValue = Utils.NotNull(oRow.Item(COL_VALUE_FINAL), String.Empty).ToString
' If new value is not empty, any error will be removed.
' Could cause problems in the future because a value might not equal to 'no error'.
If oValue <> String.Empty Then
oFieldValue.Error = FieldError.None
End If
oFieldValue.Final = oValue.Trim()
If _DocumentRow.Fields.ContainsKey(oField.Key) Then
@@ -222,15 +226,16 @@ Public Class frmRowEditor
Where(Function(c) c.Name = oKey).
SingleOrDefault()
If oColumn Is Nothing Then
Exit Sub
End If
If oColumn.Config?.Function.Name = "GLN" Then
If oColumn.Config?.Function?.Name = FUNCTION_GLN Then
e.RepositoryItem = AccountPicker
End If
If oColumn.Config?.Function.Name = "EAN" Then
If oColumn.Config?.Function?.Name = FUNCTION_EAN Then
e.RepositoryItem = ArticlePicker
End If
@@ -249,22 +254,25 @@ Public Class frmRowEditor
Dim oKey As String = oDataRow.Item(COL_KEY)
Dim oValue As String = oDataRow.Item(COL_VALUE_FINAL)
Dim oColumn = _Table.Columns.
Where(Function(c) c.Name = oKey).
SingleOrDefault()
Where(Function(c) c.Name = oKey).
SingleOrDefault()
Dim oField = _DocumentRow.Fields.
Where(Function(f) f.Key = oKey).
SingleOrDefault()
If e.Column.FieldName = COL_VALUE_FINAL Then
If oColumn Is Nothing Then
If oColumn IsNot Nothing Then
If oColumn.Config?.IsReadOnly Then
e.Appearance.BackColor = Color.LightGray
End If
End If
If oColumn.Config?.IsRequired AndAlso e.CellValue.ToString.Length = 0 Then
e.Appearance.BackColor = Color.LightCoral
End If
If oField.Value.HasError Then
e.Appearance.BackColor = Color.LightCoral
End If
End If
If oColumn.Config?.IsRequired AndAlso oValue.ToString.Length = 0 Then
If oField.Value.HasError Then
e.Appearance.BackColor = Color.LightCoral
End If
End Sub