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.

107 lines
3.3 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 UserFunction : System.Web.UI.Page
  10. {
  11. private const string ViewFunctionId = "10101300";
  12. private readonly SwiftLibrary _sl = new SwiftLibrary();
  13. protected void Page_PreInit(object sender, EventArgs e)
  14. {
  15. //MasterPageFile = GetMode().ToString() != "1" ? "~/Swift.Master" : "~/ProjectMaster.Master";
  16. }
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. Authenticate();
  20. if (!IsPostBack)
  21. {
  22. //LoadTab();
  23. LoadGrid();
  24. }
  25. }
  26. //private void LoadTab()
  27. //{
  28. // pnlBreadCrumb.Visible = GetMode() != 1;
  29. //}
  30. protected string GetUserName()
  31. {
  32. return GetStatic.ReadQueryString("userName", "");
  33. }
  34. private void Authenticate()
  35. {
  36. _sl.CheckAuthentication(ViewFunctionId);
  37. btnSave.Visible = _sl.HasRight(ViewFunctionId);
  38. }
  39. public void LoadGrid()
  40. {
  41. string userId = GetStatic.ReadQueryString("userId", "");
  42. var roleDao = new ApplicationRoleDao();
  43. DataTable dt = roleDao.GetUserFunctionList(userId, GetStatic.GetUser());
  44. if (dt.Rows.Count == 0)
  45. {
  46. rpt_grid.InnerHtml = "<center><b>No function available</b><center>";
  47. return;
  48. }
  49. var str =
  50. new StringBuilder(
  51. "<table border=\"0\" class=\"TBL\" cellpadding=\"0\" cellspacing=\"0\" align=\"left\">");
  52. str.Append("<tr>");
  53. foreach (DataColumn dc in dt.Columns)
  54. {
  55. str.Append("<th align=\"left\" class = \"formLabel\">" + dc.ColumnName + "</th>");
  56. }
  57. str.Append("</tr>");
  58. foreach (DataRow dr in dt.Rows)
  59. {
  60. str.Append("<tr>");
  61. foreach (DataColumn dc in dt.Columns)
  62. {
  63. str.Append("<td align=\"left\">" + dr[dc.ColumnName] + "</td>");
  64. }
  65. str.Append("</tr>");
  66. }
  67. str.Append("</table>");
  68. rpt_grid.InnerHtml = str.ToString();
  69. }
  70. private void ManageMessage(DbResult dbResult)
  71. {
  72. GetStatic.SetMessage(dbResult);
  73. if (dbResult.ErrorCode == "0")
  74. {
  75. Response.Redirect("List.aspx");
  76. }
  77. else
  78. {
  79. GetStatic.PrintMessage(Page);
  80. }
  81. }
  82. protected void btnSave_Click(object sender, EventArgs e)
  83. {
  84. string userId = GetStatic.ReadQueryString("userId", "");
  85. string function = GetStatic.ReadFormData("functionId", "NULL");
  86. var roleDao = new ApplicationRoleDao();
  87. DbResult dbResult = roleDao.SaveUserFunction(function, userId, GetStatic.GetUser());
  88. ManageMessage(dbResult);
  89. }
  90. protected void btnBack_Click(object sender, EventArgs e)
  91. {
  92. Response.Redirect("List.aspx");
  93. }
  94. }
  95. }