ZooFlow: Admin
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports System.ComponentModel
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraLayout
|
||||
Imports DevExpress.XtraTab
|
||||
|
||||
@@ -25,10 +26,14 @@ Public Class ClassDetailPages
|
||||
|
||||
Public Sub New(LayoutControls As List(Of LayoutControl))
|
||||
For Each oLayoutControl In LayoutControls
|
||||
AddHandler oLayoutControl.Click, AddressOf Handle_Focus
|
||||
AddHandler oLayoutControl.GotFocus, AddressOf Handle_Focus
|
||||
|
||||
For Each oContainer As LayoutControlItem In oLayoutControl.Root.Items
|
||||
Dim oControl As BaseEdit = oContainer.Control
|
||||
AddHandler oControl.GotFocus, AddressOf Handle_Focus
|
||||
AddHandler oControl.EditValueChanged, AddressOf Handle_EditValueChanged
|
||||
AddHandler oControl.Validating, AddressOf Handle_Validating
|
||||
Next
|
||||
Next
|
||||
End Sub
|
||||
@@ -43,26 +48,59 @@ Public Class ClassDetailPages
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub Handle_Focus(sender As BaseEdit, e As EventArgs)
|
||||
Private Sub Handle_Validating(sender As Object, e As CancelEventArgs)
|
||||
Dim oControl As BaseEdit = sender
|
||||
Dim oBinding As Binding = oControl.DataBindings.Item("EditValue")
|
||||
|
||||
If TypeOf oBinding.DataSource Is BindingSource Then
|
||||
Dim oSource As BindingSource = oBinding.DataSource
|
||||
Dim oTableName As String = oSource.DataMember
|
||||
Dim oDataSet As DataSet = oSource.DataSource
|
||||
Dim oTable = oDataSet.Tables(oTableName)
|
||||
Dim oColumnName As String = oBinding.BindingMemberInfo.BindingField
|
||||
Dim oColumn As DataColumn = oTable.Columns.Item(oColumnName)
|
||||
|
||||
Dim oNullable As Boolean = oColumn.AllowDBNull
|
||||
|
||||
If oNullable = False And NotNull(oControl.EditValue, String.Empty) = String.Empty Then
|
||||
Throw New NoNullAllowedException()
|
||||
End If
|
||||
End If
|
||||
|
||||
Console.WriteLine()
|
||||
End Sub
|
||||
|
||||
Private Sub Handle_Focus(sender As Control, e As EventArgs)
|
||||
Dim oControl As Control = sender
|
||||
Dim oLayoutControl As LayoutControl = Nothing
|
||||
|
||||
' Get the Layout Control containing the Edit Contol
|
||||
If TypeOf oControl.Parent Is LayoutControl Then
|
||||
Dim oLayoutControl As LayoutControl = oControl.Parent
|
||||
oLayoutControl = oControl.Parent
|
||||
ElseIf TypeOf oControl Is LayoutControl Then
|
||||
oLayoutControl = oControl
|
||||
End If
|
||||
|
||||
' Get the TabPage containing the Layout Control
|
||||
If TypeOf oLayoutControl.Parent Is XtraTabPage Then
|
||||
Dim oTabPage As XtraTabPage = oLayoutControl.Parent
|
||||
If oLayoutControl Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If Items.ContainsKey(oTabPage.Name) Then
|
||||
CurrentPage = Items.Item(oTabPage.Name)
|
||||
' Get the TabPage containing the Layout Control
|
||||
Do_Handle_Focus(oLayoutControl, oControl)
|
||||
End Sub
|
||||
|
||||
Dim oData As New DetailPageEventArgs With {.Page = Items.Item(oTabPage.Name)}
|
||||
RaiseEvent AnyControl_Focus(oControl, oData)
|
||||
Else
|
||||
CurrentPage = Nothing
|
||||
RaiseEvent AnyControl_Focus(oControl, Nothing)
|
||||
End If
|
||||
Private Sub Do_Handle_Focus(LayoutControl As LayoutControl, Control As Control)
|
||||
If TypeOf LayoutControl.Parent Is XtraTabPage Then
|
||||
Dim oTabPage As XtraTabPage = LayoutControl.Parent
|
||||
|
||||
If Items.ContainsKey(oTabPage.Name) Then
|
||||
CurrentPage = Items.Item(oTabPage.Name)
|
||||
|
||||
Dim oData As New DetailPageEventArgs With {.Page = Items.Item(oTabPage.Name)}
|
||||
RaiseEvent AnyControl_Focus(Control, oData)
|
||||
Else
|
||||
CurrentPage = Nothing
|
||||
RaiseEvent AnyControl_Focus(Control, Nothing)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Reference in New Issue
Block a user