示例#1
0
 private void btnSubmitHotkeyword_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtHotKeywords.Text.Trim()) || (txtHotKeywords.Text.Trim().Length > 60))
     {
         ShowMsg("热门关键字不能为空", false);
     }
     else if (!dropCategory.SelectedValue.HasValue)
     {
         ShowMsg("请选择商品主分类", false);
     }
     else
     {
         string[] strArray = txtHotKeywords.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' });
         int      num      = 0;
         foreach (string str in strArray)
         {
             Regex regex = new Regex("^(?!_)(?!.*?_$)(?!-)(?!.*?-$)[a-zA-Z0-9_一-龥-]+$");
             if (!(!regex.IsMatch(str) || IsSame(str, Convert.ToInt32(dropCategory.SelectedValue.Value))))
             {
                 SubsiteStoreHelper.AddHotkeywords(dropCategory.SelectedValue.Value, str);
                 num++;
             }
         }
         if (num > 0)
         {
             ShowMsg(string.Format("成功添加了{0}个热门关键字", num), true);
             txtHotKeywords.Text = "";
             BindData();
         }
     }
 }
示例#2
0
        private void btnSubmitHotkeyword_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtHotKeywords.Text.Trim()) || this.txtHotKeywords.Text.Trim().Length > 60)
            {
                this.ShowMsg("热门关键字不能为空", false);
                return;
            }
            if (!this.dropCategory.SelectedValue.HasValue)
            {
                this.ShowMsg("请选择商品主分类", false);
                return;
            }
            string text = this.txtHotKeywords.Text.Trim().Replace("\r\n", "\n");

            string[] array = text.Replace("\n", "*").Split(new char[]
            {
                '*'
            });
            int num = 0;

            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text2 = array2[i];
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^(?!_)(?!.*?_$)(?!-)(?!.*?-$)[a-zA-Z0-9_一-龥-]+$");
                if (regex.IsMatch(text2) && !this.IsSame(text2, System.Convert.ToInt32(this.dropCategory.SelectedValue.Value)))
                {
                    SubsiteStoreHelper.AddHotkeywords(this.dropCategory.SelectedValue.Value, text2);
                    num++;
                }
            }
            if (num > 0)
            {
                this.ShowMsg(string.Format("成功添加了{0}个热门关键字", num), true);
                this.txtHotKeywords.Text = "";
                this.BindData();
            }
        }