-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuAdd.Designer.cs
More file actions
224 lines (172 loc) · 5.96 KB
/
Copy pathMenuAdd.Designer.cs
File metadata and controls
224 lines (172 loc) · 5.96 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
using SmartAdmin.Controls;
using SmartAdmin.Data;
using SmartAdmin.Utils;
using System;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace SmartAdmin
{
public class MenuAdd : System.Web.UI.Page
{
protected SmartAdmin.Controls.HeaderBox HeaderBox;
protected SmartAdmin.Controls.CopyrightBox CopyrightBox;
protected SmartAdmin.Controls.SubmenuBox SubmenuBox;
protected DropDownList LstType;
protected TextBox TxtKeyID;
protected TextBox TxtEnglish;
protected TextBox TxtThai;
protected TextBox TxtFrench;
protected TextBox TxtPrice;
protected Image ImgError;
protected Button BtnSave;
protected Button BtnCancel;
protected TextBox TxtDescription;
protected ValidationSummary ValidationSummary1;
protected RequiredFieldValidator RequiredFieldValidator1;
protected RequiredFieldValidator RequiredFieldValidator2;
protected RequiredFieldValidator RequiredFieldValidator3;
protected RangeValidator RangeValidator1;
protected TextBox TxtShortName;
protected RequiredFieldValidator RequiredFieldValidator4;
protected RadioButtonList MenuSet;
protected Button BtnAdd;
protected DataGrid SubMenuGrid;
protected DropDownList LstSubMenu;
protected DropDownList LstMenuType;
protected Label TxtMenuID;
protected TextBox TxtEstimateTime;
protected HtmlTableRow MenuSetInfo_Row;
protected HtmlTableRow MenuSetType_Row;
protected HtmlTableRow MenuSetMenu_Row;
private DataTable dt = new DataTable();
protected TextBox TxtKeyText;
protected RequiredFieldValidator Requiredfieldvalidator5;
protected RegularExpressionValidator RegularExpressionValidator1;
private DataRow row;
public MenuAdd()
{
}
private void BackPage()
{
base.Response.Redirect(Pages.Url(this, Pages.MENU_LIST_PAGE));
}
private void BtnAdd_Click(object sender, EventArgs e)
{
this.row = this.dt.NewRow();
this.row["menuid"] = this.LstSubMenu.SelectedItem.Value;
this.row["menuname"] = this.LstSubMenu.SelectedItem.Text;
this.dt.Rows.Add(this.row);
this.LoadSubMenuGrid();
}
private void BtnCancel_Click(object sender, EventArgs e)
{
this.BackPage();
}
private void BtnSave_Click(object sender, EventArgs e)
{
int num = SmartAdmin.Data.Menu.MenuInsert(this.TxtKeyID.Text, this.LstType.SelectedItem.Value, this.TxtEnglish.Text, this.TxtThai.Text, this.TxtFrench.Text, this.TxtShortName.Text, this.TxtDescription.Text, this.TxtPrice.Text, this.MenuSet.SelectedItem.Value, this.TxtEstimateTime.Text);
for (int i = 0; i < this.dt.Rows.Count; i++)
{
SmartAdmin.Data.Menu.SubMenuInsert(num, int.Parse(this.dt.Rows[i]["menuid"].ToString()));
}
this.NextPage();
}
private void InitializeComponent()
{
this.MenuSet.SelectedIndexChanged += new EventHandler(this.MenuSet_SelectedIndexChanged);
this.BtnAdd.Click += new EventHandler(this.BtnAdd_Click);
this.SubMenuGrid.PageIndexChanged += new DataGridPageChangedEventHandler(this.SubMenuGrid_PageIndexChanged);
this.SubMenuGrid.DeleteCommand += new DataGridCommandEventHandler(this.SubMenuGrid_DeleteCommand);
this.BtnSave.Click += new EventHandler(this.BtnSave_Click);
this.BtnCancel.Click += new EventHandler(this.BtnCancel_Click);
base.Load += new EventHandler(this.Page_Load);
}
private void LoadMenu()
{
AdminMenu.SetMenu(this, this.HeaderBox, this.SubmenuBox, this.CopyrightBox);
}
private void LoadMenuType()
{
this.LstType.DataSource = SmartAdmin.Data.Master.MenuTypeList();
this.LstType.DataTextField = "MenuTypeName";
this.LstType.DataValueField = "MenuTypeID";
this.LstType.DataBind();
this.LstMenuType.DataSource = SmartAdmin.Data.Master.MenuTypeList();
this.LstMenuType.DataTextField = "MenuTypeName";
this.LstMenuType.DataValueField = "MenuTypeID";
this.LstMenuType.DataBind();
this.LstMenuType.SelectedIndex = 0;
this.LoadSubMenu(int.Parse(this.LstMenuType.SelectedItem.Value));
}
private void LoadSubMenu(int menutypeid)
{
this.LstSubMenu.DataSource = SmartAdmin.Data.Menu.SubMenuByTypeList(menutypeid);
this.LstSubMenu.DataTextField = "MenuNameEnglish";
this.LstSubMenu.DataValueField = "MenuID";
this.LstSubMenu.DataBind();
}
private void LoadSubMenuGrid()
{
this.SubMenuGrid.DataSource = this.dt;
this.SubMenuGrid.DataBind();
this.SubMenuGrid.Visible = true;
}
private void LstMenuType_SelectedIndexChanged(object sender, EventArgs e)
{
this.LoadSubMenu(int.Parse(this.LstMenuType.SelectedItem.Value));
}
private void MenuSet_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.MenuSet.SelectedItem.Value == "1")
{
this.MenuSetInfo_Row.Visible = true;
this.MenuSetType_Row.Visible = true;
this.MenuSetMenu_Row.Visible = true;
return;
}
this.MenuSetInfo_Row.Visible = false;
this.MenuSetType_Row.Visible = false;
this.MenuSetMenu_Row.Visible = false;
}
private void NextPage()
{
base.Response.Redirect(Pages.Url(this, Pages.MENU_EDIT_PAGE));
}
protected override void OnInit(EventArgs e)
{
this.InitializeComponent();
base.OnInit(e);
}
private void Page_Load(object sender, EventArgs e)
{
this.LoadMenu();
if (base.IsPostBack)
{
this.dt = (DataTable)this.Session["submenu"];
return;
}
this.dt.Columns.Add("menuid", typeof(string));
this.dt.Columns.Add("menuname", typeof(string));
this.Session["submenu"] = this.dt;
this.TxtEstimateTime.Text = "00:00";
this.MenuSetInfo_Row.Visible = false;
this.MenuSetType_Row.Visible = false;
this.MenuSetMenu_Row.Visible = false;
this.LoadMenuType();
}
private void SubMenuGrid_DeleteCommand(object source, DataGridCommandEventArgs e)
{
this.dt.Rows.RemoveAt(e.Item.ItemIndex);
this.LoadSubMenuGrid();
}
private void SubMenuGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
this.SubMenuGrid.CurrentPageIndex = e.NewPageIndex;
this.LoadSubMenuGrid();
}
}
}