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

                reader = comm.ExecuteReader();

                while (reader.Read())

                {

                    position++;

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

                    {

                        positionandreputation = new float[2];

                        positionandreputation[0] = position;

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

                    }

                }

                reader.Close();

                conn.Close();

                return positionandreputation;

            }

            catch (MySqlException exp)

            {

                conn.Close();

                return null;

            }

        }

        public static float[] getReputationFromSeason(string UserName, int season)

        {

            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;

                float[] positionandreputation = 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(reputation) as SUM,user from reputation where season= " + season + " 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)

                    {

                        positionandreputation = new float[2];

                        positionandreputation[0] = position;

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

                    }

                }

                reader.Close();

                conn.Close();

                return positionandreputation;

            }

            catch (MySqlException exp)

            {

                conn.Close();

                return null;

            }

        }

        public static void addReputation(string UserName, float value, int season, int game)

        {

            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();

                string sql;

                int id_user = 0;

                MySqlCommand comm = null;