UU跑腿标准版

userAllocationRole.aspx.cs 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 System.Data;
  8. using HySoft.Common;
  9. namespace HySoft.BaseCallCenter.Web.sysmanage
  10. {
  11. public partial class userAllocationRole : System.Web.UI.Page
  12. {
  13. string roleId = "";
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. if (!this.IsPostBack)
  17. {
  18. roleId = Request.QueryString["ResetRole"];
  19. getUserRoleNmae(roleId);
  20. }
  21. //初始化方法
  22. }
  23. /// <summary>
  24. /// 初始化方法
  25. /// </summary>
  26. /// <param name="userid"></param>
  27. public void getUserRoleNmae(string userid) {
  28. string sql = "select * from t_sys_userAccount where F_UserId ='" + userid + "'";
  29. DataTable dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  30. if (dt.Rows.Count > 0)
  31. {
  32. txtWorkingCode.Text = dt.Rows[0]["F_UserCode"].ToString();
  33. txtRealName.Text = dt.Rows[0]["F_UserName"].ToString();
  34. }
  35. BindDropListRoles();
  36. }
  37. #region 绑定下拉列表
  38. /// <summary>
  39. /// 绑定下拉列表角色
  40. /// </summary>
  41. private void BindDropListRoles()
  42. {
  43. DataTable dt = new DataTable();
  44. try
  45. {
  46. this.DropDownListRole.Items.Clear();
  47. dt = new HySoft.BaseCallCenter.BLL.T_Sys_RoleInfo().GetList("1=1").Tables[0];
  48. foreach (DataRow dr in dt.Rows)
  49. {
  50. DropDownListRole.Items.Add(new ListItem(dr["F_RoleName"].ToString(), dr["F_RoleId"].ToString()));
  51. }
  52. this.DropDownListRole.Items.Insert(0, new ListItem("--请选择--", ""));
  53. }
  54. catch (Exception ex)
  55. {
  56. SysLog.WriteLog(ex);
  57. }
  58. finally
  59. {
  60. dt.Clear();
  61. dt.Dispose();
  62. }
  63. }
  64. #endregion
  65. /// <summary>
  66. /// 保存方法
  67. /// </summary>
  68. /// <param name="sender"></param>
  69. /// <param name="e"></param>
  70. protected void btnSubmit_Click(object sender, EventArgs e)
  71. {
  72. try
  73. {
  74. string sql = "";
  75. string sqlstr = "";
  76. int reslust = 0;
  77. if (!string.IsNullOrEmpty(DropDownListRole.Text))
  78. {
  79. //根据用户id和原密码确定用户是否存在
  80. sqlstr = "select * from t_sys_userAccount where F_UserId='" + Request.QueryString["ResetRole"] + "'";
  81. DataTable dt = DBUtility.DbHelperSQL.Query(sqlstr).Tables[0];
  82. if (dt.Rows.Count > 0)
  83. {
  84. sql = "update t_sys_userAccount set F_RoleId='" + hfRoleName.Value + "' where F_UserId ='" + Request.QueryString["ResetRole"] + "'";
  85. reslust = DBUtility.DbHelperSQL.ExecuteSql(sql);
  86. if (reslust > 0)
  87. {
  88. MessageBoxToWindow("分配角色成功", "提示!", "success");
  89. }
  90. else
  91. {
  92. MessageBoxToWindow("分配角色失败", "提示!", "error");
  93. }
  94. }
  95. else
  96. {
  97. MessageBoxToWindow("不存在此用户", "提示!", "error");
  98. }
  99. }
  100. }
  101. catch (Exception ex)
  102. {
  103. }
  104. }
  105. #region 弹出对话框
  106. /// <summary>
  107. /// 弹出对话框
  108. /// </summary>
  109. /// <param name="title"></param>
  110. /// <param name="content"></param>
  111. /// <param name="type"></param>
  112. public void MessageBoxToWindow(string title, string content, string type)
  113. {
  114. string script = "";
  115. switch (type)
  116. {
  117. case "error"://失败
  118. type = "error";
  119. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  120. break;
  121. case "success"://成功
  122. type = "info";
  123. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',CloseThis);</script>";
  124. break;
  125. case "catch"://异常
  126. type = "warning";
  127. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  128. break;
  129. default:
  130. type = "question";
  131. break;
  132. }
  133. ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
  134. }
  135. #endregion
  136. }
  137. }