//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("plugin_forum_post", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.Forum_Post bll = new BLL.Forum_Post(subTableId); BLL.Forum_Topic bllTopic = new BLL.Forum_Topic(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int topicId = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidTopicId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { //调用与前台一样的方法 bllTopic.DeleterReply(id.ToString(), topicId); sucCount += 1; } } AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除dt_Forum_Post_" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("Post_list.aspx", "keywords={0}&subTableId={1}", this.keywords, this.subTableId.ToString())); }
private void ShowInfo(int _id) { BLL.Forum_Post bll = new BLL.Forum_Post(subTableId); Model.Forum_Post model = bll.GetModel(_id); //编写赋值操作Begin txtMessage.Text = model.Message; rblBan.SelectedValue = model.Ban.ToString(); //编写赋值操作End }
/// <summary> /// 删除回贴,标题统计,版块统计,积分一并处理,有附件的一并处理 /// </summary> public void DeleterReply(string rids, int topic_id) { Model.Forum_Topic modelTopic = GetModel(topic_id); System.Data.DataTable dt = new BLL.Forum_Post(modelTopic.PostSubTable).GetList(" id in (" + rids + ") ").Tables[0]; //获得实际积分 int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(modelTopic.BoardId, 6); BLL.Forum_Attachment bllAtt = new Forum_Attachment(); for (int i = 0; i < dt.Rows.Count; i++) { new Forum_UserExtended().UpdateField(Convert.ToInt32(dt.Rows[i]["PostUserId"]), " PostCount=PostCount-1 , Credit=Credit+" + _point); //附件处理 if (Convert.ToInt32(dt.Rows[i]["Attachment"]) != 0) { List <Model.Forum_Attachment> dtAtt = bllAtt.GetModelList(" PostId=" + dt.Rows[i]["id"].ToString()); foreach (Model.Forum_Attachment item in dtAtt) { bllAtt.Delete(item, item.Id); } } } string strSql = "DELETE [" + siteConfig.sysdatabaseprefix + "Forum_Post_" + modelTopic.PostSubTable + "] WHERE ID in (" + rids + ")"; //影响记录数相当于删了多少条数据 int _count = 0; if (!string.IsNullOrEmpty(strSql)) { _count = DbHelperSQL.ExecuteSql(strSql); } modelTopic.ReplayCount = modelTopic.ReplayCount - _count; Update(modelTopic); //版块包括父级版块的统计 string strValue = "[PostCount]=[PostCount]-" + _count + ""; Model.Forum_Board modelBoard = new BLL.Forum_Board().GetModel(modelTopic.BoardId); new Forum_Board().UpdateField(" Id in (0" + modelBoard.ClassList + "0) ", strValue); new Forum_PostId().DeleteList(rids); new Forum_PostSubTable().UpdateField(modelTopic.PostSubTable, " PostCount=PostCount-" + _count); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.Forum_Post bll = new BLL.Forum_Post(subTableId); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, 0, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("Post_list.aspx", "keywords={0}&page={1}&subTableId={2}", this.keywords, "__id__", this.subTableId.ToString()); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private bool DoEdit(int _id) { bool result = false; BLL.Forum_Post bll = new BLL.Forum_Post(subTableId); Model.Forum_Post model = bll.GetModel(_id); //编写编辑操作Begin model.Message = txtMessage.Text; model.Ban = Convert.ToInt32(rblBan.SelectedValue); //编写编辑操作End if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.Title); //记录日志 result = true; } return(result); }
private void editor(HttpContext context) { string _v = verify_code(context, vc); if (_v != "success") { JsonHelper.WriteJson(context, new { error = 1, description = _v }); } if (string.IsNullOrEmpty(message)) { JsonHelper.WriteJson(context, new { error = 1, description = "内容不写你打算做什么呢!" }); } if (!BLL.Forum_BoardPermission.CheckPermission(board_id + "|" + modelUser.GroupId, "UpdateMyselfReply")) { JsonHelper.WriteJson(context, new { error = 1, description = "您当前还没有权限哦!" }); } message = FilterWord(message); Model.Forum_Topic modelTopic = new BLL.Forum_Topic().GetModel(topic_id); foreach (string item in context.Request.Form.AllKeys) { if (item.ToLower().IndexOf("attachment_description_") != -1) { string strDescription = context.Request.Form[item].ToString(); string _id = item.ToLower().Replace("attachment_description_", "").Replace("'", ""); new BLL.Forum_Attachment().UpdateField("Id=" + _id, " Description='" + strDescription + "' "); } } //上传图片的张数 int attachment_count = new BLL.Forum_Attachment().GetCount(" [BoardId]=" + board_id + " and [UserId]=" + modelUser.UserId + " and [PostId]=" + post_id + " "); Model.Forum_Post modelPost = new BLL.Forum_Post(modelTopic.PostSubTable).GetModel(post_id); modelPost.Signature = signature; modelPost.Url = autoUrl; modelPost.Message = message; modelPost.Attachment = attachment_count; new BLL.Forum_Post(modelTopic.PostSubTable).Update(modelPost); JsonHelper.WriteJson(context, new { tid = modelTopic.Id, turl = turl }); }
private void reply(HttpContext context) { string _v = verify_code(context, vc); if (_v != "success") { JsonHelper.WriteJson(context, new { error = 1, description = _v }); } if (string.IsNullOrEmpty(message)) { JsonHelper.WriteJson(context, new { error = 1, description = "内容不写你打算做什么呢!" }); } if (!BLL.Forum_BoardPermission.CheckPermission(board_id + "|" + modelUser.GroupId, "PostReply")) { JsonHelper.WriteJson(context, new { error = 1, description = "您当前还没有权限哦!" }); } message = FilterWord(message); Model.Forum_Topic modelTopic = new BLL.Forum_Topic().GetModel(topic_id); int _post_id = new BLL.Forum_PostId().Add(new Model.Forum_PostId { TopicId = topic_id }); int attachment_count = 0; foreach (string item in context.Request.Form.AllKeys) { if (item.ToLower().IndexOf("attachment_description_") != -1) { attachment_count += 1; string strDescription = context.Request.Form[item].ToString().Replace("'", ""); string _id = item.ToLower().Replace("attachment_description_", "").Replace("'", ""); new BLL.Forum_Attachment().UpdateField("Id=" + _id, " [TopicId]=" + modelTopic.Id + ",[PostId]=" + _post_id + " , Description='" + strDescription + "' "); } } //int attachment_count = new BLL.Forum_Attachment().UpdateField(" [BoardId]=" + board_id + " and [UserId]=" + modelUser.UserId + " and [PostId]=0 ", " [TopicId]=" + modelTopic.Id + ",[PostId]=" + _post_id + " "); Model.Forum_Post modelPost = new Model.Forum_Post(); modelPost.BoardId = modelTopic.BoardId; modelPost.Title = modelTopic.Title; modelPost.Signature = signature; modelPost.Url = autoUrl; modelPost.Message = message; modelPost.TopicId = topic_id; modelPost.PostUserId = modelUser.UserId; modelPost.PostUsername = modelUser.UserName; modelPost.PostNickname = modelUser.Nickname; modelPost.PostDateTime = System.DateTime.Now; modelPost.Id = _post_id; modelPost.Attachment = attachment_count; BLL.Forum_Post bll = new BLL.Forum_Post(modelTopic.PostSubTable); //引用 if (post_id != 0) { Model.Forum_Post modelQuotePost = bll.GetModel(post_id); if (modelQuotePost != null) { if (string.IsNullOrEmpty(modelQuotePost.QuotePostIds)) { modelPost.QuotePostIds = modelQuotePost.Id.ToString(); } else { //拼接 modelPost.QuotePostIds = modelQuotePost.QuotePostIds + "," + modelQuotePost.Id.ToString(); } modelPost.QuoteUserId = modelQuotePost.PostUserId; modelPost.QuoteNickname = modelQuotePost.PostNickname; modelPost.QuoteMessage = modelQuotePost.Message; } } bll.Add(modelTopic, modelPost); HttpContext.Current.Session["SESSION_USER_EXTENDED"] = new BLL.Forum_UserExtended().SetGroupId(modelUser); JsonHelper.WriteJson(context, new { tid = modelTopic.Id, turl = new DTcms.Web.UI.BasePage().linkurl("forum_topic", modelTopic.Id, -_post_id) + "#reply_" + _post_id }); }
/// <summary> /// 内部 删除一条数据及主题的回贴并重新统计版块的主题总数,积分,我的主题,我的回复一起清除 /// </summary> public bool Delete(int Id) { Model.Forum_Topic model = GetModel(Id); //--删除回复---------------------------------- System.Data.DataTable dt = new BLL.Forum_Post(model.PostSubTable).GetList(9999999, " TopicId=" + Id + " ", " id asc ").Tables[0]; //获得实际积分,调整,删除主题不牵联其它已经回复者的积分 //int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(model.BoardId, 6); BLL.Forum_Attachment bllAtt = new Forum_Attachment(); for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i]["First"].ToString()) == 0) { new Forum_UserExtended().UpdateField(Convert.ToInt32(dt.Rows[i]["PostUserId"]), " PostCount=PostCount-1 "); } //附件处理 if (Convert.ToInt32(dt.Rows[i]["Attachment"]) != 0) { List <Model.Forum_Attachment> dtAtt = bllAtt.GetModelList(" PostId=" + dt.Rows[i]["id"].ToString()); foreach (Model.Forum_Attachment item in dtAtt) { bllAtt.Delete(item, item.Id); } } } //------------------------------------ new BLL.Forum_Post(model.PostSubTable).DeleteTopicId(Id); //版块包括父级版块的统计 string strValue = "[TopicCount]=[TopicCount]-1,[PostCount]=[PostCount]-" + model.ReplayCount; Model.Forum_Board modelBoard = new BLL.Forum_Board().GetModel(model.BoardId); string strIds = "0" + modelBoard.ClassList + "0"; new Forum_Board().UpdateField(" Id in (" + strIds + ") ", strValue); new Forum_PostSubTable().UpdateField(model.PostSubTable, " TopicCount=TopicCount-1,PostCount=PostCount-" + model.ReplayCount); //获得实际积分 int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(model.BoardId, 5); new Forum_UserExtended().UpdateField(model.PostUserId, " TopicCount=TopicCount-1, Credit=Credit+" + _point); //--主题清空随之 我的主题,我的回复一起清除---------------------------------- new BLL.Forum_MyTopic().Delete("TopicId=" + Id); new BLL.Forum_MyPost().Delete("TopicId=" + Id); return(dal.Delete(Id)); }