XAF 如何给記錄增加版本控制?
2011-03-23 12:27
399 查看
例如给订单增加版本控制
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/
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 DXExample.Module { [DefaultClassOptions] public class PO : BaseObject { public PO(Session session) : base(session) { // This constructor is used when an object is loaded from a persistent storage. // Do not place any code here or place it only when the IsLoading property is false: // if (!IsLoading){ // It is now OK to place your initialization code here. // } // or as an alternative, move your initialization code into the AfterConstruction method. } private string _PONO; public string PONO { get { return _PONO; } set { SetPropertyValue("PONO", ref _PONO, value); if (!IsLoading) {
//如果更改订单号,需重置Version _Version = 0; } } } private int _Version; [Custom("AllowEdit","False")] public int Version { get { return _Version; } set { SetPropertyValue("Version", ref _Version, value); } } private string _Note; public string Note { get { return _Note; } set { SetPropertyValue("Note", ref _Note, value); } } private DateTime _CreateOn = DateTime.Now; [Custom("AllowEdit", "False")] public DateTime CreateOn { get { return _CreateOn; } set { SetPropertyValue("CreateOn", ref _CreateOn, value); } } public override void AfterConstruction() { base.AfterConstruction(); Version = 0; } private int GetPoNoNewVersion() { int ver = 1; ver = Utility.GetNewVersion<PO>(new BinaryOperator("PONO", PONO), Session, "Version", "CreateOn"); return ver; } protected override void OnSaving() { base.OnSaving(); _Version = Version != 0 ? _Version : GetPoNoNewVersion(); } } public static class Utility { /// <summary> /// Get Version /// Tonyyang /// 2011-03-23 /// </summary> /// <typeparam name="T">BO</typeparam> /// <param name="criteriaOperator"></param> /// <param name="session"></param> /// <param name="propertyName"></param> /// <param name="sortPropertyName"></param> /// <returns></returns> public static int GetNewVersion<T>(CriteriaOperator criteriaOperator, Session session, string propertyName, string sortPropertyName) where T : XPCustomObject { int ver = 1; XPCollection<T> xpc = new XPCollection<T>(session) { Criteria = criteriaOperator }; xpc.Sorting.Clear(); xpc.Sorting.Add(new SortProperty(sortPropertyName, DevExpress.Xpo.DB.SortingDirection.Descending)); if (xpc.IsLoaded != true) xpc.Load(); ver = xpc.Count == 0 ? ver : (int)xpc[0].GetMemberValue(propertyName) + 1; return ver; } } }
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/
相关文章推荐
- XAF 如何给記錄增加版本控制?
- XAF 如何给記錄增加版本控制?
- 如何架设你的cvsnt服务器以及其实现在netbeans和eclipse中的版本控制
- 如何使用SSDT进行SQL数据库的自动化部署到生产环境和版本控制
- git如何移除某文件夹的版本控制
- 如何在Eclipse中过滤版本控制文件
- SVN的使用方法总结/如何使用TortoiseSVN工具进行版本控制
- Linux如何解决动态库的版本控制
- 如何增加之后每 VisualC++ 中生成版本信息
- 市内移出版本2.0(1、一页显示15条。2、增加控制标志。3、打印表格时绑定的list的优化。4、保存迁出登记信息时根据业务流水号判断增加还是修改。5、统一管理常量)
- Android studio如何使用SVN进行版本控制?
- 如何在VS中使用SourceAnywhere进行版本控制
- [版本控制]svn如何取消认证缓存设置?
- 探讨如何在Eclipse中过滤版本控制文件.svn
- [心得] 如何利用liquibase進行資料庫版本控制 - 實際練習
- 如何使用Bitbucket进行版本控制
- 关于CVS、SVN版本控制及Eclipse中如何使用CVS、SVN
- Android Studio中关联SVN进行版本控制(三)如何更改文件名
- Linux如何解决动态库的版本控制
- Eclipse + CVS 之 如何将文件加入版本控制和脱离版本控制