public void Execute(Document document)
        {
            CommercialDocument commercialDocument = (CommercialDocument)document;

            if (commercialDocument != null)
            {
                bool hasSystemCurrency = commercialDocument.HasSystemCurrency;
                using (ItemCoordinator coordinator = new ItemCoordinator(false, false))
                {
                    List <Item> items = new List <Item>();
                    foreach (CommercialDocumentLine line in commercialDocument.Lines)
                    {
                        Item    item = (Item)coordinator.LoadBusinessObject(BusinessObjectType.Item, line.ItemId);
                        decimal lineInitialNetPrice = commercialDocument.GetValueInSystemCurrency(line.InitialNetPrice);
                        if (item.DefaultPrice != lineInitialNetPrice)
                        {
                            item.DefaultPrice = lineInitialNetPrice;
                            items.Add(item);
                        }
                    }
                    if (items.Count > 0)
                    {
                        coordinator.SaveLargeQuantityOfBusinessObjects <Item>(false, items.ToArray());
                    }
                }
            }
        }
示例#2
0
        private void Expand()
        {
            if (ItemCoordinator == null)
            {
                return;
            }

            bool cancel;

            ItemCoordinator.OnMenuItemExpanding(this, out cancel);

            if (cancel || !HasItems || IsExpanded)
            {
                return;
            }

            if (MenuPositioningStrategy != null)
            {
                MenuPositioningStrategy.BeforeOpenPopup(this, Popup);
            }

            Popup.IsOpen = true;
            UpdateLayout();

            if (MenuPositioningStrategy != null)
            {
                MenuPositioningStrategy.AfterOpenPopup(this, Popup);
            }
        }
示例#3
0
        public static void Initialize(CoordinatorPluginPhase pluginPhase, ItemCoordinator coordinator)
        {
            if (pluginPhase != CoordinatorPluginPhase.SaveObject)
            {
                return;
            }

            coordinator.Plugins.Add(new ItemCodeExistenceCheckPlugin());
        }
示例#4
0
        protected virtual void OnIsHighlightedChanged(bool newValue)
        {
            ChangeVisualState();

            if (ItemCoordinator != null)
            {
                ItemCoordinator.OnMenuItemHighlightingChanged(this);
            }
        }
示例#5
0
        public static void Initialize(CoordinatorPluginPhase pluginPhase, ItemCoordinator coordinator, Item businessObject)
        {
            if (pluginPhase != CoordinatorPluginPhase.SaveObject)
            {
                return;
            }

            if (businessObject != null && !businessObject.IsNew)
            {
                coordinator.Plugins.Add(new ItemEquivalentGroupRemovalPlugin(businessObject));
            }
        }
示例#6
0
        protected override void OnClose()
        {
            if (!IsOpen)
            {
                return;
            }

            Popup.IsOpen = false;
            ItemCoordinator.OnMenuVisibilityChanged();
            Popup.Content = null;

            if (_closed != null)
            {
                _closed(this, EventArgs.Empty);
            }
        }
示例#7
0
        private void Collapse()
        {
            if (ItemCoordinator == null)
            {
                return;
            }

            ItemCoordinator.OnMenuItemCollapsing(this);

            foreach (var item in Items.OfType <IMenuItem>())
            {
                item.IsExpanded = false;
            }

            if (!IsExpanded)
            {
                return;
            }

            Popup.IsOpen = false;
        }
示例#8
0
        public override void OnAfterExecuteOperations(IBusinessObject businessObject)
        {
            if (this.groupId == null)
            {
                return;
            }

            ItemMapper mapper = DependencyContainerManager.Container.Get <ItemMapper>();

            XElement xml = mapper.GetItemEquivalents(this.businessObject.Id.Value, this.groupId.Value);

            if (xml.Elements().Count() == 1)
            {
                Item item = (Item)mapper.LoadBusinessObject(BusinessObjectType.Item, new Guid(xml.Element("item").Attribute("id").Value));

                item.Relations.Remove(item.Relations.Children.Where(r => r.ItemRelationTypeName == ItemRelationTypeName.Item_EquivalentGroup).First());

                using (ItemCoordinator c = new ItemCoordinator(false, false))
                {
                    c.SaveBusinessObject(item);
                }
            }
        }
示例#9
0
        private void Open()
        {
            if (!HasItems || IsOpen)
            {
                return;
            }

            this.IsTabStop = true;

            Popup.Content = this;
            UpdateLayout();

            var strategy = MenuPositioningStrategy;

            if (strategy != null)
            {
                strategy.BeforeOpenPopup(this, Popup);
            }

            Popup.IsOpen = true;
            this.Focus();

            ItemCoordinator.OnMenuVisibilityChanged();

            UpdateLayout();

            if (strategy != null)
            {
                strategy.AfterOpenPopup(this, Popup);
            }

            if (_opened != null)
            {
                _opened(this, EventArgs.Empty);
            }
        }