1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| Public Class User
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Private _laptops As New List(Of LapTop)
Public Property Laptops() As List(Of LapTop)
Get
Return _laptops
End Get
Private Set(ByVal value As List(Of LapTop))
_laptops = value
End Set
End Property
Public Sub AddLaptop(ByVal laptop As LapTop)
If Not _laptops.Contains(laptop) Then
'If LaptopDAO.UpdateLaptop(laptop, Me.Username, "update") Then
_laptops.Add(laptop)
'Else
' MessageBox.Show(messLaptopErrorAdd, titleError, MessageBoxButtons.OK, MessageBoxIcon.Error)
'End If
Else
'MessageBox.Show(messLaptopAlreadyExists, titleError, MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Public Sub RemoveLaptop(ByVal laptop As LapTop)
If _laptops.Contains(laptop) Then
'If LaptopDAO.UpdateLaptop(laptop, "", "detach") Then
_laptops.Remove(laptop)
'End If
Else
'MessageBox.Show(messLaptopNotFound, titleError, MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Public Function GetLaptop(ByVal serial As String) As LapTop
For Each laptop As LapTop In _laptops
If laptop.Serial = serial Then
Return laptop
End If
Next
Return Nothing
End Function
End Class |
Partager