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.