Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to deal with error on update?
Message
From
16/03/2010 10:45:32
 
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01454304
Message ID:
01454785
Views:
44
As always, I'm glad to help, Dmitry.

~~Bonnie



>Thank you, Bonnie. This is very helpful. My question about 'base class' was because in VFP there were a bunch of discussions regarding which base class to use for BIZ (custom, form, etc.). Then I Googled on WinForms Business class a bunch of links came up on how to business class to the controls. And I don't think it is applicable in my case since I have a dataset that I bind to controls. And no, I won't name my class BaseBiz; how about I name it BasicBiz (just kidding). Thank you, again.
>
>>>In your case 1) what is typically the base class for Biz class? And do you instantiate this Biz class in the constructor of the UI form? Thank you.
>>
>>Just start with a base Biz class based on nothing. It's just a class. You can add common methods to it as you see fit, but to begin with it doesn't have to be anything in it at all, or at least nothing fancy. Then make a sub-class to be used for whatever "functionality" you are currently work with. So, stuff like CustomerBiz or PersonnelBiz, whatever ... these would be sub-classed from your BaseBiz (I'm just throwing out class names off the top of my head, make them conform to your own naming conventions. I would never actually name a class BaseBiz <g>).
>>
>>How to instantiate in your form's constructor? Just like any other class, it's no different:
>>
>>// in declarations
>>CustomerBiz oBiz;
>>
>>// in constructor
>>this.oBiz = new CustomerBiz();
>>
>>~~Bonnie
>>
>>
>>
>>
>>
>>>
>>>>There are many, many, many ways to handle business rules and validation of those rules. Here are two simplified suggestions, based on what you said you wanted to do:
>>>>
>>>>1) You could have a business class in between your UI and your DAL. So when your UI calls a Save method, it calls it on the Biz class, not the DataAccess class. The Biz Save() method will check that the appropriate required fields contain data and pass back the error if not. If everything properly validates, then the Biz class passes the Save call on to the DataAccess class's Save method.
>>>>
>>>>2) You could skip the Biz layer for now and write a partial class for your DataSet. In that partial class you could have a method called CheckRules() or something similar that will do your validation.
>>>>
>>>>There are lots of more complicated scenarios, but these two suggestions are relatively simple and should get you started.
>>>>
>>>>~~Bonnie
>>>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform