recommendDetail.aspx.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using CB.Common;
  8. using CB.Entity;
  9. using CB.Framework;
  10. namespace CB.Admin.Plugins.Recommend
  11. {
  12. public partial class recommendDetail : AdminPage
  13. {
  14. protected string info = "";
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. if (!Page.IsPostBack)
  18. {
  19. InitData();
  20. }
  21. }
  22. protected override void InitData()
  23. {
  24. IList<RecommendInfo> list = CB.Data.RecommendsService.ToList();
  25. ddlList.DataSource = list;
  26. ddlList.DataValueField = "Id";
  27. ddlList.DataTextField = "ClassName";
  28. ddlList.DataBind();
  29. }
  30. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)
  31. {
  32. txtContent.Value = "";
  33. int _id = TypeConverter.ObjectToInt(ddlList.SelectedValue);
  34. if (0 < _id)
  35. {
  36. RecommendInfo entity = CB.Data.RecommendsService.Get(_id);
  37. if (null != entity && 0 < entity.Id)
  38. {
  39. txtContent.Value = entity.Content;
  40. }
  41. }
  42. }
  43. protected void btnUpdate_Click(object sender, EventArgs e)
  44. {
  45. RecommendInfo entity = new RecommendInfo()
  46. {
  47. Id = TypeConverter.ObjectToInt(ddlList.SelectedValue),
  48. Content = txtContent.Value.Trim()
  49. };
  50. if (string.IsNullOrEmpty(entity.Content))
  51. {
  52. ShowMessageBox("错误,推荐内容不能为空!");
  53. return;
  54. }
  55. if (CB.Data.RecommendsService.Update(entity))
  56. {
  57. Logs("推荐修改", string.Format("推荐修改[{0}]", entity.ClassName));
  58. ShowMessageBox("提示:修改成功!");
  59. }
  60. else
  61. {
  62. ShowMessageBox("提示:修改失败!");
  63. }
  64. }
  65. }
  66. }