Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text

Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.ExpressApp.Win.SystemModule
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.ExpressApp.Win.Editors

Public Class GLBankVC
    Inherits Nuvolar.Module.GLBankVC
    Private _GridListEditor As GridListEditor
    Dim _WaitFormClass As New WaitFormClass

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)

    End Sub
    Protected Overrides Sub OnActivated()
        MyBase.OnActivated()
        If View.Id = "GLBank_DetailView" Or View.Id = "GLBank_GLRows_ListView" Then
            Frame.GetController(Of WinModificationsController).ModificationsHandlingMode = SystemModule.ModificationsHandlingMode.AutoRollback
        End If

        AddHandler DoWork, AddressOf _WaitFormClass.DoWork
        AddHandler InitWork, AddressOf _WaitFormClass.Initwork
        AddHandler FinalWork, AddressOf _WaitFormClass.Finalwork

    End Sub
    Protected Overrides Sub OnDeactivated()
        MyBase.OnDeactivated()

        RemoveHandler DoWork, AddressOf _WaitFormClass.DoWork
        RemoveHandler InitWork, AddressOf _WaitFormClass.Initwork
        RemoveHandler FinalWork, AddressOf _WaitFormClass.Finalwork

        If View.Id = "GLBank_ListView" Then
            Dim editor As ListEditor = (CType(View, ListView)).Editor
            Dim gridView As GridView = (CType(editor, GridListEditor)).GridView

            RemoveHandler gridView.SelectionChanged, AddressOf GridView_SelectionChanged
        End If
    End Sub
    Protected Overrides Sub OnViewControlsCreated()
        MyBase.OnViewControlsCreated()
        If View.Id = "GLBank_ListView" Then
            Dim editor As ListEditor = (CType(View, ListView)).Editor
            Dim gridView As GridView = (CType(editor, GridListEditor)).GridView

            AddHandler gridView.SelectionChanged, AddressOf GridView_SelectionChanged
        End If
        If View.Id = "GLBank_DetailView" Then
            Beep()
        End If
    End Sub
    Private Sub GridView_SelectionChanged(ByVal sender As Object, ByVal e As DevExpress.Data.SelectionChangedEventArgs)
        Dim gridView As GridView = TryCast(sender, GridView)
        If View.SelectedObjects.Count = 1 Then
            Dim _GLBank As GLBank = TryCast(View.SelectedObjects(0), GLBank)
            If _GLBank Is Nothing Then
            Else
                Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController).Active.SetItemValue("", True)
                If _GLBank.IsEditable = False Then
                    Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController).Active.SetItemValue("", False)
                End If
            End If
        ElseIf View.SelectedObjects.Count > 1 Then
            Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController).Active.SetItemValue("", False)

        End If
    End Sub

    

End Class
