-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardPayment.vb
68 lines (59 loc) · 2.71 KB
/
CardPayment.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
Imports System.Text.RegularExpressions
Public Class CardPayment
Private Sub CardNumber_Validation(sender As Object, e As EventArgs) Handles CardNumberTextBox.Validating
If (String.IsNullOrEmpty(CardNumberTextBox.Text) = False) Then
If (IsNumeric(CardNumberTextBox.Text) = False) OrElse (CardNumberTextBox.Text.Length <> 16) Then
MessageBox.Show("Invalid Card Number.")
CardNumberTextBox.Text = ""
Return
End If
End If
End Sub
Private Sub CVV_Validation(sender As Object, e As EventArgs) Handles CVVTextBox.Validating
If (String.IsNullOrEmpty(CVVTextBox.Text) = False) Then
If (IsNumeric(CVVTextBox.Text) = False) OrElse CVVTextBox.Text.Length <> 3 Then
MessageBox.Show("Invalid CVV.")
CVVTextBox.Text = ""
Return
End If
End If
End Sub
Private Sub Month_Validation(sender As Object, e As EventArgs) Handles MonthTextBox.Validating
If Not String.IsNullOrEmpty(MonthTextBox.Text) Then
If (IsNumeric(MonthTextBox.Text) = False) OrElse CInt(MonthTextBox.Text) > 12 Then
MessageBox.Show("Enter Correct Month.")
MonthTextBox.Text = ""
Return
End If
End If
End Sub
Private Sub Date_Validation(sender As Object, e As EventArgs) Handles DateTextBox.Validating
If Not String.IsNullOrEmpty(DateTextBox.Text) Then
If (IsNumeric(DateTextBox.Text) = False) OrElse CInt(DateTextBox.Text) > 31 Then
MessageBox.Show("Enter Correct Date.")
DateTextBox.Text = ""
Return
End If
End If
End Sub
Private Sub FullName_Validation(sender As Object, e As EventArgs) Handles FullNameTextBox.Validating
If FullNameTextBox.Text.Trim() = "" OrElse Not Regex.IsMatch(FullNameTextBox.Text, "^[a-zA-Z ]+$") Then
MessageBox.Show("Please enter a valid name.")
FullNameTextBox.Text = ""
Return
End If
End Sub
Private Sub OkButton_Click(sender As Object, e As EventArgs) Handles OkButton.Click
If ValidateAllTextBoxes(Me, Array.Empty(Of TextBox)()) Then
DelayTimer.Interval = 2000
DelayTimer.Start()
End If
End Sub
Private Sub DelayTimer_Tick(sender As Object, e As EventArgs) Handles DelayTimer.Tick
DelayTimer.Stop()
MessageBox.Show("Payment was Successful.")
Close()
End Sub
Private Sub FullNameTextBox_TextChanged(sender As Object, e As EventArgs) Handles FullNameTextBox.TextChanged
End Sub
End Class