/
UserRegisterConfirm.aspx.cs
109 lines (103 loc) · 4.55 KB
/
UserRegisterConfirm.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class UserRegisterConfirm : System.Web.UI.Page
{
#region Database Config
string parameterChar = "@"; //SQLServer=@ MySQL=?
clsSQL.DBType dbType = clsSQL.DBType.SQLServer;
string cs = "cs";
#endregion
clsDefault clsDefault = new clsDefault();
clsSecurity clsSecurity = new clsSecurity();
clsSQL clsSQL = new clsSQL();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string id = clsDefault.URLRouting("id");
if (!string.IsNullOrEmpty(id))
{
string idDecrypt = clsSecurity.Decrypt(id);
string active = clsSQL.Return(
"SELECT Active FROM [User] WHERE UID=" + parameterChar + "UID",
new string[,] { { parameterChar + "UID", idDecrypt } },
dbType,
cs);
if (!string.IsNullOrEmpty(active))
{
if (active == "0")
{
string outSQL;
if (clsSQL.Update(
"[User]",
new string[,] { { "Active", "'1'" }, { "MWhen", "GETDATE()" } },
new string[,] { { "@UID", idDecrypt } },
"UID=@UID",
dbType,
cs,
out outSQL))
{
#region Mail to Admin
string outMessage;
string Name = clsSQL.Return(
"SELECT Username FROM [User] WHERE UID=" + parameterChar + "UID",
new string[,] { { parameterChar + "UID", idDecrypt } },
dbType,
cs);
clsMail clsMail = new clsMail();
if (!clsMail.SendTemplate(
"UserRegisterConfirmAdmin",
clsMail.GetEmailList("AutoSystemFrom"),
clsMail.GetEmailList("AdminTo"),
new string[,]{
{"[Username]",Name}
},
out outMessage))
{
ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail);
return;
}
#endregion
ucColorBox1.Redirect(
"/",
"ดำเนินการเสร็จสิ้น",
"ระบบยืนยันสถานะสมาชิกของคุณเรียบร้อยแล้ว");
}
else
{
ucColorBox1.Redirect(
"/",
"เกิดข้อผิดพลาด",
"ไม่พบรหัสยืนยันของคุณ");
}
}
else
{
ucColorBox1.Redirect(
"/",
"ดำเนินการเสร็จสิ้น",
"คุณเคยทำการยืนยันอีเมล์ไว้แล้ว");
}
}
else
{
ucColorBox1.Redirect(
"/",
"เกิดข้อผิดพลาด",
"ไม่พบรหัสยืนยันของคุณ");
}
}
else
{
ucColorBox1.Redirect(
"/",
"เกิดข้อผิดพลาด",
"ไม่พบรหัสยืนยันของคุณ");
}
}
}
}