private bool DoEdit(int _id) { bool result = false; BLL.Forum_PostSubTable bll = new BLL.Forum_PostSubTable(); Model.Forum_PostSubTable model = bll.GetModel(_id); //编写编辑操作Begin model.Name = txtName.Text; model.Description = txtDescription.Text; model.Avail = Convert.ToInt32(rblAvail.SelectedValue); //编写编辑操作End //不能存在没有激活的分表 if (model.Avail == 0) { Model.Forum_PostSubTable modelAvail = bll.GetModel(" Avail=1 and id<>" + _id); if (modelAvail == null) { model.Avail = 1; } } if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.Name); //记录日志 result = true; } return(result); }
/// <summary> /// 增加一条数据,内部已经处理分表回贴,版块统计,属归作者表,积分 /// </summary> public int Add(Model.Forum_Topic model, out int _subTable_id, out int _post_id) { Forum_PostSubTable bllSubTable = new Forum_PostSubTable(); Forum_Board bllBoard = new Forum_Board(); Model.Forum_PostSubTable modelSubTable = bllSubTable.GetModel("Avail=1"); //分表ID _subTable_id = modelSubTable.Id; model.PostSubTable = _subTable_id; //主题表ID int _topic_id = dal.Add(model); //回复表ID _post_id = new Forum_PostId().Add(new Model.Forum_PostId { TopicId = _topic_id }); new Forum_Post(_subTable_id).Add(model, new Model.Forum_Post { BoardId = model.BoardId, Message = model.Message, Title = model.Title, PostDateTime = model.PostDatetime, PostNickname = model.PostNickname, PostUsername = model.PostUsername, PostUserId = model.PostUserId, Id = _post_id, TopicId = _topic_id, First = 1 }); //版块包括父级版块的统计、标记最后发贴 string strValue = "[TodayTopicCount]=[TodayTopicCount]+1,[TopicCount]=[TopicCount]+1,[LastPostUserId]=" + model.PostUserId + ",[LastPostUsername]='" + model.PostUsername.Replace("'", "") + "',[LastPostNickname]='" + model.PostNickname.Replace("'", "") + "',[LastTopicId]=" + _topic_id + ",[LastTopicTitle]='" + model.Title.Replace("'", "") + "'"; Model.Forum_Board modelBoard = bllBoard.GetModel(model.BoardId); bllBoard.UpdateField(" Id in (0" + modelBoard.ClassList + "0) ", strValue); //文章归属 new Forum_MyTopic().Add(new Model.Forum_MyTopic { TopicId = _topic_id, UserId = model.PostUserId }); //获得实际积分 int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(model.BoardId, 1); new Forum_UserExtended().UpdateField(model.PostUserId, " TopicCount=TopicCount+1 ,Credit=Credit+" + _point); modelSubTable.TopicCount += 1; bllSubTable.Update(modelSubTable); return(_topic_id); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Forum_PostSubTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "Forum_PostSubTable set "); strSql.Append(" Name = @Name , "); strSql.Append(" Description = @Description , "); strSql.Append(" TopicCount = @TopicCount , "); strSql.Append(" PostCount = @PostCount , "); strSql.Append(" CreateDateTime = @CreateDateTime , "); strSql.Append(" Avail = @Avail , "); strSql.Append(" RecyclePost = @RecyclePost , "); strSql.Append(" UnauditedPost = @UnauditedPost "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 32), new SqlParameter("@Description", SqlDbType.NVarChar, 512), new SqlParameter("@TopicCount", SqlDbType.Int, 4), new SqlParameter("@PostCount", SqlDbType.Int, 4), new SqlParameter("@CreateDateTime", SqlDbType.DateTime), new SqlParameter("@Avail", SqlDbType.TinyInt, 1), new SqlParameter("@RecyclePost", SqlDbType.Int, 4), new SqlParameter("@UnauditedPost", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.Name; parameters[2].Value = model.Description; parameters[3].Value = model.TopicCount; parameters[4].Value = model.PostCount; parameters[5].Value = model.CreateDateTime; parameters[6].Value = model.Avail; parameters[7].Value = model.RecyclePost; parameters[8].Value = model.UnauditedPost; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { UpdateAvail(model.Id, model.Avail); return(true); } else { return(false); } }
private void ShowInfo(int _id) { BLL.Forum_PostSubTable bll = new BLL.Forum_PostSubTable(); Model.Forum_PostSubTable model = bll.GetModel(_id); //编写赋值操作Begin txtName.Text = model.Name; txtDescription.Text = model.Description; rblAvail.SelectedValue = model.Avail.ToString(); //编写赋值操作End }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Forum_PostSubTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "Forum_PostSubTable("); strSql.Append("Name,Description,TopicCount,PostCount,CreateDateTime,Avail,RecyclePost,UnauditedPost"); strSql.Append(") values ("); strSql.Append("@Name,@Description,@TopicCount,@PostCount,@CreateDateTime,@Avail,@RecyclePost,@UnauditedPost"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 32), new SqlParameter("@Description", SqlDbType.NVarChar, 512), new SqlParameter("@TopicCount", SqlDbType.Int, 4), new SqlParameter("@PostCount", SqlDbType.Int, 4), new SqlParameter("@CreateDateTime", SqlDbType.DateTime), new SqlParameter("@Avail", SqlDbType.TinyInt, 1), new SqlParameter("@RecyclePost", SqlDbType.Int, 4), new SqlParameter("@UnauditedPost", SqlDbType.Int, 4) }; parameters[0].Value = model.Name; parameters[1].Value = model.Description; parameters[2].Value = model.TopicCount; parameters[3].Value = model.PostCount; parameters[4].Value = model.CreateDateTime; parameters[5].Value = model.Avail; parameters[6].Value = model.RecyclePost; parameters[7].Value = model.UnauditedPost; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { int _id = Convert.ToInt32(obj); CreateForumPost(_id); UpdateAvail(_id, model.Avail); return(_id); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Forum_PostSubTable DataRowToModel(DataRow row) { if (row != null) { Model.Forum_PostSubTable model = new Model.Forum_PostSubTable(); if (row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } model.Name = row["Name"].ToString(); model.Description = row["Description"].ToString(); if (row["TopicCount"].ToString() != "") { model.TopicCount = int.Parse(row["TopicCount"].ToString()); } if (row["PostCount"].ToString() != "") { model.PostCount = int.Parse(row["PostCount"].ToString()); } if (row["CreateDateTime"].ToString() != "") { model.CreateDateTime = DateTime.Parse(row["CreateDateTime"].ToString()); } if (row["Avail"].ToString() != "") { model.Avail = int.Parse(row["Avail"].ToString()); } if (row["RecyclePost"].ToString() != "") { model.RecyclePost = int.Parse(row["RecyclePost"].ToString()); } if (row["UnauditedPost"].ToString() != "") { model.UnauditedPost = int.Parse(row["UnauditedPost"].ToString()); } return(model); } else { return(null); } }
private bool DoAdd() { Model.Forum_PostSubTable model = new Model.Forum_PostSubTable(); BLL.Forum_PostSubTable bll = new BLL.Forum_PostSubTable(); //编写添加操作Begin model.Name = txtName.Text; model.Description = txtDescription.Text; model.Avail = Convert.ToInt32(rblAvail.SelectedValue); //编写添加操作End if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加dt_Forum_PostSubTable:" + model.Name); //记录日志 return(true); } return(false); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Forum_PostSubTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据,内部会实际的生成分表 /// </summary> public int Add(Model.Forum_PostSubTable model) { int _id = dal.Add(model); return(_id); }