Parent - Child BO and Trying to Update Child


Author
Message
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K


If EventEntriesRodeoBO1.MoveFirst Then

For Each loRodeo As EventEntriesRodeoBO In Me.EventEntriesRodeoBO1.GetEnumerable



Select Case EventEntriesRodeoBO1.eventCD

Case "BB"

ContestantsRodeoBO1.EventBB = EventEntriesRodeoBO1.eventCD

Case "BR"

ContestantsRodeoBO1.EventBR = EventEntriesRodeoBO1.eventCD

End Select



Next

End If

ContestantsRodeoBO1.Save()ContestantsRodeoBO1.Save()





I am trying to iterate thru the parent(evententriesrodeobo1) and update a column in the child(contestantrodeobo1). This code is called from the click of a button on a form. Please note the attached screenshots. The parent child relationship works on the form so what am I missing in the code? I have traced the code and it seems to be doing what I need it to do except the data does not end up in the child in the database?????

I must be brain dead since this seems to be trivial BUT.?????? TIA
Attachments
ScreenShot003.gif (134 views, 21.00 KB)
ScreenShot004.gif (141 views, 14.00 KB)
Replies
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
As a follow up. Unless I put the following code after the For each lorodeo



Me.ContestantsRodeoBO1.FillByParentPrimaryKey(loRodeo.contestantId)



Nothing gets updated at all no matter where I put the save. Does that mean my parent child is not working? It does work on the form with the toolstrip.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Well it is not going to be easy to figure out without a sample, but the Me.EventEntriesRodeoBO1 BO should have been already filled and filtered using Me.ContestantsRodeoBO1.FillByParentPrimaryKey(loRodeo.contestantId) but again, that should not affect the FOR loop since.



Just to be clear, the child BO Me.EventEntriesRodeoBO1 should already have all the records related to the parent before going to the FOR loop. I usually put the FillByParentprimaryKey() in the Navigated event of the parent BO.



If still does not work, see if you can build a quick sample using the SF sample database. I have done that many times and in a more difficult way using the BO.Filter() which is very powerful and dangerous if you are not focus. BigGrin

Edhy Rijo

Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
This Child BO is the ContestantsRodeoBO and the parent is the EventEntriesRodeoBO.



I was trying to put the Me.ContestantsRodeoBO1.FillByParentPrimaryKey(loRodeo.contestantId) in the navigated of the EventEntriesRodeoBO but of course it knows nothing about the object loRodeo. I tried a couple of other combinations but can not seem to get how to get all the references correct.

This was the last try but not working? Remember the parent is Event.... and the child is contestant......





Private Sub EventEntriesRodeoBO_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles MyBase.Navigated

ContestantsRodeoBO.FillByParentPrimaryKey(Me.contestantId)

End Sub





Thanks for any help.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Here's what I would do (C#, sorry):





foreach (EventEntriesRoderBO loRodeo in EventEntriesRodeoBO1.GetEnumerable())

{

. ContestantsRodeoBO loContestants = new ContestantsRodeoBO();

. loContestants.FillByParentPrimaryKey(loRodeo.contestantID);

. if (loContestants.Count > 0)

. {

. loContestants.Edit(); 'per Edhy, this is not necessary...just showing it for clarity

. switch (loRodeo.eventCD)

. {

. case "BB":

. loContestants.EventBB = loRodeo.eventCD;

. break;

. case ...

. }

. loContestants.Save();

. }

}





I find it a lot easier to manually handle the filling of child BOs. I often get lost in the automated attempts to do so.



Hope this helps,

Bill
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
If anyone knows how to get the code spacing/indentation to work properly, please let me know. I tried placing a period at the beginning of each line, but all of the spacing following it was whacked. Sorry for the poor indentation. Hope you can still read it.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I just use html non-breaking space code: ampersand nbsp;



Be sure to copy the content as these are removed if you preview the post.



I'd love to know if there is an easier way.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
This is what I do:

I usually just edit the code in a .txt file with Notepad

    Than I copy it from there to the browser

        If I want to copy code from VS
        I copy it to the .txt file too first
        And then copy it from there to the browser

    And this usually works fine
   
