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

Public Class CRMEstate_OpportunityVC
    Inherits DevExpress.ExpressApp.ViewController

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        RegisterActions(components)
    End Sub
    Private Sub aPrintContractTemplate_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aPrintContractTemplate.Execute
        Try
            Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
            Dim _CRMEstate_Opportunity As CRMEstate_Opportunity = TryCast(View.SelectedObjects(0), CRMEstate_Opportunity)
            Dim _e As CRMEstate_Opportunity_Immovables = _CRMEstate_Opportunity.CRMEstate_Opportunity_Immovables(0)
            Dim _InOperator As InOperator
            Dim _OidArray As New ArrayList

            Dim _ImmovablesGroupsParameters As ImmovablesGroupsParameters = _ocur.FindObject(Of ImmovablesGroupsParameters)(CriteriaOperator.Parse("ImmovablesGroups=?", _
                                                                                            _CRMEstate_Opportunity.CRMEstate_Leads.ImmovablesPriceListHeader.ImmovablesGroups))
            If _ImmovablesGroupsParameters Is Nothing Then Throw New Exception("*Nincs beállítva ingatlancsoport paraméter!")

            For Each _CRMEstate_Opportunity_Immovables In _CRMEstate_Opportunity.CRMEstate_Opportunity_Immovables
                _OidArray.Add(_CRMEstate_Opportunity_Immovables.Oid)
            Next

            _InOperator = New InOperator("Oid", _OidArray)

            If _ImmovablesGroupsParameters.ReportData_Contract_Temp Is Nothing Then Throw New Exception("*Nincs beállítva nyomtatvány!")
            Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ImmovablesGroupsParameters.ReportData_Contract_Temp, _InOperator, 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
