You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.9 KiB

  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using Swift.DAL.BL.System.UserManagement;
  5. using Swift.DAL.SwiftDAL;
  6. using Swift.web.Library;
  7. namespace Swift.web.SwiftSystem.UserManagement.AdminUserSetup
  8. {
  9. public partial class UserRole : System.Web.UI.Page
  10. {
  11. private const string ViewFunctionId = "10101350";
  12. private readonly SwiftLibrary _sl = new SwiftLibrary();
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. Authenticate();
  16. btnBack.Visible = false;
  17. if (!IsPostBack)
  18. {
  19. LoadGrid();
  20. }
  21. }
  22. protected string GetUserName()
  23. {
  24. return GetStatic.ReadQueryString("userName", "");
  25. }
  26. protected long GetMode()
  27. {
  28. return GetStatic.ReadNumericDataFromQueryString("mode");
  29. }
  30. public void LoadGrid()
  31. {
  32. string userId = GetStatic.ReadQueryString("userId", "");
  33. var roleDao = new ApplicationRoleDao();
  34. DataTable dt = roleDao.GetRoleList(userId, GetStatic.GetUser());
  35. if (dt.Rows.Count == 0)
  36. {
  37. rpt_grid.InnerHtml = "<center><b></b><center>";
  38. return;
  39. }
  40. var str =
  41. new StringBuilder(
  42. "<table border=\"0\" class=\"table table-responsive table-bordered\" cellpadding=\"0\" cellspacing=\"0\" align=\"left\">");
  43. str.Append("<tr>");
  44. str.Append("<th align=\"left\">" + dt.Columns[0].ColumnName + "</th>");
  45. str.Append("</tr>");
  46. foreach (DataRow dr in dt.Rows)
  47. {
  48. str.Append("<tr>");
  49. str.Append("<td align=\"left\">" + dr[0] + "</td>");
  50. str.Append("</tr>");
  51. }
  52. str.Append("</table>");
  53. rpt_grid.InnerHtml = str.ToString();
  54. }
  55. private void Authenticate()
  56. {
  57. _sl.CheckAuthentication(ViewFunctionId);
  58. btnSave.Visible = _sl.HasRight(ViewFunctionId);
  59. }
  60. private void ManageMessage(DbResult dbResult)
  61. {
  62. GetStatic.SetMessage(dbResult);
  63. if (dbResult.ErrorCode == "0")
  64. {
  65. Response.Redirect("../ApplicationUserSetup/List.aspx");
  66. }
  67. else
  68. {
  69. GetStatic.PrintMessage(Page);
  70. }
  71. }
  72. protected void btnSave_Click(object sender, EventArgs e)
  73. {
  74. string userId = GetStatic.ReadQueryString("userId", "");
  75. string roleId = GetStatic.ReadFormData("roleId", "NULL");
  76. var roleDao = new ApplicationRoleDao();
  77. DbResult dbResult = roleDao.SaveUserRole(roleId, userId, GetStatic.GetUser());
  78. ManageMessage(dbResult);
  79. }
  80. protected void btnBack_Click(object sender, EventArgs e)
  81. {
  82. Response.Redirect("List.aspx");
  83. }
  84. }
  85. }