示例#1
0
        private void EnsureAllArticlesExists(IEnumerable<TransferItemLine> lines, ArticleManager articleManager)
        {
            foreach (var line in lines)
            {
                if (string.IsNullOrWhiteSpace(line.ArticleNo) || articleManager.ArticleExists(line.ArticleNo))
                    continue;

                _attemptsToCreateArticle++;

                if (!articleManager.CreateArticle(line.ArticleNo, line.ArticleName, _priceCalcMethodsNo, _postingTemplate, _stockProfileNo))
                {
                    _failedAttemptsToCreateArticle++;
                    lstLog.Items.Add(string.Format("Kunne ikke opprette artikkel '{0} - {1}'", line.ArticleNo, line.ArticleName));
                }
            }
        }
示例#2
0
        private void btnTransferArticlesToDestination_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            btnTransferArticlesToDestination.Enabled = false;

            var articleManager = new ArticleManager(VgConnections.DestinationConnection);
            _attemptsToCreateArticle = 0;
            _failedAttemptsToCreateArticle = 0;

            foreach (var item in _transferItems)
            {
                EnsureAllArticlesExists(item.Lines, articleManager);
            }

            lstLog.Items.Add(string.Format("{0} av {1} artikler opprettet", (_attemptsToCreateArticle - _failedAttemptsToCreateArticle), _attemptsToCreateArticle));

            btnCreateCustomerOrders.Enabled = _failedAttemptsToCreateArticle == 0;
            Cursor = Cursors.Default;
        }