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.
This commit is contained in:
John Jenko 2015-07-30 17:13:08 +00:00
parent 28a3a99c50
commit 0e255bc3d8
2 changed files with 18 additions and 3 deletions

View File

@ -349,7 +349,13 @@ namespace ROEditor
private System.Windows.Forms.MenuItem menuEditDelete; private System.Windows.Forms.MenuItem menuEditDelete;
private System.Windows.Forms.MenuItem menuEditSelAll; private System.Windows.Forms.MenuItem menuEditSelAll;
private TreeNode LastSelectedNode; 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 VlnXmlElement rootXml;
private TreeNode rootNode; private TreeNode rootNode;
@ -448,7 +454,14 @@ namespace ROEditor
// read in this element from the table. // read in this element from the table.
VlnXmlElement spro; VlnXmlElement spro;
spro = myrodb.RODB_ReadRO(tbname, recid); 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; VlnXmlElement parent;
string parentid; string parentid;
parentid = spro.GetAttribute("ParentID"); parentid = spro.GetAttribute("ParentID");

View File

@ -1666,7 +1666,9 @@ namespace RODBInterface
DBE.ReaderClose(); DBE.ReaderClose();
// if this is a group, see if children. // 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 "; string strGetSubCount = "SELECT COUNT (RecID) as cnt FROM " + tbl + " WHERE ";
strGetSubCount = strGetSubCount + "ParentID='" + recid + "'"; strGetSubCount = strGetSubCount + "ParentID='" + recid + "'";