/// <summary> /// 更新一条数据 /// </summary> public bool Update(ROYcms.Sys.Model.ROYcms_Synonyms model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ROYcms_Synonyms set "); strSql.Append("find=@find,"); strSql.Append("REPLACE=@REPLACE"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@find", SqlDbType.VarChar, 500), new SqlParameter("@REPLACE", SqlDbType.VarChar, 500), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.find; parameters[1].Value = model.REPLACE; parameters[2].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ROYcms.Sys.Model.ROYcms_Synonyms model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ROYcms_Synonyms("); strSql.Append("find,REPLACE)"); strSql.Append(" values ("); strSql.Append("@find,@REPLACE)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@find", SqlDbType.VarChar, 500), new SqlParameter("@REPLACE", SqlDbType.VarChar, 500) }; parameters[0].Value = model.find; parameters[1].Value = model.REPLACE; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (Request["id"] != null) { Model = BLL.GetModel(Convert.ToInt32(Request["id"])); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ROYcms.Sys.Model.ROYcms_Synonyms GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,find,REPLACE from ROYcms_Synonyms "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; ROYcms.Sys.Model.ROYcms_Synonyms model = new ROYcms.Sys.Model.ROYcms_Synonyms(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["find"] != null && ds.Tables[0].Rows[0]["find"].ToString() != "") { model.find = ds.Tables[0].Rows[0]["find"].ToString(); } if (ds.Tables[0].Rows[0]["REPLACE"] != null && ds.Tables[0].Rows[0]["REPLACE"].ToString() != "") { model.REPLACE = ds.Tables[0].Rows[0]["REPLACE"].ToString(); } return(model); } else { return(null); } }