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.SystemModule

Public Class ImmovablesCostRecordVC
    Inherits DevExpress.ExpressApp.ViewController
    Protected selection As ArrayList
    Protected noselect As Boolean = False

    Public Sub New()
        MyBase.New()

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

        selection = New ArrayList()
        Me.TargetObjectType = GetType(SISBusiness.Module.ImmovablesCostRecord)
    End Sub
    Protected Overrides Sub OnActivated()
        MyBase.OnActivated()

        AddHandler View.SelectionChanged, AddressOf view_SelectionChanged

    End Sub
    Private Sub aDescription_Change_ImmovablesCostRecord_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aDescription_Change_ImmovablesCostRecord.CustomizePopupWindowParams
        Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
        Dim _ImmovablesCostRecord As ImmovablesCostRecord = TryCast(View.SelectedObjects(0), ImmovablesCostRecord)
        Dim _ImmovablesCostRecordDescriptionPopup As ImmovablesCostRecordDescriptionPopup = _onew.CreateObject(Of ImmovablesCostRecordDescriptionPopup)()

        _ImmovablesCostRecordDescriptionPopup.Description = _ImmovablesCostRecord.Description_ContactRows

        e.View = Application.CreateDetailView(_onew, "ImmovablesCostRecordDescriptionPopup_DetailView", False, _ImmovablesCostRecordDescriptionPopup)


    End Sub

    Private Sub aDescription_Change_ImmovablesCostRecord_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aDescription_Change_ImmovablesCostRecord.Execute
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _ImmovablesCostRecordDescriptionPopup As ImmovablesCostRecordDescriptionPopup = TryCast(e.PopupWindow.View.SelectedObjects(0), ImmovablesCostRecordDescriptionPopup)
        Dim _ImmovablesCostRecord As ImmovablesCostRecord

        For Each _ImmovablesCostRecord In selection
            _ImmovablesCostRecord.Description_ContactRows = _ImmovablesCostRecordDescriptionPopup.Description
        Next
        _ocur.CommitChanges()

        Frame.GetController(Of RefreshController).RefreshAction.DoExecute()

    End Sub

    Private Sub view_SelectionChanged(sender As Object, e As EventArgs)
        Dim _ImmovablesCostRecord As ImmovablesCostRecord
        If View Is Nothing Then Exit Sub
        If noselect = False Then
            selection.Clear()
            For Each _ImmovablesCostRecord In View.SelectedObjects
                selection.Add(_ImmovablesCostRecord)
            Next
        End If
    End Sub

End Class
