예제 #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            User user = ConnectionClass.LoginUser(txtLogin.Text, txtPassword.Text);

            if (user != null)
            {
                Session["login"] = user.Name;
                Session["type"]  = user.Type;

                Response.Redirect("HomePage.aspx");
            }
            else
            {
                lblError.Text = "Login Failed";
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string name  = txtName.Text;
                string type  = txtType.Text;
                double price = Convert.ToDouble(txtPrice.Text);
                string image = "../images/menu images/" + ddImage.SelectedValue;

                Menu menu = new Menu(name, type, price, image);
                ConnectionClass.AddMenu(menu);
                lblResult.Text = "Upload Successfully!";
                ClearTextFields();
            }
            catch (Exception)
            {
                lblResult.Text = "Upload failed";
            }
        }
        private void FillPage()
        {
            ArrayList menuList = new ArrayList();

            if (!IsPostBack)
            {
                menuList = ConnectionClass.GetMenuByType("%");
            }
            else
            {
                menuList = ConnectionClass.GetMenuByType(DropDownList1.SelectedValue);
            }
            StringBuilder sb = new StringBuilder();

            foreach (Menu menu in menuList)
            {
                sb.Append(string.Format(@"<table class='menuTable'>
                <tr>
                    <th rowspan='3' width='150px'><img runat='server' src='{3}' /></th>
                    <th width='50px'> Name:</th>
                    <td>{0}</td>
                <tr>

                <tr>
                    <th>Type:</th>
                    <td>{1}<td>
                <tr>

                <tr>
                    <th>Price:</th>
                    <td>{2} Rs<td>
                <tr>

              </table>",
                                        menu.name, menu.type, menu.price, menu.image));

                lblOutput.Text = sb.ToString();
            }
        }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            User user = new User(txtName.Text, txtPassword.Text, txtEmail.Text, "user");

            lblResult.Text = ConnectionClass.RegisterUser(user);
        }