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

📄 novel3.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;

namespace novel
{
    public partial class novel3 : System.Web.UI.Page
    {
        DB_Class pdb = new DB_Class();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                GVBind();
            }
        }
        protected void GVBind()
        {
            GV_comment.DataSource = pdb.dst("select commentid,topicid,sender,content,times from novel_comment");
            GV_comment.DataBind();

            GridView1.DataSource = pdb.dst("select chapterid,topicid,chapter,path,length,error from novel_chapter9");
            GridView1.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            GVBind();
        }

        protected void GV_comment_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
                {
                    ((LinkButton)e.Row.Cells[5].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
                }

            }
        }

        protected void GV_comment_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string commentid = GV_comment.DataKeys[e.RowIndex].Value.ToString();
            string sqlstr = "delete from novel_comment where commentid=" + commentid;
            pdb.ExecSql(sqlstr);
            GVBind();
        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string chapterid = GridView1.DataKeys[e.RowIndex].Value.ToString();
            string sqlstr = "delete from novel_topic where chapterid=" + chapterid;
            pdb.ExecSql(sqlstr);
            GVBind();
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
                {
                    ((LinkButton)e.Row.Cells[6].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
                }

            }
        }

        protected void GV_comment_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GV_comment.PageIndex = e.NewPageIndex;
            GVBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            String insert = "insert into novel_topic(topicid,title,chapter,author,tablename,intro,length) values('" + topicid.Text + "','" + title.Text + "','" + chapter.Text + "','" + author.Text + "','" + tablename.Text + "','" + intro.Text + "','" + length.Text + "')";
            if (pdb.ExecSql(insert))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "MessageBox", "alert('保存成功')", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "MessageBox", "alert('保存失败,请检查!')", true);
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

        }
    }
}

⌨️ 快捷键说明

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