/// <summary>
        /// Called as we try an exit from this form - we need to ensure that the category name is unique
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnOK_Click(object sender, EventArgs e)
        {
            // Update the asset type definition with any changes
            _category.Name = tbCategoryName.Text;
            _category.Icon = tbIconFile.Text;

            // Ensure that this Category does not duplicate an existing one
            UserDataCategoryList listCategories = new UserDataCategoryList(_category.Scope);

            listCategories.Populate();
            UserDataCategory existingCategory = listCategories.FindCategory(_category.Name);

            if ((existingCategory != null) && (existingCategory.CategoryID != _category.CategoryID))
            {
                MessageBox.Show("A User Defined Data Category with this name already exists, please enter a unique name for this category", "Category Exists");
                DialogResult = DialogResult.None;
                return;
            }

            if (!_editing)
            {
                _category.TabOrder = new UserDataDefinitionsDAO().GetCountUserDataCategories(UserDataCategory.SCOPE.Asset);
            }

            // ...Update or add the category
            _category.Add();
        }
        /// <summary>
        /// Add a user defined data field and its value.
        ///
        /// First locate the specified asset (or create a new one if this does not exist)
        /// Locate the user defined data field (or create a new one if this does not exist)
        /// Set the value for the field given its ID and asset
        ///
        /// </summary>
        /// <param name="lvi"></param>
        private void AddUserDataField(UltraListViewItem lvi)
        {
            AssetDAO lwDataAccess = new AssetDAO();

            // Recover the data fields
            string assetName = lvi.Text;
            string category  = lvi.SubItems[2].Text;

            if (category == "Asset Data")
            {
                category = "General";
            }
            string fieldName  = lvi.SubItems[0].Text;
            string fieldValue = lvi.SubItems[1].Text;

            // Does the Asset exist?
            // Note that as we only have an asset name we can only possibly match on that
            int assetID = lwDataAccess.AssetFind(assetName);

            // If the asset exists then add the history record for it
            if (assetID != 0)
            {
                // Does the User Data Category exist?  If not create it also
                UserDataCategory parentCategory = _listCategories.FindCategory(category);
                if (parentCategory == null)
                {
                    parentCategory      = new UserDataCategory(UserDataCategory.SCOPE.Asset);
                    parentCategory.Name = category;
                    parentCategory.Add();
                    _listCategories.Add(parentCategory);
                }


                // Now look at the User Data Field and see if we have one already with this name
                UserDataField thisField = parentCategory.FindField(fieldName);
                if (thisField == null)
                {
                    // No existing field of this name in the General Category so add it
                    thisField          = new UserDataField();
                    thisField.ParentID = parentCategory.CategoryID;
                    thisField.Name     = fieldName;
                    thisField.Add();
                    parentCategory.Add(thisField);
                }

                // ...and set the value for the asset both here and in the database
                thisField.SetValueFor(assetID, fieldValue, true);
            }
        }