AccountCreation.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 AccountCreation.xaml
  19. /// </summary>
  20. public partial class AccountCreation : Window
  21. {
  22. public AccountCreation()
  23. {
  24. InitializeComponent();
  25. DataContext = _account;
  26. var roles = Triton160UiSystem.Instance.WCF.Account.GetAllRoles();
  27. foreach (var item in roles)
  28. {
  29. comboBoxGroup.Items.Add(item);
  30. }
  31. comboBoxGroup.SelectedItem = _account.Role;
  32. }
  33. Account _account = new Account();
  34. /// <summary>
  35. /// Save current configuration
  36. /// </summary>
  37. /// <param name="sender"></param>
  38. /// <param name="e"></param>
  39. private void button_Save_Click(object sender, RoutedEventArgs e)
  40. {
  41. Account account = DataContext as Account;
  42. if (string.IsNullOrEmpty((string)comboBoxGroup.SelectedValue))
  43. {
  44. MessageBox.Show("Please select role", "Account", MessageBoxButton.OK, MessageBoxImage.Warning);
  45. return;
  46. }
  47. account.Role = (string)comboBoxGroup.SelectedValue;
  48. var ret = Triton160UiSystem.Instance.WCF.Account.CreateAccount(account);
  49. if (ret.ActSucc)
  50. {
  51. DialogResult = true;
  52. Close();
  53. MessageBox.Show(string.Format("\" {0} \" created!", _account.AccountId), "Account", MessageBoxButton.OK, MessageBoxImage.Information);
  54. }
  55. else
  56. {
  57. MessageBox.Show(string.Format("\" {0} \" create failed,\r\n{1}", _account.AccountId, ret.Description), "Account", MessageBoxButton.OK, MessageBoxImage.Warning);
  58. }
  59. }
  60. }
  61. }