/// <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 dt_user_message "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Hoto.Model.user_message model = new Hoto.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> /// 重写虚方法,此方法在Init事件执行 /// </summary> protected override void InitPage() { id = HotoRequest.GetQueryInt("id"); Hoto.BLL.user_message bll = new Hoto.BLL.user_message(); if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + HotoUtils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(id); //设为已阅读状态 bll.UpdateField(id, "is_read=1,read_time='" + DateTime.Now + "'"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hoto.Model.user_message model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hoto.Model.user_message model) { return(dal.Add(model)); }
/// <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 dt_user_message "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Hoto.Model.user_message model = new Hoto.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; } }