private void ShowInfo(int _id) { BLL.Forum_Topic bll = new BLL.Forum_Topic(); Model.Forum_Topic model = bll.GetModel(_id); //编写赋值操作Begin txtUserId.Text = model.PostUserId.ToString(); ddlBoardId.SelectedValue = model.BoardId.ToString(); txtTopicTypeId.Text = model.TopicTypeId.ToString(); txtTitle.Text = model.Title; txtViewCount.Text = model.ViewCount.ToString(); txtPostDatetime.Text = model.PostDatetime.ToString(); if (model.Digest == 1) { cblItem.Items[0].Selected = true; } if (model.Top == 1) { cblItem.Items[1].Selected = true; } if (model.Ban == 1) { cblItem.Items[2].Selected = true; } rblClose.SelectedValue = model.Close.ToString(); modelPost = new BLL.Forum_Post(model.PostSubTable).GetModel(" First=1 and TopicId=" + _id + " "); txtMessage.Text = modelPost.Message; //编写赋值操作End }
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 Add(Model.Forum_Topic modelTopic, Model.Forum_Post modelPost) { modelTopic.LastPostUserId = modelPost.PostUserId; modelTopic.LastPostNickname = modelPost.PostNickname; modelTopic.LastPostUsername = modelPost.PostUsername; modelTopic.LastPostDatetime = System.DateTime.Now; modelTopic.ReplayCount = modelTopic.ReplayCount + 1; //主题与回贴不是同一人才记录入回复记录表 if (modelTopic.PostUserId != modelPost.PostUserId) { //回贴归属 new Forum_MyPost().Add(new Model.Forum_MyPost { TopicId = modelTopic.Id, UserId = modelPost.PostUserId, PostId = modelPost.Id }); } //更新主题 new Forum_Topic().Update(modelTopic); //版块统计 Model.Forum_Board modelBoard = new BLL.Forum_Board().GetModel(modelTopic.BoardId); string strIds = "0" + modelBoard.ClassList + "0"; string strSql = "UPDATE [" + siteConfig.sysdatabaseprefix + "Forum_Board] SET [PostCount]=[PostCount]+1 WHERE Id in (" + strIds + ")"; DbHelperSQL.ExecuteSql(strSql); dal.Add(modelPost); //除了标题贴 if (modelPost.First == 0) { //获得实际积分 int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(modelTopic.BoardId, 2); new Forum_UserExtended().UpdateField(modelPost.PostUserId, " PostCount=PostCount+1 ,Credit=Credit+" + _point); new BLL.Forum_PostSubTable().UpdateField(modelTopic.PostSubTable, " PostCount=PostCount+1 "); } }
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 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 }); }
private bool DoEdit(int _id) { bool result = false; BLL.Forum_Topic bll = new BLL.Forum_Topic(); Model.Forum_Topic model = bll.GetModel(_id); //编写编辑操作Begin model.BoardId = Convert.ToInt32(ddlBoardId.SelectedValue); //model.TopicTypeId = txtTopicTypeId.Text; model.Title = txtTitle.Text; model.PostDatetime = Convert.ToDateTime(txtPostDatetime.Text); model.Digest = 0; model.Top = 0; model.Ban = 0; model.Close = 0; if (cblItem.Items[0].Selected) { model.Digest = 1; } if (cblItem.Items[1].Selected) { model.Top = 1; } if (cblItem.Items[2].Selected) { model.Ban = 1; } if (rblClose.SelectedValue == "1") { model.Close = 1; } model.Message = txtMessage.Text; modelPost = new BLL.Forum_Post(model.PostSubTable).GetModel(" First=1 and TopicId=" + _id + " "); modelPost.Message = txtMessage.Text; //编写编辑操作End model.PostUserId = modelUser.id; model.PostUsername = modelUser.user_name; model.PostNickname = modelUser.nick_name; modelPost.PostUserId = modelUser.id; modelPost.PostUsername = modelUser.user_name; modelPost.PostNickname = modelUser.nick_name; if (bll.Update(model, modelPost)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.Title); //记录日志 result = true; } return(result); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Forum_Post model) { return(dal.Update(model)); }
/// <summary> /// 更新一条主题表及回贴 /// </summary> public bool Update(Model.Forum_Topic model, Model.Forum_Post modelPost) { new DAL.Forum_Post(siteConfig.sysdatabaseprefix, model.PostSubTable).Update(modelPost); return(dal.Update(model)); }
protected bool bolAttachment = false; //是否有上传附件的权限 /// <summary> /// 重写虚方法,此方法在Init事件执行 /// </summary> protected override void InitPage() { board_id = DTRequest.GetQueryInt("board_id", 0); topic_id = DTRequest.GetQueryInt("topic_id", 0); post_id = DTRequest.GetQueryInt("post_id", 0); action = DTRequest.GetQueryString("action"); if (Request.UrlReferrer == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,源路异常请正确访问!"))); return; } if (GetOnlineUser() == null) { Response.Write("<script> alert('对不起,您还未登录!');window.location.href='" + Request.UrlReferrer.ToString() + "';</script>"); Response.End(); return; } modelBoard = new BLL.Forum_Board().GetModel(board_id); if (modelBoard == null) { modelBoard = new Model.Forum_Board(); } if (topic_id != 0) { modelTopic = new BLL.Forum_Topic().GetModel(topic_id); if (modelTopic == null) { modelTopic = new Model.Forum_Topic(); } } if (action != "reply") { if (post_id != 0) { modelPost = new BLL.Forum_Post(modelTopic.PostSubTable).GetModel(post_id); if (modelPost == null) { modelPost = new Model.Forum_Post(); } } if (post_id != 0) { drAttList = new BLL.Forum_Attachment().GetList(" UserId=" + modelUserExtended.UserId + " and BoardId=" + board_id + " and TopicId=" + topic_id + " and PostId=" + post_id + " ").Tables[0].Select(" 1=1 ", "id asc"); } } drSubList = new BLL.Forum_Board().GetAllList(board_id).Select(" 1=1 ", "SortId asc"); turl = Request.UrlReferrer.ToString(); int _groupId = 0; if (modelUserExtended != null) { _groupId = modelUserExtended.GroupId; } bolAttachment = BLL.Forum_BoardPermission.CheckPermission(board_id + "|" + _groupId, "UploadAttachment"); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Model.Forum_Post model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "Forum_Post_" + postSubTableId.ToString() + "("); strSql.Append("Id,BoardId,TopicId,PostUserId,PostUsername,PostNickname,PostUserIp,PostDateTime,Title,Message,HTML,Smile,UBB,Attachment,Signature,Url,Audit,First,Invisible,Ban,Grade,Hide,UpdateUserId,UpdateUsername,UpdateNickname,UpdateTime,Support,Against,QuoteUserId,QuoteMessage,QuoteNickname,QuotePostIds"); strSql.Append(") values ("); strSql.Append("@Id,@BoardId,@TopicId,@PostUserId,@PostUsername,@PostNickname,@PostUserIp,@PostDateTime,@Title,@Message,@HTML,@Smile,@UBB,@Attachment,@Signature,@Url,@Audit,@First,@Invisible,@Ban,@Grade,@Hide,@UpdateUserId,@UpdateUsername,@UpdateNickname,@UpdateTime,@Support,@Against,@QuoteUserId,@QuoteMessage,@QuoteNickname,@QuotePostIds"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@BoardId", SqlDbType.Int, 4), new SqlParameter("@TopicId", SqlDbType.Int, 4), new SqlParameter("@PostUserId", SqlDbType.Int, 4), new SqlParameter("@PostUsername", SqlDbType.NVarChar, 64), new SqlParameter("@PostNickname", SqlDbType.NVarChar, 50), new SqlParameter("@PostUserIp", SqlDbType.NVarChar, 32), new SqlParameter("@PostDateTime", SqlDbType.DateTime), new SqlParameter("@Title", SqlDbType.NVarChar, 64), new SqlParameter("@Message", SqlDbType.NText), new SqlParameter("@HTML", SqlDbType.TinyInt, 1), new SqlParameter("@Smile", SqlDbType.TinyInt, 1), new SqlParameter("@UBB", SqlDbType.TinyInt, 1), new SqlParameter("@Attachment", SqlDbType.Int, 4), new SqlParameter("@Signature", SqlDbType.TinyInt, 1), new SqlParameter("@Url", SqlDbType.TinyInt, 1), new SqlParameter("@Audit", SqlDbType.TinyInt, 1), new SqlParameter("@First", SqlDbType.TinyInt, 1), new SqlParameter("@Invisible", SqlDbType.TinyInt, 1), new SqlParameter("@Ban", SqlDbType.TinyInt, 1), new SqlParameter("@Grade", SqlDbType.Int, 4), new SqlParameter("@Hide", SqlDbType.TinyInt, 1), new SqlParameter("@UpdateUserId", SqlDbType.Int, 4), new SqlParameter("@UpdateUsername", SqlDbType.NVarChar, 32), new SqlParameter("@UpdateNickname", SqlDbType.NVarChar, 50), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@Support", SqlDbType.Int, 4), new SqlParameter("@Against", SqlDbType.Int, 4), new SqlParameter("@QuoteUserId", SqlDbType.Int, 4), new SqlParameter("@QuoteMessage", SqlDbType.NText), new SqlParameter("@QuoteNickname", SqlDbType.NVarChar, 50), new SqlParameter("@QuotePostIds", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Id; parameters[1].Value = model.BoardId; parameters[2].Value = model.TopicId; parameters[3].Value = model.PostUserId; parameters[4].Value = model.PostUsername; parameters[5].Value = model.PostNickname; parameters[6].Value = model.PostUserIp; parameters[7].Value = model.PostDateTime; parameters[8].Value = model.Title; parameters[9].Value = model.Message; parameters[10].Value = model.HTML; parameters[11].Value = model.Smile; parameters[12].Value = model.UBB; parameters[13].Value = model.Attachment; parameters[14].Value = model.Signature; parameters[15].Value = model.Url; parameters[16].Value = model.Audit; parameters[17].Value = model.First; parameters[18].Value = model.Invisible; parameters[19].Value = model.Ban; parameters[20].Value = model.Grade; parameters[21].Value = model.Hide; parameters[22].Value = model.UpdateUserId; parameters[23].Value = model.UpdateUsername; parameters[24].Value = model.UpdateNickname; parameters[25].Value = model.UpdateTime; parameters[26].Value = model.Support; parameters[27].Value = model.Against; parameters[28].Value = model.QuoteUserId; parameters[29].Value = model.QuoteMessage; parameters[30].Value = model.QuoteNickname; parameters[31].Value = model.QuotePostIds; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Forum_Post DataRowToModel(DataRow row) { if (row != null) { Model.Forum_Post model = new Model.Forum_Post(); if (row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["BoardId"].ToString() != "") { model.BoardId = int.Parse(row["BoardId"].ToString()); } if (row["TopicId"].ToString() != "") { model.TopicId = int.Parse(row["TopicId"].ToString()); } if (row["PostUserId"].ToString() != "") { model.PostUserId = int.Parse(row["PostUserId"].ToString()); } model.PostUsername = row["PostUsername"].ToString(); model.PostNickname = row["PostNickname"].ToString(); model.PostUserIp = row["PostUserIp"].ToString(); if (row["PostDateTime"].ToString() != "") { model.PostDateTime = DateTime.Parse(row["PostDateTime"].ToString()); } model.Title = row["Title"].ToString(); model.Message = row["Message"].ToString(); if (row["HTML"].ToString() != "") { model.HTML = int.Parse(row["HTML"].ToString()); } if (row["Smile"].ToString() != "") { model.Smile = int.Parse(row["Smile"].ToString()); } if (row["UBB"].ToString() != "") { model.UBB = int.Parse(row["UBB"].ToString()); } if (row["Attachment"].ToString() != "") { model.Attachment = int.Parse(row["Attachment"].ToString()); } if (row["Signature"].ToString() != "") { model.Signature = int.Parse(row["Signature"].ToString()); } if (row["Url"].ToString() != "") { model.Url = int.Parse(row["Url"].ToString()); } if (row["Audit"].ToString() != "") { model.Audit = int.Parse(row["Audit"].ToString()); } if (row["First"].ToString() != "") { model.First = int.Parse(row["First"].ToString()); } if (row["Invisible"].ToString() != "") { model.Invisible = int.Parse(row["Invisible"].ToString()); } if (row["Ban"].ToString() != "") { model.Ban = int.Parse(row["Ban"].ToString()); } if (row["Grade"].ToString() != "") { model.Grade = int.Parse(row["Grade"].ToString()); } if (row["Hide"].ToString() != "") { model.Hide = int.Parse(row["Hide"].ToString()); } if (row["UpdateUserId"].ToString() != "") { model.UpdateUserId = int.Parse(row["UpdateUserId"].ToString()); } model.UpdateUsername = row["UpdateUsername"].ToString(); model.UpdateNickname = row["UpdateNickname"].ToString(); if (row["UpdateTime"].ToString() != "") { model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString()); } if (row["Support"].ToString() != "") { model.Support = int.Parse(row["Support"].ToString()); } if (row["Against"].ToString() != "") { model.Against = int.Parse(row["Against"].ToString()); } if (row["QuoteUserId"].ToString() != "") { model.QuoteUserId = int.Parse(row["QuoteUserId"].ToString()); } model.QuotePostIds = row["QuotePostIds"].ToString(); model.QuoteMessage = row["QuoteMessage"].ToString(); model.QuoteNickname = row["QuoteNickname"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Forum_Post model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "Forum_Post_" + postSubTableId.ToString() + " set "); strSql.Append(" Id = @Id , "); strSql.Append(" BoardId = @BoardId , "); strSql.Append(" TopicId = @TopicId , "); strSql.Append(" PostUserId = @PostUserId , "); strSql.Append(" PostUsername = @PostUsername , "); strSql.Append(" PostNickname = @PostNickname , "); strSql.Append(" PostUserIp = @PostUserIp , "); strSql.Append(" PostDateTime = @PostDateTime , "); strSql.Append(" Title = @Title , "); strSql.Append(" Message = @Message , "); strSql.Append(" HTML = @HTML , "); strSql.Append(" Smile = @Smile , "); strSql.Append(" UBB = @UBB , "); strSql.Append(" Attachment = @Attachment , "); strSql.Append(" Signature = @Signature , "); strSql.Append(" Url = @Url , "); strSql.Append(" Audit = @Audit , "); strSql.Append(" First = @First , "); strSql.Append(" Invisible = @Invisible , "); strSql.Append(" Ban = @Ban , "); strSql.Append(" Grade = @Grade , "); strSql.Append(" Hide = @Hide , "); strSql.Append(" UpdateUserId = @UpdateUserId , "); strSql.Append(" UpdateUsername = @UpdateUsername , "); strSql.Append(" UpdateNickname = @UpdateNickname , "); strSql.Append(" UpdateTime = @UpdateTime , "); strSql.Append(" Support = @Support , "); strSql.Append(" Against = @Against , "); strSql.Append(" QuoteUserId = @QuoteUserId , "); strSql.Append(" QuoteMessage = @QuoteMessage , "); strSql.Append(" QuoteNickname = @QuoteNickname "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@BoardId", SqlDbType.Int, 4), new SqlParameter("@TopicId", SqlDbType.Int, 4), new SqlParameter("@PostUserId", SqlDbType.Int, 4), new SqlParameter("@PostUsername", SqlDbType.NVarChar, 64), new SqlParameter("@PostNickname", SqlDbType.NVarChar, 50), new SqlParameter("@PostUserIp", SqlDbType.NVarChar, 32), new SqlParameter("@PostDateTime", SqlDbType.DateTime), new SqlParameter("@Title", SqlDbType.NVarChar, 64), new SqlParameter("@Message", SqlDbType.NText), new SqlParameter("@HTML", SqlDbType.TinyInt, 1), new SqlParameter("@Smile", SqlDbType.TinyInt, 1), new SqlParameter("@UBB", SqlDbType.TinyInt, 1), new SqlParameter("@Attachment", SqlDbType.Int, 4), new SqlParameter("@Signature", SqlDbType.TinyInt, 1), new SqlParameter("@Url", SqlDbType.TinyInt, 1), new SqlParameter("@Audit", SqlDbType.TinyInt, 1), new SqlParameter("@First", SqlDbType.TinyInt, 1), new SqlParameter("@Invisible", SqlDbType.TinyInt, 1), new SqlParameter("@Ban", SqlDbType.TinyInt, 1), new SqlParameter("@Grade", SqlDbType.Int, 4), new SqlParameter("@Hide", SqlDbType.TinyInt, 1), new SqlParameter("@UpdateUserId", SqlDbType.Int, 4), new SqlParameter("@UpdateUsername", SqlDbType.NVarChar, 32), new SqlParameter("@UpdateNickname", SqlDbType.NVarChar, 50), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@Support", SqlDbType.Int, 4), new SqlParameter("@Against", SqlDbType.Int, 4), new SqlParameter("@QuoteUserId", SqlDbType.Int, 4), new SqlParameter("@QuoteMessage", SqlDbType.NText), new SqlParameter("@QuoteNickname", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Id; parameters[1].Value = model.BoardId; parameters[2].Value = model.TopicId; parameters[3].Value = model.PostUserId; parameters[4].Value = model.PostUsername; parameters[5].Value = model.PostNickname; parameters[6].Value = model.PostUserIp; parameters[7].Value = model.PostDateTime; parameters[8].Value = model.Title; parameters[9].Value = model.Message; parameters[10].Value = model.HTML; parameters[11].Value = model.Smile; parameters[12].Value = model.UBB; parameters[13].Value = model.Attachment; parameters[14].Value = model.Signature; parameters[15].Value = model.Url; parameters[16].Value = model.Audit; parameters[17].Value = model.First; parameters[18].Value = model.Invisible; parameters[19].Value = model.Ban; parameters[20].Value = model.Grade; parameters[21].Value = model.Hide; parameters[22].Value = model.UpdateUserId; parameters[23].Value = model.UpdateUsername; parameters[24].Value = model.UpdateNickname; parameters[25].Value = model.UpdateTime; parameters[26].Value = model.Support; parameters[27].Value = model.Against; parameters[28].Value = model.QuoteUserId; parameters[29].Value = model.QuoteMessage; parameters[30].Value = model.QuoteNickname; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }