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
|
Private _laptops As 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 Me.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 Me.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 |
Partager