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
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.Data.Filtering
Imports DevExpress.Xpo

Public Class GLMixedVC
    Inherits DevExpress.ExpressApp.ViewController
    Protected selection As ArrayList
    Protected reconfigure As ArrayList
    Public Sub New()
        MyBase.New()
        selection = New ArrayList()
        reconfigure = New ArrayList
        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)
    End Sub
    Protected Overrides Sub OnActivated()
        MyBase.OnActivated()
        Frame.GetController(Of GLMixedVC).aViewPCIDW_RateDiff.Active.SetItemValue("", False)
        Frame.GetController(Of GLMixedVC).aViewAttachments_RateDiff_GLRows.Active.SetItemValue("", False)
        Frame.GetController(Of GLMixedVC).aViewRegistry_RateDiff_GLRows.Active.SetItemValue("", False)
        Frame.GetController(Of GLMixedVC).aCloneGLMixed.Active.SetItemValue("", False)
        If View.Id = "GLMixed_DetailView" Then
            Dim _GLMixed As GLMixed = TryCast(View.SelectedObjects(0), GLMixed)
            Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", False)
            If _GLMixed.IsEditable = False Then
                Frame.GetController(Of ModificationsController).Active.SetItemValue("", False)
                If SecuritySystem.CurrentUserName = "SysAdmin" Then
                Else
                    Frame.GetController(Of DeleteObjectsViewController).Active.SetItemValue("", False)
                End If
            End If
            If _GLMixed.IsStorno = True Then
                Frame.GetController(Of ModificationsController).Active.SetItemValue("", False)
                If SecuritySystem.CurrentUserName = "SysAdmin" Then
                Else
                    Frame.GetController(Of DeleteObjectsViewController).Active.SetItemValue("", False)
                End If
            End If

            If _GLMixed.GLDocumentType = eGLDocumentType.eGLRateDiff Then
                Frame.GetController(Of NewObjectViewController).Active.SetItemValue("", False)
                Frame.GetController(Of ModificationsController).Active.SetItemValue("", False)

                If SecuritySystem.CurrentUserName = "SysAdmin" Then
                Else
                    Frame.GetController(Of DeleteObjectsViewController).Active.SetItemValue("", False)
                End If
                Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", False)
            End If
        End If

        If View.Id = "GLMixed_ListView" Then
            Frame.GetController(Of NewObjectViewController).Active.SetItemValue("", False)
            Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", False)
            Frame.GetController(Of GLMixedVC).aCloneGLMixed.Active.SetItemValue("", True)
        End If
        If View.Id = "GLMixed_ListView_Editable" Then
            Frame.GetController(Of GLMixedVC).aCloneGLMixed.Active.SetItemValue("", True)
        End If

        If View.Id Like "GLHeader_GLRows_ListView_Mixed" Then
            Frame.GetController(Of LinkUnlinkController)().Active.SetItemValue("", False)
            Frame.GetController(Of NewObjectViewController)().Active.SetItemValue("", False)
            Frame.GetController(Of DeleteObjectsViewController)().Active.SetItemValue("", False)
            Frame.GetController(Of GLMixedVC).aViewPCIDW_RateDiff.Active.SetItemValue("", True)
            Frame.GetController(Of ListViewProcessCurrentObjectController).Active.SetItemValue("", False)
            Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", False)

            Dim nv As ListView = CType(View, ListView)
            Dim cs As PropertyCollectionSource = CType(nv.CollectionSource, PropertyCollectionSource)
            AddHandler cs.MasterObjectChanged, AddressOf cs_MasterObjectChanged

        End If
        If View.Id = "GLRows_ListView_RateDiff" Then
            Frame.GetController(Of DeleteObjectsViewController).Active.SetItemValue("", True)
            Frame.GetController(Of GLMixedVC).aViewPCIDW_RateDiff.Active.SetItemValue("", True)
            Frame.GetController(Of GLMixedVC).aViewAttachments_RateDiff_GLRows.Active.SetItemValue("", True)
            Frame.GetController(Of GLMixedVC).aViewRegistry_RateDiff_GLRows.Active.SetItemValue("", True)
            AddHandler Frame.GetController(Of DeleteObjectsViewController).DeleteAction.Executing, AddressOf Delete_Executing
            AddHandler Frame.GetController(Of DeleteObjectsViewController).DeleteAction.Executed, AddressOf Delete_Executed
        End If
        If View.Id = "GLMixed_DetailView_Dividend" Then
            Frame.GetController(Of LinkUnlinkController)().Active.SetItemValue("", False)
            Frame.GetController(Of NewObjectViewController)().Active.SetItemValue("", False)
            Frame.GetController(Of DeleteObjectsViewController)().Active.SetItemValue("", False)
            Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", False)
            Frame.GetController(Of GLMixedVC).aStorno_GLMixed.Active.SetItemValue("", False)
            Frame.GetController(Of ModificationsController).SaveAndNewAction.Active.SetItemValue("", False)
            Frame.GetController(Of ModificationsController).SaveAndCloseAction.Active.SetItemValue("", False)
            Frame.GetController(Of GLMixedVC).aFinalAndNew_GLMixed.Active.SetItemValue("", False)
            Dim _GLOpenCloseHeader = TryCast(TryCast(Frame, NestedFrame).ViewItem.View.SelectedObjects(0), GLOpenCloseHeader)
            View.CurrentObject = View.ObjectSpace.GetObject(_GLOpenCloseHeader.GLMixed_AfterDividend)
        End If
    End Sub
    Protected Overrides Sub OnDeactivated()
        MyBase.OnDeactivated()
        Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", True)
        If View.Id = "GLRows_ListView_RateDiff" Then
            RemoveHandler Frame.GetController(Of DeleteObjectsViewController).DeleteAction.Executing, AddressOf Delete_Executing
            RemoveHandler Frame.GetController(Of DeleteObjectsViewController).DeleteAction.Executed, AddressOf Delete_Executed
        End If
        'Frame.GetController(Of DeleteObjectsViewController).Active.SetItemValue("", True)
    End Sub
    Private Sub cs_MasterObjectChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim _GLMixed As GLMixed = TryCast((CType(sender, PropertyCollectionSource)).MasterObject, GLMixed)
        If _GLMixed IsNot Nothing Then
            If _GLMixed.IsEditable = False Then
                Frame.GetController(Of GLMixedVC).aToTable_GLMixed.Active.SetItemValue("", False)
            End If
        End If
    End Sub
    Private Sub aMakeEditable_GLMixed_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aMakeEditable_GLMixed.Execute
        Dim _GLMixed As GLMixed = TryCast(View.SelectedObjects(0), GLMixed)
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace

        If _GLMixed IsNot Nothing Then
            _GLMixed.IsEditable = True
            _ocur.CommitChanges()
            If TryCast(View, ListView) IsNot Nothing Then
                e.ShowViewParameters.CreatedView = Application.CreateDetailView(_onew, "GLMixed_DetailView", True, _onew.GetObjectByKey(Of GLMixed)(_GLMixed.Oid))
            End If
        End If
    End Sub
    Private Sub aFinalAndNew_GLMixed_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aFinalAndNew_GLMixed.Execute
        GLMixed_Final(e)
        Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
        Dim _GLMixed As GLMixed = _onew.CreateObject(Of GLMixed)()

        e.ShowViewParameters.CreatedView = Application.CreateDetailView(_onew, TryCast(View.Model, Model.IModelDetailView).Id, True, _GLMixed)
        e.ShowViewParameters.TargetWindow = TargetWindow.Current
    End Sub
