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

@ -84,6 +84,9 @@ Partial Public Class OrderReport
Me.GroupFooter1 = New DevExpress.XtraReports.UI.GroupFooterBand()
Me.label2 = New DevExpress.XtraReports.UI.XRLabel()
Me.ObjectDataSource1 = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource(Me.components)
Me.XrTableRow4 = New DevExpress.XtraReports.UI.XRTableRow()
Me.XrTableCell11 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell12 = New DevExpress.XtraReports.UI.XRTableCell()
CType(Me.XrTable2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.XrTable1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.table3, System.ComponentModel.ISupportInitialize).BeginInit()
@ -274,7 +277,7 @@ Partial Public Class OrderReport
'Detail
'
Me.Detail.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.XrTable2, Me.XrTable1})
Me.Detail.HeightF = 50.0!
Me.Detail.HeightF = 75.0!
Me.Detail.KeepTogether = True
Me.Detail.Name = "Detail"
'
@ -284,8 +287,8 @@ Partial Public Class OrderReport
Me.XrTable2.LocationFloat = New DevExpress.Utils.PointFloat(354.8623!, 0!)
Me.XrTable2.Name = "XrTable2"
Me.XrTable2.Padding = New DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96.0!)
Me.XrTable2.Rows.AddRange(New DevExpress.XtraReports.UI.XRTableRow() {Me.XrTableRow3, Me.XrTableRow5})
Me.XrTable2.SizeF = New System.Drawing.SizeF(288.9166!, 50.0!)
Me.XrTable2.Rows.AddRange(New DevExpress.XtraReports.UI.XRTableRow() {Me.XrTableRow3, Me.XrTableRow5, Me.XrTableRow4})
Me.XrTable2.SizeF = New System.Drawing.SizeF(288.9166!, 75.0!)
Me.XrTable2.StylePriority.UseForeColor = False
'
'XrTableRow3
@ -628,6 +631,29 @@ Partial Public Class OrderReport
Me.ObjectDataSource1.DataSource = GetType(MultiTool.[Shared].ReportSource)
Me.ObjectDataSource1.Name = "ObjectDataSource1"
'
'XrTableRow4
'
Me.XrTableRow4.Cells.AddRange(New DevExpress.XtraReports.UI.XRTableCell() {Me.XrTableCell11, Me.XrTableCell12})
Me.XrTableRow4.Name = "XrTableRow4"
Me.XrTableRow4.Weight = 1.0R
'
'XrTableCell11
'
Me.XrTableCell11.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell11.Multiline = True
Me.XrTableCell11.Name = "XrTableCell11"
Me.XrTableCell11.StylePriority.UseFont = False
Me.XrTableCell11.Text = "Bestellt von"
Me.XrTableCell11.Weight = 1.0R
'
'XrTableCell12
'
Me.XrTableCell12.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Head].[Text5]")})
Me.XrTableCell12.Multiline = True
Me.XrTableCell12.Name = "XrTableCell12"
Me.XrTableCell12.Text = "XrTableCell12"
Me.XrTableCell12.Weight = 1.0R
'
'OrderReport
'
Me.Bands.AddRange(New DevExpress.XtraReports.UI.Band() {Me.TopMargin, Me.BottomMargin, Me.ReportHeader, Me.Detail, Me.DetailReport})
@ -713,4 +739,7 @@ Partial Public Class OrderReport
Friend WithEvents XrTableCell7 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell8 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrLabel3 As DevExpress.XtraReports.UI.XRLabel
Friend WithEvents XrTableRow4 As DevExpress.XtraReports.UI.XRTableRow
Friend WithEvents XrTableCell11 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell12 As DevExpress.XtraReports.UI.XRTableCell
End Class

View File

