UserAccountEdit.xaml.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.Shapes;
  13. using System.Dynamic;
  14. using Aitex.Core.Account;
  15. namespace Aitex.Triton160.UI.Views
  16. {
  17. /// <summary>
  18. /// Interaction logic for UserAccountEdit.xaml
  19. /// </summary>
  20. public partial class UserAccountEdit : Window
  21. {
  22. public UserAccountEdit(Account account)
  23. {
  24. InitializeComponent();
  25. _account = account;
  26. DataContext = account;
  27. var roles = Triton160UiSystem.Instance.WCF.Account.GetAllRoles();
  28. foreach (var item in roles)
  29. {
  30. comboBoxGroup.Items.Add(item);
  31. }
  32. comboBoxGroup.SelectedItem = account.Role;
  33. }
  34. Account _account;
  35. /// <summary>
  36. /// Save current configuration
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="e"></param>
  40. private void button_Save_Click(object sender, RoutedEventArgs e)
  41. {
  42. Account account = DataContext as Account;
  43. if (string.IsNullOrEmpty((string)comboBoxGroup.SelectedValue))
  44. {
  45. MessageBox.Show(Application.Current.Resources["GlobalLableAccountViewRoleBeSelected"].ToString(), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  46. return;
  47. }
  48. account.Role = (string)comboBoxGroup.SelectedValue;
  49. var ret = Triton160UiSystem.Instance.WCF.Account.UpdateAccount(account);
  50. if (ret.ActSucc)
  51. {
  52. DialogResult = true;
  53. Close();
  54. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateOk"].ToString(), _account.AccountId), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
  55. }
  56. else
  57. {
  58. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateFailed"].ToString(), _account.AccountId, ret.Description), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  59. }
  60. }
  61. }
  62. }