-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChange_Password.xaml.cs
152 lines (131 loc) · 4.36 KB
/
Change_Password.xaml.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
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
namespace Money_Savings_Tool
{
/// <summary>
/// Interaction logic for Change_Password.xaml
/// </summary>
public partial class Change_Password : Window
{
string EMAIL, password;
SqlCommand command;
DatabaseConnection db = new DatabaseConnection();
public Change_Password(string email)
{
EMAIL = email;
InitializeComponent();
}
void GetPassword()
{
string sql = "select * from Registration where Email like '" + EMAIL + "' ";
SqlCommand command = new SqlCommand(sql, db.con);
DataTable dt = new DataTable();
dt.Load(command.ExecuteReader());
try
{
password = dt.Rows[0]["Password"].ToString();
// check = true;
Console.WriteLine("Balance mane taka: " + password);
}
catch (Exception)
{
Console.WriteLine("Old Password does not match!!!");
}
}
Boolean CheckPassWordBox()
{
Boolean check = false;
string Old_Password = old_password.Password;
string New_Password = new_password.Password;
string Confirm_New_Password = confirm_new_password.Password;
if (Old_Password == "")
{
Blank_Old_Password.Content = "Old Password Required !!";
}
else
{
Blank_Old_Password.Content = "";
}
if (New_Password == "")
{
Blank_New_Password.Content = "New Password Required !!";
}
else
{
Blank_New_Password.Content = "";
}
if (Confirm_New_Password == "")
{
Blank_New_Confirm_Password.Content = "Confirm New Password Required !!";
}
else
{
Blank_New_Confirm_Password.Content = "";
}
if (Old_Password != "" && New_Password != "" && Confirm_New_Password!="")
{
if (New_Password .Equals(Confirm_New_Password))
{
check = true;
}
else
{
check = false;
MessageBox.Show("Password and Confirm password Doesn't match !! ");
}
}
return check;
}
private void Back_Button(object sender, RoutedEventArgs e)
{
All_Menu.Settings s = new All_Menu.Settings(EMAIL);
this.Hide();
s.Show();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (CheckPassWordBox()==true)
{
try
{
string sql2 = "update [Registration] set Password = '" + new_password.Password + "' where Email like '" + EMAIL + "'";
command = new SqlCommand(sql2, db.con);
int result = command.ExecuteNonQuery();
if((MyCheckBox.IsChecked== true))
{
Login l = new Login();
this.Hide();
l.Show();
}
else
{
Homepage h = new Homepage(EMAIL);
this.Hide();
h.Show();
}
}
catch (Exception)
{
Console.WriteLine(e);
}
}
//else
//{
// MessageBox.Show("Old Password Doesn't match !! ");
//}
}
}
}