市长热线演示版

knowledgeclassAddandEdit.aspx.cs 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 knowledgeclassAddandEdit : 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["id"]))
  21. {
  22. Initialize(Request.QueryString["id"]);
  23. }
  24. }
  25. }
  26. #region 信息初始化
  27. void Initialize(string id)
  28. {
  29. T_RepositoryCategory = new BLL.T_RepositoryCategory().GetModel(Convert.ToInt32(id));
  30. }
  31. #endregion
  32. #region 公共属性
  33. private Model.T_RepositoryCategory T_RepositoryCategory
  34. {
  35. get
  36. {
  37. Model.T_RepositoryCategory _model = new Model.T_RepositoryCategory();
  38. if (txtF_CategoryId.Value.Trim() != "")
  39. {
  40. _model.F_CategoryId = Convert.ToInt32(txtF_CategoryId.Value.Trim());
  41. }
  42. else
  43. {
  44. _model.F_CategoryId = 0;
  45. }
  46. _model.F_CategoryName = txtF_CategoryName.Text.Trim();
  47. try
  48. {
  49. _model.F_ParentId = Convert.ToInt32(txtF_ParentId.Value.Trim());
  50. }
  51. catch
  52. {
  53. _model.F_ParentId = 0;
  54. }
  55. try
  56. {
  57. _model.F_Sort = Convert.ToInt32(txtF_Sort.Text.Trim());
  58. }
  59. catch
  60. {
  61. _model.F_Sort = 0;
  62. }
  63. if (_model.F_CreateOn == null)
  64. _model.F_CreateOn = DateTime.Now;
  65. _model.F_DeleteFlag = 0;
  66. return _model;
  67. }
  68. set
  69. {
  70. if (value != null)
  71. {
  72. this.txtF_CategoryId.Value = value.F_CategoryId.ToString();
  73. this.txtF_ParentId.Value = value.F_ParentId.ToString();
  74. this.txtF_CategoryName.Text = value.F_CategoryName;
  75. this.txtF_Sort.Text = value.F_Sort.ToString();
  76. }
  77. }
  78. }
  79. #endregion
  80. #region 保存信息
  81. private void SaveInfo()
  82. {
  83. try
  84. {
  85. if (!string.IsNullOrEmpty(Request.QueryString["action"]))
  86. {
  87. if (Request.QueryString["action"].Trim() == "Add")
  88. {
  89. int bl = new BLL.T_RepositoryCategory().Add(T_RepositoryCategory);
  90. if (bl > 0)
  91. {
  92. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
  93. }
  94. else
  95. {
  96. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
  97. }
  98. }
  99. if (Request.QueryString["action"].Trim() == "Modify")
  100. {
  101. bool bl = new BLL.T_RepositoryCategory().Update(T_RepositoryCategory);
  102. if (bl)
  103. {
  104. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
  105. }
  106. else
  107. {
  108. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
  109. }
  110. }
  111. }
  112. }
  113. catch
  114. {
  115. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('error')</script>");
  116. }
  117. }
  118. #endregion
  119. protected void btnSubmit_Click(object sender, EventArgs e)
  120. {
  121. SaveInfo();
  122. }
  123. }
  124. }