/
DangKy.aspx.cs
106 lines (103 loc) · 3.2 KB
/
DangKy.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
using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
public partial class DangKy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["nguoidung"] == null)
{
mtvRegister.ActiveViewIndex = 0;
}
else
mtvRegister.ActiveViewIndex = 1;
}
LinQtoSQLDataContext db = new LinQtoSQLDataContext();
protected void imgbtnDangKy_Click(object sender, ImageClickEventArgs e)
{
string match = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
Regex reg = new Regex(match);
string email = txtEmail.Text;
if (txtTenDangNhap.Text == "")
{
lblErrTenDangNhap_DangKy.Visible = true;
}
else if (txtMatKhau.Text == "")
{
lblErrMatKhauDK.Visible = true;
}
else if (txtXacNhanMK.Text != txtMatKhau.Text)
{
lblErrXacNhanMK.Visible = true;
}
else if (txtHoTen.Text == "")
{
lblErrTenKH.Visible = true;
}
else if (txtDiaChi.Text == "")
{
lblErrDiaChi.Visible = true;
}
else if (txtCMND.Text == "")
{
lblErrSoCMND.Visible = true;
}
else if (txtEmail.Text == "")
{
lblErrEmail.Visible = true;
}
else if (txtSDT.Text == "")
{
lblErrSDT.Visible = true;
}
else if (!reg.IsMatch(email))
{
lblErrEmail.Visible = true;
}
else
{
try
{
var qrkiemtra = from m in db.Nguoi_Dungs
where m.Ten_Nguoi_Dung == txtTenDangNhap.Text
select m;
if (qrkiemtra.Count() == 0)
{
Nguoi_Dung user = new Nguoi_Dung();
user.Admin = 0;
user.Ten_Nguoi_Dung = txtTenDangNhap.Text;
user.Mat_Khau = txtMatKhau.Text;
user.Ho_Ten = txtHoTen.Text;
user.Gioi_Tinh = ddlGioiTinh.SelectedItem.Value;
user.Dia_Chi = txtDiaChi.Text;
user.CMND = txtCMND.Text;
user.Email = txtEmail.Text;
user.SDT = txtSDT.Text;
db.Nguoi_Dungs.InsertOnSubmit(user);
db.SubmitChanges();
//Session["dangky"] = "1";
Response.Redirect("~/Thanh_Cong.aspx?capnhattt=&capnhatmk=&dangky=1&thanhtoan=");
}
else
{
lbErr.Text = "Tên Đăng Nhập đã có người sử dụng";
//Session["dangky"] = "0";
}
}
catch (Exception ex)
{
lbErr.Text = ex.Message;
}
}
}
protected void imbbtnDangXuat_DangKy_Click(object sender, ImageClickEventArgs e)
{
Session["nguoidung"] = null;
Response.Redirect("~/Default.aspx");
}
}