📄 editcomment.ascx.cs
字号:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DNNLite.Entites.Modules;
using DNNLite.DesktopModules.Comment;
using NHibernate.Expression;
using DNNLite.Service;
using System.Data;
public partial class DesktopModules_Comment_EditComment : PortalModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Request["returnurl"]))
{
btnReturnPage.Visible = false;
}
if (!IsPostBack)
{
DataTable tb = DbService.GetTable(@"select distinct sourcetabmodule from commentsubject
where not sourcetabmodule is null
and sourcetabmodule in (select tabmoduleid from tabmodule)
");
ddlTabModule.Items.Add("--全部模块--");
for (int i = 0; i < tb.Rows.Count ; i++)
{
int tabmoduleid = (int)tb.Rows[i][0];
TabModule tm = DNNLite.Service.SystemLoadController.GetTabModule(tabmoduleid);
if (tm != null)
{
ListItem itm = new ListItem();
itm.Text = tm.Tab.Title +"--"+ "[" + tm.PaneName + "]"+ tm.Title ;
itm.Value = tabmoduleid.ToString();
ddlTabModule.Items.Add(itm);
}
}
if (!string.IsNullOrEmpty(Request["subjectid"]))
{
ViewState["subjectid"] = Request["subjectid"];
BindComments(int.Parse(ViewState["subjectid"].ToString()));
MultiView1.ActiveViewIndex = 1;
return;
}
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
BindSubject();
}
#region 绑定主题列表
private void BindSubject()
{
NHibernate.Expression.ICriterion express = new LikeExpression("Subject", txtSubject.Text, MatchMode.Anywhere);
if (ddlTabModule.SelectedIndex > 0)
{
express =
new AndExpression(
express,
new EqExpression("SourceTabModule", int.Parse(ddlTabModule.SelectedValue)));
}
CommentSubject[] cs = CommentSubject.FindAll(CommentSubject.Desc("Id"),
express
);
grdSubjects.DataSource = cs;
grdSubjects.DataBind();
}
#endregion
protected void grdSubjects_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdSubjects.PageIndex = e.NewPageIndex;
BindSubject();
}
protected void grdSubjects_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "E")
{
BindComments(int.Parse(e.CommandArgument.ToString()));
MultiView1.ActiveViewIndex = 1;
}
}
#region 绑定评论列表
private void BindComments( int commentsubjectid )
{
CommentSubject cs = CommentSubject.Find(commentsubjectid);
ViewState["subjectid"] = commentsubjectid;
Comment[] c = Comment.FindAll(
Comment.Desc("CreateDate"), new EqExpression("Subject", cs),
new LikeExpression("RawCommentContent", txtSearcComment.Text , MatchMode.Anywhere )
);
litsubject.Text = cs.Subject ;
grdComments.DataSource = c;
grdComments.DataBind();
}
#endregion
protected void btnBackList_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
ViewState["subjectid"] = null;
grdComments.DataSource = null;
grdComments.DataBind();
}
protected void grdComments_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName )
{
case "S":
Comment cs = Comment.Find(int.Parse(e.CommandArgument.ToString()));
cs.Visible = !cs.Visible;
cs.UpdateAndFlush();
BindComments(int.Parse(ViewState["subjectid"].ToString()));
break;
case "D":
Comment cd = Comment.Find(int.Parse(e.CommandArgument.ToString()));
cd.Subject.CommentCount -= 1;
if (!cd.StandPoint.HasValue)
{
cd.Subject.Neutrals -= 1;
}
else if (cd.StandPoint.Value == true)
{
cd.Subject.Backers -= 1;
}
else
{
cd.Subject.Antis -= 1;
}
cd.Subject.UpdateAndFlush();
cd.DeleteAndFlush();
BindComments(int.Parse(ViewState["subjectid"].ToString()));
break;
case "E":
MultiView1.ActiveViewIndex = 2;
Comment c = Comment.Find(int.Parse(e.CommandArgument.ToString()));
BindComment(c);
break;
default:
break;
}
}
protected void btnSearchComment_Click(object sender, EventArgs e)
{
BindComments(int.Parse(ViewState["subjectid"].ToString()));
}
protected void grdComments_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdComments.PageIndex = e.NewPageIndex;
BindComments(int.Parse(ViewState["subjectid"].ToString()));
}
private void BindComment( Comment c )
{
ViewState["commentid"] = c.Id;
txtRawCommentContent.Text = c.RawCommentContent;
txtRawFeedBackContent.Text = c.RawFeedBackContent;
}
protected void btnBackCommentList_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
protected void btnUpdateComment_Click(object sender, EventArgs e)
{
Comment c = Comment.Find(int.Parse(ViewState["commentid"].ToString()));
c.RawCommentContent = txtRawCommentContent.Text;
c.RawFeedBackContent = txtRawFeedBackContent.Text;
c.UpdateAndFlush();
//BindComments(int.Parse(ViewState["subjectid"].ToString()));
}
protected void btnReturnPage_Click(object sender, EventArgs e)
{
Response.Redirect( Server.UrlDecode( Request["returnurl"]));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -