StrataFrame Forum

Getting the ChildFormDialog to Work

http://forum.strataframe.net/Topic13192.aspx

By Bill Cunnien - 12/28/2007

The following code (C#, sorry VB.NETers) is setup basically like the CRM sample application's Orders and Items:

private Boolean _NewItem;

public SalesOrderDetails(bool pIsNewItem)
{
    InitializeComponent();
    _NewItem = pIsNewItem;
}

private void SalesOrderDetails_Load(object sender, EventArgs e)
{
   
if (_NewItem)
    {
       
this.mSalesOrderDetails.Add();
   
}
   
else
   
{
       
this.mSalesOrderDetails.Edit();
       
this.mPartTemp.FillByPrimaryKey(mSalesOrderDetails.partindex);
       
if (this.mPartTemp.Count > 0)
        {
            ItemNumTextEdit.Text =
this.mPartTemp.partnum;
        }
        RefreshSubtotal(
true);
        RefreshUI(
true);
    }
}

The red highlighted line is where the application error with a BusinessLayerException stating the following:

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

The ChildFormDialog is supposed to take care of passing the BOs to the ChildForm, isn't it?  I have the BusinessObjectTranslation setup correctly.  My source is the SalesOrder form's SalesOrderDetail BO (mSalesOrderDetails) and the destination is the SalesOrderDetail form's SalesOrderDetail BO (also called mSalesOrderDetails).

Is there something else that I need to do?  What am I doing wrong?

Thanks,
Bill

By Greg McGuffey - 12/28/2007

You need to call Edit after you call the fill method. The error is simply stating that there is no data in the BO, there for it can't do an edit. The check to do any time this might occur is:



myBO.CurrentRowIndex < 0




I use this a lot to validate that there is a current row before I attempt to do something with it.
By Greg McGuffey - 12/28/2007

I really need to read the entire post before I respond.... Blush



I have never use the BrowseDialog or the the ChildDialog, so I'm not going to be much help here (and here I thought I was sooo on top of this one). Looking at the source code, the translated BO appears to be loaded before the Load event would be called, so any semblance of help I might have offered is, well, useless. Pinch



Note to self: Just skip answering posts late on a friday...
By Bill Cunnien - 12/29/2007

Note to Greg's self:  Make sure you other self doesn't find out what you're doing late on Fridays!  Could be trouble.

I guess the SF developers will have to chime in on this one.  I sure hope they are well rested, because we are going to be bombarding them next week! Smile

Thanks for responding, Greg!
Bill

By Greg McGuffey - 1/2/2008

Let the bombardment begin! Tongue
By Bill Cunnien - 1/4/2008

Still looking for help on this...bump.  Smile
By StrataFrame Team - 1/4/2008

Let the bombardment begin!

I brought my flak jacket, but I'm not sure that's going to be enough Wink

Well, the first thing we need to do is make sure that the translation is happening correctly.  So, verity that before the ChildFormDialog.ShowDialog() is called the business object in question (the one you're calling Edit() on) has at least one record.  So put a break point on the ShowDialog() line and use the watch window to check the .Count of the business object before it's translated.

By Bill Cunnien - 1/4/2008

Ben Chase (01/04/2008)
[quote]...check the .Count of the business object before it's translated.

Welcome back, Ben!  We'll be gentle.

It is 0.  Odd.  I am using the same BO (I think) to fill the ListView.  There are five records in the ListView (Count: 5).  Where did they go?

I am suspecting the RowPopulating event...checking now...

By Bill Cunnien - 1/4/2008

That was the culprit!  I had created a "new" BO to do the work of filling the ListView.  Why?  I don't know.  So, I changed it so that the translated BO is being filled, then I use that to complete the ListView.  It seems to be working, now.

Thanks a ton for the response!  I am very glad to be moving forward again on this project!!
Bill

By Trent L. Taylor - 1/4/2008

Glad you found your problem Smile