This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForgotPassword.vb
233 lines (149 loc) · 7.9 KB
/
ForgotPassword.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
Imports System.Data.OleDb
Imports System.Text
Public Class ForgotPassword
Private Sub RoundButtonCheck(btn As Button)
btn.FlatStyle = FlatStyle.Flat
btn.FlatAppearance.BorderSize = 0
btn.Cursor = Cursors.Hand
Dim Raduis As New Drawing2D.GraphicsPath
Raduis.StartFigure()
Raduis.AddArc(New Rectangle(0, 0, 20, 20), 180, 90)
Raduis.AddLine(10, 0, btn.Width - 20, 0)
Raduis.AddArc(New Rectangle(btn.Width - 20, 0, 20, 20), -90, 90)
Raduis.AddLine(btnCheck.Width, 20, btn.Width, btn.Height - 10)
Raduis.AddArc(New Rectangle(btn.Width - 25, btn.Height - 25, 25, 25), 0, 90)
Raduis.AddLine(btn.Width - 10, btn.Width, 20, btn.Height)
Raduis.AddArc(New Rectangle(0, btn.Height - 20, 20, 20), 90, 90)
Raduis.CloseFigure()
btnCheck.Region = New Region(Raduis)
End Sub
Private Sub RoundButtonClear(btn As Button)
btn.FlatStyle = FlatStyle.Flat
btn.FlatAppearance.BorderSize = 0
btn.Cursor = Cursors.Hand
Dim Raduis As New Drawing2D.GraphicsPath
Raduis.StartFigure()
Raduis.AddArc(New Rectangle(0, 0, 20, 20), 180, 90)
Raduis.AddLine(10, 0, btn.Width - 20, 0)
Raduis.AddArc(New Rectangle(btn.Width - 20, 0, 20, 20), -90, 90)
Raduis.AddLine(btnClear.Width, 20, btn.Width, btn.Height - 10)
Raduis.AddArc(New Rectangle(btn.Width - 25, btn.Height - 25, 25, 25), 0, 90)
Raduis.AddLine(btn.Width - 10, btn.Width, 20, btn.Height)
Raduis.AddArc(New Rectangle(0, btn.Height - 20, 20, 20), 90, 90)
Raduis.CloseFigure()
btnClear.Region = New Region(Raduis)
End Sub
Private Sub RoundButtonClose(btn As Button)
btn.FlatStyle = FlatStyle.Flat
btn.FlatAppearance.BorderSize = 0
btn.Cursor = Cursors.Hand
Dim Raduis As New Drawing2D.GraphicsPath
Raduis.StartFigure()
Raduis.AddArc(New Rectangle(0, 0, 20, 20), 180, 90)
Raduis.AddLine(10, 0, btn.Width - 20, 0)
Raduis.AddArc(New Rectangle(btn.Width - 20, 0, 20, 20), -90, 90)
Raduis.AddLine(btnClose.Width, 20, btn.Width, btn.Height - 10)
Raduis.AddArc(New Rectangle(btn.Width - 25, btn.Height - 25, 25, 25), 0, 90)
Raduis.AddLine(btn.Width - 10, btn.Width, 20, btn.Height)
Raduis.AddArc(New Rectangle(0, btn.Height - 20, 20, 20), 90, 90)
Raduis.CloseFigure()
btnClose.Region = New Region(Raduis)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Close()
End Sub
Private Sub FrmForgetPass_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dispose()
LoginForm.Show()
End Sub
Private Sub LinkLabel2_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
Dispose()
LoginForm.Show()
End Sub
Sub Clear()
txtUserName.Clear()
dtpDOB.Value = Today
txtPOB.Clear()
txtUserID.Clear()
End Sub
Private Function RequiredEntry() As Boolean
If txtUserName.Text = "" Or txtPOB.Text = "" Or txtUserID.Text = "" Then
MsgBox("Please enter all information", MsgBoxStyle.Critical, "Attention")
Return True
Exit Function
End If
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCheck.Click
If RequiredEntry() = True Then Return
Try
If LoginForm.cmbFormState.Text = "Teacher" Then
Dim TeacherConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database\Pre-enrollment.accdb")
If TeacherConnection.State = ConnectionState.Open Then TeacherConnection.Close()
TeacherConnection.Open()
Dim TeacherDataReader As OleDbDataReader
Dim TeacherCommand As New OleDbCommand With {
.CommandText = "select [TeacherID],[Username],[DateOfBirth],[PlaceOfBirth],[Password] from TeacherInfo where TeacherID = '" & txtUserID.Text & "'",
.Connection = TeacherConnection
}
If TeacherConnection.State = ConnectionState.Closed Then TeacherConnection.Open()
TeacherDataReader = TeacherCommand.ExecuteReader
If TeacherDataReader.Read Then
If UCase(TeacherDataReader(1)) = UCase(txtUserName.Text) And UCase(TeacherDataReader(2)) = UCase(dtpDOB.Text) And UCase(TeacherDataReader(3)) = UCase(txtPOB.Text) Then
MessageBox.Show("Your password is .:{ '" & Decrypt(TeacherDataReader(4).ToString()) & "' ]:. ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
LinkLabel2.Visible = True
TeacherConnection.Close()
Else
MessageBox.Show("Incorect input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TeacherConnection.Close()
End If
Else
MessageBox.Show("UserID is wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TeacherConnection.Close()
End If
End If
If LoginForm.cmbFormState.Text = "Admin" Then
Dim AdminConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database\Pre-enrollment.accdb")
Dim AdminDataReader As OleDbDataReader
Dim AdminCommand As New OleDbCommand
If AdminConnection.State = ConnectionState.Open Then AdminConnection.Close()
AdminConnection.Open()
AdminCommand.CommandText = "select [AdminID],[Username],[DateOfBirth],[PlaceOfBirth],[Password] from AdminInfo where AdminID = '" & txtUserID.Text & "'"
AdminCommand.Connection = AdminConnection
AdminDataReader = AdminCommand.ExecuteReader
If AdminDataReader.Read Then
If UCase(AdminDataReader("Username")) = UCase(txtUserName.Text) And UCase(AdminDataReader("DateOfBirth")) = UCase(dtpDOB.Text) And UCase(AdminDataReader("PlaceOfBirth")) = UCase(txtPOB.Text) Then
MessageBox.Show("Your password is .:{ '" & Decrypt(AdminDataReader(4).ToString()) & "' }:. ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
LinkLabel2.Visible = True
AdminConnection.Close()
Else
MessageBox.Show("Incorect input!!! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
AdminConnection.Close()
End If
Else
MessageBox.Show("UserID is wrong!!! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
AdminConnection.Close()
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Data Error")
Exit Sub
End Try
End Sub
'Decryption
Public Function Decrypt(Decryption As String) As String
Dim encodedtext As New UTF8Encoding
Dim decode As Decoder = encodedtext.GetDecoder
Dim code_byte As Byte() = Convert.FromBase64String(Decryption)
Dim charcount As Integer = decode.GetCharCount(code_byte, 0, code_byte.Length)
Dim decode_char As Char() = New Char(charcount - 1) {}
decode.GetChars(code_byte, 0, code_byte.Length, decode_char, 0)
Dim decryptext As New String(decode_char)
Return decryptext
End Function
Private Sub FrmForgetPass_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RoundButtonCheck(btnCheck)
RoundButtonClear(btnClear)
RoundButtonClose(btnClose)
dtpDOB.Value = Today
End Sub
End Class