Esempio n. 1
0
        private void CloseWorkPackage()
        {
            IEnumerable <AuditRecord> blockedRecords =
                _currentDirective.AuditRecords
                .Where(rec => rec.Task != null &&
                       rec.Task.NextPerformances != null &&
                       rec.Task.NextPerformances.Count > 0 &&
                       rec.Task.NextPerformances.Any(np => np.BlockedByPackage != null &&
                                                     np.BlockedByPackage.ItemId != _currentDirective.ItemId));

            if (_currentDirective.CanClose == false || blockedRecords.Any())
            {
                string message = "This audit can not be closed";
                foreach (AuditRecord blockedRecord in blockedRecords)
                {
                    NextPerformance np = blockedRecord.Task.NextPerformances.First(n => n.BlockedByPackage != null);
                    message += $"\nTask: {blockedRecord.Task} blocked by audit {np.BlockedByPackage}";
                }
                if (_currentDirective.MaxClosingDate < _currentDirective.MinClosingDate)
                {
                    message +=
                        $"\nMin Closing Date: {_currentDirective.MinClosingDate} better than Max Closing Date: {_currentDirective.MaxClosingDate}";
                }
                MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"],
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AuditClosingFormNew form = new AuditClosingFormNew(_currentDirective);

            form.ShowDialog();
            if (form.DialogResult == DialogResult.OK)
            {
                AnimatedThreadWorker.RunWorkerAsync();
            }
        }
Esempio n. 2
0
        private void ToolStripMenuItemCloseClick(object sender, EventArgs e)
        {
            DialogResult dlgResult = DialogResult.No;

            foreach (Audit item in _directivesViewer.SelectedItems)
            {
                if (item.Status == WorkPackageStatus.Closed)
                {
                    MessageBox.Show("Audit " + item.Title + " is already closed.",
                                    (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    continue;
                }

                if (item.AuditItemsLoaded == false)
                {
                    GlobalObjects.AuditCore.GetAuditItemsWithCalculate(item);
                }

                IEnumerable <AuditRecord> blockedRecords =
                    item.AuditRecords
                    .Where(rec => rec.Task != null &&
                           rec.Task.NextPerformances != null &&
                           rec.Task.NextPerformances.Count > 0 &&
                           rec.Task.NextPerformances.Any(np => np.BlockedByPackage != null &&
                                                         np.BlockedByPackage.ItemId != item.ItemId));
                if (item.CanClose == false || blockedRecords.Any())
                {
                    string message = "This Audit can not be closed";
                    foreach (AuditRecord blockedRecord in blockedRecords)
                    {
                        NextPerformance np = blockedRecord.Task.NextPerformances.First(n => n.BlockedByPackage != null);
                        message += $"\nTask: {blockedRecord.Task} blocked by audit {np.BlockedByPackage}";
                    }
                    if (item.MaxClosingDate < item.MinClosingDate)
                    {
                        message +=
                            $"\nMin Closing Date: {item.MinClosingDate} better than Max Closing Date: {item.MaxClosingDate}";
                    }
                    MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"],
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                AuditClosingFormNew form = new AuditClosingFormNew(item);
                form.ShowDialog();
                if (form.DialogResult == DialogResult.OK)
                {
                    dlgResult = DialogResult.OK;
                }
            }

            //Если хотя бы одно окно возвратило DialogResult.OK
            //производится перезагрузка элементов
            if (dlgResult == DialogResult.OK)
            {
                AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoWork;
                AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoFilteringWork;
                AnimatedThreadWorker.DoWork += AnimatedThreadWorkerDoWork;

                AnimatedThreadWorker.RunWorkerAsync();
            }
        }