#Region "SIS"
    Private Sub GLMixed_Final(ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs)
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _GLRows As GLRows = Nothing
        If View.SelectedObjects.Count > 0 Then
            Dim _GLMixed As GLMixed = TryCast(e.SelectedObjects(0), GLMixed)
            Dim _GLMixedNG As GLMixedNG
            For Each _GLMixed In e.SelectedObjects
                If _GLMixed.GLRows.Count <= 0 Then
                    Throw New Exception("*Nincs rögzített sor !")
                End If
                _GLMixedNG = _ocur.FindObject(Of GLMixedNG)(CriteriaOperator.Parse("CustomersFrom=?", _GLMixed.CustomersFrom), True)
                If _GLMixedNG IsNot Nothing Then
                    If _GLMixed.DocumentNumber Is Nothing Then
                        _GLMixed.DocumentNumber = _GLMixedNG.NumberGenerator.GetNewNumber(_GLMixedNG.NumberGenerator)
                    End If
                    If _GLMixed.DocumentNumber = "" Then
                        _GLMixed.DocumentNumber = _GLMixedNG.NumberGenerator.GetNewNumber(_GLMixedNG.NumberGenerator)
                    End If
                End If
                _GLMixed.IsEditable = False
                _ocur.CommitChanges()

                For Each _GLRows In _GLMixed.GLRows
                    If _GLRows.PartnerType = ePartnerType.eNotSet Then
                    Else
                        Dim _uow As New UnitOfWork(_ocur.Session.DataLayer)
                        GLFunctions.ReconfigurePCI(_uow, _GLRows.GLHeader.CustomersFrom, _GLRows.Customer, _GLRows.PartnerType, _GLRows.ConnectInfo)
                    End If
                Next
            Next
            _ocur.CommitChanges()
        End If
    End Sub
