.NET 學習

.NET 學習生活感想... 万事成蹉跎..... 贵在坚持 及时整理自己做过和学过的东西

博客园 首页 新随笔 联系 订阅 管理

 1.在列表编辑器中

2.在属性编辑器中

3.实现代码如下

代码
using System;
using System.ComponentModel;

using DevExpress.Xpo;
using DevExpress.Data.Filtering;

using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace XSolution1.Module
{
   [DefaultClassOptions]
    
public class Employee : BaseObject
    {
        
public Employee(Session session) : base(session) { }

        
private string _Name;
        
public string Name
        {
            
get
            {
                
return _Name;
            }
            
set
            {
                SetPropertyValue(
"Name"ref _Name, value);
            }
        }

        
private string _Note;
        
public string Note
        {
            
get
            {
                
return _Note;
            }
            
set
            {
                SetPropertyValue(
"Note"ref _Note, value);
            }
        }

        
private Department _Department;
        
public Department Department
        {
            
get
            {
                
return _Department;
            }
            
set
            {
                SetPropertyValue(
"Department"ref _Department, value);
            }
        }
    }

}

 

 

代码
using System;
using System.ComponentModel;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.ExpressApp.Localization;
using DevExpress.Persistent.Base.General;
namespace XSolution1.Module

    [DefaultClassOptions]   
    
public class Department : BaseObject, IHCategory
    { 
        
private string name; 
        
private Department parent; 
        
private void CheckCircularReferences(Department obj) 
        { Department currentObj 
= obj; while (currentObj != null
        {
            
if (currentObj == this) { throw new UserFriendlyException(ExceptionId.CircularReference);
            } currentObj 
= currentObj.Parent; } } 
        
public Department(Session session) : base(session) { } 
        
public Department(Session session, string name) : this(session) { this.name = name; } 
        [Association(
"DepartmentParent-DepartmentChild")]        
        
public XPCollection<Department> Children 
        {
            
get { return GetCollection<Department>("Children"); }
        } 
        [Persistent, Association(
"DepartmentParent-DepartmentChild")]        
        
public Department Parent 
        { 
            
get { return parent; } 
            
set {
                  
if (!IsLoading) 
                  { 
                      CheckCircularReferences(value);
                  }
                parent 
= value; OnChanged("Parent");
            }
        } 
        
public string Name 
        { 
            
get { return name; }
            
set { name = value; OnChanged("Name"); } 
        } 
        IBindingList ITreeNode.Children 
        {
            
get { return Children as IBindingList; }
        } 
        ITreeNode IHCategory.Parent 
        { 
            
get { return Parent as IHCategory; } 
            
set { Parent = value as Department; }
        }
        ITreeNode ITreeNode.Parent 
        { 
            
get { return Parent as ITreeNode; }
        }
    }
}

 

posted on 2010-06-22 17:20  Tonyyang  阅读(1124)  评论(1编辑  收藏  举报
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/