private void btnSubmitHotkeyword_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtHotKeywords.Text.Trim())) { 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)))) { StoreHelper.AddHotkeywords(dropCategory.SelectedValue.Value, str); num++; } } if (num > 0) { ShowMsg(string.Format("成功添加了{0}个热门关键字", num), true); txtHotKeywords.Text = ""; BindData(); } else { ShowMsg("添加失败,请检查是否存在同类型的同名关键字", false); } } }
private void btnSubmitHotkeyword_Click(object sender, System.EventArgs e) { if (string.IsNullOrEmpty(this.txtHotKeywords.Text.Trim())) { 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 (this.dropCategory.SelectedValue.HasValue) { if (regex.IsMatch(text2) && !this.IsSame(text2, System.Convert.ToInt32(this.dropCategory.SelectedValue.Value))) { StoreHelper.AddHotkeywords(this.dropCategory.SelectedValue.Value, text2, ClientType.VShop, supplierId); num++; } } else { if (regex.IsMatch(text2) && !this.IsSame(text2, null)) { StoreHelper.AddHotkeywords(null, text2, ClientType.VShop, supplierId); num++; } } } if (num > 0) { this.ShowMsg(string.Format("成功添加了{0}个热门关键字", num), true); this.txtHotKeywords.Text = ""; this.BindData(); return; } this.ShowMsg("添加失败,请检查是否存在同类型的同名关键字", false); }
private void btnSubmitHotkeyword_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtHotKeywords.Text.Trim())) { this.ShowMsg("热门关键字不能为空", false); } else if (!this.dropCategory.SelectedValue.HasValue) { this.ShowMsg("请选择商品主分类", false); } else { string text = this.txtHotKeywords.Text.Trim().Replace("\r\n", "\n"); string[] array = text.Replace("\n", "*").Split('*'); int num = 0; string[] array2 = array; foreach (string text2 in array2) { Regex regex = new Regex("^(?!_)(?!.*?_$)(?!-)(?!.*?-$)[a-zA-Z0-9_一-龥-]+$"); if (regex.IsMatch(text2) && !this.IsSame(text2, Convert.ToInt32(this.dropCategory.SelectedValue.Value))) { StoreHelper.AddHotkeywords(this.dropCategory.SelectedValue.Value, text2); num++; } } if (num > 0) { this.ShowMsg($"成功添加了{num}个热门关键字", true); this.txtHotKeywords.Text = ""; } else { this.ShowMsg("添加失败,请检查是否存在同类型的同名关键字", false); } } }