DevExpress eXpressApp -- 数据库更新
本文关键字:更新 数据库 eXpressApp DevExpress | 更新日期: 2023-09-27 18:34:14
我目前正在使用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;
}
}
你可以覆盖 Rent 类的方法 onSaving(),你可以在 中放入一些逻辑,在关联的 Client 对象中进行更改,保存它,在保存租金更改之前或之后。