diff --git a/app/TaskFlow/frmValidator.vb b/app/TaskFlow/frmValidator.vb index d4fd4cb..a5bf5f7 100644 --- a/app/TaskFlow/frmValidator.vb +++ b/app/TaskFlow/frmValidator.vb @@ -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