//单个删除 protected void lbtSingleDelete_Click(object sender, EventArgs e) { var lbtn = sender as LinkButton; BLL.CCOM.News_type bll = new BLL.CCOM.News_type(); BLL.CCOM.News news_bll = new BLL.CCOM.News(); if (lbtn != null) { bool result = false; int newsTypeId = Int32.Parse(DESEncrypt.Decrypt(lbtn.ToolTip.ToString())); if (newsTypeId > 0) { Model.CCOM.News_type model = bll.GetModel(newsTypeId); if (model.News_type_creator_id == GetAdminInfo_CCOM().User_id) { news_bll.Delete(" News_type_id=" + newsTypeId); result = bll.Delete(newsTypeId); } int page = MyRequest.GetQueryInt("page", 1); if (result) { JscriptMsg("删除成功!", Utils.CombUrlTxt("News_type_manage.aspx", "&keywords={0}&page={1}&fun_id={2}", keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Success"); } } } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { BLL.CCOM.News_type bll = new BLL.CCOM.News_type(); int count = 0; bool result = false; for (int i = 0; i < this.rptList.Items.Count; i++) { System.Web.UI.WebControls.CheckBox cb = (System.Web.UI.WebControls.CheckBox)rptList.Items[i].FindControl("chkId"); if (!cb.Checked) { continue; } else { int newsTypeId = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); if (newsTypeId > 0) { Model.CCOM.News_type model = bll.GetModel(newsTypeId); if (model.News_type_creator_id == GetAdminInfo_CCOM().User_id) { result = bll.Delete(newsTypeId); } if (result) { count++; } } } } if (count < 1) { JscriptMsg("请您选择需要删除的资讯类别!", "", "Error"); return; } string keywords = MyRequest.GetQueryString("keywords"); int page = MyRequest.GetQueryInt("page", 1); if (result == true) { JscriptMsg("批量删除成功!", Utils.CombUrlTxt("News_type_manage.aspx", "&keywords={0}&page={1}&fun_id={2}", keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Success"); } else { JscriptMsg("批量删除失败!", Utils.CombUrlTxt("News_type_manage.aspx", "keywords={0}&page={1}&fun_id={2}", keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Error"); } }
/// <summary> /// 添加通知类别 /// </summary> /// <param name="context"></param> private void AddPushType(HttpContext context) { if (!IsAdminLogin()) { FlushResponse(context, JsonConvert.SerializeObject(new ReturnObject() { Result = ERROR, Msg = "error" })); return; } String typeName = MyRequest.GetString("t").Trim(); if (!Common.Utils.IsSafeSqlString(typeName) || typeName == "") { FlushResponse(context, JsonConvert.SerializeObject(new ReturnObject() { Result = ERROR, Msg = "参数不合法!" })); return; } //添加通知类别 var typeBll = new BLL.CCOM.News_type(); var userId = GetAdminInfo().User_id; string strWhere = " News_type_name='" + typeName + "'"; if (typeBll.GetModelList(strWhere).Count == 0) { var typeModel = new Model.CCOM.News_type() { News_type_name = typeName, News_type_creator_id = (int)userId, News_type_date = DateTime.Now }; var typeId = typeBll.Add(typeModel); //添加成功,返回typeId和typeName if (typeId > 0) { FlushResponse(context, JsonConvert.SerializeObject(new ReturnType() { Result = OK, Msg = "资讯类别添加成功!", id = DESEncrypt.Encrypt(typeId.ToString()), name = typeName })); } else { FlushResponse(context, JsonConvert.SerializeObject(new ReturnObject() { Result = ERROR, Msg = "资讯类别添加失败!" })); } } else { FlushResponse(context, JsonConvert.SerializeObject(new ReturnObject() { Result = ERROR, Msg = "该资讯类别已存在!" })); } }