protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(this.txtWords.Text)) { MessageBox.ShowFailTip(this, "请输入敏感词!"); } else { Maticsoft.Model.Settings.FilterWords model = new Maticsoft.Model.Settings.FilterWords(); Maticsoft.BLL.Settings.FilterWords words2 = new Maticsoft.BLL.Settings.FilterWords(); foreach (string str in this.txtWords.Text.TrimEnd(new char[0]).Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) { if (str.IndexOf("=") < 0) { MessageBox.ShowFailTip(this, "输入的字符格式不正确!"); return; } string[] strArray2 = str.Split(new char[] { '=' }); string wordPattern = strArray2[0]; string str3 = strArray2[1]; model.WordPattern = wordPattern; switch (str3) { case "{BANNED}": model.ActionType = 0; model.RepalceWord = ""; break; case "{MOD}": model.ActionType = 1; model.RepalceWord = ""; break; case "{REPLACE}": model.ActionType = 2; model.RepalceWord = string.IsNullOrWhiteSpace(str3) ? "**" : str3; break; } Maticsoft.Model.Settings.FilterWords byWordPattern = words2.GetByWordPattern(wordPattern); if (byWordPattern != null) { words2.Delete(byWordPattern.FilterId); } words2.Add(model); } words2.ClearCache(); MessageBox.ShowSuccessTip(this, "保存成功!", "list.aspx"); } }
protected void btnSave_Click(object sender, EventArgs e) { Maticsoft.Model.Settings.FilterWords model = new Maticsoft.Model.Settings.FilterWords { WordPattern = this.tName.Text, ActionType = Globals.SafeInt(this.ddlSelectType.SelectedValue, 0), RepalceWord = this.txtAddReplace.Text }; if (this.bll.Add(model) > 0) { this.gridView.OnBind(); } else { MessageBox.ShowFailTip(this, "添加失败,请稍候再试!"); } }
public Maticsoft.Model.Settings.FilterWords DataRowToModel(DataRow row) { Maticsoft.Model.Settings.FilterWords words = new Maticsoft.Model.Settings.FilterWords(); if (row != null) { if ((row["FilterId"] != null) && (row["FilterId"].ToString() != "")) { words.FilterId = int.Parse(row["FilterId"].ToString()); } if (row["WordPattern"] != null) { words.WordPattern = row["WordPattern"].ToString(); } if ((row["ActionType"] != null) && (row["ActionType"].ToString() != "")) { words.ActionType = int.Parse(row["ActionType"].ToString()); } if (row["RepalceWord"] != null) { words.RepalceWord = row["RepalceWord"].ToString(); } } return words; }
public void gridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { int num = (int) this.gridView.DataKeys[e.RowIndex].Value; string text = (this.gridView.Rows[e.RowIndex].Cells[0].Controls[0] as TextBox).Text; string str2 = (this.gridView.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox).Text; if (string.IsNullOrWhiteSpace(text)) { MessageBox.ShowFailTip(this, "请输入敏感词!"); } else { Maticsoft.Model.Settings.FilterWords model = new Maticsoft.Model.Settings.FilterWords { WordPattern = text, FilterId = num, RepalceWord = str2 }; this.bll.Update(model); this.bll.ClearCache(); this.gridView.EditIndex = -1; this.gridView.OnBind(); } }