sql = "SELECT id from tournaments WHERE name='" + tournament + "'";
comm = new MySqlCommand(sql, conn);
reader = comm.ExecuteReader();
while (reader.Read())
{
tour = Convert.ToInt32(reader["id"].ToString());
}
reader.Close();
sql = "select sum(rating) as SUM,user from ratingppl inner join seasons on seasons.id = ratingppl.season inner join tournaments on tournaments.id = seasons.league and tournaments.id = "+tour+" 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[] getRatingPPLFromSeason(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;
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 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)
{
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 getIdSeason(string season)
{
string database = "powerplay";
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.