Clean up, fix missing TextEdit
This commit is contained in:
@@ -29,84 +29,6 @@ Public Class ClassFormat
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Public Shared Function GetFormattedValue(pControlName As String, pValueObject As Object, pFormatString As String) As String
|
||||
Try
|
||||
If pFormatString <> String.Empty Then
|
||||
' https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=net-7.0#system-datetime-tostring(system-string)
|
||||
|
||||
Select Case pFormatString
|
||||
Case ClassControlCreator.CONTROL_TYPE_CURRENCY ' 16,325.63 €
|
||||
If TypeOf pValueObject Is Double Then
|
||||
Dim oFormattedValue As Double = pValueObject
|
||||
Return oFormattedValue.ToString(CURRENCY_FORMAT)
|
||||
|
||||
ElseIf TypeOf pValueObject Is String Then
|
||||
Dim oFormattedValue As Double
|
||||
Double.TryParse(pValueObject, oFormattedValue)
|
||||
Return oFormattedValue.ToString(CURRENCY_FORMAT)
|
||||
|
||||
Else
|
||||
Return Nothing
|
||||
|
||||
End If
|
||||
|
||||
Case ClassControlCreator.CONTROL_TYPE_DOUBLE ' 16325,63
|
||||
If TypeOf pValueObject Is Double Then
|
||||
Dim oFormattedValue As Double = pValueObject
|
||||
Return oFormattedValue.ToString(DECIMAL_FORMAT)
|
||||
|
||||
ElseIf TypeOf pValueObject Is String Then
|
||||
Dim oFormattedValue As Double
|
||||
Double.TryParse(pValueObject, oFormattedValue)
|
||||
Return oFormattedValue.ToString(DECIMAL_FORMAT)
|
||||
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Case ClassControlCreator.CONTROL_TYPE_DATE ' 15.06.2008
|
||||
Dim oFormattedValue As DateTime
|
||||
|
||||
If TypeOf pValueObject Is DateTime Then
|
||||
oFormattedValue = pValueObject
|
||||
Return oFormattedValue.ToString(DATE_FORMAT)
|
||||
|
||||
ElseIf TypeOf pValueObject Is String Then
|
||||
DateTime.TryParse(pValueObject, oFormattedValue)
|
||||
Return oFormattedValue.ToString(DATE_FORMAT)
|
||||
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Case ClassControlCreator.CONTROL_TYPE_DATETIME ' 15.06.2008 9:15:07
|
||||
Dim oFormattedValue As DateTime
|
||||
|
||||
If TypeOf pValueObject Is DateTime Then
|
||||
oFormattedValue = pValueObject
|
||||
Return oFormattedValue.ToString(DATETIME_FORMAT)
|
||||
ElseIf TypeOf pValueObject Is String Then
|
||||
DateTime.TryParse(pValueObject, oFormattedValue)
|
||||
Return oFormattedValue.ToString(DATETIME_FORMAT)
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Case Else ' Unknown Format String
|
||||
LOGGER.Warn("Format String [{0}] for Control [{1}] is not valid!", pFormatString, pControlName)
|
||||
Return Nothing
|
||||
|
||||
End Select
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn($"Unexpected error while formatting Value for Control [{0}]", pControlName)
|
||||
LOGGER.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Converts a string according to the type information, using the invariant culture
|
||||
''' </summary>
|
||||
|
||||
Reference in New Issue
Block a user