MyAccount.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using Aitex.Core.Account;
  15. using Aitex.Core.Util;
  16. namespace Aitex.Triton160.UI.Views
  17. {
  18. /// <summary>
  19. /// Interaction logic for MyAccount.xaml
  20. /// </summary>
  21. public partial class MyAccount : Window
  22. {
  23. public MyAccount(Account account)
  24. {
  25. InitializeComponent();
  26. _account = account;
  27. DataContext = account;
  28. //var roles = ServiceClients.AccountServiceClient.GetAllRoles();
  29. var roles = Triton160UiSystem.Instance.WCF.Account.GetAllRoles(); // chaosong@mod 20160325 to add account management
  30. foreach (var item in roles)
  31. {
  32. comboBoxGroup.Items.Add(item);
  33. }
  34. comboBoxGroup.SelectedItem = account.Role;
  35. }
  36. public MyAccount()
  37. {
  38. InitializeComponent();
  39. _account = Globals.Session["CurrentUser"] as Account;
  40. DataContext = _account;
  41. //var roles = ServiceClients.AccountServiceClient.GetAllRoles();
  42. var roles = Triton160UiSystem.Instance.WCF.Account.GetAllRoles(); // chaosong@mod 20160325 to add account management
  43. foreach (var item in roles)
  44. {
  45. comboBoxGroup.Items.Add(item);
  46. }
  47. comboBoxGroup.SelectedItem = _account.Role;
  48. }
  49. Account _account;
  50. /// <summary>
  51. /// Save current configuration
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. private void button_Save_Click(object sender, RoutedEventArgs e)
  56. {
  57. Account account = DataContext as Account;
  58. if (account != null)
  59. {
  60. if (string.IsNullOrEmpty((string)comboBoxGroup.SelectedValue))
  61. {
  62. MessageBox.Show(Application.Current.Resources["GlobalLableAccountViewRoleBeSelected"].ToString(), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  63. return;
  64. }
  65. account.Role = (string)comboBoxGroup.SelectedValue;
  66. //var ret = ServiceClients.AccountServiceClient.UpdateAccount(account);
  67. var ret = Triton160UiSystem.Instance.WCF.Account.UpdateAccount(account); // chaosong@mod 20160325 to add account management
  68. if (ret.ActSucc)
  69. {
  70. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateOk"].ToString(), _account.AccountId), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
  71. }
  72. else
  73. {
  74. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateFailed"].ToString(), _account.AccountId, ret.Description), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  75. }
  76. }
  77. }
  78. private void button_ChangePwd_Click(object sender, RoutedEventArgs e)
  79. {
  80. Account account = DataContext as Account;
  81. if (account != null)
  82. {
  83. UserPwdChangeView view = new UserPwdChangeView(_account.AccountId) { Owner = Application.Current.MainWindow };
  84. view.ShowDialog();
  85. }
  86. }
  87. private void Button_Click(object sender, RoutedEventArgs e)
  88. {
  89. this.Close();
  90. }
  91. }
  92. }