@ -422,7 +422,7 @@ Public Class frmImportMain
SplitContainerGrids.Enabled = False
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Await WebService.TransferDocumentToWinline(oDocument)
Await WebService.TransferDocumentToWinline(oDocument, lookupMandator.EditValue)
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
Catch ex As HttpRequestException
@ -565,9 +565,11 @@ Public Class frmImportMain
Dim oMapperConfig As New Mapper(LogConfig)
Dim oHeadMapper = oMapperConfig.GetMapper(Of ReportHead)(New Dictionary(Of String, String) From {
{"Fakt_Kontonummer[External]", "Text1"},
{"Fakt_Kontonummer[Final]", "Text2"},
{"Auftrags-Bestellnummer", "Text3"},
{"Datum_Auftrag-Bestellung", "Text4"}
{"Datum_Auftrag-Bestellung", "Text4"},
{"Bestellt_von", "Text5"}
})
Dim oPositionMapper = oMapperConfig.GetMapper(Of ReportPosition)(New Dictionary(Of String, String) From {

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

View File

@ -7,6 +7,9 @@
EAN = 2
End Enum
Public Const FUNCTION_GLN = "GLN"
Public Const FUNCTION_EAN = "EAN"
Public Const SCHEMA_TYPE_DATE = "xs:date"
Public Const SCHEMA_TYPE_INTEGER = "xs:integer"
Public Const SCHEMA_TYPE_DECIMAL = "xs:decimal"

View File

@ -137,7 +137,15 @@ Namespace Documents
' The first level of Elements are the document Rows
Dim oTopLevelElements As List(Of XElement) = oRootElement.Elements.ToList
Dim oDocumentRows As New List(Of DocumentRow)
Dim oSortKey As Integer = 0
' TODO: Somehow add all fields in the correct order
'
' Right now, the method of
' - first the filled field from xml
' - then the rest from schema
'
' leads to unordered fields.
For Each oTopLevelElement As XElement In oTopLevelElements
Dim oFields As New Dictionary(Of String, DocumentRow.FieldValue)
Dim oSubElements = oTopLevelElement.Descendants().ToList()
@ -145,15 +153,12 @@ Namespace Documents
Where(Function(t) t.Name = oTopLevelElement.Name).
FirstOrDefault()
For Each oSubElement As XElement In oSubElements
Dim oSchemaField = oTable.Columns.
Where(Function(c) c.Name = oSubElement.Name).
SingleOrDefault()
Dim oRequired = oSchemaField.IsRequired
Dim oValue = oSubElement.Value.Trim()
' TODO: Needed when we have time for date times
@ -165,12 +170,13 @@ Namespace Documents
oFields.Add(oSubElement.Name.ToString, New DocumentRow.FieldValue With {
.Original = oValue,
.Final = oValue,
.DataType = oSchemaField.DataType
.DataType = oSchemaField.DataType,
.Required = oRequired
})
Next
' TODO: All fields in the schema should be generated,
' All fields in the schema are generated,
' only creating the ones with values leads to wrong visual cues when asking for
' docs/rows/fields with errors
For Each oColumn In oTable.Columns
@ -190,10 +196,12 @@ Namespace Documents
' Create a DocumentRow object for each Top Level Element
Dim oRow = New DocumentRow With {
.SortKey = oSortKey,
.Name = oTopLevelElement.Name.ToString,
.Fields = oFields
}
oSortKey += 1
oDocumentRows.Add(oRow)
Next

View File

@ -1,16 +1,37 @@
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 Id As New Guid
Public Property Fields As Dictionary(Of String, FieldValue)
Public ReadOnly Property HasErrors As Boolean
Get
Return Fields.Any(Function(f) f.Value.HasError)
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
@ -18,6 +39,10 @@
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
@ -26,16 +51,16 @@
End Enum
Public Class FieldValue
Public [Error] As FieldError = FieldError.None
Public Original As String = ""
Public External As String = ""
Public Final As String = ""
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 ReadOnly Property HasError As Boolean
Get
Return [Error] <> FieldError.None
Return [Error] <> FieldError.None Or (Required = True And Final = String.Empty)
End Get
End Property

View File

@ -22,7 +22,7 @@ Namespace Winline
AppDataPath = pAppDataPath
End Sub
Public Async Function TransferDocumentToWinline(pDocument As Document) As Task(Of Boolean)
Public Async Function TransferDocumentToWinline(pDocument As Document, pMandator As Mandator) As Task(Of Boolean)
Dim oBytes As Byte() = GetBytesFromDocument(pDocument)
Dim oWS As Config.WebServiceConfig = Config.Webservice
@ -163,8 +163,6 @@ Namespace Winline
"Fakt_Name"
}
Using oStream As New IO.MemoryStream()
Dim w = XmlWriter.Create(oStream)
@ -175,6 +173,8 @@ Namespace Winline
w.WriteAttributeString("option", pDocument.Option)
w.WriteAttributeString("printVoucher", pDocument.PrintVoucher)
pDocument.Rows.Sort()
For Each oRow In pDocument.Rows
w.WriteStartElement(oRow.Name)