/// <summary>
        ///   The deleteUnmoderated method deletes a previously
        ///   submitted joke (unmoderated) joke
        ///   (for moderators only)
        /// </summary>
        /// <param name='userName'
        ///   type='string'
        ///   desc='name of moderator'>
        /// </param>
        /// <param name='password'
        ///   type='string'
        ///   desc='password of moderator'>
        /// </param>
        /// <param name='jokeID'
        ///   type='int'
        ///   desc='joke ID of joke'>
        /// </param>
        /// <returns>true</returns>
        protected internal bool deleteUnmoderated(
            string userName, string password, int jokeID)
        {
            string retCode;

            try {
                // check if user is a moderator
                userAdminImplement myUser     = new userAdminImplement();
                SqlCommand         sqlCommand = new SqlCommand();

                myUser.createSqlCheckUser(
                    userName, password, "true", sqlCommand);

                databaseAccess myDatabase = new databaseAccess();
                sqlCommand.Connection = myDatabase.getConnection();
                sqlCommand.Connection.Open();

                sqlCommand.ExecuteNonQuery();

                retCode = sqlCommand.Parameters["@@return"].Value.ToString();

                // exit, if user not a moderator
                if (retCode != "S_OK")
                {
                    sqlCommand.Connection.Close();
                    throw new jokeException(retCode);
                }

                // delete the joke
                sqlCommand.Parameters.Clear();
                createSqlManageJoke(
                    userName, "", "", jokeID.ToString(), "delete", sqlCommand);

                sqlCommand.ExecuteNonQuery();
                sqlCommand.Connection.Close();

                retCode = sqlCommand.Parameters["@@return"].Value.ToString();

                // catch problems within the stored procedure
                if (retCode == "S_OK")
                {
                    return(true);
                }
                else
                {
                    throw new jokeException(retCode);
                }
                // catch problems with the database
            } catch (Exception e) {
                throw e;
            }
        }
        public void addUser(string userName, string password)
        {
            userAdminImplement userAdminObj = new userAdminImplement();

            try {
                userAdminObj.addUser(userName, password);
                // catch jokeExceptions
            } catch (jokeException e) {
                throwFault("Fault occurred", e.failReason, userName);
            }
            // then, catch general System Exceptions
            catch (Exception e) {
                throwFault(e.Message, "F_System", userName);
            }
        }
        /// <summary>
        ///   The getUnmoderated method retrieves howMany jokes from
        ///   the database
        ///   (for moderators only)
        /// </summary>
        /// <param name='userName'
        ///   type='string'
        ///   desc='name of moderator'>
        /// </param>
        /// <param name='password'
        ///   type='string'
        ///   desc='password of moderator'>
        /// </param>
        /// <param name='howMany'
        ///   type='int'
        ///   desc='number of jokes to return'>
        /// </param>
        /// <returns>an XML representation (xmlJokesReturn)
        ///   of a single joke</returns>
        protected internal xmlJokesReturn[] getUnmoderated(
            string userName, string password, int howMany)
        {
            string retCode;

            try {
                // check if user is a moderator
                userAdminImplement myUser     = new userAdminImplement();
                SqlCommand         sqlCommand = new SqlCommand();

                myUser.createSqlCheckUser(
                    userName, password, "true", sqlCommand);

                databaseAccess myDatabase = new databaseAccess();
                sqlCommand.Connection = myDatabase.getConnection();
                sqlCommand.Connection.Open();

                sqlCommand.ExecuteNonQuery();

                retCode = sqlCommand.Parameters["@@return"].Value.ToString();

                // exit, if user not a moderator
                if (retCode != "S_OK")
                {
                    sqlCommand.Connection.Close();
                    throw new jokeException(retCode);
                }

                // retrieve the first <howMany> unmoderated jokes

                // maximum is 10 jokes
                if ((howMany < 1) || (howMany > 10))
                {
                    throw new jokeException("F_10JokesMax");
                }

                sqlCommand.Parameters.Clear();
                createSqlReturnJokes(
                    howMany.ToString(), "false", "false", sqlCommand);

                sqlCommand.ExecuteNonQuery();

                sqlCommand.Connection.Close();

                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
                DataTable      dataTable      = new DataTable("sqlReturn");
                sqlDataAdapter.Fill(dataTable);

                // convert SQL table into xmlJokesReturn class
                int rowCount             = dataTable.Rows.Count;
                xmlJokesReturn[] myJokes = new xmlJokesReturn[rowCount];
                for (int i = 0; i < rowCount; i++)
                {
                    myJokes[i]        = new xmlJokesReturn();
                    myJokes[i].jokeID = dataTable.Rows[i][0].ToString();
                    myJokes[i].joke   = dataTable.Rows[i][1].ToString();
                    myJokes[i].rating = dataTable.Rows[i][2].ToString();
                }
                // catch problems within the stored procedure
                if (rowCount > 0)
                {
                    return(myJokes);
                }
                else
                {
                    throw new jokeException("F_noJokes");
                }
                // catch problems with the database
            } catch (Exception e) {
                throw e;
            }
        }