forked from lethienantran/MenuManagementService
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.aspx.cs
114 lines (104 loc) · 4.18 KB
/
Home.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
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SelfOrderManagementSystem
{
public partial class Home : System.Web.UI.Page
{
string CS = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] != null)
{
SqlConnection con = new SqlConnection(CS);
SqlDataAdapter da = new SqlDataAdapter("select * from users where" +
" UserID = " + Convert.ToInt32(Session["UserID"].ToString()), con);
DataTable dt = new DataTable();
da.Fill(dt);
DataRow dr = dt.Rows[0];
welcomeLabel.Visible = true;
welcomeLabel.Text = "" + dr["BrandName"];
messageLabel.Visible = false;
}
else
{
Response.Redirect("StartHome.aspx");
}
}
protected void addButton_Click(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
Response.Redirect("StartHome.aspx");
}
else
{
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand command = new SqlCommand("AddCategory", con);
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Parameters.AddWithValue("@userID", Session["UserID"].ToString());
command.Parameters.AddWithValue("@categoryname", categoryText.Text);
command.Parameters.AddWithValue("@itemname", nameText.Text);
command.Parameters.AddWithValue("@itemdescription", descriptionText.Text);
command.Parameters.AddWithValue("@itemprice", priceText.Text);
con.Open();
command.ExecuteNonQuery();
messageLabel.Visible = true;
messageLabel.Text = nameText.Text + " is added to the menu";
categoryText.Text = "";
nameText.Text = "";
descriptionText.Text = "";
priceText.Text = "";
}
}
}
protected void deleteButton_Click(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
Response.Redirect("StartHome.aspx");
}
else
{
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand command = new SqlCommand("DeleteCategory", con);
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Parameters.AddWithValue("@userID", Session["UserID"].ToString());
command.Parameters.AddWithValue("@categoryname", categoryText.Text);
command.Parameters.AddWithValue("@itemname", nameText.Text);
command.Parameters.AddWithValue("@itemdescription", descriptionText.Text);
command.Parameters.AddWithValue("@itemprice", priceText.Text);
con.Open();
command.ExecuteNonQuery();
messageLabel.Visible = true;
messageLabel.Text = nameText.Text + " is deleted from the menu";
categoryText.Text = "";
nameText.Text = "";
descriptionText.Text = "";
priceText.Text = "";
}
}
}
protected void showMenuButton_Click(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
Response.Redirect("StartHome.aspx");
}
else
{
Response.Redirect("StartOrderDisplay.aspx");//TODO: redirect to start order
}
}
}
}