Beispiel #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (txtContent.Text.Trim().Length == 0)
            {
                Response.Write("<script>alert('内容不能为空!');</script>");
                return;
            }
            NewsArticle    na             = new NewsArticle();
            NewsArticleBLL newsarticalbll = new NewsArticleBLL();
            string         title          = Server.HtmlEncode(TxtTitle.Text.Trim());
            string         writer         = Server.HtmlEncode(txtWriter.Text.Trim());

            na.AddDate = Convert.ToDateTime(txtTime.Text);
            na.Cid     = 10;
            na.Content = txtContent.Text;
            na.Hits    = 0;
            na.Title   = title;
            na.Writer  = writer;
            if (newsarticalbll.Add(na))
            {
                Response.Write("<script>alert('添加成功');window.location.href='NewsManager.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');history.back();</script>");
            }
        }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     newsarticlebll = new NewsArticleBLL();
     if (!IsPostBack)
     {
         DateBind();
     }
 }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     newsarticlebll = new NewsArticleBLL();
     if (!IsPostBack)
     {
         string id = Request["id"].ToString();
         Detailshow(int.Parse(id));
     }
 }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     newsarticalbll = new NewsArticleBLL();
     if (!IsPostBack)
     {
         labPage1 = "1";
         bindNews(null);
     }
 }
Beispiel #5
0
        protected void DataList1_DeleteCommand(object sender, DataListCommandEventArgs e)
        {
            NewsArticleBLL newsarticlebll2 = new NewsArticleBLL();;
            string         id = e.CommandArgument.ToString();

            if (newsarticlebll2.Delete(id))
            {
                Response.Write("<script>alert('删除成功');</script>");
            }
            this.Response.Redirect(this.Request.Url.ToString());
        }
Beispiel #6
0
        public void EditNews()//初始化
        {
            string         id             = Request.QueryString["id"];
            NewsArticleBLL newsarticlebll = new NewsArticleBLL();
            NewsArticle    na             = new NewsArticle();

            na              = newsarticlebll.GetNewsArticle(id);
            TxtTitle.Text   = na.Title;
            txtWriter.Text  = na.Writer;
            txtTime.Text    = na.AddDate.ToString("d");
            txtContent.Text = na.Content;
        }
Beispiel #7
0
 protected void Delete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < DataList1.Items.Count; i++)
     {
         if (((CheckBox)DataList1.Items[i].FindControl("selected")).Checked == true)
         {
             object         s = ((System.Web.UI.WebControls.HyperLink)DataList1.Items[i].FindControl("Hyperlink3")).Text;
             NewsArticleBLL NewsArticleBLL = new NewsArticleBLL();
             if (NewsArticleBLL.Delete(s))
             {
                 Response.Write("<script>alert('删除成功');</script>");
             }
         }
     }
     this.Response.Redirect(this.Request.Url.ToString());
 }
Beispiel #8
0
 public void bindNews()//首页新闻
 {
     newsarticalbll = new NewsArticleBLL();
     this.DatalistNews.DataSource = newsarticalbll.Getlist(10, 6);
     this.DatalistNews.DataBind();
 }