/// <summary> /// Called as we try an exit from this form - we need to ensure that the asset type 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 _assetType.Name = tbName.Text.Trim(); _assetType.Icon = tbIconFile.Text; // AssetTypeList listAssetTypes = new AssetTypeList(); listAssetTypes.Populate(); // Does this name duplicate an existing item? AssetType existingAsset = listAssetTypes.FindByNameAndParentID(_assetType); if (existingAsset != null) { if ((_assetType.AssetTypeID != existingAsset.AssetTypeID) && (_assetType.ParentID == existingAsset.ParentID)) { MessageBox.Show("An Asset Type of this name has already been created, please enter a different name for this type"); tbName.Focus(); this.DialogResult = DialogResult.None; return; } } // OK the name is fine so either create a new asset type or update an existing one _assetType.Add(); }