using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Account;
using Aitex.Core.Util;
namespace Aitex.Triton160.UI.Views
{
///
/// Interaction logic for MyAccount.xaml
///
public partial class MyAccount : Window
{
public MyAccount(Account account)
{
InitializeComponent();
_account = account;
DataContext = account;
//var roles = ServiceClients.AccountServiceClient.GetAllRoles();
var roles = Triton160UiSystem.Instance.WCF.Account.GetAllRoles(); // chaosong@mod 20160325 to add account management
foreach (var item in roles)
{
comboBoxGroup.Items.Add(item);
}
comboBoxGroup.SelectedItem = account.Role;
}
public MyAccount()
{
InitializeComponent();
_account = Globals.Session["CurrentUser"] as Account;
DataContext = _account;
//var roles = ServiceClients.AccountServiceClient.GetAllRoles();
var roles = Triton160UiSystem.Instance.WCF.Account.GetAllRoles(); // chaosong@mod 20160325 to add account management
foreach (var item in roles)
{
comboBoxGroup.Items.Add(item);
}
comboBoxGroup.SelectedItem = _account.Role;
}
Account _account;
///
/// Save current configuration
///
///
///
private void button_Save_Click(object sender, RoutedEventArgs e)
{
Account account = DataContext as Account;
if (account != null)
{
if (string.IsNullOrEmpty((string)comboBoxGroup.SelectedValue))
{
MessageBox.Show(Application.Current.Resources["GlobalLableAccountViewRoleBeSelected"].ToString(), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
account.Role = (string)comboBoxGroup.SelectedValue;
//var ret = ServiceClients.AccountServiceClient.UpdateAccount(account);
var ret = Triton160UiSystem.Instance.WCF.Account.UpdateAccount(account); // chaosong@mod 20160325 to add account management
if (ret.ActSucc)
{
MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateOk"].ToString(), _account.AccountId), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableAccountViewMsgUpdateFailed"].ToString(), _account.AccountId, ret.Description), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}
private void button_ChangePwd_Click(object sender, RoutedEventArgs e)
{
Account account = DataContext as Account;
if (account != null)
{
UserPwdChangeView view = new UserPwdChangeView(_account.AccountId) { Owner = Application.Current.MainWindow };
view.ShowDialog();
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}