/
template.master.cs
executable file
·99 lines (86 loc) · 2.37 KB
/
template.master.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class template : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
this.chaomung();
this.loadDanhMuc();
this.countShoppingCart();
this.xoaSessionMK();
this.dannhmuc();
}
// cau chao mung
private void chaomung()
{
if (Session["userPublic"] != null)
{
List<userpublicDAL> usp = (List<userpublicDAL>)Session["userPublic"];
lbTen.Text = usp[0].hoten;
lbtnLog.Text = "Thoát";
lbtnLog.PostBackUrl = "logout.aspx";
}
else
{
lbTen.Text = "Chào khách !";
lbtnLog.Text = "Đăng nhập";
lbtnLog.PostBackUrl = "dangnhap.aspx";
}
}
// danh muc :
private void loadDanhMuc()
{
danhmucBLL bs = new danhmucBLL();
menusubtitle.DataSource = bs.getMenu();
menusubtitle.DataBind();
}
//private void page()
//{
// string[] file = Request.CurrentExecutionFilePath.Split('/');
// string fileName = file[file.Length - 1];
//}
// dem so luong san pham trong gio hang
private void countShoppingCart()
{
if (Session["cart"] != null)
{
List<giohangDAL> cart = (List<giohangDAL>)Session["cart"];
if (cart.Count() > 0)
{
lbCountCart.Text = cart.Count().ToString();
}
}
else
{
lbCountCart.Visible = false;
}
}
// xoa session doi mat khau :
private void xoaSessionMK()
{
string[] file = Request.CurrentExecutionFilePath.Split('/');
string fileName = file[file.Length - 1];
if (fileName != "quenmatkhau-matkhaumoi.aspx")
{
if (Session["quenmatkhau"] != null)
{
Session.Remove("quenmatkhau");
}
}
}
// load danh muc tim kiem
private void dannhmuc()
{
danhmucBLL bs = new danhmucBLL();
IList<danhmucDAL> list = bs.getDanhMucTimKiem();
search_se.Items.Add("Tất cả");
for (int i = 0; i <= list.Count - 1; i++)
{
search_se.Items.Add(list[i].ten_danhmuc);
}
}
}