From 0e255bc3d853239e5d467b0b6c95e169084f4475 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 30 Jul 2015 17:13:08 +0000 Subject: [PATCH] Added a message box to notify the user when an RO cannot be found. This is used when you do a Go To RO in PROMS. Added a NULL reference check. --- .../Exe/RefObj/ROEditor/ROEditor.cs | 17 +++++++++++++++-- .../LibSource/RODBInterface/RODBInterface.cs | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs index 8c3d6d18..8bc2bc5f 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs @@ -349,7 +349,13 @@ namespace ROEditor private System.Windows.Forms.MenuItem menuEditDelete; private System.Windows.Forms.MenuItem menuEditSelAll; private TreeNode LastSelectedNode; - private TextBox CurrentTextBox; // currently selected TextBox field + private TextBox _CurrentTextBox; // currently selected TextBox field + + public TextBox CurrentTextBox + { + get { return _CurrentTextBox; } + set { _CurrentTextBox = value; } + } private VlnXmlElement rootXml; private TreeNode rootNode; @@ -448,7 +454,14 @@ namespace ROEditor // read in this element from the table. VlnXmlElement spro; spro = myrodb.RODB_ReadRO(tbname, recid); - + // RODB_ReadRO will return a NULL if the RO cannot be found + // Pop up a message box to notify the user. + // This will leave the RO Editor open. The user can continue to work or just close it. + if (spro == null) + { + MessageBox.Show("Could not find this RO", "RO Not Found", MessageBoxButtons.OK); + return; + } VlnXmlElement parent; string parentid; parentid = spro.GetAttribute("ParentID"); diff --git a/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs b/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs index 2a630a73..9c7dc452 100644 --- a/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs +++ b/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs @@ -1666,7 +1666,9 @@ namespace RODBInterface DBE.ReaderClose(); // if this is a group, see if children. - if (retele.Name == "vlnGroup") + // if the DBE.Read() cannot find the RO, then retele remains a NULL + // the null check was added to prevent a null reference error + if (retele != null && retele.Name == "vlnGroup") { string strGetSubCount = "SELECT COUNT (RecID) as cnt FROM " + tbl + " WHERE "; strGetSubCount = strGetSubCount + "ParentID='" + recid + "'";