/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Forum_PostId model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "Forum_PostId("); strSql.Append("TopicId"); strSql.Append(") values ("); strSql.Append("@TopicId"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TopicId", SqlDbType.Int, 4) }; parameters[0].Value = model.TopicId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Forum_PostId model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "Forum_PostId set "); strSql.Append(" TopicId = @TopicId "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@TopicId", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.TopicId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Forum_PostId DataRowToModel(DataRow row) { if (row != null) { Model.Forum_PostId model = new Model.Forum_PostId(); if (row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["TopicId"].ToString() != "") { model.TopicId = int.Parse(row["TopicId"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Forum_PostId model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Forum_PostId model) { return(dal.Add(model)); }