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 StorageTransactionsInPrint
    Inherits DevExpress.ExpressApp.ViewController
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        RegisterActions(components)
    End Sub
    Private Sub aStorageTransactionsInPrint_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aStorageTransactionsInPrint.Execute
        Dim _ReportData As ReportData
        Dim _StorageInHeader As StorageInHeader
        If e.SelectedObjects.Count > 0 Then
            _StorageInHeader = TryCast(e.SelectedObjects.Item(0), StorageInHeader)
            If _StorageInHeader Is Nothing Then
            Else
                _ReportData = _StorageInHeader.Storage.ReportIn
                If _ReportData Is Nothing Or _StorageInHeader Is Nothing Then
                Else
                    Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, CriteriaOperator.Parse("DocumentNumber =?", _StorageInHeader.DocumentNumber), True)
                End If
            End If
        End If
    End Sub

    Private Sub aStorageInPrint_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aStorageInPrint.Execute
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)

        Dim _ReportData As ReportData = _ocur.FindObject(Of ReportData)(CriteriaOperator.Parse("Oid=?", _StorageInHeader.Storage.ReportIn.Oid), True)
        If _ReportData Is Nothing Or _StorageInHeader Is Nothing Then
        Else
            Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, CriteriaOperator.Parse("StorageInHeader.DocumentNumber =?", _StorageInHeader.DocumentNumber), True)
        End If
    End Sub
End Class
