Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.ExpressApp.SystemModule
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.Data.Filtering

Public Class SetDefaultCountryHungaryVC
    Inherits DevExpress.ExpressApp.ViewController

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)
        TargetObjectType = GetType(Address)

    End Sub
    Protected Overrides Sub OnActivated()
        MyBase.OnActivated()
        If View.Id = "Address_DetailView" Then
            Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
            Dim _Address As Address = TryCast(View.SelectedObjects(0), Address)
            Dim _Country As Country = _ocur.FindObject(Of Country)(CriteriaOperator.Parse("Name='Magyarország'"))
            If _ocur.Session.IsNewObject(_Address) Then _Address.Country = _Country
        End If
    End Sub
End Class
