PasswordWindow.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using ivf_tl_Entity.Enums;
  2. using ivf_tl_Manage.Converts;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. namespace ivf_tl_Manage.Win
  17. {
  18. /// <summary>
  19. /// PasswordWindow.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class PasswordWindow : Window
  22. {
  23. public PasswordWindow()
  24. {
  25. InitializeComponent();
  26. this.Owner = AppData.Instance.MainWindow;
  27. this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
  28. }
  29. private void Cancel_MouseUp(object sender, MouseButtonEventArgs e)
  30. {
  31. this.DialogResult = false;
  32. return;
  33. }
  34. private void Cancel_Click(object sender, RoutedEventArgs e)
  35. {
  36. this.DialogResult = false;
  37. return;
  38. }
  39. private void Ok_Click(object sender, RoutedEventArgs e)
  40. {
  41. try
  42. {
  43. string oldPass = this.PasswordBox_Old.Password;
  44. string new1 = this.PasswordBox_New1.Password;
  45. string new2 = this.PasswordBox_New2.Password;
  46. if (string.IsNullOrEmpty(oldPass))
  47. {
  48. //MessageBoxShow("请输入原密码");
  49. MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0265"));
  50. return;
  51. }
  52. if (string.IsNullOrEmpty(new1))
  53. {
  54. //MessageBoxShow("请输入新密码");
  55. MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0266"));
  56. return;
  57. }
  58. if (string.IsNullOrEmpty(new2))
  59. {
  60. //MessageBoxShow("请再次输入新密码");
  61. MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0267"));
  62. return;
  63. }
  64. if(new1 != new2)
  65. {
  66. //MessageBoxShow("两次密码不一致,请重新输入");
  67. MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0285"));
  68. return;
  69. }
  70. string error = AppData.Instance.HttpServiceCall.UpdatePasswordApi(oldPass, new1, new2);
  71. if (!string.IsNullOrEmpty(error))
  72. {
  73. //MessageBoxShow($"操作失败:{error}");
  74. MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0286")}:{error}");
  75. return;
  76. }
  77. this.DialogResult= true;
  78. return;
  79. }
  80. catch (Exception ex)
  81. {
  82. ExLog(ex, "Ok_Click");
  83. //MessageBoxShow($"操作异常:{ex.Message}");
  84. MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0291")}:{ex.Message}");
  85. }
  86. }
  87. private void MessageBoxShow(string mess)
  88. {
  89. this.message.Text = mess;
  90. }
  91. private void ExLog(Exception ex, string name)
  92. {
  93. AppData.Instance.LogService.ExceptionLog(ex, $"PasswordWindow.{name}", LogEnum.RunException);
  94. }
  95. private void ErrorLog(string message, LogEnum logType)
  96. {
  97. AppData.Instance.LogService.TLLog($"PasswordWindow.{message}", logType);
  98. }
  99. private void PasswordBox_Old_Click(object sender, RoutedEventArgs e)
  100. {
  101. if (!(sender is PasswordBox source)) return;
  102. source.Password = "";
  103. }
  104. }
  105. }