市长热线演示版

indexcategoryedit.aspx.cs 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 indexcategoryedit : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. if (!IsPostBack)
  16. {
  17. BindList();
  18. if (!string.IsNullOrEmpty(Request.QueryString["id"]))
  19. {
  20. InitObj(Request.QueryString["id"].Trim());
  21. }
  22. if (!string.IsNullOrEmpty(Request.QueryString["categoryid"]))
  23. {
  24. dropF_Category.Value = Request.QueryString["categoryid"].Trim();
  25. }
  26. }
  27. }
  28. private void BindList()
  29. {
  30. DataTable dt = new DataTable();
  31. try
  32. {
  33. dropF_Category.Items.Clear();
  34. dropF_Category.Items.Add(new ListItem("根分类", "0"));
  35. dt = new BLL.T_QC_IndexCategory().GetList(" F_DeleteFlag=0 and F_ParentId=0 order by F_Sort ").Tables[0];
  36. if (dt != null)
  37. {
  38. for (int i = 0; i < dt.Rows.Count; i++)
  39. {
  40. dropF_Category.Items.Add(new ListItem(dt.Rows[i]["F_CategoryName"].ToString().Trim(), dt.Rows[i]["F_CategoryId"].ToString().Trim()));
  41. }
  42. }
  43. }
  44. catch
  45. { }
  46. finally
  47. {
  48. dt.Clear();
  49. dt.Dispose();
  50. }
  51. }
  52. void InitObj(string id)
  53. {
  54. try
  55. {
  56. T_QC_IndexCategoryObj = new BLL.T_QC_IndexCategory().GetModel(Convert.ToInt32(id));
  57. }
  58. catch (Exception ex)
  59. {
  60. }
  61. }
  62. private Model.T_QC_IndexCategory T_QC_IndexCategoryObj
  63. {
  64. get
  65. {
  66. Model.T_QC_IndexCategory model = new Model.T_QC_IndexCategory();
  67. if (Request.QueryString["otype"].Trim() == "modify")
  68. {
  69. model.F_CategoryId = Convert.ToInt32(Request.QueryString["id"].Trim());
  70. }
  71. else
  72. {
  73. model.F_CategoryId = 0;
  74. }
  75. //model.F_CategoryNumber = F_CategoryNumber;
  76. model.F_CategoryName = txtF_CategoryName.Text.Trim();
  77. try
  78. {
  79. model.F_Sort = Convert.ToInt32(txtF_Sort.Text.Trim());
  80. }
  81. catch
  82. { }
  83. model.F_ParentId = Convert.ToInt32(dropF_Category.Value.Trim());
  84. model.F_CreateOn = DateTime.Now;
  85. try
  86. {
  87. LoginUser p_LoginUser = new LoginUser(this.Context);
  88. model.F_CreateBy = p_LoginUser.UserID;
  89. }
  90. catch { }
  91. model.F_DeleteFlag = 0;
  92. return model;
  93. }
  94. set
  95. {
  96. if (value != null)
  97. {
  98. this.txtF_CategoryId.Value = value.F_CategoryId.ToString();
  99. txtF_CategoryName.Text = value.F_CategoryName.Trim();
  100. txtF_Sort.Text = value.F_Sort.ToString();
  101. dropF_Category.Value = value.F_ParentId.ToString();
  102. }
  103. }
  104. }
  105. protected void btnSubmit_Click(object sender, EventArgs e)
  106. {
  107. try
  108. {
  109. if (Request.QueryString["otype"] == "new")
  110. {
  111. if (new BLL.T_QC_IndexCategory().Add(T_QC_IndexCategoryObj) > 0)
  112. {
  113. MessageBoxToWindow("新增成功", "新增提示", "success");
  114. }
  115. else
  116. {
  117. MessageBoxToWindow("新增失败", "新增提示!", "error");
  118. }
  119. }
  120. if (Request.QueryString["otype"] == "modify")
  121. {
  122. if (new BLL.T_QC_IndexCategory().Update(T_QC_IndexCategoryObj))
  123. {
  124. MessageBoxToWindow("修改成功", "修改提示!", "success");
  125. }
  126. else
  127. {
  128. MessageBoxToWindow("修改失败!", "修改提示!", "error");
  129. }
  130. }
  131. }
  132. catch
  133. {
  134. MessageBoxToWindow("保存失败!", "保存提示!", "error");
  135. }
  136. }
  137. #region 弹出对话框
  138. /// <summary>
  139. /// 弹出对话框
  140. /// </summary>
  141. /// <param name="title"></param>
  142. /// <param name="content"></param>
  143. /// <param name="type"></param>
  144. public void MessageBoxToWindow(string title, string content, string type)
  145. {
  146. string script = "";
  147. switch (type)
  148. {
  149. case "error"://失败
  150. type = "error";
  151. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  152. break;
  153. case "success"://成功
  154. type = "info";
  155. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',CloseThis);</script>";
  156. break;
  157. case "catch"://异常
  158. type = "warning";
  159. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  160. break;
  161. default:
  162. type = "question";
  163. break;
  164. }
  165. ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
  166. }
  167. #endregion
  168. }
  169. }