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

Public Class AssetsHandlingCPBVC
    Inherits DevExpress.ExpressApp.ViewController

    Public Sub New()
        MyBase.New()

        InitializeComponent()
        RegisterActions(components)

    End Sub

    Private Sub aToTable_AHCPB_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTable_AHCPB.Execute
        Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
        Dim _AssetsHandlingCPBA As AssetsHandlingCPB = TryCast(View.SelectedObjects(0), AssetsHandlingCPB)
        Dim _AssetsHandlingCPBActivity As AssetsHandlingCPBActivity

        If _AssetsHandlingCPBA IsNot Nothing Then

            _AssetsHandlingCPBActivity = _onew.CreateObject(Of AssetsHandlingCPBActivity)()
            _AssetsHandlingCPBActivity.Customers = _onew.GetObject(_AssetsHandlingCPBA.Customers)
            _AssetsHandlingCPBActivity.Amount = _AssetsHandlingCPBA.row_Amount
            _AssetsHandlingCPBActivity.AmountPercent = _AssetsHandlingCPBA.row_AmountPercent
            _AssetsHandlingCPBActivity.ConversationType = _AssetsHandlingCPBA.row_ConversationType
            _AssetsHandlingCPBActivity.DateDeadline = _AssetsHandlingCPBA.row_DateDeadline
            _AssetsHandlingCPBActivity.NoteCustomers = _AssetsHandlingCPBA.row_NoteCustomers
            _AssetsHandlingCPBActivity.NotePrivate = _AssetsHandlingCPBA.row_NotePrivate
            _AssetsHandlingCPBActivity.Customers.AssetsHandling_Note = _AssetsHandlingCPBA.row_NoteCustomers
            _onew.CommitChanges()

            Dim _DetailView As DetailView = TryCast(View, DetailView)
            If _DetailView IsNot Nothing Then
                Dim _ListPropertyEditor As ListPropertyEditor = _DetailView.FindItem("AssetsHandlingCPBActivity")
                If _ListPropertyEditor IsNot Nothing Then
                    TryCast(_ListPropertyEditor.ListView, ListView).CollectionSource.Reload()
                End If
            End If
        End If
    End Sub

    Private Sub aToTableD_AHCPB_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTableD_AHCPB.Execute
        Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
        Dim _AssetsHandlingCPBActivity_Collection As New List(Of AssetsHandlingCPBActivity)
        Dim _AssetsHandlingCPBActivity As AssetsHandlingCPBActivity
        Dim _DetailView As DetailView = TryCast(View, DetailView)
        If _DetailView IsNot Nothing Then
            Dim _ListPropertyEditor As ListPropertyEditor = _DetailView.FindItem("AssetsHandlingCPBActivity")
            If _ListPropertyEditor IsNot Nothing Then
                Dim _ListView As ListView = TryCast(_ListPropertyEditor.ListView, ListView)
                If _ListView IsNot Nothing Then
                    For Each _AssetsHandlingCPBActivity In _ListView.SelectedObjects
                        _AssetsHandlingCPBActivity_Collection.Add(_onew.GetObject(_AssetsHandlingCPBActivity))
                    Next
                    _onew.Delete(_AssetsHandlingCPBActivity_Collection)
                    _onew.CommitChanges()
                End If
                TryCast(_ListPropertyEditor.ListView, ListView).CollectionSource.Reload()
            End If
        End If
    End Sub

    Private Sub aViewAtachments_AHCPB_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewAtachments_AHCPB.Execute
        Dim _PCIGroup As PCIGroup = TryCast(View.SelectedObjects(0), PCIGroup)

        Dim _CustomersFrom As CustomersFrom = _PCIGroup.CustomersFrom
        Dim _Customers As Customers = _PCIGroup.Customers
        Dim _DocumentNumber As String = _PCIGroup.ConnectInfo
        ViewAttachments.ViewAttachments(View.ObjectSpace, Frame, _CustomersFrom, _Customers, _DocumentNumber, "")
    End Sub
End Class
