/// <summary> /// 得到一个对象实体 /// </summary> public Model.user_message GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,type,post_user_name,accept_user_name,is_read,title,content,post_time,read_time from " + databaseprefix + "user_message "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Coseo.Model.user_message model = new Coseo.Model.user_message(); 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]["type"] != null && ds.Tables[0].Rows[0]["type"].ToString() != "") { model.type = int.Parse(ds.Tables[0].Rows[0]["type"].ToString()); } if (ds.Tables[0].Rows[0]["post_user_name"] != null && ds.Tables[0].Rows[0]["post_user_name"].ToString() != "") { model.post_user_name = ds.Tables[0].Rows[0]["post_user_name"].ToString(); } if (ds.Tables[0].Rows[0]["accept_user_name"] != null && ds.Tables[0].Rows[0]["accept_user_name"].ToString() != "") { model.accept_user_name = ds.Tables[0].Rows[0]["accept_user_name"].ToString(); } if (ds.Tables[0].Rows[0]["is_read"] != null && ds.Tables[0].Rows[0]["is_read"].ToString() != "") { model.is_read = int.Parse(ds.Tables[0].Rows[0]["is_read"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["post_time"] != null && ds.Tables[0].Rows[0]["post_time"].ToString() != "") { model.post_time = DateTime.Parse(ds.Tables[0].Rows[0]["post_time"].ToString()); } if (ds.Tables[0].Rows[0]["read_time"] != null && ds.Tables[0].Rows[0]["read_time"].ToString() != "") { model.read_time = DateTime.Parse(ds.Tables[0].Rows[0]["read_time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Coseo.Model.user_message model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Coseo.Model.user_message model) { return(dal.Add(model)); }