#End Region
    Private Sub aToTableD_GLMixed_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTableD_GLMixed.Execute
        'Törli a táblázatban lévő sort
        Dim _GUID As Guid
        Dim _GLMixed As GLMixed = TryCast(View.SelectedObjects(0), GLMixed)
        Dim _GLRows_ListEditor As ListPropertyEditor
        Dim _GLRows As GLRows
        Dim i As Long
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)

        Dim _CustomersFrom As CustomersFrom = Nothing
        Dim _Customers As Customers = Nothing
        Dim _PartnerType As ePartnerType
        Dim _ConnectInfo As String = ""

        _GLRows_ListEditor = TryCast(View, DetailView).FindItem("GLRows")

        _GLRows = TryCast(_GLRows_ListEditor.ListView.CurrentObject, GLRows)
        If _GLRows IsNot Nothing Then
            _GUID = _GLRows.GLRowsGUID
            selection.Clear()
            For Each _GLRows In _GLMixed.GLRows
                If _GLRows.GLRowsGUID = _GUID Then
                    selection.Add(_GLRows)
                End If
            Next
            For i = 0 To selection.Count - 1
                _GLRows = TryCast(selection(i), GLRows)
                If _GLRows.PartnerType = ePartnerType.ePayabels Or _GLRows.PartnerType = ePartnerType.eReceivables Then
                    _CustomersFrom = _GLMixed.CustomersFrom
                    _Customers = _GLRows.Customer
                    _ConnectInfo = _GLRows.ConnectInfo
                    _PartnerType = _GLRows.PartnerType
                End If
                _GLRows.Delete()
                _ocur.CommitChanges()

                Dim _uow_pci As New UnitOfWork(_ocur.Session.DataLayer)
                GLFunctions.ReconfigurePCI(_uow_pci, _CustomersFrom, _Customers, _PartnerType, _ConnectInfo)
            Next
            View.Refresh()
        End If
    End Sub
    Private Sub aBackToRowEdit_GLMixed_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aBackToRowEdit_GLMixed.Execute
        'Visszatölti a sort editáláshoz
        Dim _GLMixed As GLMixed = TryCast(View.SelectedObjects(0), GLMixed)
        Dim _GLRows_ListEditor As ListPropertyEditor
        Dim _GLRows As GLRows

        _GLRows_ListEditor = TryCast(View, DetailView).FindItem("GLRows")
        _GLRows = TryCast(_GLRows_ListEditor.ListView.CurrentObject, GLRows)

        If _GLRows IsNot Nothing Then
            _GLMixed.row_DebitChartOfAccounts = _GLRows.DebitChartOfAccounts
            _GLMixed.row_AmountHUF = _GLRows.AmountHUF
            _GLMixed.row_AmountDEV = _GLRows.AmountDEV
            _GLMixed.row_Controlling = _GLRows.Controlling
            _GLMixed.row_Customer = _GLRows.Customer
            _GLMixed.row_ConnectInfo = _GLRows.ConnectInfo
            _GLMixed.row_JobNumberObjects = _GLRows.JobNumberObjects
            _GLMixed.row_UniqueObjects = _GLRows.UniqueObjects
            _GLMixed.row_CostHolder = _GLRows.CostHolder
            _GLMixed.row_CostPlace = _GLRows.CostPlace
            _GLMixed.row_CreditChartOfAccounts = _GLRows.CreditChartOfAccounts
            _GLMixed.row_NoteRows = _GLRows.NoteRows
            _GLMixed.row_PartnerType = _GLRows.PartnerType
        End If

        View.Refresh()
    End Sub
    Private Sub aToTable_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTable_GLMixed.Execute
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _GLMixed As GLMixed = TryCast(View.SelectedObjects(0), GLMixed)
        Dim _GLHeader As GLHeader = TryCast(View.SelectedObjects(0), GLHeader)
        Dim _GLRows As GLRows

        If _GLMixed IsNot Nothing Then

            Dim _GUID As Guid = Guid.NewGuid()

            _GLRows = _ocur.CreateObject(Of GLRows)()

            Select Case _GLMixed.row_TransactionType
                Case eTransactionType.eNormalCredit, eTransactionType.ePartnerCredit
                    _GLRows.InAmountHUF = _GLMixed.row_AmountHUF
                    _GLRows.InAmountDEV = _GLMixed.row_AmountDEV
                Case eTransactionType.eNormalDebit, eTransactionType.ePartnerDebit
                    _GLRows.OutAmountHUF = _GLMixed.row_AmountHUF
                    _GLRows.OutAmountDEV = _GLMixed.row_AmountDEV
                Case Else
                    _GLRows.InAmountDEV = 0
                    _GLRows.InAmountDEV2 = 0
                    _GLRows.InAmountHUF = 0
                    _GLRows.OutAmountHUF = 0
                    _GLRows.OutAmountDEV = 0
                    _GLRows.OutAmountDEV2 = 0
            End Select
            _GLRows.AddGLRows(_GLHeader, _GLHeader.row_DebitChartOfAccounts, _GLHeader.row_CreditChartOfAccounts, _
                              _GLHeader.row_AmountDEV, _GLHeader.row_AmountHUF, _GLHeader.row_LiquidAssets, _
                              _GLHeader.row_Customer, _GLHeader.row_DateVAT, _GLHeader.row_VAT, _
                              _GLHeader.row_NoteRows, _GLHeader.row_UniqueObjects, _GLHeader.row_Controlling, _
                              _GLHeader.row_JobNumberObjects, _GLHeader.row_CostPlace, _GLHeader.row_CostHolder, _
                              _GLHeader.row_ConnectInfo, eGLRowsTypeVAT.eNettoRow, _GUID, _GLMixed.row_TransactionType, eCashType.eNormal, _GLMixed.row_PartnerType)
            _ocur.CommitChanges()
            View.Refresh()
        End If

    End Sub
    Private Sub aFinal_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aFinal_GLMixed.Execute
        GLMixed_Final(e)
        View.Close(False)
    End Sub
    Private Sub aStorno_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aStorno_GLMixed.Execute
        Dim _s_GLMixed As New GLMixed(TryCast(View.ObjectSpace, Xpo.XPObjectSpace).Session)
        Dim _GLMixed As GLMixed
        Dim _GLRows As GLRows
        For Each _GLMixed In e.SelectedObjects
            _s_GLMixed.GLDocumentType = _GLMixed.GLDocumentType
            _s_GLMixed.CustomersFrom = _GLMixed.CustomersFrom
            _s_GLMixed.CurrencyName = _GLMixed.CurrencyName
            _s_GLMixed.CurrencyRate = _GLMixed.CurrencyRate
            _s_GLMixed.DocumentNumber = _GLMixed.DocumentNumber
            _s_GLMixed.RegistryNumber = _GLMixed.RegistryNumber
            _s_GLMixed.DateCreated = _GLMixed.DateCreated
            _s_GLMixed.DateExecution = _GLMixed.DateExecution
            _s_GLMixed.DatePayment = _GLMixed.DatePayment
            _s_GLMixed.NoteHeader = _GLMixed.NoteHeader
            _s_GLMixed.IsEditable = _GLMixed.IsEditable
            _s_GLMixed.IsStorno = _GLMixed.IsStorno
            _GLMixed.IsStorno = True
            _s_GLMixed.IsStorno = True
            _s_GLMixed.IsEditable = False
            For Each _GLRows In _GLMixed.GLRows
                _s_GLMixed.row_DebitChartOfAccounts = _GLRows.DebitChartOfAccounts
                _s_GLMixed.row_CreditChartOfAccounts = _GLRows.CreditChartOfAccounts
                _s_GLMixed.row_AmountHUF = _GLRows.AmountHUF * -1
                _s_GLMixed.row_AmountDEV = _GLRows.AmountDEV * -1
                _s_GLMixed.row_LiquidAssets = _GLRows.LiquidAssets
                _s_GLMixed.row_Customer = _GLRows.Customer
                _s_GLMixed.row_DateVAT = _GLRows.DateVAT
                _s_GLMixed.row_VAT = _GLRows.VAT
                _s_GLMixed.row_NoteRows = _GLRows.NoteRows
                _s_GLMixed.row_UniqueObjects = _GLRows.UniqueObjects
                _s_GLMixed.row_Controlling = _GLRows.Controlling
                _s_GLMixed.row_JobNumberObjects = _GLRows.JobNumberObjects
                _s_GLMixed.row_CostPlace = _GLRows.CostPlace
                _s_GLMixed.row_CostHolder = _GLRows.CostHolder
                _s_GLMixed.row_ConnectInfo = _GLRows.ConnectInfo

                Dim _s_GLRows As GLRows = New GLRows(TryCast(View.ObjectSpace, Xpo.XPObjectSpace).Session)
                _s_GLRows.AddGLRows(_s_GLMixed, _s_GLMixed.row_DebitChartOfAccounts, _s_GLMixed.row_CreditChartOfAccounts, _s_GLMixed.row_AmountDEV, _s_GLMixed.row_AmountHUF, _s_GLMixed.row_LiquidAssets, _s_GLMixed.row_Customer, _s_GLMixed.row_DateVAT, _s_GLMixed.row_VAT, _s_GLMixed.row_NoteRows, _s_GLMixed.row_UniqueObjects, _s_GLMixed.row_Controlling, _s_GLMixed.row_JobNumberObjects, _s_GLMixed.row_CostPlace, _s_GLMixed.row_CostHolder, _s_GLMixed.row_ConnectInfo, Nothing, Nothing)

            Next
            _s_GLMixed.Save()
            TryCast(View.ObjectSpace, Xpo.XPObjectSpace).Session.CommitTransaction()
        Next
    End Sub
    Private Sub aViewPCIDW_RateDiff_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewPCIDW_RateDiff.Execute
        Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _GLRows As GLRows = TryCast(View.SelectedObjects(0), GLRows)

        ViewPDCI.ViewPDCIDetail(_onew, Application, e, _GLRows.GLHeader.CustomersFrom, _
                          _GLRows.Customer, _GLRows.PartnerType, _
                          _GLRows.ConnectInfo)
    End Sub
    Private Sub aViewAttachments_RateDiff_GLRows_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewAttachments_RateDiff_GLRows.Execute
        Dim _GLRows As GLRows = TryCast(View.SelectedObjects(0), GLRows)
        Dim _CustomersFrom As CustomersFrom = _GLRows.GLHeader.CustomersFrom
        Dim _Customers As Customers = _GLRows.Customer
        Dim _DocumentNumber As String = _GLRows.ConnectInfo

        ViewAttachments.ViewAttachments(View.ObjectSpace, Frame, _CustomersFrom, _Customers, _DocumentNumber, "")
    End Sub
    Private Sub aViewRegistry_RateDiff_GLRows_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewRegistry_RateDiff_GLRows.Execute
        Dim _GLRows As GLRows = TryCast(View.SelectedObjects(0), GLRows)
        Dim _CustomersFrom As CustomersFrom = _GLRows.GLHeader.CustomersFrom
        Dim _Customers As Customers = _GLRows.Customer
        Dim _DocumentNumber As String = _GLRows.ConnectInfo

        ViewRegistry.ViewRegistry(View.ObjectSpace, Application, e, _CustomersFrom, _Customers, _DocumentNumber)
    End Sub
    Private Sub aCloneGLMixed_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aCloneGLMixed.Execute
        Try
            Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace
            Dim _GLMixed_Base As GLMixed = TryCast(View.SelectedObjects(0), GLMixed)

            If _GLMixed_Base Is Nothing Then Throw New Exception("*Nincs kiválasztott elem!")

            Dim _GLMixed_New As GLMixed = _ocur.CreateObject(Of GLMixed)()

            _GLMixed_New.GLDocumentType = eGLDocumentType.eGLMixed
            '_GLMixed_New.CustomersFrom = _GLMixed_Base.CustomersFrom
            _GLMixed_New.CurrencyName = _GLMixed_Base.CurrencyName
            _GLMixed_New.DateCreated = _GLMixed_Base.DateCreated
            _GLMixed_New.DateExecution = _GLMixed_Base.DateExecution
            _GLMixed_New.DatePayment = _GLMixed_Base.DatePayment
            _GLMixed_New.NoteHeader = _GLMixed_Base.NoteHeader
            _GLMixed_New.IsEditable = True
            _GLMixed_New.IsStorno = False

            If _GLMixed_Base.GLRows.Count > 0 Then
                For Each _GLRows_Base As GLRows In _GLMixed_Base.GLRows
                    Dim _GLRows As GLRows = _ocur.CreateObject(Of GLRows)()

                    _GLRows.GLHeader = _GLMixed_New
                    _GLRows.DebitChartOfAccounts = _GLRows_Base.DebitChartOfAccounts
                    _GLRows.CreditChartOfAccounts = _GLRows_Base.CreditChartOfAccounts
                    _GLRows.AmountHUF = _GLRows_Base.AmountHUF
                    _GLRows.AmountDEV = _GLRows_Base.AmountDEV
                    _GLRows.Customer = _GLRows_Base.Customer
                    _GLRows.NoteRows = _GLRows_Base.NoteRows
                    _GLRows.UniqueObjects = _GLRows_Base.UniqueObjects
                    _GLRows.Controlling = _GLRows_Base.Controlling
                    _GLRows.JobNumberObjects = _GLRows_Base.JobNumberObjects
                    _GLRows.CostPlace = _GLRows_Base.CostPlace
                    _GLRows.CostHolder = _GLRows_Base.CostHolder
                    _GLRows.ConnectInfo = _GLRows_Base.ConnectInfo
                    _GLRows.PartnerType = _GLRows_Base.PartnerType
                    _GLRows.GLRowsGUID = Guid.NewGuid
                    _GLRows.GLRowsTypeVAT = eGLRowsTypeVAT.eNettoRow
                Next
            End If
            Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
            _ocur.CommitChanges()
            e.ShowViewParameters.CreatedView = Application.CreateDetailView(_onew, "GLMixed_DetailView", True, _onew.GetObject(_GLMixed_New))
        Catch exp As Exception
            MsgBox(exp.Message)
        End Try
    End Sub

    Private Sub Delete_Executing(sender As Object, e As CancelEventArgs)
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)

        Dim _GLRows As GLRows
        Dim _GLRows_Original As GLRows

        reconfigure.Clear()
        For Each _GLRows In View.SelectedObjects
            reconfigure.Add(_GLRows)
            _GLRows_Original = _ocur.FindObject(Of GLRows)(CriteriaOperator.Parse("GLRowsRateDiff.Oid=?", _GLRows.Oid))

            If _GLRows_Original IsNot Nothing Then
                _GLRows_Original.GLRowsRateDiff = Nothing
                _GLRows.GLRowsRateDiff = Nothing
            End If
        Next
        e.Cancel = False
    End Sub
    Private Sub Delete_Executed(sender As Object, e As ActionBaseEventArgs)
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _uow As New UnitOfWork(_ocur.Session.DataLayer)
        Dim _GLRows As GLRows
        Dim i As Long
        _ocur.CommitChanges()
        For i = 0 To reconfigure.Count - 1
            _GLRows = reconfigure(i)

            Dim _CustomersFrom_Collection As New XPCollection(Of CustomersFrom)(_ocur.Session)
            Dim _CustomersFrom As CustomersFrom

            For Each _CustomersFrom In _CustomersFrom_Collection
                GLFunctions.ReconfigurePCI(_uow, _CustomersFrom, _GLRows.Customer, _GLRows.PartnerType, _GLRows.ConnectInfo)
            Next
        Next
        _ocur.CommitChanges()
    End Sub

    Private Sub aSetDateGLMixed_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aSetDateGLMixed.Execute
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _GLMixed As GLMixed = TryCast(View.SelectedObjects(0), GLMixed)
        Dim _GLRows As GLRows

        If _GLMixed IsNot Nothing Then
            If _GLMixed.IsEditable = True Then
                For Each _GLRows In _GLMixed.GLRows
                    _GLRows.DateExecution = _GLMixed.DateExecution
                Next
            End If
        End If
    End Sub
End Class