/// <summary>
        /// Clears all articles from the stock model.
        /// </summary>
        public void Clear()
        {
            _articles.Clear();
            _selectedArticle = null;

            UpdateModel();
        }
        /// <summary>
        /// Updates the internal data model.
        /// </summary>
        private void UpdateModel()
        {
            _articleModel.Rows.Clear();
            _packModel.Rows.Clear();

            foreach (var articleCode in _articles.Keys)
            {
                if (string.IsNullOrEmpty(_filter) == false)
                {
                    bool keepArticle = articleCode.Contains(_filter);

                    keepArticle |= !String.IsNullOrEmpty(_articles[articleCode].VirtualId) &&
                                   _articles[articleCode].VirtualId.Contains(_filter);

                    if (!keepArticle)
                    {
                        if ((_selectedArticle != null) &&
                            (_selectedArticle.Id == articleCode))
                        {
                            _selectedArticle = null;
                        }

                        continue;
                    }
                }

                if (_selectedArticle == null)
                {
                    _selectedArticle = _articles[articleCode];
                }

                var article = _articles[articleCode];

                DataRow row = _articleModel.NewRow();
                row[0] = articleCode;
                row[1] = article.Name != null ? article.Name : string.Empty;
                row[2] = article.DosageForm != null ? article.DosageForm : string.Empty;
                row[3] = article.PackagingUnit != null ? article.PackagingUnit : string.Empty;
                row[4] = article.MaxSubItemQuantity;
                row[5] = article.PackCount;
                row[6] = article.VirtualId;
                _articleModel.Rows.Add(row);
            }

            UpdatePackModel();
        }
        /// <summary>
        /// Replaces the internal stock model with the specified article list.
        /// </summary>
        /// <param name="articleList">The article list to use.</param>
        public void Replace(List <IArticle> articleList)
        {
            if (articleList == null)
            {
                throw new ArgumentException(nameof(articleList));
            }

            _articles.Clear();

            foreach (var article in articleList)
            {
                _articles[article.Id] = new StockArticle(article);
            }

            _selectedArticle = (_articles.Count > 0) ? _articles[articleList[0].Id] : null;
            UpdateModel();
        }
 /// <summary>
 /// Selects the article with the specified article code.
 /// </summary>
 /// <param name="articleCode">Code of the article to select.</param>
 public void SelectArticle(string articleCode)
 {
     _selectedArticle = _articles.ContainsKey(articleCode) ? _articles[articleCode] : null;
     UpdatePackModel();
 }
 /// <summary>
 /// Clears the article selection.
 /// </summary>
 public void ClearArticleSelection()
 {
     _selectedArticle = null;
     UpdatePackModel();
 }