Why does Childformdialog not work correctly


Author
Message
Thomas Holste
Thomas Holste
StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi there,

I have a main form with a BO and a Businessbindingsource to use it with a datagridview. To add new records I call a childform with the childformdialog. This is how it's done:



LieferBO1.Add()

Dim para As New Liefneuparams

para.cNeu = "N"

para.cModule = "Latitelneu"

para.cLiefer = ""

para.lSolo = False

If Childliefneu.ShowDialog(para) = DialogResult.OK Then .......



This works the first time I call it but the second time the liefpos.add()  does not add a new record and the bo is positioned on the actual record.

Does anyone know why this is not working?

Best regards

Thomas












Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Remember that the BOs are essentially just being passed over.  When I am working on child dialogs, I definitely use the child form dialog so I can map my BOs, but I manage the state of the as part of the showing of the child form dialog.  First, take advantage of the SaveCurrentDataTableToSnapshot method on the BO.  This is better than an undo because you may go into the child form more than once as part of editing that record.  The first time, things would be good, but if you go back in and cancel...well, you just toasted the record or table state.  For example:

private void AddRecord() 
{      
      myBo.SaveCurrentDataTableToSnapshot("Adding");      
      myBo.Add();      

      if(myChildForm.ShowDialog() == DialogResult.Cancel)       
      {
            myBo.RestoreCurrentDataTableSnapshot("Adding", true);
      }
}


Take this same logic and apply it to an edit.  You would just replace the Add with an Edit.  You can do it in the same method if you pass over the state you are expecting and the record you are wanting to load.  Prior to the edit, you can do a seek to the PK or whatever if you pass it in.
Edited 9 Years Ago by Trent L. Taylor
Thomas Holste
Thomas Holste
StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)StrataFrame User (294 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Trent,




thank you for the Explanation but the error was much simpler. After adding the record I performed a sort on the BO to have the new record shown in the right Position. Resetting the sort before adding works fine.

Best regards

Thomas
Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Glad you got it going!
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