protected void btnSave_Click(object sender, EventArgs e) { if (CheckUser() == 0) // ошибок не было { if (Mode == "Add") { NewNews = new DbLink.News(); NewNews.Created = DateTime.Now; } NewNews.Title = tbTitle.Text; NewNews.Content = tbContent.Text; if (Mode == "Add") { if (GlobalVariables.Link.AddNews(NewNews, Session["login"].ToString())) { Response.Redirect(GlobalVariables.UrlHost + "/News/News.aspx"); } else { ErrMessage = "Ошибка вставки в базу данных"; } } else { if (GlobalVariables.Link.EditNews(NewNews, Session["login"].ToString())) { Response.Redirect(GlobalVariables.UrlHost + "/News/News.aspx"); } else { ErrMessage = "Ошибка вставки в базу данных"; } } } }
protected void Edit() { if (Session["login"] == null || Session["group"].ToString() != "1") { Response.Redirect(GlobalVariables.UrlStop); } Mode = "Edit"; ModeAddEdit.Visible = true; ltHeader.Text = "Редактировать новость"; string strId = Request.QueryString["id"]; if (!string.IsNullOrEmpty(strId)) { Int32.TryParse(strId, out Id); if (Id <= 0) { Response.Redirect(GlobalVariables.UrlHost + "/news/News.aspx"); } NewNews = GlobalVariables.Link.GetOneNews(Id); if (NewNews == null) { Response.Redirect(GlobalVariables.UrlHost + "/news/News.aspx"); } if (!IsPostBack) { tbTitle.Text = NewNews.Title; tbContent.Text = NewNews.Content; } } }
protected void View() { Mode = "View"; ModeView.Visible = true; string strId = Request.QueryString["id"]; if (string.IsNullOrEmpty(strId)) { Response.Redirect(GlobalVariables.UrlHost + "/news/News.aspx"); } Int32.TryParse(strId, out Id); if (Id <= 0) { Response.Redirect(GlobalVariables.UrlHost + "/news/News.aspx"); } NewNews = GlobalVariables.Link.GetOneNews(Id); if (NewNews == null) { Response.Redirect(GlobalVariables.UrlHost + "/news/News.aspx"); } if (Session["login"] != null && Session["group"].ToString() == "1") { NewsEdit.Visible = true; } NewsCreated.Text = NewNews.Created.ToString(); NewsContent.Text = NewNews.Content; }
protected void Add() { if (Session["login"] == null || Session["group"].ToString() != "1") { Response.Redirect(GlobalVariables.UrlStop); } Mode = "Add"; NewNews = new DbLink.News(); }
protected void Add() { if (Session["login"] == null || Session["group"].ToString() != "1") { Response.Redirect(GlobalVariables.UrlStop); } Mode = "Add"; ModeAddEdit.Visible = true; ltHeader.Text = "Добавить новость"; NewNews = new DbLink.News(); }