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

                if (team_filter != "" || game_filter != "" || round_filter != "")

                {

                    where = " WHERE h.N>0 ";

                }

                sql = "select h.N,h.R,h.Home,a.Away,a.date from (select " + table_calendar + ".id as N, " + table_calendar + ".round as R, teams.name as Home from " + table_calendar + " inner join teams on teams.id = " + table_calendar + ".home) as h inner join(select " + table_calendar + ".id as N, " + table_calendar + ".round as R, teams.name as Away, " + table_calendar + ".date_tab as DATE from " + table_calendar + " inner join teams on teams.id = " + table_calendar + ".away) as a on h.N = a.N "+where+" "+team_filter+" "+game_filter+" "+round_filter +";";

                dt.Clear();

                da = new MySqlDataAdapter(sql, conn);

                da.Fill(dt);

                report.DataSource = dt;

                report.DataBind();

                //for (int i = 0; i < report.Rows.Count; i++)

                //{

                //    report.Rows[i].Cells[0].Text = (i + 1).ToString();

                //    if (i % 2 == 0) report.Rows[i].BackColor = System.Drawing.Color.Beige;

                //    else report.Rows[i].BackColor = System.Drawing.Color.LightGray;

                //    if (report.Rows[i].Cells[1].Text == team)

                //    {

                //        report.Rows[i].BackColor = System.Drawing.Color.Pink;

                //    }

                //}

                conn.Close();

            }

            catch (MySqlException exp)

            {

                conn.Close();

            }

        }

        public static void getStatsOfTeamsByGame(GridView report, string team, int game, 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_team_stats = season+"_teamstats";

                conn = new MySqlConnection(connectionString);

                conn.Open();

                string sql;

                MySqlDataAdapter da = null;

                DataTable dt = new DataTable();

                string team_filter = "";

                string game_filter = "";

                string where = "";

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

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

                {

                    team_filter = " AND teams.name = '" + team + "' ";

                }

                else

                {

                    team_filter = "";

                }

                if (game <= 0)

                {

                    game_filter = "";

                }

                else

                {

                    game_filter = " AND (" + table_team_stats + ".game = "+game+") ";

                }

                if (team_filter != "" || game_filter != "")

                {

                    where = " WHERE " + table_team_stats + ".game>0 ";

                }