-
Notifications
You must be signed in to change notification settings - Fork 0
/
DangNhap.aspx.cs
93 lines (85 loc) · 2.89 KB
/
DangNhap.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;
public partial class DangNhap : System.Web.UI.Page
{
CSDL x = new CSDL();
protected void Page_Load(object sender, EventArgs e)
{
Session["Tendangnhap"] = txttendangnhap.Text;
}
protected void btndangnhap_Click(object sender, EventArgs e)
{
clDangKyTT dangky = new clDangKyTT();
ketnoi.cmd = new System.Data.SqlClient.SqlCommand("login_form", ketnoi.getconn());
ketnoi.cmd.CommandType = System.Data.CommandType.StoredProcedure;
ketnoi.cmd.Parameters.AddWithValue("@taikhoan", txttendangnhap.Text);
ketnoi.cmd.Parameters.AddWithValue("@matkhau", txtpassword.Text);
ketnoi.rd = ketnoi.cmd.ExecuteReader();
bool login = ketnoi.rd.Read();
if (login)
{
int check = phanquyen(txttendangnhap.Text);
switch (check)
{
case 2:
Response.Write("<script> alert('Đăng nhập thành công')</script>");
Response.Redirect("~/admin/trangadmin.aspx");
txttendangnhap.Focus();
txttendangnhap.Text = "";
break;
case 1:
Response.Write("<script>alert('Đăng nhập thành công')");
Response.Redirect("Default.aspx");
break;
}
}
else
{
Response.Write("<script> alert('Sai tên đăng nhập hoặc mật khẩu')</script>");
return;
}
//clDangKyTT dangky = new clDangKyTT();
//if(dangky.kiemtraid(int value("1"))
//{
// Response.Write("<script> alert('user')</script>");
//}
//else
//{
// dangky.getID(txttendangnhap.Text,txtpassword.Text);
// Response.Redirect("tranguser.aspx");
//}
}
public int phanquyen(string input)
{
ketnoi.cmd = new System.Data.SqlClient.SqlCommand("kiemtraquyen", ketnoi.getconn());
ketnoi.cmd.CommandType = System.Data.CommandType.StoredProcedure;
ketnoi.cmd.Parameters.AddWithValue("@Tendangnhap", input);
int maquyen = (int)ketnoi.cmd.ExecuteScalar();
return maquyen;
}
//private void CkeckGioHang()
//{
// if (Session["Giohang"] != null)
// {
// DataTable dt = new DataTable();
// dt = (DataTable)Session["Giohang"];
// System.Int32 Quantity = 0;
// foreach (DataRow r in dt.Rows)
// {
// Quantity += Convert.ToInt32(r["SoLuong"]);
// lbcart.Text = Quantity.ToString();
// }
// }
// else
// {
// lbcart.Text = "O";
// }
//}
}