Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String username = Request.Cookies["user"].Value;

            if (!username.Equals("*****@*****.**"))
            {
                Response.Redirect("~/Default.aspx");
            }

            menuID = int.Parse(Request.Params[0]);
            if (menuID <= 0)
            {
                Response.Redirect("Menu.aspx");
            }

            db = new DbLayer();

            if (!this.IsPostBack)
            {
                SqlDataReader sr = db.GetMenuByID(menuID);
                sr.Read();
                shopID           = sr.GetInt32(1);
                tbMenuName.Text  = sr.GetString(2);
                tbMenuPrice.Text = sr.GetDouble(3).ToString();
                tbMenuDesc.Text  = sr.GetString(4);
                if (sr.GetString(5).Equals("1"))
                {
                    tbMenuPromo.Text = "TRUE";
                }
                else
                {
                    tbMenuPromo.Text = "FALSE";
                }
                tbMenuPromoPrice.Text = sr.GetDouble(6).ToString();
                Image1.ImageUrl       = sr.GetString(7);
                sr.Close();
                sr = null;
            }
            else
            {
                SqlDataReader sr = db.GetMenuByID(menuID);
                sr.Read();
                shopID = sr.GetInt32(1);
                sr.Close();
                sr = null;
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                userName = Request.Cookies["user"].Value;

                if (!userName.Equals("*****@*****.**"))
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }

            if (!this.IsPostBack)
            {
                DbLayer       dao    = new DbLayer();
                SqlDataReader reader = dao.GetAllShop(DropDownList1.Text, tbSearch.Text);

                lbTest.Text += "<table style='border: 1px #000000 solid;'>";
                lbTest.Text += " <tr style='background-color: yellow'> <th> Shop ID </th> <th> Shop Name </th> <th> Shop SubName </th> <th> Shop Introduce </th> <th> Shop Address </th> <th> Shop Phone </th> <th> Shop Region </th> <th> Image </th> <th> EDIT </th> <th> DELETE </th> <th> VIEW MENU </th> </tr>";

                while (reader.Read())
                {
                    lbTest.Text += "<tr style='background-color: #bfbeb8'>";
                    lbTest.Text += "<td> " + reader.GetInt32(0) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(1) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(2) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(3) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(4) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(5) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(6) + "</td>";
                    lbTest.Text += "<td><img src='" + reader.GetString(7) + "' width='100px' height='100px' /></td>";
                    lbTest.Text += "<td style='text-align:center;'> <a href=UpdateShop.aspx?shopID=" + reader.GetInt32(0) + "> EDIT </td>";
                    lbTest.Text += "<td style='text-align:center;'> <a href=DeleteShop.aspx?shopID=" + reader.GetInt32(0) + "> DELETE </td>";
                    lbTest.Text += "<td style='text-align:center;'> <a href=menu.aspx?shopID=" + reader.GetInt32(0) + "> GO </td>";
                    lbTest.Text += "</tr>";
                }

                lbTest.Text += " </table>";
                reader.Close();
                dao.closeConnection();
            }
        }
Exemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            LinkButton btn = (LinkButton)sender;

            string userName = Request.Cookies["user"].Value;

            db = new DbLayer();
            int nMaxFavourite = db.getMaxFavouriteID() + 1;

            if (!db.insertFavourite(nMaxFavourite, userName, int.Parse(btn.CommandArgument.ToString())))
            {
                string script = "alert(\"Already Add Favourite!\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
                return;
            }

            Response.Redirect("Search.aspx");
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            menuID = int.Parse(Request.Params[0]);
            if (menuID <= 0)
            {
                Response.Redirect("Menu.aspx");
            }

            db = new DbLayer();

            if (!this.IsPostBack)
            {
                SqlDataReader sr = db.GetMenuByID(menuID);
                sr.Read();
                shopID           = sr.GetInt32(1);
                tbMenuName.Text  = sr.GetString(2);
                tbMenuPrice.Text = sr.GetDouble(3).ToString();
                tbMenuDesc.Text  = sr.GetString(4);
                if (sr.GetString(5).Equals("1"))
                {
                    cbPromotion.Checked = true;
                }
                else
                {
                    cbPromotion.Checked = false;
                }
                tbPromoPrice.Text = sr.GetDouble(6).ToString();
                Image1.ImageUrl   = sr.GetString(7);
                sr.Close();
                sr = null;
            }
            else
            {
                SqlDataReader sr = db.GetMenuByID(menuID);
                sr.Read();
                shopID = sr.GetInt32(1);
                sr.Close();
                sr = null;
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                userName = Request.Cookies["user"].Value;

                if (!userName.Equals("*****@*****.**"))
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }

            DbLayer       dao    = new DbLayer();
            SqlDataReader reader = dao.GetAllUser();

            lbTest.Text += "<table style='border: 1px #000000 solid;'>";
            lbTest.Text += " <tr height='60px' style='background-color: yellow'> <th> User ID </th> <th> User Name </th> <th> User Email </th> <th> User Connection Count </th> <th> User Region </th> <th> EDIT USER </th> <th> EDIT PASSWORD </th> <th> DELETE </th> </tr>";
            while (reader.Read())
            {
                lbTest.Text += "<tr height='60px' style='background-color: #bfbeb8'>";
                lbTest.Text += "<td> " + reader.GetInt32(0) + "</td>";
                lbTest.Text += "<td> " + reader.GetString(3) + "</td>";
                lbTest.Text += "<td> " + reader.GetString(1) + "</td>";
                lbTest.Text += "<td style='text-align:center;'> " + reader.GetInt32(4) + "</td>";
                lbTest.Text += "<td> " + reader.GetString(5) + "</td>";
                lbTest.Text += "<td> <a href=UpdateUser.aspx?userID=" + reader.GetInt32(0) + "> EDIT USER </td>";
                lbTest.Text += "<td> <a href=UpdateUserPwd.aspx?userID=" + reader.GetInt32(0) + "> EDIT PASSWORD </td>";
                lbTest.Text += "<td> <a href=DeleteUser.aspx?userID=" + reader.GetInt32(0) + "> DELETE </td>";
                lbTest.Text += "</tr>";
            }

            lbTest.Text += " </table>";
            reader.Close();
            dao.closeConnection();
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                strCookieNmae = Request.Cookies["user"].Value;
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }

            //if (!this.IsPostBack)
            {
                DbLayer       dao    = new DbLayer();
                SqlDataReader reader = dao.GetAllFavourite(strCookieNmae);

                lbTest.Text += "<table style='border: 1px #000000 solid;'>";
                lbTest.Text += " <tr><td colspan='7' height='60px' style='font-size:x-large;text-align: center;color: blue;'><strong>" + strCookieNmae + " Favourite List</strong></td></tr> ";
                lbTest.Text += " <tr style='background-color: yellow'> <th> Shop Name </th> <th> Shop SubName </th> <th> Shop Introduce </th> <th> Shop Address </th> <th> Shop Phone </th> <th> Shop Image </th> <th> DELETE </th> </tr>";

                while (reader.Read())
                {
                    lbTest.Text += "<tr style='background-color: #bfbeb8'>";
                    lbTest.Text += "<td> " + reader.GetString(0) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(1) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(2) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(3) + "</td>";
                    lbTest.Text += "<td> " + reader.GetString(4) + "</td>";
                    lbTest.Text += "<td><img src='" + reader.GetString(5) + "' width='100px' height='100px' /></td>";
                    lbTest.Text += "<td style='text-align:center;'> <a href=DeleteFavourite.aspx?favouriteID=" + reader.GetInt32(6) + "> DELETE </td>";
                    lbTest.Text += "</tr>";
                }

                lbTest.Text += " </table>";
                reader.Close();
                dao.closeConnection();
            }
        }
