-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegisterPetsPage.vb
45 lines (40 loc) · 1.78 KB
/
RegisterPetsPage.vb
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
Public Class RegisterPetsPage
Public petPanelsList As New List(Of RegisterPetPanel)
Private Sub btnAddPet_Click(sender As Object, e As EventArgs) Handles btnAddPet.Click
Dim petPanel As New RegisterPetPanel
petInputPanel.Controls.Add(petPanel)
petPanelsList.Add(petPanel)
End Sub
Private Sub btnRegisterPets_Click(sender As Object, e As EventArgs) Handles btnRegisterPets.Click
Dim inputControls As List(Of Control) = GetAllInputControls(petInputPanel)
Dim fieldsAreEmpty As Boolean = ConflictChecker.checkIfControlsTextIsEmpty(inputControls)
If fieldsAreEmpty Then
MsgBox("Please fill in all fields.", vbOKOnly + vbExclamation, "Pet Registration")
Exit Sub
End If
Dim registeredPetsList As New List(Of Pet)
For Each petPanel In petPanelsList
registeredPetsList.Add(petPanel.getPetObject())
Next
activeAccount.petsList = registeredPetsList
FileManipulator.SavePets(activeAccount)
MsgBox("Pets Registered!", vbOKOnly + vbInformation, "Pet Registration")
End Sub
Public Sub loadRegisterPetsPage()
NavigatorPage.childForm(Me)
Me.petInputPanel.Controls.Clear()
petPanelsList.Clear()
If activeAccount.petsList.Count = 0 Then
Dim petPanel As RegisterPetPanel = New RegisterPetPanel()
Me.petInputPanel.Controls.Add(petPanel)
Me.petPanelsList.Add(petPanel)
Else
For Each pet In activeAccount.petsList
Dim petPanel As RegisterPetPanel = New RegisterPetPanel()
Me.petInputPanel.Controls.Add(petPanel)
petPanel.setPetObject(pet)
Me.petPanelsList.Add(petPanel)
Next
End If
End Sub
End Class