protected override void OnSavingRecord() { base.OnSavingRecord(); if (Session.IsNewObject(this)) { Item.UpdateQuantityOnHand(RecordType, Shop, TransactionUnit, Quantity); return; } double quantityOldValue = 0; Unit unitOldValue = null; if (WXafHelper.IsProrpotyChanged(ClassInfo, this, nameof(Quantity)) && WXafHelper.IsProrpotyChanged(ClassInfo, this, nameof(TransactionUnit))) { quantityOldValue = Convert.ToDouble(WXafHelper.GetOldValue(ClassInfo, this, nameof(Quantity))); unitOldValue = (Unit)WXafHelper.GetOldValue(ClassInfo, this, nameof(TransactionUnit)); Item.UpdateQuantityOnHand(NotRecordType, Shop, unitOldValue, quantityOldValue); Item.UpdateQuantityOnHand(RecordType, Shop, TransactionUnit, Quantity); } else if (WXafHelper.IsProrpotyChanged(ClassInfo, this, nameof(TransactionUnit))) { unitOldValue = (Unit)WXafHelper.GetOldValue(ClassInfo, this, nameof(TransactionUnit)); Item.UpdateQuantityOnHand(NotRecordType, Shop, unitOldValue, Quantity); Item.UpdateQuantityOnHand(RecordType, Shop, TransactionUnit, Quantity); } else if (WXafHelper.IsProrpotyChanged(ClassInfo, this, nameof(Quantity))) { quantityOldValue = Convert.ToDouble(WXafHelper.GetOldValue(ClassInfo, this, nameof(Quantity))); Item.UpdateQuantityOnHand(NotRecordType, Shop, TransactionUnit, quantityOldValue); Item.UpdateQuantityOnHand(RecordType, Shop, TransactionUnit, Quantity); } }