Trim values from user on save

This commit is contained in:
Jonathan Jenne 2021-11-01 10:47:09 +01:00
parent f71b53b5c3
commit 00165025f6

View File

@ -10,8 +10,13 @@ Imports DigitalData.Modules.Language
Imports DevExpress.XtraEditors.Controls
Imports System.Globalization
Imports DevExpress.XtraEditors
Imports DigitalData.Modules.Logging
Public Class frmRowEditor
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private ReadOnly FormHelper As FormHelper
Private ReadOnly _Columns As List(Of String)
Private ReadOnly _DataTable As New DataTable
Private ReadOnly _Accounts As List(Of Account)
@ -40,10 +45,14 @@ Public Class frmRowEditor
End Get
End Property
Public Sub New(pColumns As List(Of String), pDocumentRow As DocumentRow, pMandator As Mandator, pWinline As Data)
Public Sub New(pLogConfig As LogConfig, pColumns As List(Of String), pDocumentRow As DocumentRow, pMandator As Mandator, pWinline As Data)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
LogConfig = pLogConfig
Logger = pLogConfig.GetLogger()
FormHelper = New FormHelper(pLogConfig)
_Columns = pColumns
_Accounts = pWinline.Accounts.Where(Function(a) a.Mandator.Id = pMandator.Id).ToList()
_Articles = pWinline.Articles.Where(Function(a) a.Mandator.Id = pMandator.Id).ToList()
@ -119,6 +128,7 @@ Public Class frmRowEditor
End Sub
Private Sub btnSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSave.ItemClick
Try
GridView1.CloseEditor()
For Each oRow As DataRow In _DataTable.Rows
@ -141,7 +151,8 @@ Public Class frmRowEditor
End If
If Not oFieldValue.Final.Equals(oGridValue) Then
oFieldValue.Final = Utils.NotNull(oRow.Item(COL_VALUE_FINAL), String.Empty)
Dim oValue = Utils.NotNull(oRow.Item(COL_VALUE_FINAL), String.Empty).ToString
oFieldValue.Final = oValue.Trim()
If _DocumentRow.Fields.ContainsKey(oField.Key) Then
_DocumentRow.Fields.Item(oField.Key) = oFieldValue
@ -154,6 +165,10 @@ Public Class frmRowEditor
DialogResult = DialogResult.OK
Close()
Catch ex As Exception
MsgBox("")
Logger.Error(ex)
End Try
End Sub
Private Function TryParseDate(pValue As String)