Parent Form - Child Form - Second Child Form


Author
Message
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Forgot the pictures but here they are..
Attachments
ScreenShot001.gif (133 views, 16.00 KB)
ScreenShot002.gif (130 views, 14.00 KB)
ScreenShot003.gif (119 views, 17.00 KB)
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Alright I retooled my Parent-Child project to 2 forms a parent that shows the parent records and the child records if a parent is selected. Look at screenshot1 where no parents are selected and screenshot2 to see when a parent is selected.

Now the parent form seems to work as it should. Then when I double click a child record or the edit button on the toolbar I get the correct data on the child form using a childformdialog. See screenshot3.

Charles on one of your replies you asked "How are you getting the child records?" This is how I am doing it. I don't know if it is correct but it works.





Private Sub lvChild_BeforeChildFormExecuted(ByVal sender As System.Object, ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.ListViewBeforeChildExecuteEventArgs) Handles lvChild.BeforeChildFormExecuted



BbPointsBO1.FillByPrimaryKey(lvChild.SelectedItems(0).Tag)



End Sub





So if what I have is correct, why on the Child Form can I not edit the fields? I set the ManageUIReadOnlyState on the childBO to false but that did not help.



Op's I think I found the correct One IgnoreManageReadOnlyState on the textbox and combobox themselves. Also, the Save and Cancel buttons on the child form also work. So I guess my only question is, Am I getting my child data correctly before going to the child form?????



Thanks so much for all of your help. I feel like I have come a 1000 miles this week end in terms of what I have learned and now I need to step back and see if I can reproduce what I have done........

YEE HA!!!!!!
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
You also might consider doing the save in the childform like so





Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

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

Me.DialogResult = Windows.Forms.DialogResult.Cancel

End Sub



Private Sub btn_Save(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

Me.ContactResultsBO1.Save()

Me.DialogResult = Windows.Forms.DialogResult.OK

End Sub





and then in the form with the listview





Private Sub lvContactResults_ChildFormResults(ByVal sender As Object, ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.ListViewChildFormResultsEventArgs) _

Handles lvContactResults.ChildFormResults



' Reads the return value from the ContactResults form and if the ADD has not been cancelled, requeries the

' listview to display the new record



If e.Results = Windows.Forms.DialogResult.OK Then

e.Requery = True

End If



End Sub







This way you are doing your save and cancels in the BO on the childform so you don't have to depend on the translation back to the calling form and you can handle the refreshing of the listview in the calling form itself ( and then you don't need the code you posted )





Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Just looked at your screenshot again and I think I get it now. You have an lv of parents and from there you need to launch a form that has the lv of children. Ok.



But remember the second form is a parent individual record form. you need to translate the parentBO to the second form ( which should probably have the parent detail fields on it as well ) then you still have a situation where you need to somehow fill the appropriate child records into the child bO and then requery the lvchild (remember it has its own datastore that is filled from the bo )



Lay out in detail how you are doing all that and I'm sure we can get you through it. I really sympathize as I found all this part very mystical at one time.

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
So this is just parent child?



So, on the parentform you have parent data and an lv of children, correct?



It sounds like you have three forms, but for just parent child you only need two - one for the parent , which also contains a list of children, and one for the single child record ( the childform)



It sounds like you have three, the second containing the lv for the list of children. That is unnecessary and kind of complicates the issue. May I suggest first you try to get it working just putting the lvchild on the parent form and getting that working.



With just parent child you should not need to override the onload the way I was showing you.



Then on the parent you need a childformdialog pointing to the childform ( the single child for adding or editing )



Throw up some full screen shots of your three forms if you can.







How are you getting the child records?



Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
OK I think it was putting the OnLoad Override in the middle form that made it work. Now I can see the info that I want to edit on the last form.

But, now when I click the Save Button the Changed Data does not get saved. I have the following code on the middle form and the parent form.



