Questions about remove/delete

Posts   
 
    
slacroix
User
Posts: 4
Joined: 19-Jan-2005
# Posted on: 19-Jan-2005 22:35:24   

My tables are Workcell, WorkcellToProdLine, and ProdLine. Standard many to many relationship.

Workcell

*WorkcellId other things here

WorkcellToProdLine

*WorkcellId *ProdLineId other things here

ProdLine

*ProdLineId other things here

Currently I have a windows forms app with three listboxes: lstWorkcells, lstAllProdLines and lstAssociatedProdLines and three buttons add, remove, and save.

I populate listWorkcells and listAllProdLines on form load. I select a Workcell and populate the lstAssociatedProdLines with the workcell's associated prodlines. This I can do no problem:

lstWorkcells is bound to all Workcell rows. lstAllProdLines is bound all ProdLine rows. lstAssociated is bound to currentWorkcell.ProdLine

I want to be able to click the add button and "copy" a prodline from listAllProdLines to listAssociatedProdLines which should eventually create a new entry in WorkcellToProdLine. When I click delete i want it to remove itself from listAssociatedProdLines (disassociate).

Once all changes are made I have the user click a Save button which should make the changes permanent.

I'm having problems with each step here. How do I add/remove and do the final update at the end?

in add: I create a new WorkcellToProdLineEntity, populate it with data, set the Workcell property to currentWorkcell and set the ProdLine property to listAllProdline.selectedItem. It doesnt immediately add to listAssociatedProdlines...but it does persist if the user clicks save.

in delete: not sure here...tried creating a new WorkcellToProdLineEntity and used the method .Delete(). This deletes the entity before the user clicks save...

Ive also tried the Add and remove methods of the related collections...

Any ideas here? If i provided enough information that is...let me know if its not enough.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 20-Jan-2005 10:16:06   

slacroix wrote:

My tables are Workcell, WorkcellToProdLine, and ProdLine. Standard many to many relationship.

Workcell

*WorkcellId other things here

WorkcellToProdLine

*WorkcellId *ProdLineId other things here

ProdLine

*ProdLineId other things here

Currently I have a windows forms app with three listboxes: lstWorkcells, lstAllProdLines and lstAssociatedProdLines and three buttons add, remove, and save.

I populate listWorkcells and listAllProdLines on form load. I select a Workcell and populate the lstAssociatedProdLines with the workcell's associated prodlines. This I can do no problem:

lstWorkcells is bound to all Workcell rows. lstAllProdLines is bound all ProdLine rows. lstAssociated is bound to currentWorkcell.ProdLine

I want to be able to click the add button and "copy" a prodline from listAllProdLines to listAssociatedProdLines which should eventually create a new entry in WorkcellToProdLine. When I click delete i want it to remove itself from listAssociatedProdLines (disassociate).

So when you click 'Add', you create a new WorkcellToProdLine entity, assign the 2 other entities to it and add it to workcell.Prodline. Remove the WorkcellToProdLine from the list and the databinding code should take care of the visual updates.

Once all changes are made I have the user click a Save button which should make the changes permanent.

I'm having problems with each step here. How do I add/remove and do the final update at the end?

in add: I create a new WorkcellToProdLineEntity, populate it with data, set the Workcell property to currentWorkcell and set the ProdLine property to listAllProdline.selectedItem. It doesnt immediately add to listAssociatedProdlines...but it does persist if the user clicks save.

This was a bug, fixed in runtime library v1.0.2004.1 01042005, so any version after january 4th 2005 should fix this.

in delete: not sure here...tried creating a new WorkcellToProdLineEntity and used the method .Delete(). This deletes the entity before the user clicks save...

Ive also tried the Add and remove methods of the related collections... Any ideas here? If i provided enough information that is...let me know if its not enough.

You could use a UnitOfWork or an entity collection which collects the entities to delete, then DeleteMulti() that collection after you've saved the graph.

Frans Bouma | Lead developer LLBLGen Pro