MS BackColor

This commit is contained in:
2023-04-24 16:44:38 +02:00
parent f2ed8c14d2
commit bd3f3e22d0
3 changed files with 60 additions and 8 deletions

View File

@@ -17,6 +17,7 @@ Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.ZooFlow.Constants
Imports DigitalData.GUIs.Common
Imports DevExpress.XtraGrid.Columns
Imports System.Globalization
Public Class frmValidator
Private Property Current_Document As DocumentResultList.Document = Nothing
@@ -3115,6 +3116,7 @@ Public Class frmValidator
End If
Dim oValueFromSource
Dim oFormattedValue As String = ""
Dim oControlId = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid
Dim oControlRow = (From form In DTVWCONTROL_INDEX.AsEnumerable()
Select form
@@ -3134,7 +3136,9 @@ Public Class frmValidator
oControName = oControl.Name
Dim oLoadIndex As Boolean = oControlRow.Item("LOAD_IDX_VALUE")
If oSourceIndexName = "Netto" Then
Console.WriteLine("Bing Netto")
End If
LOGGER.Debug("INDEX: " & oSourceIndexName & " - CONTROLNAME: " & oControl.Name & " - LOAD IDXVALUES: " & oLoadIndex.ToString)
Select Case oType
@@ -3183,14 +3187,65 @@ Public Class frmValidator
End If
Try
oControl.Text = NotNull(oValueFromSource, oDefaultValue)
Dim oFormatString As String = oControlRow.Item("CTRL_FORMAT_STRING")
If oFormatString <> String.Empty Then
Try
Dim oSPlit = Split(oFormatString, ";")
If oSPlit(0) = "Decimal" Then
oFormattedValue = oValueFromSource
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
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
oControl.Text = NotNull(oValueFromSource, oDefaultValue)
End If
Try
Dim oBackColor As String = oControlRow.Item("CTRL_BACKCOLOR_IF")
If oBackColor <> String.Empty Then
Dim oSPlit = Split(oBackColor, ";")
If oSPlit.Length = 3 Then
Dim oValueConverted
If IsNumeric(oValueFromSource) Then
oValueConverted = oValueFromSource.ToString.Replace(",", ".")
Else
oValueConverted = oValueFromSource
End If
Dim oExpression = $"{oValueConverted} {oSPlit(0)}"
Dim oSQl = $"SELECT CASE WHEN {oExpression} THEN CONVERT(BIT,1) ELSE CONVERT(BIT,0) END "
Dim oColorName = IIf(DatabaseECM.GetScalarValue(oSQl), oSPlit(1), oSPlit(2))
oControl.BackColor = Color.FromName(oColorName)
End If
End If
Catch ex As Exception
LOGGER.Warn($"Unexpected error in Set Backcolor [{oControl.Name}]: {ex.Message}")
LOGGER.Error(ex)
End Try
ClassControlCreator.GridTables_HandleControlValueChange(PanelValidatorControl, DT_COLUMNS_GRID_WITH_SQL_WITH_CTRL_PLACEHOLDER)
Catch ex As Exception
LOGGER.Info("ERROR while converting defaultValue [" & oDefaultValue & "]: " & ex.Message)
LOGGER.Info("Error While converting defaultValue [" & oDefaultValue & "]: " & ex.Message)
oControl.Text = ""
End Try