Jonathan Jenne ee23cdd7e8 WIP
2021-11-19 13:53:38 +01:00

77 lines
2.4 KiB
VB.net

Namespace Documents
Public Class DocumentRow
Implements IComparable
''' <summary>
''' GUID to match DocumentRow with Row from Grid/DataTable
''' </summary>
Public Property Id As New Guid
''' <summary>
''' Counter to ensure consistency and order when writing XML
''' </summary>
Public Property SortKey As Integer
''' <summary>
''' Tabellen/Elementname aus XML
''' </summary>
Public Property Name As String
Public Property Fields As Dictionary(Of String, FieldValue)
Public ReadOnly Property HasErrors As Boolean
Get
If Errors.Count > 0 Then
Return True
Else
Return False
End If
End Get
End Property
Public ReadOnly Property Errors As List(Of String)
Get
Return Fields.
Where(Function(f) f.Value.HasError).
Select(Function(f) f.Key).ToList()
End Get
End Property
Public Sub New()
Id = Guid.NewGuid()
End Sub
Public Function CompareTo(other As Object) As Integer Implements IComparable.CompareTo
Return SortKey.CompareTo(DirectCast(other, DocumentRow).SortKey)
End Function
Public Enum FieldError
None
MissingValue
AccountNotFound
ArticleNotFound
End Enum
Public Class FieldValue
Public Property DataType As Constants.ColumnType = Constants.ColumnType.String
Public Property [Error] As FieldError = FieldError.None
Public Property Original As String = ""
Public Property External As String = ""
Public Property Final As String = ""
Public Property Required As Boolean = False
Public Property SortKey As Integer = 0
Public ReadOnly Property HasError As Boolean
Get
Return Required = True And (
[Error] <> FieldError.None Or Final = String.Empty
)
End Get
End Property
Public Overrides Function ToString() As String
Return Final
End Function
End Class
End Class
End Namespace