Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to Add New Records in Related BO/Table
Message
From
25/11/2010 11:07:21
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
25/11/2010 08:30:40
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01490394
Message ID:
01490483
Views:
28
>>>>>Hi,
>>>>>
>>>>>using MM.NET 3.6 in an ASP.NET project with C#.
>>>>>
>>>>>I have a Receipt table, with a one to many relationship with a Receipt Details (Line Items) table. For particular types of line items, I need to generate commission records in the commissions table.
>>>>>
>>>>>What's the best way to handle this?
>>>>
>>>>Frank,
>>>>Are you just trying to add records behind the scenes for the commissions? Can't you just instantiate the business object for commissions and add the records you need? I may not be understanding the full context of your question.
>>>>Tim
>>>
>>>Yeah, I had been thinking about this post and thought I had not stated it clearly.
>>>
>>>I see this as being a business object thing, again I go back to having a business object manager that handles the relationships between the multiple business objects which is what I am used to in my VFP framework. So I would like a Receipt BO Manager that would have the Receipt BO as the main BO, ReceiptDetailBO as a child and CommissionsBO as another child. Then, whenever a "ReceiptDetailBO.AddRecord" takes place, a "CommissionBO.AddRecord" will get called if the correct receipt detail type has been added.
>>>
>>>Since I don't think MM has this concept of a BO Manager, I was looking at somehow implementing it as part of the ReceiptDetailBO, but have no idea where to start.
>>>
>>>I guess I can implement this all at the form level pretty easily, but it just doesn't feel right as it is a Business Process thing to my mind.
>>
>>Hi Frank,
>>Your thinking is correct in that it really shouldn't be in the form. I honestly don't see any reason why it can't be in your receipt business object or another class you create in your business object library. There doesn't have to be only the regular business objects in that project you can create other classes that broker activity between business objects.
>>That said, if this is part of the receipt process, then I don't see why the receipt business object cannot have a method such as SaveReceiptWithCommission() and you call this from your form. This method can save the rows of the receipt and also create an instance of the Commission business object to ask that biz obj to save rows of commission type.
>>Tim
>
>Thanks Tim,
>
>I'm struggling to get started with this.
>
>I see this as something that should automatically be done when a DetailReceipt record gets saved. The logic should be something like:
>
>Form's save is called, which calls the ReceiptBO.Save(), which then calls the ReceiptDetail.Save(), now somewhere in that Save I need to check "is this ReceiptDetail a Premium Payment?" If it is, then I need to call the CommissionBO.AddRecord() (or whatever it is called) and update the entity values with the calculated commission, then call the CommissionBO.Save(). Of course, this should all be part of the same update transaction so that if the save at any level is unsuccessful, then the entire save is unsuccessful.
>
>Could you suggest what method I should be overriding to add this code in?

Hi Frank,

I would be happy to give you some good ideas on this when I get back home on Saturday. However if the Receipt information has everything that is needed to be able to create the commission record you could put this in a Hook Pre Save method where it would then call the Commission biz object passing in a copy of the values needed from the receipt entity. That would allow you to use the form save method as you are without overriding any of the actual save methods. If the receipt entity does not contain enough information to generate the commission record, then you may need to override the business objects save method that gets called by the form method. I can look at that closer when I get home if the first method isn't enough.

If in your receipt business object you type override Hook... you should get intellisense letting you know which hook methods are available around the saves. You can put code in the pre or post save but the pre would provide better control over the save and would have the current entity available for information.
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform