public void SetEnt(BuPost ent, IDataReader dr) { ent.PostId = MyConvert.ToInt(dr["PostId"]); ent.PostName = MyConvert.ToString(dr["PostName"]); ent.UserId = MyConvert.ToInt(dr["UserId"]); ent.UserName = MyConvert.ToString(dr["UserName"]); }
/// <summary> /// 得到列表 /// </summary> /// <param name="ent"></param> /// <returns></returns> public List <BuPost> GetBuPostList(string Where) { List <BuPost> list = new List <BuPost>(); using (DbDataReader reader = DataBaseManage.ExecuteReader(DalSql + Where)) { while (reader.Read()) { BuPost ent = new BuPost(); SetEnt(ent, reader); list.Add(ent); } } return(list); }
/// <summary> /// 根据PostId得到 BuPost 实体 /// </summary> /// <param name="ent"></param> /// <returns></returns> public BuPost GetBuPost(int PostId) { BuPost ent = null; string sql = DalSql; sql = sql + " And PostId"; MySqlParameter[] paras = new MySqlParameter[] { new MySqlParameter("PostId", PostId) }; using (DbDataReader reader = DataBaseManage.ExecuteReader(sql, paras)) { if (reader.Read()) { ent = new BuPost(); SetEnt(ent, reader); } } return(ent); }
public PostViewModel(BuPost post, uint floorno) { //填写楼层信息 if (floorno == 1) { FloorNo = "楼主"; } else { FloorNo = floorno.ToString() + "楼"; } QuoteItems = new ObservableCollection <QuoteViewModel>(); //加载图片 if (post.attachment != null) { ImageSrc = BuAPI.GetImageSrc(HttpUtility.UrlDecode(post.attachment)); } string message = HttpUtility.UrlDecode(post.message); List <BuQuote> quotes = BuAPI.parseQuotes(ref message); foreach (var quote in quotes) { QuoteItems.Add(new QuoteViewModel(quote.author + " " + quote.time + "\r\n" + quote.content.Trim())); } DateTime dt = BuAPI.DateTimeConvertTime(post.dateline); //格式化时间”年-月-日 小时:分钟“ string strtime = dt.ToString("yyyy-M-d HH:mm"); Message = (BuAPI.parseHTML(message)).Trim(); AddInfo = HttpUtility.UrlDecode(post.author) + " " + strtime; post.dateline = strtime; post.message = Message; post.author = HttpUtility.UrlDecode(post.author); _post = post; }