index.aspx.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using CB.Entity;
  9. using CB.Data;
  10. namespace CB.TVUCenter.Web
  11. {
  12. public partial class index : System.Web.UI.Page
  13. {
  14. protected StringBuilder ConsultString = new StringBuilder();
  15. protected StringBuilder AnnouncementString = new StringBuilder();
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. if (!IsPostBack)
  19. {
  20. BindInfo(11);
  21. }
  22. }
  23. /// <summary>
  24. /// 咨询
  25. /// </summary>
  26. /// <returns>
  27. ///
  28. /// <returns>
  29. private void BindInfo(int displayCount)
  30. {
  31. int Record = 0;
  32. List<TopicInfo> lists = TopicService.ToPaging("205,206", 15, 1, out Record,"Tid DESC").ToList();
  33. if (lists == null && lists.Count < 1) return;
  34. displayCount = lists.Count < displayCount ? lists.Count : displayCount;
  35. for (int i = 0; i < displayCount; i++)
  36. {
  37. if (i < 3) BindConsult(lists[i], i);
  38. else BindAnnouncement(lists[i]);
  39. }
  40. }
  41. /// <summary>
  42. /// 绑定中间的咨询/公告
  43. /// </summary>
  44. /// <param name="list"></param>
  45. /// <param name="id"></param>
  46. private void BindConsult(TopicInfo list, int id)
  47. {
  48. string img = "";
  49. string consult = "";
  50. if (list.ListThumbsURL != null && list.ListThumbsURL.Count > 0)
  51. img = "<img src='" + list.ListThumbsURL[0] + @"' width='120' height='96'/>";
  52. if (id == 0 || img == "")
  53. consult = "<li><a href='info_" + list.Id + "_" + list.Cid + @".html'>
  54. <h3 title='" + list.Title + "'>" + (list.Title.Length > 20 ? list.Title.Substring(0, 20) : list.Title) + @"</h3>
  55. <p>" + (list.Context.Length > 80 ? list.Context.Substring(0, 80) + "……" : list.Context) + @"</p>
  56. </a></li>";
  57. else
  58. consult = @"<li><a href='info_" + list.Id + "_" + list.Cid + @".html'>
  59. <div class='figure'>" + img + @"</div>
  60. <div class='works' title='" + list.Title + "'><h4>" + (list.Title.Length > 20 ? list.Title.Substring(0, 20) : list.Title) + @"</h4><p>" + (list.Context.Length > 80 ? list.Context.Substring(0, 80) + "……" : list.Context) + @"</p>
  61. </div>
  62. </a></li>";
  63. ConsultString.Append(consult);
  64. }
  65. /// <summary>
  66. /// 绑定右边的列表
  67. /// </summary>
  68. /// <param name="list"></param>
  69. private void BindAnnouncement(TopicInfo list)
  70. {
  71. string Announcement = " <li><a href='info_" + list.Id + "_" + list.Cid + @".html' title='" + list.Title + "'><span></span>"
  72. + (list.Title.Length > 20 ? list.Title.Substring(0, 20) : list.Title) + @"</a>
  73. <span class='time'>" + list.Addtime.ToString("MM-dd") + "</span></li>";
  74. AnnouncementString.Append(Announcement);
  75. }
  76. }
  77. }