-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.aspx.cs
96 lines (88 loc) · 2.78 KB
/
Menu.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Input;
using Restaurant003.App_Code;
namespace Restaurant003
{
public partial class Menu : System.Web.UI.Page
{
DataUtil data = new DataUtil();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
HienThi();
}
if (Session["email"] != null)
{
username.Text = Session["email"].ToString().Substring(0, 8);
btndn.Visible = false;
btndk.Visible = false;
}
else
{
username.Text = "Tài khoản";
btndx.Visible = false;
}
}
public void HienThi()
{
DataList1.DataSource = data.LayDsMonAn();
DataBind();
}
protected void ChoVaoGio_Click(object sender, CommandEventArgs e)
{
if (e.CommandName == "choVaoGio")
{
List<CartItem> dsMon = (List<CartItem>)Session["cartItems"];
if (dsMon == null)
{
dsMon = new List<CartItem>();
}
int m = Convert.ToInt16(e.CommandArgument);
Restaurant003.App_Code.MonAn mon = data.Lay1Mon(m);
CartItem item = new CartItem();
item.itemId = mon.maMon;
item.itemName = mon.tenMon;
item.quantity = 1;
item.price = mon.donGia;
item.subTotal = item.quantity * item.price;
if (dsMon.Contains(item))
{
int i = dsMon.IndexOf(item);
dsMon[i].quantity++;
dsMon[i].subTotal = dsMon[i].quantity * dsMon[i].price;
}
else
{
dsMon.Add(item);
}
Session["cartItems"] = dsMon;
Session["itemsQuantity"] = dsMon.Count;
}
}
protected void logout(object sender, EventArgs e)
{
Session.RemoveAll();
Response.Redirect("Home.aspx");
}
protected void btnTimKiem_Click(object sender, EventArgs e)
{
string ten = txtTimKiem.Text;
if (data.LayDsMonAnTheoTen(ten).Count != 0)
{
DataList1.DataSource = data.LayDsMonAnTheoTen(ten);
DataBind();
}
else
{
DataList1.Visible = false;
message.Text = "Không có món ăn nào có tên: " + txtTimKiem.Text;
}
}
}
}