UserAccountEdit.xaml.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Windows;
  2. using Aitex.Core.Account;
  3. namespace MECF.Framework.UI.Core.Accounts
  4. {
  5. /// <summary>
  6. /// Interaction logic for UserAccountEdit.xaml
  7. /// </summary>
  8. public partial class UserAccountEdit : Window
  9. {
  10. public UserAccountEdit(Account account)
  11. {
  12. InitializeComponent();
  13. _account = account;
  14. DataContext = account;
  15. var roles = AccountClient.Instance.Service.GetAllRoles();
  16. foreach (var item in roles)
  17. {
  18. comboBoxGroup.Items.Add(item);
  19. }
  20. comboBoxGroup.SelectedItem = account.Role;
  21. }
  22. Account _account;
  23. /// <summary>
  24. /// Save current configuration
  25. /// </summary>
  26. /// <param name="sender"></param>
  27. /// <param name="e"></param>
  28. private void button_Save_Click(object sender, RoutedEventArgs e)
  29. {
  30. Account account = DataContext as Account;
  31. if (string.IsNullOrEmpty((string)comboBoxGroup.SelectedValue))
  32. {
  33. MessageBox.Show(Application.Current.Resources["GlobalLableAccountViewRoleBeSelected"].ToString(), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  34. return;
  35. }
  36. account.Role = (string)comboBoxGroup.SelectedValue;
  37. var ret = AccountClient.Instance.Service.UpdateAccount(account);
  38. if (ret.ActSucc)
  39. {
  40. DialogResult = true;
  41. Close();
  42. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateOk"].ToString(), _account.AccountId), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
  43. }
  44. else
  45. {
  46. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateFailed"].ToString(), _account.AccountId, ret.Description), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  47. }
  48. }
  49. }
  50. }