Создание веб-приложения, сочетающего в себе проектирование и создание баз данных, работу со сторонними форматами данных, программирование в NET и веб-разработку, страница 69

                        return true;

                    }

                }

            }

            catch (MySqlException exp)

            {

                conn.Close();

                return false;

            }

        }

        public static int[] getRatingPPL(string UserName)

        {

            string database = "powerplay";

            string password_db = "admin";

            string user_db = "root";

            string server_db = "localhost";

            connectionString = ("server=" + server_db + "; user id=" + user_db + "; password=" + password_db + "; database=" + database + "");

            MySqlConnection conn = null;

            try

            {

                //ОБЪЯВЛЕНИЕ

                conn = new MySqlConnection(connectionString);

                conn.Open();

                int id_user = 0;

                int position = 0;

                int []positionandratinppl = null;

                string sql;

                MySqlCommand comm = null;

                MySqlDataReader reader = null;

                //ПРОВЕРЯЕМ, ЕСТЬ ЛИ УЖЕ ТАКОЙ ЮЗЕР

                sql = "SELECT id from auth_user WHERE name='"+UserName+"'";

                comm = new MySqlCommand(sql, conn);

                reader = comm.ExecuteReader();

                while (reader.Read())

                {

                        id_user = Convert.ToInt32(reader["id"].ToString());

                }

                reader.Close();

                sql = "select sum(rating) as SUM,user from ratingppl group by user order by SUM DESC";

                comm = new MySqlCommand(sql, conn);

                reader = comm.ExecuteReader();

                while (reader.Read())

                {

                    position++;

                    if (Convert.ToInt32(reader["user"].ToString()) == id_user)

                    {

                        positionandratinppl = new int[2];

                        positionandratinppl[0] = position;

                        positionandratinppl[1] = Convert.ToInt32(reader["SUM"].ToString());

                    }

                }

                reader.Close();

                conn.Close();

                return positionandratinppl;

            }

            catch (MySqlException exp)

            {

                conn.Close();

                return null;

            }

        }

        public static int[] getRatingPPLFromTournament(string UserName, string tournament)

        {

            string database = "powerplay";

            string password_db = "admin";

            string user_db = "root";

            string server_db = "localhost";

            connectionString = ("server=" + server_db + "; user id=" + user_db + "; password=" + password_db + "; database=" + database + "");

            MySqlConnection conn = null;

            try

            {

                //ОБЪЯВЛЕНИЕ

                conn = new MySqlConnection(connectionString);

                conn.Open();

                int id_user = 0;

                int tour = 0;

                int position = 0;

                int[] positionandratinppl = null;

                string sql;

                MySqlCommand comm = null;

                MySqlDataReader reader = null;

                //ПРОВЕРЯЕМ, ЕСТЬ ЛИ УЖЕ ТАКОЙ ЮЗЕР

                sql = "SELECT id from auth_user WHERE name='" + UserName + "'";

                comm = new MySqlCommand(sql, conn);

                reader = comm.ExecuteReader();

                while (reader.Read())

                {

                    id_user = Convert.ToInt32(reader["id"].ToString());

                }

                reader.Close();