Good Afternoon,
I have searched other questions for an answer this this, but although there are some that are similar there doesn't seem to be one that helps me with what I'm trying to do.
I have a C# Windows Form application. One of the forms is to show the customer's addresses. The form has a CheckBox which highlights whether the address is the customer's Main Address or not - this tickbox writes a 1 or 0 back to the database in a column called main_address - the form is pictured below.
As you will see the form has a BindingNavigator to allow a user to look through the addresses listed for the selected customer (the form is passed the customer ID from the parent form which is used as a filter in the bindingnavigator datasource).
Here's a couple of scenarios:
- A user logs into the system to make a change to a customer's address and unticks the "Main Address" checkbox and clicks save, resulting in no addresses being logged as the main address for the selected customer.
- A user logs into the system to add another address to a customer and ticks the "Main Address" checkbox and clicks save, resulting in two addresses set as the Main Address for the selected customer.
When saving, I need the form to do the following:
- Error if there are no addresses set as the Main Address.
- Error if there are multiple addresses set as the Main Address.
Or put simply - There must always be 1 and only 1 address ticked as the Main Address.
Has anyone ever managed to do anything like this?
Many thanks in advance.
Aucun commentaire:
Enregistrer un commentaire