ZooFlow: Admin

This commit is contained in:
Jonathan Jenne
2021-05-10 14:50:21 +02:00
parent 1decc85753
commit ec2916cebd
10 changed files with 162 additions and 63 deletions

View File

@@ -20,6 +20,7 @@ Public Class ClassDetailPages
Public Event AnyControl_Changed As EventHandler(Of DetailPageEventArgs)
Public Event CurrentPage_Changed As EventHandler(Of DetailPageEventArgs)
Private RaiseChangedEvents As Boolean = True
Private CurrentPage As DetailPage
Public Property Current As DetailPage
@@ -94,7 +95,9 @@ Public Class ClassDetailPages
Items.Add(Page.TabPage.Name, Page)
AddHandler Page.BindingSource.AddingNew, Sub(sender As Object, e As EventArgs)
RaiseChangedEvents = False
Page.AddedWhoEdit.EditValue = Environment.UserName
RaiseChangedEvents = True
End Sub
End Sub
@@ -122,6 +125,27 @@ Public Class ClassDetailPages
End Try
End Function
Public Function PrepareLoad() As Boolean
Dim oItem = Items.
Where(Function(Item) Item.Value.IsPrimary).
FirstOrDefault()
Dim oPage = oItem.Value
If oPage Is Nothing Then
Return False
End If
If oPage.IsInsert Then
RaiseChangedEvents = False
oPage.BindingSource.AddNew()
RaiseChangedEvents = True
End If
CurrentPage = oPage
Return True
End Function
''' <summary>
''' Saves the pending changes to the binding source
''' </summary>
@@ -137,12 +161,17 @@ Public Class ClassDetailPages
oPage.BindingSource.EndEdit()
If oPage.DataTable.GetChanges() IsNot Nothing Then
RaiseChangedEvents = False
HostForm.HasChanges = True
If oPage.IsInsert Then
oPage.AddedWhoEdit.EditValue = My.Application.User.UserName
Else
oPage.ChangedWhoEdit.EditValue = My.Application.User.UserName
End If
RaiseChangedEvents = True
oPage.BindingSource.EndEdit()
Return True
Else
@@ -241,6 +270,10 @@ Public Class ClassDetailPages
Private Sub Handle_EditValueChanged(sender As BaseEdit, e As EventArgs)
Dim oControl As BaseEdit = sender
If RaiseChangedEvents = False Then
Exit Sub
End If
' Get the Layout Control containing the Edit Contol
If TypeOf oControl.Parent Is LayoutControl Then
Dim oLayoutControl As LayoutControl = oControl.Parent