protected void btnSubmit_Click(object sender, EventArgs e) { M_Tag model = new M_Tag(); model.Name = txtTagName.Text.Trim(); model.TagCategoryId = int.Parse(ddlTagCategoryId.SelectedValue); model.ModelType = int.Parse(ddlModelType.SelectedValue); model.UserId = 0; model.UserName = "******"; if (model.Name.Length == 0 || model.Name.Length > 20) { LitMsg.Text = "<script type='text/javascript'>alert('关键字名称必须填写');</script>"; return; } bool flag = TagBll.Add(model); if (!flag) { LitMsg.Text = "<script type='text/javascript'>alert('该关键字已经存在,无需再添加');</script>"; return; } Bind(); }
public bool Add(M_Tag model) { return this.dal.Add(model); }
public bool Add(M_Tag model) { SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Name", model.Name), new SqlParameter("@TagCategoryId", model.TagCategoryId), new SqlParameter("@ModelType", model.ModelType), new SqlParameter("@UserId", model.UserId), new SqlParameter("@UserName", model.UserName) }; return (SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringKy, CommandType.StoredProcedure, "Up_Tag_Add", commandParameters) == 1); }