Exemplo n.º 1
0
        /**
         * Validates user details against DB
         * returns true if user details exist.
         */
        private bool IsExist(string username, string password)
        {
            string    cmdStr     = string.Format("SELECT * FROM UserDetails WHERE [UserName]=N'{0}' and Password=N'{1}'", username, password);
            DBAccesor dbAccessor = ServiceLocator.Instance.GetService <DBAccesor>();

            return(dbAccessor.isExist(cmdStr));
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string user = (string)Session["UserName"];

            if (Request.Form["menu"] != null)

            {
                DBAccesor dB = ServiceLocator.Instance.GetService <DBAccesor>();
                if (user != null)
                {
                    string cmdStr = string.Format("SELECT * FROM TetrisHighScore WHERE [UserName]=N'{0}'", user);
                    int    score  = int.Parse(Request.Form["scoreDB"]);
                    if (dB.isExist(cmdStr))
                    {
                        var table     = dB.runSelectCmd(cmdStr);
                        int highScore = (int)table.Rows[0]["Score"];
                        if (score > highScore)
                        {
                            table.Rows[0]["Score"] = score;
                            dB.updateTable(cmdStr, table);
                        }
                    }
                    else
                    {
                        string cmdStr1 = string.Format($"INSERT INTO TetrisHighScore(UserName, Score) VALUES (N'{user}',{score})");
                        dB.runSqlCommand(cmdStr1);
                    }
                }
                Response.Redirect("tetrisGameOver.aspx");
            }
        }
Exemplo n.º 3
0
        private bool isExist(string user, int id)
        {
            string cmdString = string.Format($"SELECT * FROM  Cart WHERE UserName = N'{user}' and OrderId = {id} ");

            DBAccesor dbAccessor = ServiceLocator.Instance.GetService <DBAccesor>();

            return(dbAccessor.isExist(cmdString));
        }
Exemplo n.º 4
0
        /**
         * Run query against DB
         * return true if result exist otherwise false.
         */
        private bool checkDB(string query)
        {
            DBAccesor dbAccessor = ServiceLocator.Instance.GetService <DBAccesor>();

            return(dbAccessor.isExist(query));
        }