From 403d23db93a041910ac34903719d3692fc09d0d4 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 15 Aug 2022 14:21:08 +0200 Subject: [PATCH] fix Controls2B_EnDisabled_on_Load, remove enable_sql_conn_id --- app/DD_PM_WINDREAM/frmValidator.vb | 79 +++++++++++++----------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index 7cd6ea7..ef50190 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -2139,34 +2139,32 @@ Public Class frmValidator End If Next - - - Catch ex As Exception - LOGGER.Error(ex) - End Try - End Sub - Private Sub Controls2beDisabled() - Try - Dim oFilteredDatatable As DataTable = DT_CONTROLS.Clone() - Dim oExpression = $"LEN(SQL_ENABLE) > 0" - DT_CONTROLS.Select(oExpression).CopyToDataTable(oFilteredDatatable, LoadOption.PreserveChanges) - If oFilteredDatatable.Rows.Count > 0 Then - LOGGER.Debug($"We got {oFilteredDatatable.Rows.Count} controls which need to be disabled!!") - End If - For Each oRowEnablingControl As DataRow In oFilteredDatatable.Rows - Dim oENABLE_GUID = oRowEnablingControl.Item("GUID") - Dim oENABLE_CtrlName = oRowEnablingControl.Item("NAME") - For Each oControl As Control In PanelValidatorControl.Controls - If oENABLE_GUID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid Then - oControl.Enabled = False - Exit For - End If - Next - Next Catch ex As Exception LOGGER.Error(ex) End Try End Sub + 'Private Sub Controls2beDisabled() + ' Try + ' Dim oFilteredDatatable As DataTable = DT_CONTROLS.Clone() + ' Dim oExpression = $"LEN(SQL_ENABLE) > 0" + ' DT_CONTROLS.Select(oExpression).CopyToDataTable(oFilteredDatatable, LoadOption.PreserveChanges) + ' If oFilteredDatatable.Rows.Count > 0 Then + ' LOGGER.Debug($"We got {oFilteredDatatable.Rows.Count} controls which need to be disabled!!") + ' End If + ' For Each oRowEnablingControl As DataRow In oFilteredDatatable.Rows + ' Dim oENABLE_GUID = oRowEnablingControl.Item("GUID") + ' Dim oENABLE_CtrlName = oRowEnablingControl.Item("NAME") + ' For Each oControl As Control In PanelValidatorControl.Controls + ' If oENABLE_GUID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid Then + ' oControl.Enabled = False + ' Exit For + ' End If + ' Next + ' Next + ' Catch ex As Exception + ' LOGGER.Error(ex) + ' End Try + 'End Sub Private Sub Controls2B_EnDisabled_on_Load() Try Dim oFilteredDatatable As DataTable = DT_CONTROLS.Clone() @@ -2181,31 +2179,22 @@ Public Class frmValidator For Each oControl As Control In PanelValidatorControl.Controls If oENABLE_GUID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid Then LOGGER.Debug($"Found the Control on panel which needs to be checked [{oENABLE_GUID}]...") - Dim oSqlCommand = IIf(IsDBNull(oRowEnablingControl.Item("SQL_ENABLE_ON_LOAD")), "", oRowEnablingControl.Item("SQL_ENABLE_ON_LOAD")) - Dim oConID = oRowEnablingControl.Item("SQL_ENABLE_ON_LOAD_CONID") - If Not IsDBNull(oConID) Then - oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, PanelValidatorControl, True) - - Dim oConnectionId As Integer = oRowEnablingControl.Item("CONNECTION_ID") - Dim oENABLERESULT As Boolean = False - - oENABLERESULT = DatabaseFallback.GetScalarValueWithConnection(oSqlCommand, oConnectionId) - + 'Dim oSqlCommand = IIf(IsDBNull(oRowEnablingControl.Item("SQL_ENABLE_ON_LOAD")), "", oRowEnablingControl.Item("SQL_ENABLE_ON_LOAD")) + 'Dim oConID = oRowEnablingControl.Item("SQL_ENABLE_ON_LOAD_CONID") + Dim oConnectionId As Integer = oRowEnablingControl.ItemEx("CONNECTION_ID", 0) + Dim oSqlCommand = oRowEnablingControl.ItemEx("SQL_ENABLE_ON_LOAD", String.Empty) + oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, PanelValidatorControl, True) + Dim oResult = DatabaseFallback.GetScalarValueWithConnection(oSqlCommand, oConnectionId) - Try - LOGGER.Debug($"oENABLERESULT [{oENABLERESULT}]...") - oControl.Enabled = oENABLERESULT - Catch ex As Exception - LOGGER.Warn($"Error en/disabling control onLoad: [{ex.Message}]") - End Try - Else - LOGGER.Warn($"Attention SQL_ENABLE_ON_LOAD_CONID seems to be null!") - End If - - + Try + LOGGER.Debug($"Result of Enable SQL [{oResult}]...") + oControl.Enabled = oResult + Catch ex As Exception + LOGGER.Warn($"Error en/disabling control onLoad: [{ex.Message}]") + End Try End If Next