📄 commentmodify.cs
字号:
namespace PowerEasy.WebSite.User.Contents
{
using PowerEasy.Contents;
using PowerEasy.Controls;
using PowerEasy.Model.Contents;
using PowerEasy.Model.UserManage;
using PowerEasy.UserManage;
using PowerEasy.Web.UI;
using PowerEasy.WebSite.Controls;
using System;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class CommentModify : DynamicPage
{
protected Button BtnReset;
protected Button BtnSubmit;
protected CheckBox ChkReplyIsPrivate;
private string commonlink = ("CommentID=" + BasePage.RequestInt32("CommentID").ToString() + "&GeneralID=" + BasePage.RequestInt32("GeneralID").ToString() + "&NodeID=" + BasePage.RequestInt32("NodeID").ToString() + "&Title=" + BasePage.RequestInt32("Title").ToString());
protected HtmlForm form1;
protected HtmlHead Head1;
protected Label LblCommentTitle;
protected Label LblUserInfo;
protected Label LblUserName;
protected PowerEasy.WebSite.Controls.ScoreControl ScoreControl;
protected HtmlTableRow trEmail;
protected HtmlTableRow trUser;
protected TextBox TxtCommentContent;
protected TextBox TxtCommentTitle;
protected TextBox TxtEmail;
protected PowerEasy.Controls.RequiredFieldValidator ValrCommentContent;
protected PowerEasy.Controls.RequiredFieldValidator ValrCommentTitle;
protected void BtnReset_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("CommentManage.aspx?" + this.commonlink);
}
protected void BtnSubmit_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
CommentInfo commentInfo = Comment.GetCommentInfo(BasePage.RequestInt32("CommentID"));
if (commentInfo.IsNull)
{
DynamicPage.WriteErrMsg("<li>该评论不存在,请返回!</li>");
}
if (commentInfo.UserId != 0)
{
UserInfo userById = Users.GetUserById(commentInfo.UserId);
if (userById.IsNull)
{
DynamicPage.WriteUserErrMsg("<li>该评论所属的用户不存在,请返回!</li>");
}
commentInfo.UserName = userById.UserName;
commentInfo.Email = userById.Email;
}
else
{
commentInfo.Email = this.TxtEmail.Text;
}
commentInfo.CommentTitle = this.TxtCommentTitle.Text;
commentInfo.Content = this.TxtCommentContent.Text;
commentInfo.Score = this.ScoreControl.Score;
if (this.ChkReplyIsPrivate.Checked)
{
commentInfo.IsPrivate = true;
}
else
{
commentInfo.IsPrivate = false;
}
if (Comment.Update(commentInfo))
{
DynamicPage.WriteUserSuccessMsg("<li>修改评论成功。</li>", "CommentManage.aspx?" + this.commonlink);
}
else
{
DynamicPage.WriteUserErrMsg("<li>修改评论失败,请返回。</li>");
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!base.IsPostBack)
{
CommentInfo commentInfo = Comment.GetCommentInfo(BasePage.RequestInt32("CommentID"));
if (commentInfo.IsNull)
{
DynamicPage.WriteUserErrMsg("<li>该评论不存在,请返回!</li>");
}
if (commentInfo.UserId != 0)
{
this.LblUserInfo.Visible = true;
StringBuilder builder = new StringBuilder();
UserInfo userById = Users.GetUserById(commentInfo.UserId);
if (userById.IsNull)
{
DynamicPage.WriteUserErrMsg("<li>该评论所属的用户不存在,请返回!</li>");
}
builder.Append("<tr class='tdbg'>");
builder.Append("<td class='tdbgleft' align='right' style='width: 150px; '>");
builder.Append("<strong>用户名: </strong></td>");
builder.Append("<td class='tdbg' align='left' >");
builder.Append(userById.UserName);
builder.Append("</td></tr>");
builder.Append("<tr class='tdbg'>");
builder.Append("<td class='tdbgleft' align='right' style='width: 150px; '>");
builder.Append("<strong>邮件: </strong></td>");
builder.Append("<td class='tdbg' align='left' >");
builder.Append(userById.Email);
builder.Append("</td></tr>");
this.LblUserInfo.Text = builder.ToString();
this.trUser.Visible = false;
this.trEmail.Visible = false;
}
this.LblUserName.Text = commentInfo.ReplyUserName;
this.TxtEmail.Text = commentInfo.Email;
this.TxtCommentTitle.Text = commentInfo.CommentTitle;
this.TxtCommentContent.Text = commentInfo.Content;
this.ScoreControl.Score = commentInfo.Score;
if (commentInfo.IsPrivate)
{
this.ChkReplyIsPrivate.Checked = true;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -