市长热线演示版

knowledgelistAddandEdit.aspx.cs 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. namespace HySoft.BaseCallCenter.Web.knowledgemanage
  8. {
  9. public partial class knowledgelistAddandEdit : System.Web.UI.Page
  10. {
  11. protected void Page_Load(object sender, EventArgs e)
  12. {
  13. Response.Expires = -1;
  14. if (!IsPostBack)
  15. {
  16. if (!string.IsNullOrEmpty(Request.QueryString["categoryId"]))
  17. {
  18. txtF_ParentId.Value = Request.QueryString["categoryId"].Trim();
  19. }
  20. if (!string.IsNullOrEmpty(Request.QueryString["singleFlage"]))
  21. {
  22. Initialize(Request.QueryString["singleFlage"]);
  23. }
  24. }
  25. }
  26. protected void btnSubmit_Click(object sender, EventArgs e)
  27. {
  28. SaveInfo();
  29. }
  30. private void SaveInfo()
  31. {
  32. try
  33. {
  34. if (!string.IsNullOrWhiteSpace(Request.QueryString["actionFlag"].Trim())) {
  35. string actionFlag = Request.QueryString["actionFlag"].Trim();
  36. if (actionFlag == "add")
  37. {
  38. int bl = new BLL.T_RepositoryInformation().Add(T_RepositoryInformation);
  39. if (bl > 0)
  40. {
  41. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
  42. }
  43. else
  44. {
  45. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
  46. }
  47. }
  48. if (actionFlag == "edit")
  49. {
  50. bool b2 = new BLL.T_RepositoryInformation().Update(T_RepositoryInformation);
  51. if (b2)
  52. {
  53. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
  54. }
  55. else
  56. {
  57. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
  58. }
  59. }
  60. }
  61. }
  62. catch
  63. {
  64. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('error')</script>");
  65. }
  66. }
  67. #region 信息初始化
  68. private void Initialize(string id)
  69. {
  70. T_RepositoryInformation = new BLL.T_RepositoryInformation().GetModel(Convert.ToInt32(id));
  71. }
  72. #endregion
  73. #region 公共属性
  74. private Model.T_RepositoryInformation T_RepositoryInformation
  75. {
  76. get
  77. {
  78. Model.T_RepositoryInformation _model = new Model.T_RepositoryInformation();
  79. try
  80. {
  81. _model.F_CategoryId = Convert.ToInt32(txtF_ParentId.Value.Trim());
  82. }
  83. catch
  84. {
  85. _model.F_CategoryId = 0;
  86. }
  87. if (!string.IsNullOrEmpty(txtF_RepositoryId.Value))
  88. _model.F_RepositoryId = Convert.ToInt32(txtF_RepositoryId.Value);
  89. _model.F_Title = txtTitle.Text.Trim();
  90. _model.F_KeyWords = txtKeyWords.Text.Trim();
  91. _model.F_Description = Common.StringUtil.ClearHtmlCode(txtContent.InnerText.TrimEnd());
  92. _model.F_Content = txtContent.InnerHtml.TrimEnd();
  93. _model.F_DeleteFlag = 0;
  94. if (_model.F_CreateOn == null)
  95. _model.F_CreateOn = DateTime.Now;
  96. _model.F_ModifyOn = DateTime.Now;
  97. return _model;
  98. }
  99. set
  100. {
  101. if (value != null)
  102. {
  103. this.txtF_CategoryId.Value = value.F_CategoryId.ToString();
  104. this.txtF_RepositoryId.Value = value.F_RepositoryId.ToString();
  105. txtTitle.Text = value.F_Title;
  106. txtKeyWords.Text = value.F_KeyWords;
  107. txtF_Description.Text = value.F_Description;
  108. txtContent.InnerHtml = value.F_Content;
  109. }
  110. }
  111. }
  112. #endregion
  113. }
  114. }