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

        //    catch (MySqlException exp)

        //    {

        //        conn.Close();

        //        return null;

        //    }

        //}

        public static string getTeamByAbb(string abb)

        {

            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_team = 0;

                string team = "";

                string sql;

                MySqlCommand comm = null;

                MySqlDataReader reader = null;

                //ВЫБИРАЕМ ID КОМАНДЫ

                    sql = "SELECT name FROM teams WHERE abb='" + abb + "';";

                    comm = new MySqlCommand(sql, conn);

                    reader = comm.ExecuteReader();

                    while (reader.Read())

                    {

                        team = reader[0].ToString();

                    }

                    reader.Close();

                    conn.Close();

                    return team;

            }

            catch (MySqlException exp)

            {

                conn.Close();

                return null;

            }

        }

        //int played - флаг типа матчей. -1 = все, 0 = несыгранные, 1 = сыгранные.

        public static void getGames(GridView report, string team, int played, string round, string 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

            {

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

                string table_calendar = "calendar_khl20122013_1";

                conn = new MySqlConnection(connectionString);

                conn.Open();

                string sql;

                MySqlDataAdapter da = null;

                DataTable dt = new DataTable();

                string team_filter = "";

                string round_filter = "";

                string game_filter = "";

                string where = "";

                //ВЫБИРАЕМ СТРОКУ ИЗ ТАБЛИЦЫ

                if (team != null && team != "")

                {

                    team_filter = " AND (a.Away = '" + team + "' or h.Home = '"+team+"') ";

                }

                else

                {

                    team_filter = "";

                }

                if (played == -1)

                {

                    game_filter = "";

                }

                else if (played == 0)

                {

                    game_filter = " AND (a.date is null or a.date = '') ";

                }

                else if (played == 1)

                {

                    game_filter = " AND (a.date is not null or a.date != '') ";

                }

                if (round != null && round != "")

                {

                    round_filter = " AND (h.R = '"+round+"') ";

                }