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.Data.Filtering
Imports DevExpress.Persistent.BaseImpl

Public Class OrderInPrint
    Inherits DevExpress.ExpressApp.ViewController
    Public Sub New()
        MyBase.New()
        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)
    End Sub
    Private Sub aOrderInPrint_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aOrderInPrint.Execute
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _ReportData As ReportData
        Dim _OrderInAcknowledgementHeader As OrderInAcknowledgementHeader = TryCast(View.SelectedObjects(0), OrderInAcknowledgementHeader)

        If _OrderInAcknowledgementHeader IsNot Nothing Then
            _ReportData = _OrderInAcknowledgementHeader.OrderInHeader.OrderInParameters.ReportDataAcknowledgement
            If _ReportData IsNot Nothing Then
                _OrderInAcknowledgementHeader.RecalculateOrderInAcknowledgement(_OrderInAcknowledgementHeader, _ocur)
                _ocur.CommitChanges()
                Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, CriteriaOperator.Parse("OrderInAcknowledgementHeader.Oid=?", _OrderInAcknowledgementHeader.Oid), True)
            Else
                '------------TESZT MIATT!!!! -----------------------------
                Throw New Exception("*Nincs nyomtatvány beállítva!")
            End If
        End If
    End Sub
End Class
