private void DeleteCategory() { AssetType activeAssetType = _activeItem.Tag as AssetType; AssetTypeList listSubCategories = _listAssetTypes.EnumerateChildren(activeAssetType.AssetTypeID); if (listSubCategories.Count == 0) { if (MessageBox.Show("Are you sure that you want to delete this Asset Category?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } } else { if (MessageBox.Show("Are you sure that you want to delete this Asset Category? Deleting the category will also delete all child asset types.", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } } // Delete this asset type and any sub-types if (activeAssetType.Delete() != 0) { MessageBox.Show("Failed to delete the selected Category - there may still be references to one of the child asset types which must be removed before the category may be deleted", "Delete Failed"); } _activeItem = null; // We should still refresh as we have partially deleted the category RefreshTab(); }
private void DeleteType() { // Get the currently selected asset type in the list view (if any) if (this.ulvAssetTypes.SelectedItems.Count == 0) { return; } AssetType subType = this.ulvAssetTypes.SelectedItems[0].Tag as AssetType; if (MessageBox.Show("Are you sure that you want to delete this Asset Type?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } // Delete this asset type if (subType.Delete() != 0) { MessageBox.Show("Failed to delete the selected Asset Type - there may still be references to this asset type which must be removed before this type can be deleted", "Delete Failed"); } // We should still refresh as we have partially deleted the category RefreshTab(); }