diff --git a/app/DD_PM_WINDREAM/ClassControlCreator.vb b/app/DD_PM_WINDREAM/ClassControlCreator.vb index 2e56dc8..a818507 100644 --- a/app/DD_PM_WINDREAM/ClassControlCreator.vb +++ b/app/DD_PM_WINDREAM/ClassControlCreator.vb @@ -42,6 +42,12 @@ Public Class ClassControlCreator Public Location As Point Public [Font] As Font Public [Color] As Color + Public [ReadOnly] As Boolean + End Class + + Public Class ControlMetadata + Public Guid As Integer + Public [ReadOnly] As Boolean End Class Private Shared Function TransformDataRow(row As DataRow) As ControlDBProps @@ -52,25 +58,31 @@ Public Class ClassControlCreator Dim familyString As String = NotNull(row.Item("FONT_FAMILY"), DEFAULT_FONT_FAMILY) Dim family As FontFamily = New FontFamily(familyString) - Dim Guid As Integer = row.Item("GUID") - Dim Name As String = row.Item("NAME") - Dim Location As New Point(x, y) - Dim Font As New Font(family, size, style, GraphicsUnit.Point) - Dim Color As Color = IntToColor(NotNull(row.Item("FONT_COLOR"), DEFAULT_COLOR)) + Dim oGuid As Integer = row.Item("GUID") + Dim oName As String = row.Item("NAME") + Dim oLocation As New Point(x, y) + Dim oFont As New Font(family, size, style, GraphicsUnit.Point) + Dim oColor As Color = IntToColor(NotNull(row.Item("FONT_COLOR"), DEFAULT_COLOR)) + Dim oReadOnly As Boolean = row.Item("READ_ONLY") Return New ControlDBProps() With { - .Guid = Guid, - .Name = Name, - .Location = Location, - .Font = Font, - .Color = Color + .Guid = oGuid, + .Name = oName, + .Location = oLocation, + .Font = oFont, + .Color = oColor, + .ReadOnly = oReadOnly } End Function Public Shared Function CreateBaseControl(ctrl As Control, row As DataRow, designMode As Boolean) As Control Dim props As ControlDBProps = TransformDataRow(row) - ctrl.Tag = props.Guid + ctrl.Tag = New ControlMetadata() With { + .Guid = props.Guid, + .ReadOnly = props.ReadOnly + } + 'ctrl.Tag = props.Guid ctrl.Name = props.Name ctrl.Location = props.Location ctrl.Font = props.Font @@ -80,6 +92,10 @@ Public Class ClassControlCreator ctrl.Cursor = Cursors.Hand End If + If props.ReadOnly Then + ctrl.BackColor = Color.Gray + End If + Return ctrl End Function diff --git a/app/DD_PM_WINDREAM/frmFormDesigner.vb b/app/DD_PM_WINDREAM/frmFormDesigner.vb index 4ff528f..82c1560 100644 --- a/app/DD_PM_WINDREAM/frmFormDesigner.vb +++ b/app/DD_PM_WINDREAM/frmFormDesigner.vb @@ -298,7 +298,11 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, label.Name, "LBL", label.Text, label.Location.X, label.Location.Y, Environment.UserName, label.Size.Height, label.Size.Width) CurrentControl = label - CurrentControl.Tag = GetLastID() + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = GetLastID(), + .ReadOnly = False + } + pnldesigner.Controls.Add(label) @@ -309,7 +313,10 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, txt.Name, "TXT", txt.Name, txt.Location.X, txt.Location.Y, Environment.UserName, txt.Size.Height, txt.Size.Width) CurrentControl = txt - CurrentControl.Tag = GetLastID() + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = GetLastID(), + .ReadOnly = False + } pnldesigner.Controls.Add(txt) @@ -320,7 +327,10 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, cmb.Name, "CMB", cmb.Name, cmb.Location.X, cmb.Location.Y, Environment.UserName, cmb.Size.Height, cmb.Size.Width) CurrentControl = cmb - CurrentControl.Tag = GetLastID() + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = GetLastID(), + .ReadOnly = False + } pnldesigner.Controls.Add(cmb) @@ -331,7 +341,10 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, dtp.Name, "DTP", dtp.Name, dtp.Location.X, dtp.Location.Y, Environment.UserName, dtp.Size.Height, dtp.Size.Width) CurrentControl = dtp - CurrentControl.Tag = GetLastID() + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = GetLastID(), + .ReadOnly = False + } pnldesigner.Controls.Add(dtp) @@ -342,7 +355,10 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, chk.Name, "CHK", chk.Text, chk.Location.X, chk.Location.Y, Environment.UserName, chk.Size.Height, chk.Size.Width) CurrentControl = chk - CurrentControl.Tag = GetLastID() + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = GetLastID(), + .ReadOnly = False + } pnldesigner.Controls.Add(chk) @@ -354,7 +370,10 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, lc.Name, "LOOKUP", lc.Name, lc.Location.X, lc.Location.Y, Environment.UserName, lc.Size.Height, lc.Size.Width) CurrentControl = lc - CurrentControl.Tag = GetLastID() + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = GetLastID(), + .ReadOnly = False + } pnldesigner.Controls.Add(lc) @@ -366,11 +385,16 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, tb.Name, "TABLE", tb.Name, tb.Location.X, tb.Location.Y, Environment.UserName, tb.Size.Height, tb.Size.Width) - CurrentControl = tb - CurrentControl.Tag = GetLastID() + Dim oControlId = GetLastID() - TBPM_CONTROL_TABLETableAdapter.Insert(CurrentControl.Tag, "column1", "Column1", 95, Environment.UserName) - TBPM_CONTROL_TABLETableAdapter.Insert(CurrentControl.Tag, "column2", "Column2", 95, Environment.UserName) + CurrentControl = tb + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = oControlId, + .ReadOnly = False + } + + TBPM_CONTROL_TABLETableAdapter.Insert(oControlId, "column1", "Column1", 95, Environment.UserName) + TBPM_CONTROL_TABLETableAdapter.Insert(oControlId, "column2", "Column2", 95, Environment.UserName) pnldesigner.Controls.Add(tb) Case ClassControlCreator.PREFIX_LINE @@ -381,7 +405,10 @@ Public Class frmFormDesigner TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(ProfileId, line.Name, "LINE", line.Name, line.Location.X, line.Location.Y, Environment.UserName, line.Size.Height, line.Size.Width) CurrentControl = line - CurrentControl.Tag = GetLastID() + CurrentControl.Tag = New ClassControlCreator.ControlMetadata() With { + .Guid = GetLastID(), + .ReadOnly = False + } pnldesigner.Controls.Add(line) @@ -440,7 +467,7 @@ Public Class frmFormDesigner Dim oHitinfo As GridHitInfo = oView.CalcHitInfo(sender.PointToClient(Cursor.Position)) CurrentControl = sender - CURRENT_CONTROL_ID = sender.Tag + CURRENT_CONTROL_ID = DirectCast(sender.Tag, ClassControlCreator.ControlMetadata).Guid If oHitinfo.IsValid And oHitinfo.InColumn Then Dim oColumn As GridColumn = oHitinfo.Column @@ -717,21 +744,23 @@ Public Class frmFormDesigner LOGGER.Info(ex) End Try + Dim oControlId = DirectCast(sender.Tag, ClassControlCreator.ControlMetadata).Guid + row = dt.AsEnumerable().Where(Function(r As DataRow) - Return r.Item("GUID") = sender.Tag + Return r.Item("GUID") = oControlId End Function).SingleOrDefault() ' Control-Id wurde nicht in DataRow gefunden If IsNothing(row) Then - LOGGER.Info($"Error while filtering Controls by Guid '{sender.Tag}' in LoadControlProperties:") - MsgBox($"Control mit der Id {sender.Tag} wurde nicht gefunden!", MsgBoxStyle.Critical, "Fehler beim Laden der Control Eigenschaften") + LOGGER.Info($"Error while filtering Controls by Guid '{oControlId}' in LoadControlProperties:") + MsgBox($"Control mit der Id {oControlId} wurde nicht gefunden!", MsgBoxStyle.Critical, "Fehler beim Laden der Control Eigenschaften") Exit Sub End If ' Globale Variablen setzen CurrentControl = sender - CURRENT_CONTROL_ID = sender.Tag + CURRENT_CONTROL_ID = oControlId SetActiveControlColor() diff --git a/app/DD_PM_WINDREAM/frmMassValidator.vb b/app/DD_PM_WINDREAM/frmMassValidator.vb index 2f713a6..3fe5da7 100644 --- a/app/DD_PM_WINDREAM/frmMassValidator.vb +++ b/app/DD_PM_WINDREAM/frmMassValidator.vb @@ -345,7 +345,7 @@ Public Class frmMassValidator CTRLS_Loaded = True FillIndexValues() For Each oControl As Control In pnldesigner.Controls - LoadSimpleData(oControl, oControl.Tag) + LoadSimpleData(oControl, DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid) Next Catch ex As Exception LOGGER.Info("Unvorhergesehener Fehler bei Load_Controls:" & ex.Message) @@ -363,7 +363,7 @@ Public Class frmMassValidator Dim oLOOKUPValue = SelectedValues.Item(0) Dim oLOOKUPName = oLookup.Name - Dim oControlID = oLookup.Tag + Dim oControlID = DirectCast(oLookup.Tag, ClassControlCreator.ControlMetadata).Guid Dim filteredData As DataTable = DTCONTROLS.Clone() Dim oExpression = $"SQL_UEBERPRUEFUNG like '%#CTRL#{oLOOKUPName}%'" DTCONTROLS.Select(oExpression).CopyToDataTable(filteredData, LoadOption.PreserveChanges) @@ -382,7 +382,7 @@ Public Class frmMassValidator Try Dim oDependingLookup As LookupControl2 = pnldesigner.Controls.Find(oDEPENDING_CtrlName, False).FirstOrDefault() For Each oControl As Control In pnldesigner.Controls - If oControl.Tag = oDEPENDING_GUID Then + If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = oDEPENDING_GUID Then Dim oDependingLookup1 As LookupControl2 = oControl oDependingLookup1.DataSource = oDTDEPENDING_RESULT _dependingControl_in_action = False @@ -411,14 +411,14 @@ Public Class frmMassValidator Dim resultvalue Try - For Each inctrl As Control In Me.pnldesigner.Controls + For Each oControl As Control In Me.pnldesigner.Controls - Dim CONTROL_ID = inctrl.Tag + Dim CONTROL_ID = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid Dim controlRow = (From form In DTCONTROLS.AsEnumerable' DD_DMSLiteDataSet.VWPM_CONTROL_INDEX.AsEnumerable() Select form Where form.Item("GUID") = CONTROL_ID).Single() - Dim Type As String = inctrl.GetType.ToString + Dim Type As String = oControl.GetType.ToString Dim Typ As String = controlRow.Item("CTRL_TYPE") If Typ = "LBL" Or Typ = "LINE" Then Continue For @@ -428,29 +428,29 @@ Public Class frmMassValidator Dim defaultValue As String = NotNull(controlRow.Item("DEFAULT_VALUE"), String.Empty) indexname = idxname Dim LoadIDX As Boolean = controlRow.Item("LOAD_IDX_VALUE") - LOGGER.Debug("INDEX: " & idxname & " - CONTROLNAME: " & inctrl.Name & " - LOAD IDXVALUES: " & LoadIDX.ToString) + LOGGER.Debug("INDEX: " & idxname & " - CONTROLNAME: " & oControl.Name & " - LOAD IDXVALUES: " & LoadIDX.ToString) Dim wertWD Select Case Type Case "System.Windows.Forms.TextBox" Try controltype = "Textbox" If idxname = "" Then - MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & inctrl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) + MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & oControl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) Exit For End If If idxname Is Nothing = False Then If LoadIDX = False Or idxname = "DD PM-ONLY FOR DISPLAY" Then ' Wenn kein Index exisitiert, defaultValue laden - inctrl.Text = defaultValue + oControl.Text = defaultValue LOGGER.Debug("Indexwert soll nicht geladen werden.") Exit Select End If wertWD = GetWM_Value_Multiple_Docs(idxname) If wertWD = "" And defaultValue <> "" Then - inctrl.Text = defaultValue + oControl.Text = defaultValue Else - inctrl.Text = NotNull(wertWD, defaultValue) + oControl.Text = NotNull(wertWD, defaultValue) End If End If @@ -467,9 +467,9 @@ Public Class frmMassValidator Case "System.Windows.Forms.ComboBox" controltype = "ComboBox" - Dim cmb As ComboBox = inctrl + Dim cmb As ComboBox = oControl If idxname = "" Then - MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & inctrl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) + MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & oControl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) Exit For End If If idxname Is Nothing = False Then @@ -496,9 +496,9 @@ Public Class frmMassValidator End If Case "System.Windows.Forms.DataGridView" controltype = "DataGridView" - Dim dgv As DataGridView = inctrl + Dim dgv As DataGridView = oControl If idxname = "" Then - MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & inctrl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) + MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & oControl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) Exit For End If If idxname Is Nothing = False Then @@ -568,12 +568,12 @@ Public Class frmMassValidator Case "System.Windows.Forms.CheckBox" controltype = "CheckBox" If idxname = "" Then - MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & inctrl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) + MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & oControl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) Exit For End If If idxname Is Nothing = False Then - Dim chk As CheckBox = inctrl + Dim chk As CheckBox = oControl If LoadIDX = False Then LOGGER.Debug("Indexwert soll nicht geladen werden.") @@ -634,14 +634,14 @@ Public Class frmMassValidator End If Case "System.Windows.Forms.DateTimePicker" controltype = "DateTimePicker" - Dim DTP As DateTimePicker = inctrl + Dim DTP As DateTimePicker = oControl If idxname = "" Then - MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & inctrl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) + MsgBox("Achtung fehlerhafte Konfiguration:" & vbNewLine & "Für das Control " & oControl.Name & " wurde KEIN INDEX hinterlegt!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical) Exit For End If Case "DigitalData.Controls.LookupGrid.LookupControl2" Try - Dim oLookup As LookupControl2 = inctrl + Dim oLookup As LookupControl2 = oControl Dim oWindreamValue = GetWM_Value_Multiple_Docs(idxname) If Not IsNothing(oWindreamValue) Then @@ -1136,24 +1136,24 @@ Public Class frmMassValidator Dim CTRL_ID = element.Value.Substring(2, element.Value.Length - 3) CTRL_ID = CTRL_ID.Replace("CTRLID", "") Dim value_from_control - For Each inctrl As Control In Me.pnldesigner.Controls - If IsNothing(inctrl.Tag) Then + For Each oControl As Control In Me.pnldesigner.Controls + If IsNothing(oControl.Tag) Then Continue For End If - If inctrl.Tag = CTRL_ID Then + If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = CTRL_ID Then '###### - Dim Type As String = inctrl.GetType.ToString + Dim Type As String = oControl.GetType.ToString Select Case Type Case "System.Windows.Forms.TextBox" Try - value_from_control = inctrl.Text + value_from_control = oControl.Text Catch ex As Exception LOGGER.Error(ex) value_from_control = String.Empty End Try Case "System.Windows.Forms.ComboBox" - Dim cmb As ComboBox = inctrl + Dim cmb As ComboBox = oControl Try value_from_control = cmb.Text Catch ex As Exception @@ -1161,7 +1161,7 @@ Public Class frmMassValidator value_from_control = String.Empty End Try Case "System.Windows.Forms.DateTimePicker" - Dim dtp As DateTimePicker = inctrl + Dim dtp As DateTimePicker = oControl Try value_from_control = dtp.Value.ToString Catch ex As Exception @@ -1170,7 +1170,7 @@ Public Class frmMassValidator End Try Case "System.Windows.Forms.CheckBox" - Dim chk As CheckBox = inctrl + Dim chk As CheckBox = oControl Try value_from_control = chk.Checked Catch ex As Exception diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index 5d88327..92a14a6 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -1028,7 +1028,7 @@ Public Class frmValidator Dim oLOOKUPValue = SelectedValues.Item(0) Dim oLOOKUPName = oLookup.Name - Dim oControlID = oLookup.Tag + Dim oControlID = DirectCast(oLookup.Tag, ClassControlCreator.ControlMetadata).Guid Dim filteredData As DataTable = DTCONTROLS.Clone() Dim oExpression = $"SQL_UEBERPRUEFUNG like '%#CTRL#{oLOOKUPName}%'" DTCONTROLS.Select(oExpression).CopyToDataTable(filteredData, LoadOption.PreserveChanges) @@ -1048,7 +1048,7 @@ Public Class frmValidator 'Dim oDependingLookup As LookupControl2 = pnldesigner.Controls.Find(oDEPENDING_CtrlName, False).FirstOrDefault() For Each oControl As Control In pnldesigner.Controls - If oControl.Tag = oDEPENDING_GUID Then + If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = oDEPENDING_GUID Then If oControl.GetType.ToString = "System.Windows.Forms.TextBox" Then oControl.Text = oDTDEPENDING_RESULT.Rows(0).Item(0) Else @@ -1580,7 +1580,7 @@ Public Class frmValidator FillIndexValues(first) For Each oControl As Control In pnldesigner.Controls - LoadSQLData(oControl, oControl.Tag) + LoadSQLData(oControl, DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid) Next LOGGER.Debug("Indexmaske geladen") @@ -2054,7 +2054,7 @@ Public Class frmValidator If DD_DMSLiteDataSet.VWPM_CONTROL_INDEX.Rows.Count > 0 Then Dim oCount As Integer = 0 For Each oControl As Control In Me.pnldesigner.Controls - Dim oControlId = oControl.Tag + Dim oControlId = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid Dim oControlRow = (From form In DD_DMSLiteDataSet.VWPM_CONTROL_INDEX.AsEnumerable() Select form Where form.Item("GUID") = oControlId).Single() @@ -2791,24 +2791,24 @@ Public Class frmValidator Dim CTRL_ID = element.Value.Substring(2, element.Value.Length - 3) CTRL_ID = CTRL_ID.Replace("CTRLID", "") Dim value_from_control - For Each inctrl As Control In Me.pnldesigner.Controls - If IsNothing(inctrl.Tag) Then + For Each oControl As Control In Me.pnldesigner.Controls + If IsNothing(DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid) Then Continue For End If - If inctrl.Tag = CTRL_ID Then + If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = CTRL_ID Then '###### - Dim Type As String = inctrl.GetType.ToString + Dim Type As String = oControl.GetType.ToString Select Case Type Case "System.Windows.Forms.TextBox" Try - value_from_control = inctrl.Text + value_from_control = oControl.Text Catch ex As Exception LOGGER.Error(ex) value_from_control = String.Empty End Try Case "System.Windows.Forms.ComboBox" - Dim cmb As ComboBox = inctrl + Dim cmb As ComboBox = oControl Try value_from_control = cmb.Text Catch ex As Exception @@ -2816,7 +2816,7 @@ Public Class frmValidator value_from_control = String.Empty End Try Case "System.Windows.Forms.DateTimePicker" - Dim dtp As DateTimePicker = inctrl + Dim dtp As DateTimePicker = oControl Try value_from_control = dtp.Value.ToString Catch ex As Exception @@ -2825,7 +2825,7 @@ Public Class frmValidator End Try Case "System.Windows.Forms.CheckBox" - Dim chk As CheckBox = inctrl + Dim chk As CheckBox = oControl Try value_from_control = chk.Checked Catch ex As Exception