UserList.aspx.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. namespace LYFZ.WeixinServers.WeiXinAPP
  9. {
  10. public partial class UserList : System.Web.UI.Page
  11. {
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. CommonHandler.CheckLoginJump(this);
  15. if (!IsPostBack)
  16. {
  17. if (Request.QueryString["del"] != null && Request.QueryString["del"].ToString().Length>0)
  18. {
  19. try
  20. {
  21. if (CommonHandler.CheckAdmin(this))
  22. {
  23. int delID = Convert.ToInt32(Request.QueryString["del"].ToString());
  24. if (CommonHandler.GetAdminUser(this).ID != delID)
  25. {
  26. deleteUser(delID);
  27. }
  28. else {
  29. showMsegesBox("对不起,当前登录帐号不能删除!");
  30. }
  31. }
  32. }
  33. catch (Exception ex){
  34. showMsegesBox("删除失败,请重试.错误原因:"+ex.Message);
  35. }
  36. }
  37. }
  38. bindUserList();
  39. }
  40. void deleteUser(int id)
  41. {
  42. if (userDal.Delete(id))
  43. {
  44. this.Response.Redirect("UserList.aspx");
  45. }
  46. else {
  47. showMsegesBox("删除失败,请重试.");
  48. }
  49. }
  50. void showMsegesBox(string msg)
  51. {
  52. Response.Write("<script>alert('" + msg + "');document.location='UserList.aspx';</script>"); return;
  53. }
  54. LYFZ.WeixinServiceDate.DAL.DAL_AdminUser userDal = new WeixinServiceDate.DAL.DAL_AdminUser();
  55. public System.Text.StringBuilder UserListHtmlTb = new System.Text.StringBuilder();
  56. void bindUserList()
  57. {
  58. DataSet ds = userDal.GetList("Competence <> 2");
  59. int index = 0;
  60. foreach (DataRow row in ds.Tables[0].Rows) {
  61. UserListHtmlTb.AppendFormat(@"
  62. <tr>
  63. <td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td>
  64. <td>
  65. <a href=""AddUser.aspx?eid={8}"" style=""margin-right:10px;""><i class=""fa fa-pencil""></i></a>
  66. <a href=""#myModal"" role=""button"" onclick=""setModalValue({8})"" data-toggle=""modal""><i class=""fa fa-remove""></i></a>
  67. </td>
  68. </tr>",
  69. index++,
  70. row["UserName"].ToString(),
  71. row["Account"].ToString(),
  72. row["sex"].ToString(),
  73. row["Phone"].ToString(),
  74. row["Email"].ToString(),
  75. Convert.ToDateTime(row["CreateTime"]).ToString("yyyy-MM-dd hh:mm:ss"),
  76. CommonHandler.I18NAccountType((int)row["Competence"]),
  77. row["id"].ToString());
  78. }
  79. }
  80. }
  81. }