-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrm_CahgePass.cs
120 lines (110 loc) · 4.37 KB
/
Frm_CahgePass.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
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_CahgePass : Form
{
DB_Function function = new DB_Function();
string query;
public Frm_CahgePass()
{
InitializeComponent();
}
private void BtnBack_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnChange_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.");
this.Close();
}
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;
}
}
}