-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmForgotPass.cs
224 lines (206 loc) · 7.98 KB
/
frmForgotPass.cs
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
using System;
using System.Data;
using System.Windows.Forms;
namespace ShreeWellnessCenter
{
public partial class frmForgotPass : Form
{
public frmForgotPass()
{
InitializeComponent();
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void lblInvalidUsrPassword_Click(object sender, EventArgs e)
{
}
private void btnBack_Click(object sender, EventArgs e)
{
frm_login frm_Login = new frm_login();
this.Hide();
frm_Login.Show();
}
private void frmForgotPass_Load(object sender, EventArgs e)
{
txtSecretKey.Select();
}
private void btnUpdatePass_Click(object sender, EventArgs e)
{
if(txtSecretKey.Text == "0292")
{
lblInvalidKey.Visible = false;
if (txtUsrName.Text != "")
{
db DB = new db();
//Query for comparing data from database recard
string txt = "admin";
string usrname = txtUsrName.Text.ToString();
string upass = txtUsrPass.Text.ToString();
string pass = txtUsrPass.Text.ToString();
string query1 = "select user_id, password,user_type from user_details where user_type = 'admin'";
DataSet dataSet = DB.GetData(query1);
if (dataSet.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
{
if (dataSet.Tables[0].Rows[i]["User_ID"].ToString() == usrname)
{
lblInvalidUsrName.Visible = false;
if (txtUsrPass.Text != "")
{
lblPas.Visible = false;
try
{
//query for uppdate
string query2 = "update user_details set password ='" + upass + "' where user_id = '" + usrname + "'";
DataSet dataSet2 = DB.GetData(query2);
DialogResult = MessageBox.Show("अपडेट Sucessfull !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (DialogResult == DialogResult.OK)
{
txtSecretKey.Text = "";
txtUsrName.Text = "";
txtUsrPass.Text = "";
this.Close();
frm_login lf = new frm_login();
lf.Show();
}
}
catch
{
MessageBox.Show("अपडेट Fail !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtSecretKey.Text = "";
txtUsrName.Text = "";
txtUsrPass.Text = "";
}
}
else
{
lblPas.Visible = true;
txtUsrPass.Select();
}
}
else
{
if (txtUsrName.Text == "")
{
lblInvalidUsrName.Visible = true;
txtUsrName.Select();
}
else
{
lblInvalidUsrName.Visible = true;
lblInvalidUsrName.Text = "अमान्य उपयोगकर्ता !";
txtUsrName.Select();
}
}
}
}
else
{
MessageBox.Show(" अमान्य विवरण !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
lblInvalidUsrName.Visible = true;
txtUsrName.Select();
}
}
else
{
if (txtSecretKey.Text != "")
{
lblInvalidKey.Text = "अमान्य कुंजी !";
lblInvalidKey.Visible = true;
txtSecretKey.Select();
}
else
{
lblInvalidKey.Text = "कुंजी लिखें !";
lblInvalidKey.Visible = true;
txtSecretKey.Select();
}
}
}
private void txtSecretKey_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter ||e.KeyCode == Keys.Down || e.KeyCode== Keys.Tab)
{
if(txtSecretKey.Text !="")
{
lblInvalidKey.Visible=false;
txtUsrName.Select();
}
else
{
lblInvalidKey.Text = "कुंजी लिखें !";
lblInvalidKey.Visible = true;
txtSecretKey.Select();
}
}
else if(e.KeyCode == Keys.Escape|| e.KeyCode == Keys.Up) { txtSecretKey.SelectAll(); }
}
private void txtSecretKey_Click(object sender, EventArgs e)
{
lblInvalidKey.Visible = false;
}
private void txtUsrName_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Down || e.KeyCode == Keys.Tab)
{
if (txtUsrName.Text != "")
{
lblInvalidUsrName.Visible=false;
txtUsrPass.Select();
}
else
{
lblInvalidUsrName.Visible = true;
txtUsrName.Select();
}
}
else if (e.KeyCode == Keys.Escape )
{
txtUsrName.SelectAll();
}
else if(e.KeyCode == Keys.Up )
{
txtSecretKey.Select();
}
}
private void txtUsrName_Click(object sender, EventArgs e)
{
lblInvalidUsrName.Visible = false;
}
private void txtUsrPass_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Down || e.KeyCode == Keys.Tab)
{
if (txtUsrPass.Text != "")
{
lblPas.Visible = false;
btnUpdatePass.Select();
}
else
{
lblPas.Visible = true;
txtUsrPass.Select();
}
}
else if (e.KeyCode == Keys.Escape)
{
txtUsrPass.SelectAll();
}
else if (e.KeyCode == Keys.Up)
{
txtUsrName.Select();
}
}
private void txtUsrPass_Click(object sender, EventArgs e)
{
lblPas.Visible=false;
}
}
}