-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForgotPassword.cs
136 lines (102 loc) · 3.88 KB
/
ForgotPassword.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
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 System.Data.SqlClient;
namespace Movie_Ticketing_System
{
public partial class ForgotPassword : Form
{
String ConnectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Ali Khattak\Documents\Visual Studio 2013\Projects\Movie Ticketing System\Movie Ticketing System\CinemaTicketing_DBS.mdf;Integrated Security=True";
public ForgotPassword()
{
InitializeComponent();
label5.Visible = false;
textBox2.Visible = false;
SaveChanges.Visible = false;
NextButton.Visible = true;
}
private void Sign_btn_CL_Click(object sender, EventArgs e)
{
String User_Email_Validate = textBox1.Text;
if (User_Email_Validate == "")
{
string message = "Provide Email First!";
string title = "Error !";
MessageBox.Show(message, title);
return;
}
try
{
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
string query = "SELECT * FROM UserPage WHERE Email=@Email";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@Email", User_Email_Validate);
SqlDataAdapter Adapter = new SqlDataAdapter(command);
DataTable dataTable = new DataTable();
Adapter.Fill(dataTable);
if (dataTable.Rows.Count == 1)
{
label5.Visible = true;
textBox2.Visible = true;
SaveChanges.Visible = true;
NextButton.Visible = false;
}
else
{
string message = "Invalid Email! \nNo Email Exist.";
string title = "Error !";
MessageBox.Show(message, title);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void SaveChanges_Click(object sender, EventArgs e)
{
string UserNewPassword = textBox2.Text;
if (UserNewPassword == "")
{
string message = "Provide Email First!";
string title = "Error !";
MessageBox.Show(message, title);
return;
}
else
{
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
string User_Email_Validate = textBox1.Text;
string query = "UPDATE UserPage SET Password=@NewPassword WHERE Email=@Emaill";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@NewPassword", UserNewPassword);
command.Parameters.AddWithValue("@Emaill", User_Email_Validate);
command.ExecuteNonQuery();
connection.Close();
MessageBox.Show("Password Changed Successfully", "Updated");
textBox2.Text = string.Empty;
textBox1.Text = string.Empty;
}
}
private void pictureBox5_Click(object sender, EventArgs e)
{
Form1 form = new Form1();
form.Show();
this.Hide();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
Customer_Login login = new Customer_Login();
login.Show();
this.Hide();
}
}
}