If e.Results = Windows.Forms.DialogResult.Cancel Then

' Cancel - Edit

'MessageBox.Show("Canceled - Edit")

BbPointsBO1.Undo(BusinessUndoType.AllRows)

ListView1.Requery()

ListView1.Focus()

Else

' OK - Save Results

BbPointsBO1.Save()

ListView1.Requery()

ListView1.Focus()

End If





Again I want to thank you for your help to get me this far.

TiA.

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Sorry I forgot to attach the screens.



Actually all I have is a Parent - Child that is one-to-many. I have the parent form with a lv on it (screencapture013) and when I double click one of the records I get the First child form with a lv on it (screencapture014) that represents the many side of the ChildBO. Now I want to double click on one of these records and I want to be able to edit it's information (screencapture015). But maybe what you recommended is what I still need to do. I will try to follow what you gave me and see if I can get it too work. Thank you for your help.

Attachments
ScreenShot013.gif (153 views, 15.00 KB)
ScreenShot014.gif (136 views, 7.00 KB)
ScreenShot015.gif (128 views, 8.00 KB)
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Actually all I have is a Parent - Child that is one-to-many. I have the parent form with a lv on it (screencapture013) and when I double click one of the records I get the First child form with a lv on it (screencapture014) that represents the many side of the ChildBO. Now I want to double click on one of these records and I want to be able to edit it's information (screencapture015). But maybe what you recommended is what I still need to do. I will try to follow what you gave me and see if I can get it too work. Thank you for your help.
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
So if I understand correctly : you have a parent-child-grandchild. The childform brings up the child ok on adding a record in the parent, but in the child the listview representing the grandchild won't bring up the grandchild (child of child ) single record dialog ?



First, you need a childformdialog on the child, with bo translation setup.



You need to have the listview on the child setup with the addobject and editobject properties pointing to the buttons.



And you need to be sure you are doing something to fill the grandchild with records - either by querying against the child pk ( IOW its parent ) or by using the autofilter.



One other gotcha - especially if you are passing all the data along from the parent - i.e. you pulled parent-child-grandchild data in the parent form, set autofiltering and are passing the data long with the BO translations :



You need to override the OnLoad of the child ( middle ) form to reset the business object of the listview representing grandchild records :





' this is in the ContactForm - the "child" - i.e the middle form between parent and grandchild

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

MyBase.OnLoad(e)

'-- This may be needed to rehook translated BOs

'-- ContactResults (the grandchild) was first loaded in the Customer form (the parent)

'-- Without this override the lvContactResults will not be pointed at the translated BO



lvContactResults.BusinessObject = Me.ContactResultsBO1



'-- If we were using a BBS for a datagridview, for example we'd rehook that



'-- Rebind my BBS to the BO

' MyBBS.BusinessObject = MyChildBO;



End Sub





In this case we loaded all the data in Customersform, set the autofilter and then passed all the BOs in the childform dialog using translation.



In the childform dialog on this - the Contacts (child) form - we are passing the ContactsBO1 and the ContactResultsBO1 on to ContactResultsForm



HTH
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
On the Parent Form I am using a Listview and have successfully set it up so if I double click a record in the Parent BO it shows a Child form and list the child records of that parent in a listview.

Now when I double Click on one of the child Records I want to call a Form to Edit some of the data found in that child record. But, I get the following error when I double click the child reccod:



BusinessLayerException

There are no rows in the current data table. An edit is not allowed.



Source : MicroFour StrataFrame Business



Stack Trace:

at MicroFour.StrataFrame.Business.BusinessLayer.Edit(Boolean CheckSecurity)

at MicroFour.StrataFrame.UI.Windows.Forms.ListView.EditChildRecord()

at System.Windows.Forms.ListView.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)

at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



I am using a childformdialog to call the 2nd Child form. The 2nd child form never does appear. I have checked everything that I know to check but obviously I am missing some piece.

TIA.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search