private void ShowInfo(int _id) { BLL.forum_posts bll = new BLL.forum_posts(); Model.forum_posts model = bll.GetModel(id); DTcms.BLL.users ubll = new DTcms.BLL.users(); DTcms.Model.users umodel = ubll.GetModel(model.user_id); ddlCategoryId.SelectedValue = model.board_id.ToString(); txtUserName.Text = umodel.user_name; txtUserName.ReadOnly = true; if (model.is_lock == 1) { cblItem.Items[0].Selected = true; } if (model.is_top == 1) { cblItem.Items[1].Selected = true; } if (model.is_red == 1) { cblItem.Items[2].Selected = true; } if (model.is_hot == 1) { cblItem.Items[3].Selected = true; } txtPostName.Text = model.title; txtPostContent.Value = model.content; }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("plugin_forum_post", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; //成功数量 int errorCount = 0; //失败数量 BLL.forum_posts bll = new BLL.forum_posts(); Repeater rptList = new Repeater(); rptList = this.rptList1; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount++; } else { errorCount++; } } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除帖子成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("post_list.aspx", "board_id={0}&keywords={1}&property={2}", this.board_id.ToString(), this.keywords, this.property)); }
private bool DoAdd() { bool result = false; BLL.forum_posts bll = new BLL.forum_posts(); Model.forum_posts model = new Model.forum_posts(); DTcms.BLL.users ubll = new DTcms.BLL.users(); DTcms.Model.users umodel = new DTcms.Model.users(); //判断用户名是否存在 if (!ubll.Exists(txtUserName.Text.Trim())) { JscriptMsg("用户名不存在,请重新填写!", ""); return(result); } umodel = ubll.GetModel(txtUserName.Text.Trim()); string _userip = System.Web.HttpContext.Current.Request.UserHostAddress; model.class_layer = 1; model.title = txtPostName.Text.Trim(); model.content = txtPostContent.Value; model.user_id = umodel.id; model.user_ip = _userip; model.board_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.parent_post_id = 0; model.post_type = 1;//主题帖 model.reply_time = DateTime.Now; model.click = 0; model.is_lock = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; if (cblItem.Items[0].Selected == true) { model.is_lock = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } model.add_time = DateTime.Now; if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "发布了帖子:" + model.title); //记录日志 result = true; } return(result); }
//批量移动 protected void ddlMoveId_SelectedIndexChanged(object sender, EventArgs e) { ChkAdminLevel("plugin_forum_post", DTEnums.ActionEnum.Edit.ToString()); //检查权限 int sucCount = 0; //成功数量 int postcount = 0; int replycount = 0; if (ddlMoveId.SelectedValue == "") { ddlMoveId.SelectedIndex = 0; JscriptMsg("请选择要移动的类别!", string.Empty); return; } BLL.forum_posts bll = new BLL.forum_posts(); BLL.forum_board bbll = new BLL.forum_board(); Model.forum_board bmodel = new Model.forum_board(); Repeater rptList = new Repeater(); rptList = this.rptList1; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int oldboardid = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidBid")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { DataTable dt = bll.GetList(0, "id=" + id + " or parent_post_id=" + id, "id desc").Tables[0]; foreach (DataRow dr in dt.Rows) { if (int.Parse(dr["parent_post_id"].ToString()) == 0) { postcount += 1; replycount += 1; } else { replycount += 1; } sucCount++; bll.UpdateField(int.Parse(dr["id"].ToString()), "board_id=" + ddlMoveId.SelectedValue); } bmodel = bbll.GetModel(oldboardid); bmodel.subject_count -= postcount; bmodel.post_count -= replycount; bbll.Update(bmodel); bmodel = bbll.GetModel(int.Parse(ddlMoveId.SelectedValue)); bmodel.subject_count += postcount; bmodel.post_count += replycount; bbll.Update(bmodel); } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "批量移动频道内容分类"); //记录日志 JscriptMsg("批量移动成功" + sucCount + "条", Utils.CombUrlTxt("post_list.aspx", "board_id={0}&keywords={1}&property={2}", this.board_id.ToString(), this.keywords, this.property)); }
//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { ChkAdminLevel("plugin_forum_post", DTEnums.ActionEnum.Edit.ToString()); //检查权限 int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.forum_posts bll = new BLL.forum_posts(); Model.forum_posts model = bll.GetModel(id); switch (e.CommandName) { case "lbtnIsTop": if (model.is_top == 1) { bll.UpdateField(id, "is_top=0"); } else { bll.UpdateField(id, "is_top=1"); } break; case "lbtnIsRed": if (model.is_red == 1) { bll.UpdateField(id, "is_red=0"); } else { bll.UpdateField(id, "is_red=1"); } break; case "lbtnIsHot": if (model.is_hot == 1) { bll.UpdateField(id, "is_hot=0"); } else { bll.UpdateField(id, "is_hot=1"); } break; case "lbtnIsLock": if (model.is_lock == 1) { bll.UpdateField(id, "is_lock=0"); } else { bll.UpdateField(id, "is_lock=1"); } break; } this.RptBind(this.board_id, "post_type=1" + CombSqlTxt(this.keywords, this.property), "add_time desc,id desc"); }
private void RptBind(int _board_id, string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); if (this.board_id > 0) { this.ddlCategoryId.SelectedValue = _board_id.ToString(); } this.ddlProperty.SelectedValue = this.property; this.txtKeywords.Text = this.keywords; BLL.forum_posts bll = new BLL.forum_posts(); this.rptList1.DataSource = bll.GetList(_board_id, this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList1.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("post_list.aspx", "board_id={0}&keywords={1}&property={2}&page={3}", _board_id.ToString(), this.keywords, this.property, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//批量审核 protected void btnAudit_Click(object sender, EventArgs e) { ChkAdminLevel("plugin_forum_post", DTEnums.ActionEnum.Audit.ToString()); //检查权限 BLL.forum_posts bll = new BLL.forum_posts(); Repeater rptList = new Repeater(); rptList = this.rptList1; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { bll.UpdateField(id, "is_lock=0"); } } AddAdminLog(DTEnums.ActionEnum.Audit.ToString(), "审核频道内容信息"); //记录日志 JscriptMsg("批量审核成功!", Utils.CombUrlTxt("post_list.aspx", "board_id={0}&keywords={1}&property={2}", this.board_id.ToString(), this.keywords, this.property)); }
private bool DoEdit(int _id) { bool result = false; BLL.forum_posts bll = new BLL.forum_posts(); Model.forum_posts model = bll.GetModel(_id); model.board_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.is_lock = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; if (cblItem.Items[0].Selected == true) { model.is_lock = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } model.title = txtPostName.Text; model.content = txtPostContent.Value; if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改帖子信息:" + model.title); //记录日志 result = true; } return(result); }