Thank you for your answers, Stephen and Cerebrus!
But now, could you please give me an example of definition and how to
implement the classes?
I've got an example and there are points i don'get. here my questions.

*Side 1*
*Class Customer *
Friend Sub SetBudget(ByVal budget As Budget)
_budget = budget
End Sub

Public Property Budget() As Budget
Get
  Return _budget
End Get
Set(ByVal Value As Budget)
If Not _budget Is Nothing Then
_budget.Customers_with_budget.Delete(Me)
End If
_distribuidora = Value
If Not _budget Is Nothing Then
_budget. .Customers_with_budget.Append(Me)
End If
End Set
End Property
'what about add and delete methods? when I delete a customer shoud I delete
a budget? Don't know how to do this

*Side * *
'here I create a collection of customers with budget
*Public Class Customers_with_budget*
Implements IEnumerable
Private _budget As Budget
Private _htCustomers_with_budget As Hashtable
Friend Sub New(ByVal  budget As Budget )
_budget = budget
_htCustomers_with_budget = New Hashtable
End Sub
…
End Class

Public Sub Add(ByVal customer As Customer)
If Not _ht Customers_with_budget.Contains(customer) Then
_htCustomers_with_budget.Add(customer.Name, ... ,Customer) 'here I add
other properties of a customer like address, contact number, etc
customer.setBudget(_budget)
Else
Throw New System.Exception("Already existing Customer")
End If
End Sub
Friend Sub Append(ByVal customer As Customer)
_htCustomers_with_budget.Add(customer.Name, ..., customer)
End Sub

Public Sub Remove(ByVal customer As Customer)
customer.SetBudget(Nothing) 'remove opposite reference
Me.Delete(customer)  'delete customer from collection
End Sub

Public Sub Remove(ByVal name As String)
'Delete opposite reference
Item(name).SetBudget(Nothing)
Me.Delete(Item(name)) ‘remove from collection
End Sub
Friend Sub Delete(ByVal customer As Customer)
_htCustomers_with_budget.Remove(customer.Name) *'what about other elements
in customer class like address and contact number?*
End Sub

'Clear method is called from Dispose method in Budget class and deletes
elements of collection class
Public Sub Clear()
Dim en As IDictionaryEnumerator
Dim name As String
en = _htCustomers_with_budget.GetEnumerator
While en.MoveNext()
name = CType(en.Key, String)* 'i don't get this Ctype function*
Me.Remove(name)
End While
_htCustomers_with_budget.Clear()
End Sub

and next question is how do I implement the collection class with table
Budget?

thanks a million!
Dani


On Tue, Jan 10, 2012 at 2:51 PM, Stephen Russell <[email protected]>wrote:

> On Wed, Jan 4, 2012 at 3:24 PM, Dani <[email protected]> wrote:
> > Hi all,
> > I'm programming an application with OOP. I've got a one to many
> > relationship between 2 tables, and I read this can be implemented thru
> > class association.
> >
> > I've got 2 tables: Customers and Budgets. One Cutomer may have
> > multiple Budgets.
> >
> > In the VS Class Diagram, I tried to create the association but I need
> > to define the property Budget in class Customer, as a list, otherwise
> > it wouldn't let me do it.
> >
> > Any ideas about this?
> >
> > Thanks a lot in advance.
> -----------------------------------------
>
>
> Think of a container, Customer, that holds other containers like
> List<Budget> and List<Orders>.
>
>
> --
> Stephen Russell
>
> 901.246-0159 cell
>
> --
> You received this message because you are subscribed to the Google
> Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
> Web Services,.NET Remoting" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
> or visit the group website at http://megasolutions.net
>

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to