ChildForm with child BO and Broken Rules....
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



ChildForm with child BO and Broken Rules....Expand / Collapse
Author
Message
Posted 05/01/2008 8:46:05 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 1:52:08 PM
Posts: 400, Visits: 1,618
Hi,

I have a ListView which calls a ChildForm with a child BO which I would like to control the saving and broken rules on the childform.  I have the following code in the Save button of my ChildForm:

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click

     If Me.PolicyBO1.Save() = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

          Me.DialogResult = Windows.Forms.DialogResult.OK

     Else

          Me.PolicyBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)

          Me.DialogResult = Windows.Forms.DialogResult.Cancel

     End If

End Sub

The problem is that the broken rules are not shown in the form and the form is released, but in the parent form the childbo state is Editing.

How can I accomplish having control on the ChildForm to Save/Undo the data and when returning to the Parent Form not worrying about the childBO state?

Edhy Rijo
Progytech (Computer Consultants)
Post #16065
Posted 05/01/2008 9:35:36 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:54:01 AM
Posts: 4,104, Visits: 4,177
You are generally always better of only saving records from a single location...for example, the parent form.  But in any case, you could do this to check the rules:

If MyBo.CheckRules(True) Then
    DialogResult = OK
End If

Then on the Parent form you will look to see what the results of the Dialog were and take appropriate action.  If you are using the ListView then handle the ChildFormResults event, but if you are calling the ChildFormDialog directly, the logic would be the same, but just be wrapped around the ShowDialog.

If MyChildDialog.ShowDialog() = OK Then
    '-- Reload the list view, for example
    lstMyList.Requery()
Else
    '-- Undo the changes
    MyChildBo.Undo(CurrentRowOnly)
End If

It would look something like that.

Post #16066
Posted 05/01/2008 10:30:07 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 1:52:08 PM
Posts: 400, Visits: 1,618
Trent L. Taylor (05/01/2008)
You are generally always better of only saving records from a single location...for example, the parent form.

In this case, the Parent form will manage 1 child BO and this will manage another child BO and this another one. That is the reason I prefer to manage the save in each ChildForm.

I tried MyBo.CheckRules(True) and it worked but it did not show the Infobox, then I found another message in the forum suggesting to use the form's Save() http://forum.strataframe.net/Topic6212-6-1.aspx so I endup with the code below which so far give me the functionality I want when calling the ChildForm via the new enhanced ListView:

If Me.Save() <> MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

     Exit Sub

ElseIf Me.Save() = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

     Me.DialogResult = Windows.Forms.DialogResult.OK

Else

     Me.PolicyBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)

     Me.DialogResult = Windows.Forms.DialogResult.Cancel

End If

Thanks for your recommendations!

Edhy Rijo
Progytech (Computer Consultants)
Post #16067
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 7:02pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.