/// <summary> /// 加载个人说说 /// </summary> private void Load_SelfSaySay() { skinPanel1.Controls.Clear(); //先清空 int count = 0; var list = isaysayInfoDAL.LoadPageEntities(s => s.UserId == F_Main.current_user.Guid_id && s.DelFlag == false, s => s.Subtime, 1, 5, out count).ToList(); foreach (var onesaysay in list) { Yyu_SelfSaySay ys = new Yyu_SelfSaySay(); ys.Dock = DockStyle.Top; ys.Top = 30; //控件赋值 if (onesaysay.Pic != null) { ys.pic.Image = CommonHelper.BytesToPic(onesaysay.Pic); } ys.lbName.Text = F_Main.current_user.Name; ys.txtContent.Text = onesaysay.Content; ys.yyu_PraiseNum1.labPraiseNum.Text = onesaysay.PraiseNum.ToString(); //end ys.btnReply.Tag = onesaysay.Guid_id; //存储本条说说的Id ys.btnReply.Click += new EventHandler((a, b) => //回复button注册事件 { F_SaySayReplay fs = new F_SaySayReplay(onesaysay.Guid_id); fs.Show(); }); skinPanel1.Controls.Add(ys); } }
/// <summary> /// 加载我的好友的说说 /// </summary> private void Load_MyFriend() { //从数据库加载数据 dynamic list = isaysayInfoService.LoadMyFriend(F_Main.current_user.Guid_id, myFriend_pageIndex, myFriend_pageSize, out myFriend_count); //saysayId = s.Guid_id, // s.Pic, // u.Name, // s.PraiseNum, // s.Subtime, // s.Content, //userId = u.Guid_id, // 该说说的发表者Id tableLayoutPanel2.Controls.Clear(); //清理 foreach (dynamic item in list) { Yyu_SaySayDetails yssd = new Yyu_SaySayDetails(); //反射得到匿名类型值 并 填充控件 Type t = item.GetType(); PropertyInfo[] pros = t.GetProperties(); yssd.Tag = pros[0].GetValue(item); //存储“说说Id” byte[] picByte = pros[1].GetValue(item) as byte[]; if (picByte != null) { yssd.pic.Image = CommonHelper.BytesToPic(picByte); } yssd.llbName.Text = pros[2].GetValue(item); yssd.yyu_PraiseNum1.labPraiseNum.Text = pros[3].GetValue(item).ToString(); yssd.lbSubtime.Text = "时间:" + CommonHelper.StampToDateTime(pros[4].GetValue(item).ToString()); yssd.txtContent.Text = pros[5].GetValue(item); //点赞注册事件 yssd.yyu_PraiseNum1.AddPraise += new Action(() => { var entity_saysay = isaysayInfoService.LoadEntities(s => s.Guid_id == (Guid)yssd.Tag).First(); entity_saysay.PraiseNum++; isaysayInfoService.EditEntity(entity_saysay); }); //回复 注册事件 yssd.llbName.Click += new EventHandler((a, b) => { //F_SimplyReply fs = new F_SimplyReply(); //fs.Text = "回复:" + yssd.llbName.Text; //fs.Show(); //fs.func += new Func<bool>(() => // { // if (!string.IsNullOrEmpty(fs.txtContent.Text)) // { // isaysaycommentInfoService.AddEntity(new saysaycommentinfo() // { // Guid_id = Guid.NewGuid(), // Content = fs.txtContent.Text, // SaysayId = (Guid)pros[0].GetValue(item), // Subtime = Common.CommonHelper.GetCurrentDateStamp(), // ToUserId = (Guid)pros[6].GetValue(item), // UserId = F_Main.current_user.Guid_id // }); // MessageYyu.ShowMessage("评论成功~~"); // fs.Close(); // } // return true; // }); F_SaySayReplay fssr = new F_SaySayReplay((Guid)pros[0].GetValue(item)); fssr.ShowDialog(); }); //添加控件 tableLayoutPanel2.Controls.Add(yssd); } }