Hope it helps


Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Hmmm....this didn't work for me. I typed in some text into notepad, selected all, copied into codesnippet (tried a quote too)...indentation was lost. You have some fancy-mancy notepad? Wink
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Oh, never thought of that... I use Notepad2.exe (http://www.flos-freeware.ch/notepad2.html).

It was recommended to me by Sir Steve Taylor. Smile

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I just tried out notepad2 and it's not keeping tabs/extra spaces either. Could there be some setting I'm missing? Or maybe this works with Vista/Win7 and not XP?
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I went the notepad2 route, also. Here is my pasting of code from notepad2 which was originally from VS2k8:





public partial class Invoicing_Export : Aspire.UI.Windows.Forms.AspireBaseForm

{

public Invoicing_Export()

{

InitializeComponent();

}

}





How does that look?

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Not so good... I am on W7 64bit.





public partial class Invoicing_Export : Aspire.UI.Windows.Forms.AspireBaseForm

    {

        public Invoicing_Export()

        {

            InitializeComponent();

        }

    }





This is the same code with the non-breaking spaces included.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Annoyingly pragmatic.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
I can sell copies of mine... non-refundable. Tongue
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Oh, I bet I know the diff. Yours is probably in Portuguese. Tongue
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Narf!
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I want to thank everyone for their help on my parent - child problem. It was great help and I learned a great deal. Thanks again I have it working and I understand how to do it next time.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
This is a great community out here. Thanks for all of your contributions! Smile
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Related to formatting code in the forum. I just found another method. Not as pretty as using Ivan's Portuguese Notepad2, but it saves having to use non-breaking spaces. just put <pre> tags just inside the codesnippet tags. This also doesn't completely fubar your formatting if you use preview.



//-- code just typed in via forum editor

public class BetterForumEditing : SF.WickedCoolEditor

public BetterForumEditing()

{

this.Property1 = "No reason to set this here...";

}

}




As you can see, it indents nicely, but there lines are spaces a bit far apart. Not sure which I like best: using non-breaking spaces, using the <pre> tag (which also works without codesnippet too) or learning Portuguese. Tongue
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Terry Bottorff - 15 Years Ago
Bill Cunnien - 15 Years Ago
Bill Cunnien - 15 Years Ago
Edhy Rijo - 15 Years Ago
Bill Cunnien - 15 Years Ago
                         Your are welcome Bill. :)

Terry, I just noticed that you...
Edhy Rijo - 15 Years Ago
                 Edhy beat me to the fix...good job! :D
Bill Cunnien - 15 Years Ago
Edhy Rijo - 15 Years Ago
Terry Bottorff - 15 Years Ago
Terry Bottorff - 15 Years Ago
Terry Bottorff - 15 Years Ago
                     Hi Terry,

You have to be very careful when using the...
Edhy Rijo - 15 Years Ago
                         Sorry I have been so late on this but I have been working on another...
Terry Bottorff - 15 Years Ago
                             As a follow up. Unless I put the following code after the For each...
Terry Bottorff - 15 Years Ago
                                 Well it is not going to be easy to figure out without a sample, but...
Edhy Rijo - 15 Years Ago
                                     This Child BO is the ContestantsRodeoBO and the parent is the...
Terry Bottorff - 15 Years Ago
                                         Here's what I would do (C#, sorry):

[codesnippet]...
Bill Cunnien - 15 Years Ago
                                             If anyone knows how to get the code spacing/indentation to work...
Bill Cunnien - 15 Years Ago
                                                 I just use html non-breaking space code: ampersand nbsp;

Be...
Greg McGuffey - 15 Years Ago
                                                     This is what I do: [codesnippet] I usually just edit the code in a...
Ivan George Borges - 15 Years Ago
                                                         Hmmm....this didn't work for me. I typed in some text into notepad,...
Greg McGuffey - 15 Years Ago
                                                             Oh, never thought of that... I use Notepad2.exe (...
Ivan George Borges - 15 Years Ago
                                                                 I just tried out notepad2 and it's not keeping tabs/extra spaces...
Greg McGuffey - 15 Years Ago
                                                                     I went the notepad2 route, also. Here is my pasting of code from...
Bill Cunnien - 15 Years Ago
                                                                         Not so good... I am on W7 64bit.

[codesnippet]
public...
Bill Cunnien - 15 Years Ago
                                                                             Annoyingly pragmatic.
Bill Cunnien - 15 Years Ago
                                                                                 I can sell copies of mine... non-refundable. :P
Ivan George Borges - 15 Years Ago
                                                                                     Oh, I bet I know the diff. Yours is probably in Portuguese. :P
Greg McGuffey - 15 Years Ago
                                                                                         Narf!
Bill Cunnien - 15 Years Ago
                                                                                             I want to thank everyone for their help on my parent - child problem....
Terry Bottorff - 15 Years Ago
                                                                                                 This is a great community out here. Thanks for all of your...
Trent L. Taylor - 15 Years Ago
                                                                                                     Related to formatting code in the forum. I just found another method....
Greg McGuffey - 15 Years Ago
Russell Scott Brown - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search