using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace AeroNet { /// /// Summary description for Airport. /// public class Country : Common { protected int reg; protected string title = "Аэропорты мира:   "; protected string country; protected string images; protected int i; protected int j; protected int countryid; protected void PrintCountry () { //Считать количество строк в DataReader // Соединение с SQL-сервером SqlConnection connCounter = new SqlConnection(connString); //Создать команду SqlCommand cmdCounter = new SqlCommand(("SELECT * FROM V_CountryCount WHERE regionid='"+reg.ToString()+"'"), connCounter); //Открыть соединение connCounter.Open(); //Создать DataReader и считать данные SqlDataReader drCounter; drCounter = cmdCounter.ExecuteReader(); if (drCounter.Read()) { i = Convert.ToInt32(drCounter["counter"]); } //Закрываем DataReader и соединение drCounter.Close(); connCounter.Close(); // Соединение с SQL-сервером SqlConnection connCountry = new SqlConnection(connString); //Создать команду SqlCommand cmdCountry = new SqlCommand(("SELECT * FROM V_Country WHERE regionid='"+reg.ToString()+"' ORDER BY countryRus ASC"), connCountry); //Открыть соединение connCountry.Open(); //Создать DataReader и считать данные SqlDataReader drCountry; drCountry = cmdCountry.ExecuteReader(); j = 1; while (drCountry.Read()) { if (j <= ((i/2)+1) || j > ((i/2)+2)) { Response.Write ("  "+drCountry["countryRus"].ToString()+"
"); j = j+1; } else { Response.Write ("  "+drCountry["countryRus"].ToString()+"
"); j = j+1; } } //Закрываем DataReader и соединение drCountry.Close(); connCountry.Close(); } protected void PrintCity () { //Считать количество строк в DataReader // Соединение с SQL-сервером SqlConnection connAirportCounter = new SqlConnection(connString); //Создать команду SqlCommand cmdAirportCounter = new SqlCommand(("SELECT * FROM V_AirportCount WHERE countryid='"+countryid.ToString()+"'"), connAirportCounter); //Открыть соединение connAirportCounter.Open(); //Создать DataReader и считать данные SqlDataReader drAirportCounter; drAirportCounter = cmdAirportCounter.ExecuteReader(); if (drAirportCounter.Read()) { i = Convert.ToInt32(drAirportCounter["counter"]); } //Закрываем DataReader и соединение drAirportCounter.Close(); connAirportCounter.Close(); // Соединение с SQL-сервером SqlConnection connAirport = new SqlConnection(connString); //Создать команду SqlCommand cmdAirport = new SqlCommand(("SELECT * FROM V_AirportCountry WHERE CountryID='"+countryid.ToString()+"' ORDER BY RusName ASC"), connAirport); //Открыть соединение connAirport.Open(); //Создать DataReader и считать данные SqlDataReader drAirport; drAirport = cmdAirport.ExecuteReader(); j = 1; while (drAirport.Read()) { if (i <= 15) { Response.Write ("  "+drAirport["RusName"].ToString()+"
"); } else { if (j <= ((i/2)+1) || j > ((i/2)+2)) { Response.Write ("  "+drAirport["RusName"].ToString()+"
"); j = j+1; } else { Response.Write ("  "+drAirport["RusName"].ToString()+"
"); j = j+1; } } } //Закрываем DataReader и соединение drAirport.Close(); connAirport.Close(); } private void Page_Load(object sender, System.EventArgs e) { //Загрузить верхнее меню TopMenu(); //Получить reg из строки запроса if (Request.QueryString["reg"] == null) { reg = 1; } else { reg = Convert.ToInt32(Request.QueryString["reg"]); } //Получить countryid из строки запроса if (Request.QueryString["countryid"] == null) { countryid = 0; } else { countryid = Convert.ToInt32(Request.QueryString["countryid"]); } if (countryid == 0) { //Установить заголовок switch(reg) { case 1: country = "Европа"; images = "Европа    "; break; case 2: country = "Азия и Дальний Восток"; images = "Европа    "; break; case 3: country = "Ближний и Средний Восток"; images = "Европа    "; break; case 4: country = "Австралия и Океания"; images = "Европа    "; break; case 5: country = "Африка"; images = "Европа    "; break; default: country = "Европа"; images = "Европа    "; break; } } else { // Соединение с SQL-сервером SqlConnection connCity = new SqlConnection(connString); //Создать команду SqlCommand cmdCity = new SqlCommand(("SELECT * FROM V_Country WHERE countryid='"+countryid.ToString()+"'"), connCity); //Открыть соединение connCity.Open(); //Создать DataReader и считать данные SqlDataReader drCity; drCity = cmdCity.ExecuteReader(); if (drCity.Read()) { country = drCity["countryRus"].ToString(); images = ""+drCity["countryRus"].ToString()+"    "; } else { Response.Redirect("Country.aspx"); } //Закрываем DataReader и соединение drCity.Close(); connCity.Close(); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }