个人博客系统毕业论文设计(终稿)(5)

2020-02-21 22:30

西安航空技术高等专科学校计算机工程系

5.3普通用户对管理员进行留言或查看管理员回复的留言

普通用户可以给管理员留言,也可以查看管理员给的回复具体代码如下: 给管理员留言的代码如下:

protected void btnMessage_Click(object sender, EventArgs e) {

if (txtName.Text.Trim() == \ || txtTitle.Text.Trim() == \ || txtContent.Text.Trim()==\) {

Response .Write (\网友昵称、留言标题、留言内容不能为空!')\); }

MessageManage mm = new MessageManage(); mm.MassageNickName = txtName.Text.Trim(); mm.MessageContent = txtContent.Text.Trim(); mm.MessageTitle = txtTitle.Text.Trim();

mm.MessageHomePage = txtHomePage.Text.Trim(); mm.MessageDate = DateTime.Now; mm.MessageReply = null; mm.AddMessage(); txtName.Text =\; txtContent.Text = \; txtTitle.Text = \; txtHomePage.Text = \; MessageBind();

}

运行界面如下:

16

西安航空技术高等专科学校计算机工程系

5.4管理员登录界面

从数据库中提取管理员的账号和密码,如果数据库中存在该用户的信息且账号和密码都输入正确则进入后台管理界面并将账号和密码存入session中,否则不能进入后台管理,具体代码如下: 登录后台管理的代码如下:

protected void btnLogin_Click(object sender, EventArgs e) {

if (txtLoginID.Text.Trim() == \) {

Response.Write(\用户名不能为空!')\);

return; }

if(txtLoginPWD.Text.Trim()==\) {

Response.Write(\密码不能为空!')\);

return; }

string sqlString = string.Format(\where adminId='{0}' and adminPWD='{1}'\, txtLoginID.Text, txtLoginPWD.Text);

DBOperate DBOp=new DBOperate();

if (DBOp.Scalar(sqlString)>0) {

Session[\] = txtLoginID.Text.Trim(); Session[\] = txtLoginPWD.Text.Trim(); Response.Redirect(\); } else {

Response.Write(\用户名或密码错误!')\);

return; } }

运行界面如下:

17

西安航空技术高等专科学校计算机工程系

5.5后台文章管理界面

管理员可以更新文章的类容,如果该文章没有评论则可以删除文章,有评论则提示不能删除该文章请先删除该文章的评论,具体代码如下: 编辑文章的代码如下:

protected void btnEditArticle_Click(object sender, EventArgs e) {

ArticleManage am = new ArticleManage();

am.ArticleAuthor = txtarticleAuthor.Text.Trim(); am.ArticleBrief = txtarticleBrief.Text.Trim(); am.ArticleTitle = txtarticleTitle.Text.Trim(); am.ArticleContent = txtarticleContent.Text.Trim(); am.ArticleDate = DateTime.Now;

am.ClassId =Convert.ToInt32( drpclassName.SelectedValue); string

value=Server.UrlDecode(Request.QueryString[\]); am.UpdateArticle(value);

Response.Redirect(\); }

删除文章的代码如下:

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) {

ArticleManage am = new ArticleManage(); string keyValue =

GridView1.DataKeys[e.RowIndex].Value.ToString(); int deleteResult;

string IsDeleteResult = null;

IsDeleteResult = am.IsDelete(keyValue);

18

西安航空技术高等专科学校计算机工程系

if (IsDeleteResult == null) {

deleteResult = am.DeleteArticle(keyValue); if (deleteResult > 0) {

string myMessage = \:删除成功!\;

Response.Write(\alert('\ + myMessage + \); } else {

string myMessage = \删除失败,在试一次,如果出现相同的情况,请向开发者报告情况\;

Response.Write(\alert('\ + myMessage + \);

}

} else {

string myMessage = \删除失败原因是:\ + IsDeleteResult; Response.Write(\ + myMessage + \); }

Bind(); }

运行界面如下:

19

西安航空技术高等专科学校计算机工程系

5.6后台添加文章

向数据库中插入添加文章的信息,具体代码如下:

protected void btnAddArticle_Click(object sender, EventArgs e) {

if (txtarticleAuthor.Text.Trim().ToString() == \ || txtarticleTitle.Text.Trim().ToString() == \ || txtarticleBrief.Text.Trim().ToString() == \ || txtarticleContent.Text.Trim().ToString() == \) {

Response.Write(\文章作者、文章标题、文章摘要、文章类容均不能为空!')\); } else {

ArticleManage am = new ArticleManage(); am.ArticleAuthor =

txtarticleAuthor.Text.Trim().ToString(); am.ArticleTitle =

txtarticleTitle.Text.Trim().ToString(); am.ArticleBrief =

txtarticleBrief.Text.Trim().ToString(); am.ArticleContent =

txtarticleContent.Text.Trim().ToString();

am.ArticleDate = DateTime.Now; am.ArticleRQ = 0; am.ArticleReply = 0; am.ClassId =

Convert.ToInt32(drpclassName.SelectedValue.ToString()); int i = 0;

i=am.AddArticle(); if (i > 0) {

Response.Redirect(\); } else {

Response.Write(\添加文章失败!')\); } } }

运行界面如下:

20


个人博客系统毕业论文设计(终稿)(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:八年级地理 会考模拟试卷

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: