市长热线演示版

indexedit.aspx.cs 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 HySoft.Common;
  8. using System.Data;
  9. namespace HySoft.BaseCallCenter.Web.qualitymanage
  10. {
  11. public partial class indexedit : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. if (!IsPostBack)
  16. {
  17. if (!string.IsNullOrEmpty(Request.QueryString["id"]))
  18. {
  19. InitObj(Request.QueryString["id"].Trim());
  20. }
  21. if (!string.IsNullOrEmpty(Request.QueryString["categoryid"]))
  22. {
  23. txtF_CategoryId.Value = Request.QueryString["categoryid"].Trim();
  24. }
  25. }
  26. }
  27. void InitObj(string id)
  28. {
  29. try
  30. {
  31. T_QC_IndexBaseObj = new BLL.T_QC_IndexBase().GetModel(Convert.ToInt32(id));
  32. }
  33. catch (Exception ex)
  34. {
  35. }
  36. }
  37. private Model.T_QC_IndexBase T_QC_IndexBaseObj
  38. {
  39. get
  40. {
  41. Model.T_QC_IndexBase model = new Model.T_QC_IndexBase();
  42. if (Request.QueryString["otype"].Trim() == "modify")
  43. {
  44. model.F_IndexId = Convert.ToInt32(Request.QueryString["id"].Trim());
  45. }
  46. else
  47. {
  48. model.F_IndexId = 0;
  49. }
  50. try
  51. {
  52. model.F_CategoryId = Convert.ToInt32(txtF_CategoryId.Value.Trim());
  53. }
  54. catch
  55. {
  56. }
  57. try
  58. {
  59. model.F_Score = Convert.ToInt32(txtF_Score.Text.Trim());
  60. }
  61. catch
  62. {
  63. }
  64. try
  65. {
  66. model.F_Sort = Convert.ToInt32(txtF_Sort.Text.Trim());
  67. }
  68. catch
  69. {
  70. }
  71. model.F_Title = txtF_Title.Text.Trim();
  72. model.F_Remark = txtF_Remark.Text.Trim();
  73. model.F_CreateOn = DateTime.Now;
  74. try
  75. {
  76. LoginUser p_LoginUser = new LoginUser(this.Context);
  77. model.F_CreateBy = p_LoginUser.UserID;
  78. }
  79. catch { }
  80. model.F_DeleteFlag = 0;
  81. return model;
  82. }
  83. set
  84. {
  85. if (value != null)
  86. {
  87. this.txtF_IndexId.Value = value.F_IndexId.ToString();
  88. this.txtF_CategoryId.Value = value.F_CategoryId.ToString();
  89. this.txtF_Score.Text = value.F_Score.ToString();
  90. this.txtF_Title.Text = value.F_Title;
  91. this.txtF_Remark.Text = value.F_Remark;
  92. this.txtF_Sort.Text = value.F_Sort.ToString();
  93. }
  94. }
  95. }
  96. protected void btnSubmit_Click(object sender, EventArgs e)
  97. {
  98. try
  99. {
  100. if (Request.QueryString["otype"] == "new")
  101. {
  102. if (new BLL.T_QC_IndexBase().Add(T_QC_IndexBaseObj) > 0)
  103. {
  104. try
  105. {
  106. SetScoreByCategory(this.txtF_CategoryId.Value);
  107. }
  108. catch
  109. { }
  110. MessageBoxToWindow("新增成功", "新增提示", "success");
  111. }
  112. else
  113. {
  114. MessageBoxToWindow("新增失败", "新增提示!", "error");
  115. }
  116. }
  117. if (Request.QueryString["otype"] == "modify")
  118. {
  119. if (new BLL.T_QC_IndexBase().Update(T_QC_IndexBaseObj))
  120. {
  121. try
  122. {
  123. SetScoreByCategory(this.txtF_CategoryId.Value);
  124. }
  125. catch
  126. { }
  127. MessageBoxToWindow("修改成功", "修改提示!", "success");
  128. }
  129. else
  130. {
  131. MessageBoxToWindow("修改失败!", "修改提示!", "error");
  132. }
  133. }
  134. }
  135. catch
  136. {
  137. MessageBoxToWindow("保存失败!", "保存提示!", "error");
  138. }
  139. }
  140. private void SetScoreByCategory(string categoryid)
  141. {
  142. DataTable dt = new DataTable();
  143. try
  144. {
  145. Model.T_QC_IndexCategory model = new BLL.T_QC_IndexCategory().GetModel(Convert.ToInt32(categoryid));
  146. if (model != null)
  147. {
  148. string parentid = model.F_ParentId.ToString();
  149. dt = new BLL.T_QC_IndexBase().GetList("F_DeleteFlag=0 and (F_CategoryId=" + model.F_CategoryId + " or F_CategoryId in (select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + categoryid + " )) ").Tables[0];
  150. int score=0;
  151. for(int i=0;i<dt.Rows.Count;i++)
  152. {
  153. score+=Convert.ToInt32(dt.Rows[i]["F_Score"].ToString().Trim());
  154. }
  155. model.F_Expand1 = score.ToString();
  156. if (new BLL.T_QC_IndexCategory().Update(model))
  157. {
  158. if (parentid != "0")
  159. {
  160. SetScoreByCategory(parentid);
  161. }
  162. }
  163. }
  164. }
  165. catch { }
  166. finally
  167. {
  168. dt.Clear();
  169. dt.Dispose();
  170. }
  171. }
  172. #region 弹出对话框
  173. /// <summary>
  174. /// 弹出对话框
  175. /// </summary>
  176. /// <param name="title"></param>
  177. /// <param name="content"></param>
  178. /// <param name="type"></param>
  179. public void MessageBoxToWindow(string title, string content, string type)
  180. {
  181. string script = "";
  182. switch (type)
  183. {
  184. case "error"://失败
  185. type = "error";
  186. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  187. break;
  188. case "success"://成功
  189. type = "info";
  190. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',CloseThis);</script>";
  191. break;
  192. case "catch"://异常
  193. type = "warning";
  194. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  195. break;
  196. default:
  197. type = "question";
  198. break;
  199. }
  200. ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
  201. }
  202. #endregion
  203. }
  204. }