-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrm_ForgotPassword.cs
More file actions
128 lines (119 loc) · 4.63 KB
/
Frm_ForgotPassword.cs
File metadata and controls
128 lines (119 loc) · 4.63 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace Hostel_Managment_System
{
public partial class Frm_ForgotPassword : Form
{
DB_Function function = new DB_Function();
string query;
public Frm_ForgotPassword()
{
InitializeComponent();
}
private void BtnBack_Click(object sender, EventArgs e)
{
FrmLofgin lf = new FrmLofgin();
this.Close();
lf.Show();
}
private void BtnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
//BtnContinue
private void BtnLogin_Click(object sender, EventArgs e)
{
if (TxtUID.Text != "")
{
MySqlConnection con = new MySqlConnection("data source = MySQL Community Server - GPL;integrated security = True;server=localhost;user=root;database=Hostel;port=3306;password=jinu0292");
con.Open();
MySqlCommand cmd = new MySqlCommand("select * from UserDetails where UserID = '" + TxtUID.Text + "'", con);
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
if (dataTable.Rows.Count > 0)
{
for (int i = 0; i < dataTable.Rows.Count; i++)
{
if (TxtUID.Text != "" && TxtPass.Text != "" && TxtConfPass.Text != "")
{
if (TxtUID.Text == dataTable.Rows[i]["UserID"].ToString())
{
if (TxtPass.Text == TxtConfPass.Text)
{
try
{
query = "update UserDetails set Password = '" + TxtConfPass.Text + "' where UserID = '" + TxtUID.Text + "'";
function.SetData(query, "Details updated.");
FrmLofgin lf = new FrmLofgin();
this.Close();
lf.Show();
}
catch
{
LblMsg_UserNotExist.Visible = true;
TxtUID.Text = "";
TxtPass.Text = "";
TxtConfPass.Text = "";
}
}
else
{
LblMsg_PasNotSame.Visible = true;
}
}
else
{
LblMsg_UserNotExist.Visible = true;
TxtUID.Text = "";
TxtPass.Text = "";
TxtConfPass.Text = "";
}
}
else
{
LblMsg_UserNotExist.Visible = true;
TxtUID.Text = "";
TxtPass.Text = "";
TxtConfPass.Text = "";
}
}
}
}
else
{
LblMsg_UserNotExist.Visible = true;
LblMsg_UserNotExist.Text = "Enter user ID.";
}
}
private void TxtUID_Click(object sender, EventArgs e)
{
if (LblMsg_UserNotExist.Visible == true)
LblMsg_UserNotExist.Visible = false;
else
LblMsg_UserNotExist.Visible = false;
}
private void TxtPass_Click(object sender, EventArgs e)
{
if (LblMsg_PasNotSame.Visible == true)
LblMsg_PasNotSame.Visible = false;
else
LblMsg_PasNotSame.Visible = false;
}
private void TxtConfPass_Click(object sender, EventArgs e)
{
if (LblMsg_PasNotSame.Visible == true)
LblMsg_PasNotSame.Visible = false;
else
LblMsg_PasNotSame.Visible = false;
}
}
}