-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonAn.aspx.cs
109 lines (100 loc) · 3.24 KB
/
MonAn.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;
using Restaurant003.App_Code;
namespace Restaurant003
{
public partial class MonAn : System.Web.UI.Page
{
DataUtil data = new DataUtil();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
HienThi();
txtTimDmMon.DataSource = data.LayDm();
txtTimDmMon.DataTextField = "tenDm";
txtTimDmMon.DataValueField = "maDm";
DataBind();
}
if (ddlMaDm.SelectedValue == "Tên món")
{
txtTimTenMon.Visible = true;
txtTimDmMon.Visible = false;
}
else
{
txtTimTenMon.Visible = false;
txtTimDmMon.Visible = true;
}
}
public void HienThi()
{
gridMon.DataSource = data.LayDsMonAn();
DataBind();
}
protected void gridMon_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridMon.PageIndex = e.NewPageIndex;
HienThi();
}
protected void gridMon_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Xoa_Click(object sender, CommandEventArgs e)
{
if(e.CommandName == "xoa")
{
int m = Convert.ToInt16(e.CommandArgument);
data.XoaMon(m);
HienThi();
}
}
protected void Sua_Click(object sender, CommandEventArgs e)
{
if (e.CommandName == "sua")
{
int m = Convert.ToInt16(e.CommandArgument);
Restaurant003.App_Code.MonAn mon = data.Lay1Mon(m);
Session["mon"] = mon;
Response.Redirect("SuaMon.aspx");
}
}
protected void btnTimKiem_Click(object sender, EventArgs e)
{
if (ddlMaDm.SelectedValue == "Danh mục")
{
int maDm = int.Parse(txtTimDmMon.SelectedValue);
if(data.LayDsMonAnTheoDm(maDm).Count == 0)
{
testdm.Text = "Không tìm thấy món ăn nào có danh mục này";
gridMon.Visible = false;
}
else
{
gridMon.Visible = true;
gridMon.DataSource = data.LayDsMonAnTheoDm(maDm);
DataBind();
}
}
if(ddlMaDm.SelectedValue == "Tên món")
{
string tenMon = txtTimTenMon.Text;
if(data.LayDsMonAnTheoTen(tenMon).Count == 0)
{
testdm.Text = "Không tìm thấy món ăn nào có tên này";
gridMon.Visible = false;
}
else
{
gridMon.Visible = true;
gridMon.DataSource = data.LayDsMonAnTheoTen(tenMon);
DataBind();
}
}
}
}
}