Exemplo n.º 7
0
        protected void Add_Click(object sender, EventArgs e)
        {
            db = new DbLayer();
            int    menuID  = db.getMaxMenuID() + 1;
            String imgPath = "";

            if (FileUpload1.HasFile)
            {
                String FileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName).Substring(1);

                String filePath = Request.PhysicalApplicationPath + "images";
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                filePath += @"\menu" + menuID + "." + FileExtension;
                imgPath   = "./images/menu" + menuID + "." + FileExtension;

                FileUpload1.SaveAs(filePath);
            }
            else
            {
                imgPath = "./images/menu0.jpg";
            }

            String strCheckbox = "0";

            if (tbMenuPromo.Checked)
            {
                strCheckbox = "1";
            }

            db.insertMenu(menuID, shopID, tbMenuName.Text, Double.Parse(tbMenuPrice.Text), tbMenuDesc.Text, strCheckbox, Double.Parse(tbMenuPromoPrice.Text), imgPath);
            db.closeConnection();
            Response.Redirect("Menu.aspx?shopID=" + shopID);
        }
Exemplo n.º 8
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            DbLayer db = new DbLayer();

            // Validation Old Password
            bool bCheckPwdOld = PasswordCheck.IsValidPassword(tbOldPwd.Text, 8, 4, true, true, true, true);

            if (!bCheckPwdOld)
            {
                string script = "alert(\"At least 8 characters, all strong conditions met (>= 8 chars with 1 or more UC letters, LC letters, digits & special chars)\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
                return;
            } //A1contact!

            string passwordHashSha256 = db.getUserPwd(tbEmail.Text);

            if (passwordHashSha256 == null)
            {
                string script = "alert(\"Try Again!\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
                return;
            }

            // Hashing Password
            string pwdOldCheck = "";

            if (Request.Cookies["user"].Value.Length / 3 == 0)
            {
                pwdOldCheck = SimpleHash.VerifyHash(tbOldPwd.Text, "SHA2", passwordHashSha256).ToString();
            }
            else if (Request.Cookies["user"].Value.Length / 3 == 2)
            {
                pwdOldCheck = SimpleHash.VerifyHash(tbOldPwd.Text, "SHA256", passwordHashSha256).ToString();
            }
            else
            {
                pwdOldCheck = SimpleHash.VerifyHash(tbOldPwd.Text, "SHA512", passwordHashSha256).ToString();
            }

            if (pwdOldCheck.Equals("False"))
            {
                string script = "alert(\"Input Correct Password!\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
                return;
            }

            // Validation Password
            bool bCheckPwd = PasswordCheck.IsValidPassword(tbRegPwd.Text, 8, 4, true, true, true, true);

            if (!bCheckPwd)
            {
                string script = "alert(\"At least 8 characters, all strong conditions met (>= 8 chars with 1 or more UC letters, LC letters, digits & special chars)\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
                return;
            } //A1contact!

            string pwd = "";

            if (tbUserName.Text.Length / 3 == 0)
            {
                pwd = SimpleHash.ComputeHash(tbRegPwd.Text, "SHA1", null);
            }
            else if (tbUserName.Text.Length / 3 == 2)
            {
                pwd = SimpleHash.ComputeHash(tbRegPwd.Text, "SHA256", null);
            }
            else
            {
                pwd = SimpleHash.ComputeHash(tbRegPwd.Text, "SHA512", null);
            }

            //int id = db.getMaxUser();
            db.UpdateUserPwd(userID, pwd);
            Response.Redirect("Login.aspx");
        }
 public BusinessLogicLayer()
 {
     db = new DbLayer();
 }