WIP: Currency & Date Formatting
This commit is contained in:
parent
1e98e4a9ab
commit
e7a60d3515
@ -3184,25 +3184,30 @@ Public Class frmValidator
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
Try
|
|
||||||
Dim oFormatString As String = oControlRow.Item("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}")
|
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim oFormatString As String = oControlRow.ItemEx("CTRL_FORMAT_STRING", "")
|
||||||
|
If oFormatString <> 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 oFormatString
|
||||||
|
Case "Currency" ' 16,325.63 €
|
||||||
|
Dim oValue As Double = oValueFromSource
|
||||||
|
oFormattedValue = oValue.ToString("C2")
|
||||||
|
|
||||||
|
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
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@ -3210,8 +3215,34 @@ Public Class frmValidator
|
|||||||
LOGGER.Error(ex)
|
LOGGER.Error(ex)
|
||||||
End Try
|
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
|
|
||||||
|
' 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
|
If Not IsNothing(oFormattedValue) And oFormattedValue <> String.Empty Then
|
||||||
oControl.Text = NotNull(oFormattedValue, oDefaultValue)
|
oControl.Text = NotNull(oFormattedValue, oDefaultValue)
|
||||||
Else
|
Else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user