DevExpress eXpressApp - 数据库更新

时间:2012-05-16 08:58:17

标签: c# devexpress

我目前正在使用DevExpress的eXpressApp。我想知道如何在触发视频时触发客户表的更新,也可能是租借历史表?我需要在代码中执行此操作吗?或者我可以在调用CommitChanges()时创建可以自动调用的触发器或查询

 public class Rent : VideoRentBaseObject {
        MovieItem item;
        int days;
        DateTime? returnedOn;
        Receipt receipt;
        Receipt receiptOverdue;
        decimal payment;
        decimal overduePayment;

        public Rent(Session session) : base(session) { }
        public Rent(Session session, int selfId)
            : this(session) {
            SelfId = selfId;
        }
        public Rent(Receipt receipt, MovieItem item) : this(receipt, item, 0) { }
        public Rent(Receipt receipt, MovieItem item, int days)
            : this(receipt.Session) {
            if(receipt == null) throw new ArgumentNullException("Receipt");
            if(item == null) throw new ArgumentNullException("Item");
            if(item.Status != MovieItemStatus.Active) throw new ArgumentException("Item is not active");
            Receipt = receipt;
            Item = item;
            if(receipt.Type == ReceiptType.Purchases) {
                Item.Status = MovieItemStatus.Sold;
                Item.AvailableForSell = false;
                Days = 0;
            } else {
                Item.Status = MovieItemStatus.Rented;
                Days = days != 0 ? days : item.Movie.Category.GetPrice(item.Format).DefaultRentDays;
            }
        }
        public override void AfterConstruction() {
            base.AfterConstruction();
            Days = 1;
        }
}

1 个答案:

答案 0 :(得分:0)

你可以覆盖Rent Class的onSaving()方法,你可以放入一些逻辑,在关联的Client对象中进行更改,保存,保存租金变化之前或之后。