.net layered design: return error code to forms indicating which controls have an error
- by David Casillas
Let's say I have a simple application. It tries to add a new entry to a database grabing the info from the user. The information is a tipical MasterDetail objetc like an invoice.
The Invoice object used to collect the data has some simple atributes (Id, Date, etc...) and a List of InvoiceDetail, consisting of some simple atributes (invoiceId, productId, quantity, etc...)
A form in the UI Layer collects the data from the user, creates an instance of Invoice and sends it to the Bussiness Layer.
The Bussines layer sends the data to a Validation Module. If any error in the input is detected it has to return some kind of error code.
The Bussiness Layer has to send the error code back to the Form to let the user correct the worng information.
I want the application to display some kind of warning (a different background color for example) in every form control with an error.
¿What's a good aproach to I manage the errors to be able to inform the form which controls are wrong?
¿Can I create an error object?¿Use delegates?.
I'm using VB.net but don't think this is relevant to the solution of the problem.
P.D: Please suggest me some tags to this post.