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.ExpressApp.Utils
Imports DevExpress.Persistent.BaseImpl

Public Class StorageTransactionsOutPrint
    Inherits DevExpress.ExpressApp.ViewController
    Public Sub New()
        MyBase.New()
        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)
    End Sub
    Private Sub aStorageTransactionsOutPrint_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aStorageTransactionsOutPrint.Execute
        Dim _ReportData As ReportData
        Dim _StorageOutHeader As StorageOutHeader
        If e.SelectedObjects.Count > 0 Then
            _StorageOutHeader = TryCast(e.SelectedObjects.Item(0), StorageOutHeader)
            If _StorageOutHeader Is Nothing Then
            Else
                _ReportData = _StorageOutHeader.Storage.ReportOut
                If _ReportData Is Nothing Or _StorageOutHeader Is Nothing Then
                Else
                    Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, CriteriaOperator.Parse("StorageOutRows.StorageOutHeader.DocumentNumber =?", _StorageOutHeader.DocumentNumber), True)
                End If
            End If
        End If
    End Sub
    Private Sub aStorageOutRowsInRowsPrint_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aStorageOutRowsInRowsPrint.Execute
        Try
            If View.SelectedObjects.Count = 0 Then Throw New Exception("*Nincs kiválasztva egyetlen sor sem!")
            Dim _StorageOutHeader As StorageOutHeader = TryCast(View.SelectedObjects(0), StorageOutRowsInRows).StorageOutRows.StorageOutHeader
            If _StorageOutHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt a folyamat megszakadt!")
            Dim _ReportData As ReportData = _StorageOutHeader.Storage.ReportOut
            If _ReportData Is Nothing Then Throw New Exception("*Nincs beállítva nyomtatvány!")

            Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, CriteriaOperator.Parse("StorageOutRows.StorageOutHeader.DocumentNumber =?", _StorageOutHeader.DocumentNumber), True)

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
        End Try
    End Sub
End Class
