我目前正在使用 DevExpress 的 eXpressApp。我想知道如何在租用视频时触发客户表的更新,以及可能是一个rentalHistory 表?我需要用代码来做吗?或者我可以创建触发器或查询,当调用 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;
}
}