UU跑腿标准版

ReasonAddandEdit.aspx.cs 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using HySoft.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. namespace HySoft.BaseCallCenter.Web.telmanage
  9. {
  10. public partial class ReasonAddandEdit : System.Web.UI.Page
  11. {
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. Response.Expires = -1;
  15. if (!IsPostBack)
  16. {
  17. if (!string.IsNullOrEmpty(Request.QueryString["categoryid"]))
  18. {
  19. txtF_ParentId.Value = Request.QueryString["categoryid"].Trim();
  20. }
  21. if (!string.IsNullOrEmpty(Request.QueryString["id"]))
  22. {
  23. Initialize(Request.QueryString["id"]);
  24. }
  25. }
  26. }
  27. #region 信息初始化
  28. void Initialize(string id)
  29. {
  30. Model.T_Call_Reason T_Reason = new BLL.T_Call_Reason().GetModel(Convert.ToInt32(id));
  31. this.txtF_ReasonId.Value = T_Reason.F_ReasonID.ToString();
  32. txtF_ParentId.Value = T_Reason.F_ParentID.ToString();
  33. hidpid.Value = T_Reason.F_ParentID.ToString();
  34. this.txtF_ReasonName.Text = T_Reason.F_ReasonName;
  35. //if (T_Reason.F_SType.ToString() != "")
  36. // this.drpF_SType.SelectedValue = T_Reason.F_SType.ToString();
  37. //else
  38. // this.drpF_SType.SelectedValue = "0";
  39. }
  40. #endregion
  41. #region 保存信息
  42. private void SaveInfo()
  43. {
  44. try
  45. {
  46. if (!string.IsNullOrEmpty(Request.QueryString["action"]))
  47. {
  48. Model.T_Call_Reason T_Reason = new Model.T_Call_Reason();
  49. #region
  50. if (Request.QueryString["action"].Trim() == "Modify")
  51. {
  52. T_Reason = new BLL.T_Call_Reason().GetModel(Convert.ToInt32(Request.QueryString["id"]));
  53. }
  54. T_Reason.F_ReasonName = txtF_ReasonName.Text.Trim();
  55. try
  56. {
  57. T_Reason.F_ParentID = Convert.ToInt32(txtF_ParentId.Value.Trim());
  58. }
  59. catch
  60. {
  61. T_Reason.F_ParentID = 0;
  62. }
  63. //try
  64. //{
  65. // T_Reason.F_SType = Convert.ToInt32(drpF_SType.SelectedValue);
  66. //}
  67. //catch
  68. //{
  69. // T_Reason.F_SType = 1;
  70. //}
  71. T_Reason.F_SType = 1;
  72. if (!hidpid.Value.Trim().Equals(txtF_ParentId.Value.Trim()))
  73. {
  74. if (T_Reason.F_ParentID > 0)
  75. {
  76. Model.T_Call_Reason pModel = new Model.T_Call_Reason();
  77. pModel = new BLL.T_Call_Reason().GetModel(T_Reason.F_ParentID.Value);
  78. T_Reason.F_Layer = pModel.F_Layer + 1;//目录级别为父级别+1
  79. T_Reason.F_ParentName = pModel.F_ReasonName;
  80. if (pModel.F_AllPID != "")
  81. {
  82. T_Reason.F_AllPID = pModel.F_AllPID + "," + pModel.F_ReasonID.ToString();
  83. T_Reason.F_AllPName = pModel.F_AllPName + "-" + pModel.F_ReasonName;
  84. }
  85. else
  86. {
  87. T_Reason.F_AllPID = pModel.F_ReasonID.ToString();
  88. T_Reason.F_AllPName = pModel.F_ReasonName;
  89. }
  90. }
  91. else
  92. {
  93. T_Reason.F_Layer = 1;
  94. T_Reason.F_ParentName = "";
  95. T_Reason.F_AllPID = "";
  96. T_Reason.F_AllPName = "";
  97. }
  98. }
  99. #endregion
  100. if (Request.QueryString["action"].Trim() == "Add")
  101. {
  102. LoginUser loginUser = new LoginUser(Context);
  103. T_Reason.F_ISChildren = 0;
  104. T_Reason.F_CreateBy = loginUser.UserID;
  105. T_Reason.F_CreateByCode = loginUser.UserCode;
  106. T_Reason.F_CreateByName = loginUser.UserName;
  107. T_Reason.F_CreateOn = DateTime.Now;
  108. T_Reason.F_DeleteFlag = 0;
  109. int bl = new BLL.T_Call_Reason().Add(T_Reason);
  110. if (bl > 0)
  111. {
  112. if (T_Reason.F_ParentID > 0)
  113. {
  114. new BLL.T_Call_Reason().UpdateCHILD(T_Reason.F_ParentID.Value, 1);
  115. }
  116. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
  117. }
  118. else
  119. {
  120. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
  121. }
  122. }
  123. if (Request.QueryString["action"].Trim() == "Modify")
  124. {
  125. bool bl = new BLL.T_Call_Reason().Update(T_Reason);
  126. if (bl)
  127. {
  128. if (!hidpid.Value.Trim().Equals(txtF_ParentId.Value.Trim()))
  129. {
  130. if (T_Reason.F_ParentID > 0)
  131. {//此父级的子集数量+1
  132. new BLL.T_Call_Reason().UpdateCHILD(T_Reason.F_ParentID.Value, 1);
  133. }
  134. if (hidpid.Value.Trim() != "" && hidpid.Value.Trim() != "0")
  135. {//此父级的子集数量-1
  136. new BLL.T_Call_Reason().UpdateCHILD(int.Parse(hidpid.Value.Trim()), 2);
  137. }
  138. }
  139. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
  140. }
  141. else
  142. {
  143. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
  144. }
  145. }
  146. }
  147. }
  148. catch
  149. {
  150. ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('error')</script>");
  151. }
  152. }
  153. #endregion
  154. protected void btnSubmit_Click(object sender, EventArgs e)
  155. {
  156. SaveInfo();
  157. }
  158. }
  159. }