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; using System.Globalization; namespace AeroNet { /// /// Summary description for news. /// public class news : Common { protected int t; protected int M; protected int y; protected string id; protected string txtM; protected string txtDate; protected string txtNewsTitle; protected string txtNewsAuthor; protected string txtNewsText; protected string title; private void Page_Load(object sender, System.EventArgs e) { //Загрузить верхнее меню TopMenu(); //Получить id из строки запроса if (Request.QueryString["id"] == null) { id = "1"; } else { id = Request.QueryString["id"]; } // Соединение с SQL-сервером SqlConnection connNews = new SqlConnection(connString); //Создать команду SqlCommand cmdNews = new SqlCommand(("SELECT ID, [Date], Type, Title, Author, Text, M, y FROM V_News WHERE ID="+id), connNews); //Открыть соединение connNews.Open(); //Создать DataReader и считать данные SqlDataReader drNews; drNews = cmdNews.ExecuteReader(); if (drNews.Read()) { //Название месяца в txtM switch(Convert.ToInt32(drNews["M"])) { case 1: txtM = "Январь"; break; case 2: txtM = "Февраль"; break; case 3: txtM = "Март"; break; case 4: txtM = "Апрель"; break; case 5: txtM = "Май"; break; case 6: txtM = "Июнь"; break; case 7: txtM = "Июль"; break; case 8: txtM = "Август"; break; case 9: txtM = "Сентябрь"; break; case 10: txtM = "Октябрь"; break; case 11: txtM = "Ноябрь"; break; case 12: txtM = "Декабрь"; break; default: txtM = "Январь"; break; } //Считать год и раздел новостей из DataReader y = Convert.ToInt32(drNews["y"]); M = Convert.ToInt32(drNews["M"]); t = Convert.ToInt32(drNews["Type"]); //Считать из DataReader и установить заголовок switch(t) { case 1: title = "Н о в о с т и:    Г р а ж д а н с к а я   а в и а ц и я"; break; case 2: title = "Н о в о с т и:    В о е н н а я   а в и а ц и я"; break; case 3: title = "Н о в о с т и:    А в и а к о с м и ч е с к а я   п р о м ы ш л е н н о с т ь"; break; case 4: title = "Н о в о с т и:    К о с м о с"; break; case 5: title = "Н о в о с т и:    К а т а с т р о ф ы   и   п р о и с ш е с т в и я"; break; default: title = "Н о в о с т и"; break; } //Считывание даты текущей новости CultureInfo ci = new CultureInfo("ru-RU"); txtDate = ((DateTime)drNews["Date"]).ToString("dd.MM.yyyy",ci); //Считывание заголовка новости txtNewsTitle = drNews["Title"].ToString(); //Считывание источника новости txtNewsAuthor = drNews["Author"].ToString(); //Считывание текста новости txtNewsText = drNews["Text"].ToString(); } else { Response.Write ("

Ошибка сервера ...

"); } //Закрываем DataReader и соединение drNews.Close(); connNews.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 } }