WIP: Currency & Date Formatting
This commit is contained in:
parent
1e98e4a9ab
commit
e7a60d3515
@ -3184,34 +3184,65 @@ Public Class frmValidator
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oFormatString As String = oControlRow.Item("CTRL_FORMAT_STRING")
|
||||
Dim oFormatString As String = oControlRow.ItemEx("CTRL_FORMAT_STRING", "")
|
||||
If oFormatString <> String.Empty Then
|
||||
Try
|
||||
Dim oSPlit = Split(oFormatString, ";")
|
||||
If oSPlit(0) = "Decimal" Then
|
||||
LOGGER.Debug("FORMAT_STRING DECIMAL")
|
||||
oFormattedValue = oValueFromSource
|
||||
LOGGER.Debug($"Unformatted String: {oFormattedValue}")
|
||||
Dim oFormattedDec As Decimal = oValueFromSource
|
||||
If oSPlit.Length = 3 Then
|
||||
oFormattedValue = $"{oFormattedDec.ToString(oSPlit(1))} {oSPlit(2)}"
|
||||
ElseIf oSPlit.Length = 4 Then
|
||||
oFormattedValue = $"{oFormattedDec.ToString(oSPlit(1), New CultureInfo(oSPlit(2)))} {oSPlit(3)}"
|
||||
Else
|
||||
oFormatString = oFormatString.Replace("Decimal;", "")
|
||||
End If
|
||||
LOGGER.Debug($"Formatted String: {oFormattedValue}")
|
||||
' https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=net-7.0#system-datetime-tostring(system-string)
|
||||
|
||||
Select Case oFormatString
|
||||
Case "Currency" ' 16,325.63 €
|
||||
Dim oValue As Double = oValueFromSource
|
||||
oFormattedValue = oValue.ToString("C2")
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn($"Unexpected error in Format String [{oControl.Name}]: {ex.Message}")
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
Case "Decimal" ' 16325,63
|
||||
Dim oValue As Double = oValueFromSource
|
||||
oFormattedValue = oValue.ToString("F")
|
||||
|
||||
Case "Date" ' 15.06.2008
|
||||
Dim oValue As DateTime = oValueFromSource
|
||||
oFormattedValue = oValue.ToString("d")
|
||||
|
||||
Case "DateTime" ' 15.06.2008 9:15:07
|
||||
Dim oValue As DateTime = oValueFromSource
|
||||
oFormattedValue = oValue.ToString("G")
|
||||
|
||||
End Select
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn($"Unexpected error in Format String [{oControl.Name}]: {ex.Message}")
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
|
||||
Try
|
||||
'Dim oFormatString As String = oControlRow.ItemEx("CTRL_FORMAT_STRING", "")
|
||||
'If oFormatString <> String.Empty Then
|
||||
' Try
|
||||
' Dim oSPlit = Split(oFormatString, ";")
|
||||
' If oSPlit(0) = "Decimal" Then
|
||||
' LOGGER.Debug("FORMAT_STRING DECIMAL")
|
||||
' oFormattedValue = oValueFromSource
|
||||
' LOGGER.Debug($"Unformatted String: {oFormattedValue}")
|
||||
' Dim oFormattedDec As Decimal = oValueFromSource
|
||||
' If oSPlit.Length = 3 Then
|
||||
' oFormattedValue = $"{oFormattedDec.ToString(oSPlit(1))} {oSPlit(2)}"
|
||||
' ElseIf oSPlit.Length = 4 Then
|
||||
' oFormattedValue = $"{oFormattedDec.ToString(oSPlit(1), New CultureInfo(oSPlit(2)))} {oSPlit(3)}"
|
||||
' Else
|
||||
' oFormatString = oFormatString.Replace("Decimal;", "")
|
||||
' End If
|
||||
' LOGGER.Debug($"Formatted String: {oFormattedValue}")
|
||||
|
||||
|
||||
' End If
|
||||
' Catch ex As Exception
|
||||
' LOGGER.Warn($"Unexpected error in Format String [{oControl.Name}]: {ex.Message}")
|
||||
' LOGGER.Error(ex)
|
||||
' End Try
|
||||
|
||||
|
||||
'End If
|
||||
If Not IsNothing(oFormattedValue) And oFormattedValue <> String.Empty Then
|
||||
oControl.Text = NotNull(oFormattedValue, oDefaultValue)
|
||||
Else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user