-
Notifications
You must be signed in to change notification settings - Fork 0
/
PasswordRetrive.aspx.cs
113 lines (103 loc) · 3.05 KB
/
PasswordRetrive.aspx.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
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using AlarmasABC.BLL.ProcessUser;
using AlarmasABC.DAL.Queries;
using AlarmasABC.Utilities;
public partial class CompanyAdmin_PasswordRetrive : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["userName"] != null && Session["email"] != null)
{
txtUserName.Text = Session["userName"].ToString();
txtEmail.Text = Session["email"].ToString();
Session["userName"] = null;
Session["email"] = null;
}
}
}
private bool userIsValid()
{
try
{
string strSQL = "SELECT * FROM tblUser WHERE login = '" + txtUserName.Text.Trim() +
"' AND email = '" + txtEmail.Text.Trim() + "';";
DataSet _ds = new DataSet();
ExecuteSQL exec = new ExecuteSQL();
_ds = exec.getDataSet(strSQL);
if (_ds.Tables[0].Rows.Count > 0)
{
Session["userID"] = _ds.Tables[0].Rows[0]["uID"].ToString();
Session["userName"] = _ds.Tables[0].Rows[0]["login"].ToString();
Session["securityQID"] = _ds.Tables[0].Rows[0]["securityQuestion"].ToString();
Session["email"] = _ds.Tables[0].Rows[0]["email"].ToString();
}
else
{
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "The supplied user name and email does not exist in our database.";
return false;
}
}
catch (Exception ex)
{
Console.WriteLine("PasswordRetrive::userIsValid(): " + ex.Message.ToString());
}
finally
{
}
return true;
}
private void SendEmail(string email, string subject, string text)
{
try
{
// Send contact email....
Mailer.SendMailMessage("webmaster@xtremek.com", email, "", "",
subject, text);
}
catch (Exception ex)
{
Console.WriteLine("SendMail(): " + ex.Message.ToString());
}
}
private bool isValidData()
{
if (txtUserName.Text == "")
{
lblMessage.Text = "Please Enter Login Name.";
lblMessage.ForeColor = System.Drawing.Color.Red;
return false;
}
else if (txtEmail.Text == "")
{
lblMessage.Text = "Please Enter Email Address.";
lblMessage.ForeColor = System.Drawing.Color.Red;
return false;
}
return true;
}
protected void btnOk_Click(object sender, EventArgs e)
{
if (isValidData())
{
if (userIsValid())
{
Response.Redirect("PasswordRetrive_p2.aspx");
}
}
}
}