prevent error when clicking on control buttons

This commit is contained in:
Jonathan Jenne 2019-10-28 10:40:34 +01:00
parent dbe4abfb39
commit 28ce2af63d
2 changed files with 21 additions and 11 deletions

View File

@ -7,10 +7,10 @@ Imports DigitalData.Controls.RegexEditor
Imports DigitalData.Modules.Windows.Window
Public Class ctrlApplicationAssignment
Public SelectedProfileId As Integer = 0
Public SelectedProcessId As Integer = 0
Public SelectedWindowId As Integer = 0
Public SelectedControlId As Integer = 0
Public Property SelectedProfileId As Integer = 0
Public Property SelectedProcessId As Integer = 0
Public Property SelectedWindowId As Integer = 0
Public Property SelectedControlId As Integer = 0
Private Sub ctrlApplicationAssignment_Load(sender As Object, e As EventArgs) Handles Me.Load
TBCW_PROFILE_PROCESSTableAdapter.Connection.ConnectionString = MyConnectionString
@ -352,6 +352,7 @@ Public Class ctrlApplicationAssignment
MyDataset.TBCW_PROF_REL_WINDOW.Clear()
If e.FocusedRowHandle < 0 Then
SelectedProcessId = 0
Exit Sub
End If
@ -377,17 +378,18 @@ Public Class ctrlApplicationAssignment
Private Sub GridView_Window_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridView_Window.FocusedRowChanged
Try
If e.FocusedRowHandle < 0 Then
SelectedWindowId = 0
Exit Sub
End If
Dim oSelectedRow As DataRow = GridView_Window.GetDataRow(e.FocusedRowHandle)
Dim oWindowId As String = oSelectedRow.Item("GUID")
SelectedWindowId = oWindowId
If Control_Load() = False Then
MsgBox($"Error while loading controls for window {oWindowId}", vbCritical, "")
End If
SelectedWindowId = oWindowId
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
@ -395,7 +397,7 @@ Public Class ctrlApplicationAssignment
Private Sub GridView_Control_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridView_Control.FocusedRowChanged
If e.FocusedRowHandle < 0 Then
SelectedControlId = Nothing
SelectedControlId = 0
Exit Sub
End If

View File

@ -679,6 +679,10 @@ Public Class frmAdministration
End Sub
Private Sub BarButtonItem24_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem24.ItemClick
If CtrlApplicationAssignment1.SelectedControlId = 0 Then
Exit Sub
End If
If MsgBox($"Wollen Sie die Feld-Zuordnung löschen?", MsgBoxStyle.Exclamation Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.No Then
Exit Sub
End If
@ -691,6 +695,10 @@ Public Class frmAdministration
End Sub
Private Sub BarButtonItem25_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem25.ItemClick
If CtrlApplicationAssignment1.SelectedControlId = 0 Then
Exit Sub
End If
If CtrlApplicationAssignment1.Control_SaveAssignment() = False Then
MsgBox("Error while saving control", MsgBoxStyle.Critical, Text)
Else
@ -699,6 +707,10 @@ Public Class frmAdministration
End Sub
Private Sub BarButtonItem27_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem27.ItemClick
If CtrlApplicationAssignment1.SelectedControlId = 0 Then
Exit Sub
End If
If CtrlApplicationAssignment1.Control_EditAssignment() = False Then
MsgBox("Error while saving control", MsgBoxStyle.Critical, Text)
Else
@ -716,8 +728,4 @@ Public Class frmAdministration
MsgBox("Profile has been duplicated. Please check the dependencies!", MsgBoxStyle.Information)
End If
End Sub
Private Sub GridViewProfiles_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewProfiles.FocusedRowChanged
End Sub
End Class