/// <summary> /// 添加/修改 Tag标签 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { string tag = txtTag.Text.Replace(" ", ""); tagKeyInfoModel = new EyouSoft.Model.NewsStructure.TagKeyInfo() { Category = EyouSoft.Model.NewsStructure.ItemCategory.Tag, ItemName = EyouSoft.Common.Function.StringValidate.Encode(tag), OperatorId = base.MasterUserInfo.ID }; bool result = false; try { if (btnAdd.CommandName.Equals("Add")) { if (tagKeyInfoBLL.TagExists(tag, 0)) //检测tag是否存在 { MessageBox.Show(this, "该tag已经存在,请重新输入!!!"); return; } result = tagKeyInfoBLL.Add(tagKeyInfoModel); } else if (btnAdd.CommandName.Equals("Edit")) { int ID; result = int.TryParse(hfid.Value, out ID); if (result) { if (tagKeyInfoBLL.TagExists(tag, ID)) //检测tag是否存在 { MessageBox.Show(this, "该tag已经存在,请重新输入!!!"); return; } tagKeyInfoModel.Id = ID; result = tagKeyInfoBLL.Update(tagKeyInfoModel); } } if (result) { hfid.Value = string.Empty; MessageBox.ShowAndRedirect(this, "Tag标签操作成功", "Tag.aspx"); } else { MessageBox.Show(this, "操作失败"); } } catch (Exception) { MessageBox.Show(this, "操作失败"); } }
private void EditKeywordAjax() { string id = Utils.GetFormValue("tid"); string key = Utils.GetFormValue("k").Replace(" ", ""); string url = Utils.GetFormValue("u").Replace(" ", "");; string msg = string.Empty; if (tagKeyInfoBLL.KeyWordExists(key, int.Parse(id))) { msg = "false"; } else { EyouSoft.Model.NewsStructure.TagKeyInfo tagKeyInfoModel = new EyouSoft.Model.NewsStructure.TagKeyInfo() { Category = EyouSoft.Model.NewsStructure.ItemCategory.KeyWord, Id = int.Parse(id), ItemName = key, ItemUrl = url, OperatorId = base.MasterUserInfo.ID }; bool result = tagKeyInfoBLL.Update(tagKeyInfoModel); if (result) { msg = "true"; } else { msg = "ftrue"; } } Response.Clear(); Response.Write("{\"msg\":\"" + msg + "\"}"); Response.End(); }