Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two bool checkboxes in the UI. At least one user is assigned to any of the fields. So when deleting the user, it has to check at least one user is checked with that fields or not.

Note: It's not mandatory that only single user is assigned to both check box fields. But for a checkbox, at least one user should be assigned.

If at least 1 user is available for that checkbox field, then we can give permission to delete the other user who is having the same fields.

Look at below code what I have tried:
1) When deleting the 2nd user having assigned with that field it gives me this message which is not correct validation. Because already 1 user is there, so we can delete the 2nd user.
2) If I write like countOfContractors < 1 and imagine only 1 user is having assigned with both fields, if I delete that user, 1<1 is false so it will be deleted. but it should not be deleted when 1 = 1.

What I have tried:

If (countOfcontractors<= 1) Then
                confirmationMessage.Text = "At least one other user in the system must be made a Contractor before deactivating this user as a Contractor."
                Exit Sub
            End If
Posted
Updated 13-Jun-21 19:12pm
Comments
[no name] 10-Jun-21 14:04pm    
It appears that the problem is with how you "calculate" the value of countOfcontractors. And we can't see how you did ... you just assume it has some particular value.

1 solution

VB
What with (countOfcontractors > 1)

Also if the user has permision to delete others why not simply block deleting himself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900