示例#1
0
        /// <summary>
        /// 添加/编辑关键字组
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string key = txtKeyword.Text.Replace(" ", "");

            if (IsHasCHZN(txtUrl.Text.Trim()))
            {
                MessageBox.Show(this, "URL链接不能有中文字符.");
                return;
            }
            tagKeyInfoModel = new EyouSoft.Model.NewsStructure.TagKeyInfo()
            {
                Category   = EyouSoft.Model.NewsStructure.ItemCategory.KeyWord,
                ItemName   = EyouSoft.Common.Function.StringValidate.Encode(key),
                ItemUrl    = txtUrl.Text.Trim(),
                OperatorId = base.MasterUserInfo.ID
            };
            bool result = false;

            try
            {
                if (btnAdd.CommandName.Equals("Add"))        //添加关键字
                {
                    if (tagKeyInfoBLL.KeyWordExists(key, 0)) //如果该关键字已经存在
                    {
                        MessageBox.Show(this, "关键字已经存在,请重新输入!!!");
                        return;
                    }
                    result = tagKeyInfoBLL.Add(tagKeyInfoModel);
                }
                else if (btnAdd.CommandName.Equals("Edit")) //编辑关键字
                {
                    int ID;
                    result = int.TryParse(hfID.Value, out ID);
                    if (result)
                    {
                        if (tagKeyInfoBLL.KeyWordExists(key, ID))  //如果该关键字已经存在
                        {
                            MessageBox.Show(this, "关键字已经存在,请重新输入!!!");
                            return;
                        }
                        tagKeyInfoModel.Id = ID;
                        result             = tagKeyInfoBLL.Update(tagKeyInfoModel);
                    }
                }
                if (result)
                {
                    hfID.Value = string.Empty;
                    MessageBox.ShowAndRedirect(this, "关键字组操作成功", "Keyword.aspx");
                }
                else
                {
                    MessageBox.Show(this, "操作失败");
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "操作失败");
            }
        }
示例#2
0
        /// <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, "操作失败");
            }
        }