MyAccount.xaml.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System.Windows;
  2. using Aitex.Core.Account;
  3. using Aitex.Core.Util;
  4. namespace MECF.Framework.UI.Core.Accounts
  5. {
  6. /// <summary>
  7. /// Interaction logic for MyAccount.xaml
  8. /// </summary>
  9. public partial class MyAccount : Window
  10. {
  11. public MyAccount(Account account)
  12. {
  13. InitializeComponent();
  14. _account = account;
  15. DataContext = account;
  16. var roles = AccountClient.Instance.Service.GetAllRoles();
  17. foreach (var item in roles)
  18. {
  19. comboBoxGroup.Items.Add(item);
  20. }
  21. comboBoxGroup.SelectedItem = account.Role;
  22. }
  23. public MyAccount()
  24. {
  25. InitializeComponent();
  26. _account = AccountClient.Instance.CurrentUser;
  27. DataContext = _account;
  28. var roles = AccountClient.Instance.Service.GetAllRoles();
  29. foreach (var item in roles)
  30. {
  31. comboBoxGroup.Items.Add(item);
  32. }
  33. comboBoxGroup.SelectedItem = _account.Role;
  34. }
  35. Account _account;
  36. /// <summary>
  37. /// Save current configuration
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="e"></param>
  41. private void button_Save_Click(object sender, RoutedEventArgs e)
  42. {
  43. Account account = DataContext as Account;
  44. if (account != null)
  45. {
  46. if (string.IsNullOrEmpty((string)comboBoxGroup.SelectedValue))
  47. {
  48. MessageBox.Show(Application.Current.Resources["GlobalLableAccountViewRoleBeSelected"].ToString(), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  49. return;
  50. }
  51. account.Role = (string)comboBoxGroup.SelectedValue;
  52. var ret = AccountClient.Instance.Service.UpdateAccount(account);
  53. if (ret.ActSucc)
  54. {
  55. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateOk"].ToString(), _account.AccountId), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
  56. }
  57. else
  58. {
  59. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateFailed"].ToString(), _account.AccountId, ret.Description), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  60. }
  61. }
  62. }
  63. private void button_ChangePwd_Click(object sender, RoutedEventArgs e)
  64. {
  65. Account account = DataContext as Account;
  66. if (account != null)
  67. {
  68. UserPwdChangeView view = new UserPwdChangeView(_account.AccountId) { Owner = Application.Current.MainWindow };
  69. view.ShowDialog();
  70. }
  71. }
  72. private void Button_Click(object sender, RoutedEventArgs e)
  73. {
  74. this.Close();
  75. }
  76. }
  77. }