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);
            }
        }
Esempio n. 2
0
        public override void UpdateNode(ModelNode node)
        {
            var Parent = (IModelDetailView)node.Parent;
            var type   = XafTypesInfo.Instance.FindTypeInfo(Parent.ModelClass.Name);

            if (WXafHelper.CheckIfWXafBase(type))
            {
                //var type = Type.GetType(Parent.ModelClass.Name);
                //if (type != null && type is IWXafObject) {
                string          Name       = "UserPanel";
                IModelUserPanel Item       = node.AddNode <IModelUserPanel>(Name);
                var             layoutItem = Parent.Layout.AddNode <IModelLayoutViewItem>(Name + "Layout");
                layoutItem.ShowCaption = false;
                layoutItem.ViewItem    = Item;
            }
            // }
        }