From 977e358eaf5b1dc240c5f64257b5cccaa8ef51c1 Mon Sep 17 00:00:00 2001 From: Digital Data - Marlon Schreiber Date: Fri, 31 Jan 2020 14:40:06 +0100 Subject: [PATCH] MS --- app/DD_PM_WINDREAM/ClassIDBData.vb | 23 +++++++++++++++++++++-- app/DD_PM_WINDREAM/frmMain.vb | 3 +++ app/DD_PM_WINDREAM/frmValidator.vb | 14 ++++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/DD_PM_WINDREAM/ClassIDBData.vb b/app/DD_PM_WINDREAM/ClassIDBData.vb index 464590e..2429b4c 100644 --- a/app/DD_PM_WINDREAM/ClassIDBData.vb +++ b/app/DD_PM_WINDREAM/ClassIDBData.vb @@ -129,6 +129,17 @@ Return Nothing End Try + End Function + Public Function Delete_AttributeData(pIDB_OBJID As Int64, pAttributeName As String) As Object + Try + Dim oDELSQL = $"EXEC PRIDB_DELETE_ATTRIBUTE_DATA {pIDB_OBJID},'{pAttributeName}','{USER_USERNAME}'" + ClassDatabase.Execute_non_Query_ConStr(oDELSQL, CONNECTION_STRING_IDB) + + Catch ex As Exception + LOGGER.Error(ex) + Return Nothing + End Try + End Function Public Function SetVariableValue(oAttributeName As String, oNewValue As Object, Optional CheckDeleted As Boolean = False, Optional oIDBTyp As Integer = 0) @@ -136,10 +147,12 @@ Dim omytype = oNewValue.GetType.ToString If omytype = "System.Data.DataTable" Then Dim oDTMyNewValues As DataTable = oNewValue + Dim oOldAttributeResult + Dim oTypeOldResult If CheckDeleted = True Then - Dim oOldAttributeResult = GetVariableValue(oAttributeName, oIDBTyp) - Dim oTypeOldResult = oOldAttributeResult.GetType.ToString + oOldAttributeResult = GetVariableValue(oAttributeName, oIDBTyp) + oTypeOldResult = oOldAttributeResult.GetType.ToString If oTypeOldResult = "System.Data.DataTable" Then Dim myOldValues As DataTable = oOldAttributeResult If myOldValues.Rows.Count > 1 Then @@ -164,7 +177,13 @@ Next End If + Else + Dim oInfo = $"Value [{oOldAttributeResult}] of Attribute [{oAttributeName}] obviously was updated during runtime - will be deleted!" + LOGGER.Info(oInfo) + SetVariableValue(CURRENT_PROFILE_LOG_INDEX, oInfo) + Delete_Term_Object_From_Metadata(oAttributeName, oOldAttributeResult) End If + End If For Each oNewValueRow As DataRow In oDTMyNewValues.Rows diff --git a/app/DD_PM_WINDREAM/frmMain.vb b/app/DD_PM_WINDREAM/frmMain.vb index b04e98b..e4432eb 100644 --- a/app/DD_PM_WINDREAM/frmMain.vb +++ b/app/DD_PM_WINDREAM/frmMain.vb @@ -827,6 +827,9 @@ Public Class frmMain End If If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.SaveViewInfo() + If Application.OpenForms().OfType(Of frmValidator).Any Then + Exit Sub + End If 'If Not Application.OpenForms().OfType(Of frmValidator).Any Then ' Dim oUpdate = "Not Defined" ' Try diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index f098dc2..31833a3 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -4240,17 +4240,17 @@ Public Class frmValidator Case "DevExpress.XtraGrid.GridControl" Dim dgv As GridControl = oControl - Dim Zeilen As Integer = dgv.DataSource.Rows.Count + Dim oRowCount As Integer = dgv.DataSource.Rows.Count 'Wenn kein Wert ausgewählt wurde und der Index aber gesetzt werden muss - If oIsRequired = True And Zeilen = 0 Then + If oIsRequired = True And oRowCount = 0 Then oMissing = True oErrorMessage = "Fehlende Eingabe in Tabelle '" & dgv.Name & "'" oControl.BackColor = Color.Red Exit For - ElseIf Zeilen > 0 Then + ElseIf oRowCount > 0 Then Dim ZeilenGrid As Integer = 0 Dim myVektorArr As String() 'Jeden Werte des Datagridviews durchlaufen @@ -4326,9 +4326,15 @@ Public Class frmValidator oErrorMessage = $"Error while indexing table (2) {dgv.Name} - ERROR: " & idxerr_message Exit For End If + Else + Dim oDT As DataTable = IDBData.GetVariableValue(oIndexName, oIDBTyp) + If oDT.Rows.Count > 0 Then + LOGGER.Debug("User cleared the grid, so data needs to be erased!") + IDBData.Delete_AttributeData(CURRENT_DOC_ID, oIndexName) + End If End If - End If + End If End Select End If 'End If für Control und ReadOnly = False Next