void UpdateDocuments() { int docId = this.CurrentDocumentId; Document.UpdateDocuments(this.dtDocumentsUpdated); bool newDoc, urgent; if (AreDocumentsChanged(out newDoc, out urgent)) { bool initialLoad = this.dtDocuments == null; if (initialLoad) { dtDocuments = DataTableUtils.Clone(dtDocumentsUpdated); Sort(this.tbbSortByDate); } else { DataTableUtils.CopyRows(dtDocumentsUpdated, dtDocuments); } dataGrid.DataSource = this.dtDocuments; CurrentDocumentId = docId; DataGridUtils.SelectCurRow(dataGrid); UpdateInfo(); UpdateControls(); if (!initialLoad) { if (urgent) { Utils.MessageBoxExcl("Urgent request received."); // Microsoft.VisualBasic.Interaction.Beep(); } else if (newDoc) { Utils.MessageBoxExcl("New request received."); } if (App.ScanHandler != null) { DocumentForm form = App.ScanHandler as DocumentForm; if (form != null) { DocumentState docStateId = (DocumentState)form.Document.DocumentStateId; if (docStateId == DocumentState.Discarded || docStateId == DocumentState.Removed) { int openedDocId = form.Document.DocumentId; bool hasOpenedDoc = false; foreach (DataRow dr in dtDocuments.Rows) { Document doc = new Document(dr); if (doc.DocumentId == openedDocId) { hasOpenedDoc = true; break; } } if (!hasOpenedDoc) { Utils.MessageBoxExcl("Request canceled. Please close the form."); form.Discard(); } } } } } } }