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.

87 lines
2.4 KiB

  1. using Swift.DAL.BL.System.UserManagement;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. namespace Swift.web.Remit.AgentOperation.UserManagement
  6. {
  7. public partial class ResetPassword : System.Web.UI.Page
  8. {
  9. private const string AddEditFunctionId = "40112510";
  10. private readonly ApplicationUserDao _obj = new ApplicationUserDao();
  11. private readonly SwiftLibrary _sl = new SwiftLibrary();
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. PopulateUserName();
  15. if (!IsPostBack)
  16. {
  17. Authenticate();
  18. //LoadTab();
  19. }
  20. }
  21. //private void LoadTab()
  22. //{
  23. // pnlBreadCrumb.Visible = true;
  24. //}
  25. protected long GetMode()
  26. {
  27. return GetStatic.ReadNumericDataFromQueryString("mode");
  28. }
  29. protected string GetAgent()
  30. {
  31. return GetStatic.ReadQueryString("agentId", "");
  32. }
  33. protected void btnReset_Click(object sender, EventArgs e)
  34. {
  35. Update();
  36. }
  37. private void Authenticate()
  38. {
  39. _sl.CheckAuthentication(AddEditFunctionId);
  40. btnReset.Visible = _sl.HasRight(AddEditFunctionId);
  41. }
  42. protected string GetUserName()
  43. {
  44. return GetStatic.ReadQueryString("userName", "");
  45. }
  46. protected void PopulateUserName()
  47. {
  48. userName.Text = GetUserName();
  49. userName.Enabled = false;
  50. }
  51. private void ManageMessage(DbResult dbResult)
  52. {
  53. GetStatic.SetMessage(dbResult);
  54. if (dbResult.ErrorCode == "0")
  55. {
  56. Response.Redirect("List.aspx?agentId=" + GetAgent() + "&mode=" + GetMode());
  57. }
  58. else
  59. {
  60. if (GetMode() == 1)
  61. GetStatic.AlertMessage(Page);
  62. else
  63. GetStatic.PrintMessage(Page);
  64. }
  65. }
  66. private void Update()
  67. {
  68. DbResult dbResult = _obj.ResetPassword(GetStatic.GetUser(), GetUserName(), pwd.Text);
  69. ManageMessage(dbResult);
  70. }
  71. protected void btnBack_Click(object sender, EventArgs e)
  72. {
  73. Response.Redirect("List.aspx?agentId=" + GetAgent() + "&mode=" + GetMode());
  74. }
  75. }
  76. }