⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_articleedit.aspx.cs

📁 新闻网站
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL.System;
using BLL;
using System.Data.SqlClient;
using System.Collections.Generic;
using Common.Entities;
//该源码下载自www.51aspx.com(51aspx.com)

public partial class Admin_Admin_ArticleEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userName"] == null)
        {
            Response.Redirect("Admin_Error.aspx");
        }
        if (!IsPostBack) 
        {
            int articleId = int.Parse(Request.QueryString["articleId"]);
            ArticleSystem articleSystem = new ArticleSystem();
            ArticleData articleData = articleSystem.GetModel(articleId);
            this.lblId.Text = articleId.ToString();
            this.txtTitle.Text = articleData.Title;
            this.txtImage.Text = articleData.TitleImg;
            if (articleData.ImgNews)
            {
                this.chkImagNews.Checked = true;
            }
            if (articleData.HeadLine)
            {
                this.chkHeadLine.Checked = true;
            }

            this.FreeTextBox1.Text = articleData.Content;
            //绑定分类列表
            BindDrpClass(0, "-");
            this.drpClass.SelectedValue = articleData.ClassId.ToString();
            //绑定专题列表//5_1_a_s_p_x.c_o_m

            BindDrpTopic();
            this.drpTopic.SelectedValue = articleData.Topicid.ToString();
        }        
       
        
    }
    protected void BindDrpClass(int parentId, string str)
    {
        ClassSystem classSystem = new ClassSystem();
        ArrayList list = classSystem.GetClassData(parentId);
        str += str;
        foreach (ClassData classData in list)
        {
            drpClass.Items.Add(new ListItem(str + classData.ClassName, classData.ClassID.ToString()));
            BindDrpClass(classData.ClassID, str);
        }       
    }
    protected void BindDrpTopic()
    {
        TopicSystem topicSystem = new TopicSystem();
        SqlDataReader reader = topicSystem.GetList();      
        OperateControl.BindDropDownList(drpTopic, reader, "TopicId", "TopicName");     
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        ArticleData articleData = new ArticleData();
        articleData.ArticleId = int.Parse(this.lblId.Text);
        articleData.ClassId = int.Parse(this.drpClass.SelectedValue);
        articleData.Title = this.txtTitle.Text;
        articleData.TitleImg = this.txtImage.Text;
        if (this.chkImagNews.Checked)
        {
            articleData.ImgNews = true;
        }
        else
        {
            articleData.ImgNews = false;
        }
        if (this.chkHeadLine.Checked)
        {
            articleData.HeadLine = true;
        }
        else
        {
            articleData.HeadLine = false;
        }
        articleData.Topicid = int.Parse(this.drpTopic.SelectedValue);
        articleData.Content = this.FreeTextBox1.Text;
        articleData.MemberName = Session["userName"].ToString();
        ArticleSystem articleSystem = new ArticleSystem();
        articleSystem.Update(articleData);
        this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!')</script>");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -