Andrew MC

Andrew MC

  • NA
  • 5
  • 5.5k

How do i handle retreival of collections from a form?

Jul 17 2014 11:55 PM
I have the following form that will save Product brands with their models.



What so special about this is, the user could add brands and models separately to gridview controls and save them at once  i.e. Before user clicks save, user may add Brand Names first, then he can add model names for each brand. Then he can save all at once by clicking save.

I have two classes in my Business layer Brand and Model.  There structure is as follows



As you can see the client form has an object that associates with the Brand class "MyBrand". I can access the "AllMyModels" collection through "MyBrand" and I don't have an issue with that. But the issue arises when I try to save a collection of Brands with a collection of Models. As you can see In the above form GUI the user can save a collection of brands with their models at once. When this happens the above class diagram breaks because FrmNewBrand does not have a collection of brands, it only has a collection of Model "AllMyModels" through "MyBrand" object.

if i give you a real example, assume cars, brands and models first the user enters to the brands datagrid a list of car brands (toyota, honda etc.) then he selects a car brand and enters all the models of that brand to models datagrid and he does the same to all the brands. then he saves all the brands with all their related models!

So how do I modify the above class diagram to save a collection of Brands along with their collection of models at the same time?

thanks