-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUIHandler.vb
675 lines (520 loc) · 25.6 KB
/
GUIHandler.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
Public Module GUIHandler
Public isClosing As Boolean = False
Public activeAccount As PetOwner = Nothing
Public Sub closingApplication(e As FormClosingEventArgs)
If (isClosing = False) Then
Dim result As DialogResult = MessageBox.Show("Are you sure you want to exit?", "Exit Program", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = DialogResult.Yes Then
isClosing = True
Application.Exit()
Else
e.Cancel = True
End If
End If
End Sub
Public Sub clearAllFields(fields() As Control)
For Each field In fields
field.Text = ""
Next
End Sub
Public Function GetAllInputControls(parentControl As Control) As List(Of Control)
Dim inputControls As New List(Of Control)
For Each control As Control In parentControl.Controls
If TypeOf control Is TextBox OrElse
TypeOf control Is ComboBox OrElse
TypeOf control Is NumericUpDown Then
inputControls.Add(control)
End If
If control.Controls.Count > 0 Then
inputControls.AddRange(GetAllInputControls(control))
End If
Next
Return inputControls
End Function
Public Class PetPanel
Inherits TableLayoutPanel
Public petObject As Pet
Public Sub New(petObject As Pet)
Me.petObject = petObject
Me.BackColor = Color.FromArgb(251, 254, 249)
Me.AutoSize = True
Me.Padding = New Padding(10, 10, 10, 10)
Me.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
Me.ColumnCount = 1
Me.RowCount = 2
Dim lblPetName As New PetLabel
lblPetName.Text = petObject.strName
lblPetName.Font = New Font("Microsoft Sans Serif", 18, FontStyle.Bold)
lblPetName.AutoSize = True
lblPetName.Anchor = AnchorStyles.Bottom
Me.Controls.Add(lblPetName, 0, 0)
Dim lblTypeLabel As New PetLabel
lblTypeLabel.Text = "Type:"
Dim lblTypeValue As New PetLabel
lblTypeValue.Text = petObject.strType.ToUpper()
Dim lblBdayLabel As New PetLabel
lblBdayLabel.Text = "Birthdate:"
Dim lblBdayValue As New PetLabel
lblBdayValue.Text = petObject.dateBirthday
Dim lblAgeLabel As New PetLabel
lblAgeLabel.Text = "Age:"
Dim lblAgeValue As New PetLabel
lblAgeValue.Text = petObject.intAge & " yr(s) old"
Dim lblWeightLabel As New PetLabel
lblWeightLabel.Text = "Weight:"
Dim lblWeightValue As New PetLabel
lblWeightValue.Text = petObject.dblWeight & " kg"
Dim lblPetStatusLabel As New PetLabel
lblPetStatusLabel.Text = "Vac Status:"
Dim lblPetStatusValue As New PetLabel
lblPetStatusValue.Text = petObject.boolVaccinated
Dim lblPetNextVisitLabel As New PetLabel
lblPetNextVisitLabel.Text = "Next Visit:"
Dim lblPetNextVisitValue As New PetLabel
lblPetNextVisitValue.Text = petObject.dateOfNextVisit
Dim PetLabels() As PetLabel = {lblTypeLabel, lblBdayLabel, lblAgeLabel, lblWeightLabel, lblPetStatusLabel, lblPetNextVisitLabel}
Dim PetValues() As PetLabel = {lblTypeValue, lblBdayValue, lblAgeValue, lblWeightValue, lblPetStatusValue, lblPetNextVisitValue}
Dim propertiesPanel As New TableLayoutPanel
propertiesPanel.AutoSize = True
propertiesPanel.Padding = New Padding(5, 5, 5, 5)
propertiesPanel.ColumnCount = 2
propertiesPanel.RowCount = 6
Me.Controls.Add(propertiesPanel, 0, 1)
With propertiesPanel
For i = 0 To PetLabels.Length - 1
PetLabels(i).AutoSize = True
PetLabels(i).Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
.Controls.Add(PetLabels(i), 0, i)
PetValues(i).AutoSize = True
PetValues(i).Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
.Controls.Add(PetValues(i), 1, i)
Next
End With
End Sub
End Class
Public Class AppointmentPanel
Inherits TableLayoutPanel
Public appointment As Appointment
Public Sub New(appointment As Appointment)
Me.appointment = appointment
Me.BackColor = Color.FromArgb(251, 254, 249)
Me.AutoSize = True
Me.Padding = New Padding(10, 10, 10, 10)
Me.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
Me.ColumnCount = 1
Me.RowCount = 2
Dim headerPanel As New TableLayoutPanel
headerPanel.Size = New System.Drawing.Size(216, 31)
headerPanel.ColumnCount = 2
headerPanel.RowCount = 1
Me.Controls.Add(headerPanel, 0, 0)
Dim iconPicture As New PictureBox
iconPicture.Image = My.Resources.calendarIcon
iconPicture.SizeMode = PictureBoxSizeMode.Zoom
iconPicture.Size = New System.Drawing.Size(37, 28)
iconPicture.Margin = New Padding(5, 0, 5, 10)
headerPanel.Controls.Add(iconPicture, 0, 0)
Dim lblPetAppointment As New PetLabel
lblPetAppointment.Text = appointment.dateAppointment.ToString("MMMM d, yyyy")
lblPetAppointment.Font = New Font("Microsoft Sans Serif", 16, FontStyle.Bold)
lblPetAppointment.AutoSize = True
lblPetAppointment.Margin = New Padding(0, 0, 5, 5)
headerPanel.Controls.Add(lblPetAppointment, 1, 0)
Dim infoPanel As New TableLayoutPanel
infoPanel.AutoSize = True
infoPanel.Padding = New Padding(5, 5, 5, 5)
infoPanel.ColumnCount = 2
infoPanel.RowCount = 2
Dim lblPetNameLabel As New PetLabel
lblPetNameLabel.Text = "Pet: "
Dim lblPetNameValue As New PetLabel
lblPetNameValue.Text = appointment.pet
Dim lblPetProcedureLabel As New PetLabel
lblPetProcedureLabel.Text = "Procedure: "
Dim lblPetProcedureValue As New PetLabel
lblPetProcedureValue.Text = appointment.strProcedure
infoPanel.Controls.Add(lblPetNameLabel, 0, 0)
infoPanel.Controls.Add(lblPetNameValue, 1, 0)
infoPanel.Controls.Add(lblPetProcedureLabel, 0, 1)
infoPanel.Controls.Add(lblPetProcedureValue, 1, 1)
Me.Controls.Add(infoPanel, 0, 1)
End Sub
End Class
Public Class RegisterPetPanel
Inherits TableLayoutPanel
Public lblPetName As New PetLabel
Public lblPetBirthday As New PetLabel
Public lblPetType As New PetLabel
Public lblPetAge As New PetLabel
Public lblPetWeight As New PetLabel
Public lblPetVaccineStatus As New PetLabel
Public txtPetName As New TextBox
Public dtpPetBirthday As New DateTimePicker
Public cbPetType As New ComboBox
Public numPetAge As New NumericUpDown
Public numPetWeight As New NumericUpDown
Public cbPetVacStatus As New ComboBox
Public petObject As Pet
Public Sub New()
Me.petObject = petObject
Me.BackColor = Color.White
Me.AutoSize = True
Me.Padding = New Padding(10, 10, 10, 10)
Me.Margin = New Padding(0, 0, 0, 5)
Me.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
Me.ColumnCount = 6
Me.RowCount = 2
For i As Integer = 1 To Me.ColumnCount
Me.ColumnStyles.Add(New ColumnStyle(SizeType.AutoSize))
Next
For i As Integer = 1 To Me.RowCount
Me.RowStyles.Add(New RowStyle(SizeType.AutoSize))
Next
'Labels
lblPetName.Text = "Pet Name:"
lblPetBirthday.Text = "Pet Birthday: "
lblPetType.Text = "Type: "
lblPetAge.Text = "Pet Age(yr):"
lblPetWeight.Text = "Pet Weight(kg):"
lblPetVaccineStatus.Text = "Vaccine Status: "
Dim PetLabels() As PetLabel = {lblPetName, lblPetBirthday, lblPetType, lblPetAge, lblPetWeight, lblPetVaccineStatus}
'Inputs
txtPetName.Size = New System.Drawing.Size(155, 26)
dtpPetBirthday.Size = New System.Drawing.Size(196, 20)
cbPetType.Size = New System.Drawing.Size(145, 28)
cbPetType.DropDownStyle = ComboBoxStyle.DropDownList
cbPetType.Items.Add("Feline")
cbPetType.Items.Add("Canine")
cbPetType.Items.Add("Reptile")
cbPetType.SelectedItem = "Feline"
numPetAge.Size = New System.Drawing.Size(64, 20)
numPetWeight.Size = New System.Drawing.Size(64, 20)
cbPetVacStatus.Size = New System.Drawing.Size(150, 28)
cbPetVacStatus.DropDownStyle = ComboBoxStyle.DropDownList
cbPetVacStatus.Items.Add("Complete")
cbPetVacStatus.Items.Add("Incomplete")
cbPetVacStatus.SelectedItem = "Incomplete"
With Me
For i = 0 To PetLabels.Length - 1
PetLabels(i).AutoSize = True
PetLabels(i).Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
.Controls.Add(PetLabels(i), i, 0)
Next
.Controls.Add(txtPetName, 0, 1)
.Controls.Add(dtpPetBirthday, 1, 1)
.Controls.Add(cbPetType, 2, 1)
.Controls.Add(numPetAge, 3, 1)
.Controls.Add(numPetWeight, 4, 1)
.Controls.Add(cbPetVacStatus, 5, 1)
End With
End Sub
Public Overridable Function getPetObject() As Pet
petObject = New Pet(txtPetName.Text, numPetAge.Text, dtpPetBirthday.Value.Date, numPetWeight.Text, cbPetType.SelectedItem, cbPetVacStatus.SelectedItem, "N/A")
Return petObject
End Function
Public Overridable Sub setPetObject(petObject As Pet)
Me.txtPetName.Text = petObject.strName
Me.numPetAge.Value = petObject.intAge
Me.dtpPetBirthday.Value = petObject.dateBirthday
Me.numPetWeight.Value = petObject.dblWeight
Me.cbPetType.SelectedItem = petObject.strType
Me.cbPetVacStatus.SelectedItem = petObject.boolVaccinated
End Sub
End Class
Public Class WalkInPetInputPanel
Inherits RegisterPetPanel
Public lblPetProcedure As New PetLabel
Public cbPetProcedure As New ComboBox
Public Sub New()
Me.ColumnCount = 7
lblPetProcedure.Text = "Procedure:"
lblPetProcedure.AutoSize = True
lblPetProcedure.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
Me.Controls.Add(lblPetProcedure, 7, 0)
cbPetProcedure.Size = New System.Drawing.Size(100, 28)
cbPetProcedure.DropDownStyle = ComboBoxStyle.DropDownList
cbPetProcedure.Items.Add("Check-Up")
cbPetProcedure.Items.Add("Vaccine")
cbPetProcedure.Items.Add("Both")
cbPetProcedure.SelectedItem = "Check-Up"
Me.Controls.Add(cbPetProcedure, 7, 1)
cbPetType.Size = New System.Drawing.Size(125, 28)
cbPetVacStatus.Size = New System.Drawing.Size(125, 28)
AddHandler Me.cbPetVacStatus.SelectedIndexChanged, AddressOf Me.cbPetVacStatus_SelectedIndexChanged
End Sub
Private Sub cbPetVacStatus_SelectedIndexChanged(sender As Object, e As EventArgs)
If cbPetVacStatus.SelectedItem = "Complete" Then
cbPetProcedure.Items.Clear()
cbPetProcedure.Items.Add("Check-Up")
cbPetProcedure.SelectedItem = "Check-Up"
ElseIf cbPetVacStatus.SelectedItem = "Incomplete" Then
cbPetProcedure.Items.Clear()
cbPetProcedure.Items.Add("Check-Up")
cbPetProcedure.Items.Add("Vaccine")
cbPetProcedure.Items.Add("Both")
cbPetProcedure.SelectedItem = "Vaccine"
End If
End Sub
Public Overrides Function getPetObject() As Pet
petObject = New Pet(txtPetName.Text, numPetAge.Text, dtpPetBirthday.Value.Date, numPetWeight.Text, cbPetType.SelectedItem, cbPetVacStatus.SelectedItem, "N/A")
Return petObject
End Function
End Class
Public Class SessionPetPanel
Inherits TableLayoutPanel
Public Sub New(petWithProcedureString As String)
Me.BackColor = Color.FromArgb(251, 254, 249)
Me.AutoSize = True
Me.Padding = New Padding(1, 1, 1, 1)
Me.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
Me.ColumnCount = 1
Me.RowCount = 2
Dim lblPetName As New PetLabel
lblPetName.Text = petWithProcedureString.Split("#"c)(0)
lblPetName.Font = New Font("Microsoft Sans Serif", 18, FontStyle.Bold)
lblPetName.AutoSize = True
lblPetName.Anchor = AnchorStyles.Bottom
Me.Controls.Add(lblPetName, 0, 0)
Dim lblTypeLabel As New PetLabel
lblTypeLabel.Text = "Type:"
Dim lblTypeValue As New PetLabel
lblTypeValue.Text = petWithProcedureString.Split("#"c)(1)
Dim lblVacLabel As New PetLabel
lblVacLabel.Text = "Vac Status:"
Dim lblVacValue As New PetLabel
lblVacValue.Text = petWithProcedureString.Split("#"c)(2)
Dim lblProcedureLabel As New PetLabel
lblProcedureLabel.Text = "Procedure:"
Dim lblProcedureValue As New PetLabel
lblProcedureValue.Text = petWithProcedureString.Split("#"c)(3)
Dim PetLabels() As PetLabel = {lblTypeLabel, lblVacLabel, lblProcedureLabel}
Dim PetValues() As PetLabel = {lblTypeValue, lblVacValue, lblProcedureValue}
Dim propertiesPanel As New TableLayoutPanel
propertiesPanel.AutoSize = True
propertiesPanel.Padding = New Padding(5, 5, 5, 5)
propertiesPanel.ColumnCount = 2
propertiesPanel.RowCount = 2
Me.Controls.Add(propertiesPanel, 0, 1)
With propertiesPanel
For i = 0 To PetLabels.Length - 1
PetLabels(i).AutoSize = True
PetLabels(i).Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
.Controls.Add(PetLabels(i), 0, i)
PetValues(i).AutoSize = True
PetValues(i).Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
.Controls.Add(PetValues(i), 1, i)
Next
End With
End Sub
End Class
Public Class SessionNextVisitPanel
Inherits TableLayoutPanel
Public lblPetName As New PetLabel
Public lblNextVisitChooser As New PetLabel
Public lblNextVisitDate As New PetLabel
Public lblPetVaccineStatus As New PetLabel
Public lblProcedure As New PetLabel
Public lblErrorMessage As New Label
Public rbYes As New RadioButton
Public rbNo As New RadioButton
Public dtpNextVisitDate As New DateTimePicker
Public cbPetProcedure As New ComboBox
Public cbPetVacStatus As New ComboBox
Public Sub New(petWithProcedureString As String)
Me.BackColor = Color.White
'Me.Size = New System.Drawing.Size(769, 67)
Me.AutoSize = True
Me.Padding = New Padding(10, 10, 10, 10)
Me.Margin = New Padding(0, 0, 0, 5)
Me.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
Me.ColumnCount = 2
Me.RowCount = 1
lblPetName.Text = petWithProcedureString.Split("#"c)(0)
lblPetName.Font = New Font("Microsoft Sans Serif", 18, FontStyle.Bold)
lblPetName.AutoSize = True
lblPetName.Anchor = AnchorStyles.Left
Me.Controls.Add(lblPetName, 0, 0)
lblNextVisitChooser.Text = "Next Visit?:"
lblNextVisitDate.Text = "Date of Next Visit:"
lblPetVaccineStatus.Text = "Vaccine Status:"
lblProcedure.Text = "Procedure:"
Dim PetLabels() As PetLabel = {lblNextVisitChooser, lblNextVisitDate, lblPetVaccineStatus, lblProcedure}
'Inputs
rbYes.Text = "Yes"
rbNo.Text = "No"
rbYes.AutoSize = True
rbNo.AutoSize = True
AddHandler Me.rbYes.CheckedChanged, AddressOf Me.rbYes_CheckedChanged
AddHandler Me.rbNo.CheckedChanged, AddressOf Me.rbNo_CheckedChanged
dtpNextVisitDate.Size = New System.Drawing.Size(196, 20)
AddHandler Me.dtpNextVisitDate.ValueChanged, AddressOf Me.dtpNextVisitDate_ValueChanged
lblErrorMessage.Font = New Font("Microsoft Sans Serif", 7.5, FontStyle.Regular)
lblErrorMessage.ForeColor = Color.IndianRed
lblErrorMessage.Visible = False
lblErrorMessage.AutoSize = True
Dim datepickerGroup As New TableLayoutPanel
datepickerGroup.AutoSize = True
datepickerGroup.ColumnCount = 1
datepickerGroup.RowCount = 2
datepickerGroup.Controls.Add(dtpNextVisitDate, 0, 0)
datepickerGroup.Controls.Add(lblErrorMessage, 0, 1)
cbPetProcedure.Size = New System.Drawing.Size(145, 28)
cbPetProcedure.Items.Add("Check-Up")
cbPetProcedure.Items.Add("Vaccine")
cbPetProcedure.Items.Add("Both")
cbPetVacStatus.Size = New System.Drawing.Size(150, 28)
cbPetVacStatus.Items.Add("Complete")
cbPetVacStatus.Items.Add("Incomplete")
cbPetVacStatus.DropDownStyle = ComboBoxStyle.DropDownList
Dim petProcedure As String = petWithProcedureString.Split("#"c)(3)
If petProcedure = "Vaccine" Or petProcedure = "Both" Then
cbPetVacStatus.SelectedItem = "Complete"
Else
cbPetVacStatus.SelectedItem = petWithProcedureString.Split("#"c)(2)
End If
Call Me.cbPetVacStatus_SelectedIndexChanged(Me.cbPetVacStatus, EventArgs.Empty)
Dim propertiesPanel As New TableLayoutPanel
propertiesPanel.AutoSize = True
propertiesPanel.Padding = New Padding(5, 5, 5, 5)
propertiesPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
propertiesPanel.ColumnCount = 4
propertiesPanel.RowCount = 2
Me.Controls.Add(propertiesPanel, 1, 0)
With propertiesPanel
For i = 0 To PetLabels.Length - 1
PetLabels(i).AutoSize = True
PetLabels(i).Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
.Controls.Add(PetLabels(i), i, 0)
Next
Dim radioPanel As New FlowLayoutPanel
radioPanel.AutoSize = True
radioPanel.Controls.Add(rbYes)
radioPanel.Controls.Add(rbNo)
.Controls.Add(radioPanel, 0, 1)
.Controls.Add(datepickerGroup, 1, 1)
.Controls.Add(cbPetVacStatus, 2, 1)
.Controls.Add(cbPetProcedure, 3, 1)
rbYes.PerformClick()
End With
End Sub
Private Sub dtpNextVisitDate_ValueChanged(sender As Object, e As EventArgs)
SessionHandlingPage.reloadAllDateTimePicker(SessionHandlingPage.nextVisitPanelsList)
End Sub
Public Shared Sub checkIfDatePickedIsValid(dtpAppointmentDate As DateTimePicker, lblErrorMessage As Label)
lblErrorMessage.Visible = False
Dim bookingsList As List(Of Appointment) = FileManipulator.ReadBookings()
Dim datesList As List(Of Date) = bookingsList.Select(Function(appointment) appointment.dateAppointment).ToList()
Dim nvPanelListEnabledDtps As List(Of SessionNextVisitPanel) = SessionHandlingPage.nextVisitPanelsList.Where(Function(nv) nv.dtpNextVisitDate.Enabled).ToList()
If dtpAppointmentDate.Enabled = True Then
If dtpAppointmentDate.Value.Date < DateTime.Now.Date Then
lblErrorMessage.Visible = True
lblErrorMessage.Text = "Date has passed already."
Exit Sub
End If
If dtpAppointmentDate.Value.Date.DayOfWeek = DayOfWeek.Sunday Then
lblErrorMessage.Visible = True
lblErrorMessage.Text = "Clinic is not open on Sundays."
Exit Sub
End If
For Each dateObj In datesList
If dateObj = dtpAppointmentDate.Value.Date Then
lblErrorMessage.Visible = True
lblErrorMessage.Text = "There is already an appointment that day."
Exit For
End If
Next
For Each nextVisitPanel In nvPanelListEnabledDtps
If dtpAppointmentDate.Value.Date = nextVisitPanel.dtpNextVisitDate.Value.Date And Not (dtpAppointmentDate Is nextVisitPanel.dtpNextVisitDate) Then
lblErrorMessage.Visible = True
lblErrorMessage.Text = "There is already an appointment that day."
Exit For
End If
Next
End If
End Sub
Private Sub cbPetVacStatus_SelectedIndexChanged(sender As Object, e As EventArgs)
If cbPetVacStatus.SelectedItem = "Complete" Then
cbPetProcedure.Items.Clear()
cbPetProcedure.Items.Add("Check-Up")
cbPetProcedure.SelectedItem = "Check-Up"
ElseIf cbPetVacStatus.SelectedItem = "Incomplete" Then
cbPetProcedure.Items.Clear()
cbPetProcedure.Items.Add("Check-Up")
cbPetProcedure.Items.Add("Vaccine")
cbPetProcedure.Items.Add("Both")
cbPetProcedure.SelectedItem = "Vaccine"
End If
End Sub
Public Function getNextVistObject() As NextVisit
Dim nextVisitObject As NextVisit
If rbYes.Checked Then
nextVisitObject = New NextVisit(lblPetName.Text, rbYes.Checked, dtpNextVisitDate.Value.Date, cbPetVacStatus.SelectedItem, cbPetProcedure.SelectedItem)
Else
nextVisitObject = New NextVisit(lblPetName.Text, rbYes.Checked, "N/A", cbPetVacStatus.SelectedItem, cbPetProcedure.SelectedItem)
End If
Return nextVisitObject
End Function
Private Sub rbYes_CheckedChanged(sender As Object, e As EventArgs)
SessionHandlingPage.reloadAllDateTimePicker(SessionHandlingPage.nextVisitPanelsList)
End Sub
Private Sub rbNo_CheckedChanged(sender As Object, e As EventArgs)
SessionHandlingPage.reloadAllDateTimePicker(SessionHandlingPage.nextVisitPanelsList)
End Sub
End Class
Public Class BillingRowPanel
Inherits TableLayoutPanel
Public lblPetName As New PetLabel
Public lblPetType As New PetLabel
Public lblProcedure As New PetLabel
Public lblTotal As New PetLabel
Public Sub New(petWithProcedureString As String)
Me.BackColor = Color.Transparent
Me.AutoSize = False
'Me.Width = 376
Me.Size = New System.Drawing.Size(376, 40)
Me.ColumnCount = 4
Me.RowCount = 1
Me.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 25))
Me.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 25))
Me.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 27))
Me.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 23))
Me.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
Dim petType As String = petWithProcedureString.Split("#"c)(1)
Dim petProcedure As String = petWithProcedureString.Split("#"c)(3)
lblPetName.Text = petWithProcedureString.Split("#"c)(0)
lblPetName.Font = New Font("Tw Cen MT", 12, FontStyle.Regular)
lblPetType.Text = petType
lblPetType.Font = New Font("Tw Cen MT", 12, FontStyle.Regular)
lblProcedure.Text = petProcedure
lblProcedure.Font = New Font("Tw Cen MT", 12, FontStyle.Regular)
lblTotal.Text = ToPesoFormat(computeTotalBill(petType, petProcedure))
lblTotal.Font = New Font("Tw Cen MT", 12, FontStyle.Bold)
Dim PetLabels() As Label = {lblPetName, lblPetType, lblProcedure, lblTotal}
With Me
For i = 0 To PetLabels.Length - 1
PetLabels(i).AutoSize = True
PetLabels(i).Anchor = AnchorStyles.None
.Controls.Add(PetLabels(i), i, 0)
Next
End With
End Sub
End Class
Public Class ReceiptRowPanel
Inherits BillingRowPanel
Public Sub New(petWithProcedureString As String)
MyBase.New(petWithProcedureString)
Me.AutoSize = False
Me.Size = New System.Drawing.Size(540, 30)
End Sub
End Class
Public Class PetLabel
Inherits Label
Public Sub New()
Me.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Regular)
Me.AutoSize = True
End Sub
End Class
Public Function ToPesoFormat(ByVal decimalNum As Double) As String
Return decimalNum.ToString("C2", Globalization.CultureInfo.GetCultureInfo("en-PH"))
End Function
End Module