예제 #1
0
파일: OrderForm.cs 프로젝트: hdgardner/ECF
        /// <summary>
        /// Accepts the changes.
        /// </summary>
        public override void AcceptChanges()
        {
            if (_Parent == null)
            {
                throw new NoNullAllowedException("Parent");
            }

            if (_Parent.ObjectState == MetaObjectState.Added)
            {
                throw new MetaException("Must save parent object");
            }

            if (this.ObjectState != MetaObjectState.Deleted)
            {
                this["OrderGroupId"] = _Parent.OrderGroupId;
            }

            using (TransactionScope scope = new TransactionScope())
            {
                base.AcceptChanges();

                if (this.ObjectState != MetaObjectState.Deleted)
                {
                    // Save shipments
                    Shipments.AcceptChanges();

                    // Save payments
                    Payments.AcceptChanges();

                    // Save payments
                    LineItems.AcceptChanges();

                    // Save discounts
                    Discounts.AcceptChanges();
                }

                scope.Complete();
            }
        }