Beispiel #1
0
        /// <summary>
        /// This method will return an object of class user if the user found. Otherwise it will return null
        /// </summary>
        /// <param name="username">The username of the user</param>
        /// <param name="password">The password of the user</param>
        /// <returns></returns>
        public static HRUser authenticate(string username, string password)
        {
            DatabaseHandler handler = new DatabaseHandler();
            handler.setSQL("SELECT * FROM [User] WHERE user_name = @name AND user_password = @password");
            handler.addParameter("@name", username);
            handler.addParameter("@password", password);
            handler.queryExecute();
            while (handler.reader.Read()) {
                HRUser u = new HRUser(int.Parse(handler.reader["user_id"].ToString()));
                return u;
            }

            return null;
        }
        /// <summary>
        /// This method will return an object of class user if the user found. Otherwise it will return null
        /// </summary>
        /// <param name="username">The username of the user</param>
        /// <param name="password">The password of the user</param>
        /// <returns></returns>
        public static HRUser authenticate(string username, string password)
        {
            DatabaseHandler handler = new DatabaseHandler();

            handler.setSQL("SELECT * FROM [User] WHERE user_name = @name AND user_password = @password");
            handler.addParameter("@name", username);
            handler.addParameter("@password", password);
            handler.queryExecute();
            while (handler.reader.Read())
            {
                HRUser u = new HRUser(int.Parse(handler.reader["user_id"].ToString()));
                return(u);
            }

            return(null);
        }