|
|
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Windows;
|
|
|
using System.ComponentModel;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Documents;
|
|
|
using System.Threading;
|
|
|
using System.Diagnostics;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.IO;
|
|
|
using GummingCommon;
|
|
|
using System.Reflection;
|
|
|
using GummingEntity;
|
|
|
using GummingBusiness;
|
|
|
|
|
|
namespace Gumming
|
|
|
{
|
|
|
public class PasswordEditViewModule : ViewModelBase
|
|
|
{
|
|
|
#region base parameters
|
|
|
public PasswordEditView View { get; set; }
|
|
|
|
|
|
public bool IsConfirm { get; set; }
|
|
|
#endregion
|
|
|
|
|
|
#region constructor
|
|
|
public PasswordEditViewModule(bool canCreateNewTargetField = true)
|
|
|
{
|
|
|
View = new PasswordEditView();
|
|
|
View.DataContext = this;
|
|
|
InitializeCommands();
|
|
|
InitializeParameters();
|
|
|
LoadDefaultValue();
|
|
|
}
|
|
|
|
|
|
|
|
|
public void ShowDialog()
|
|
|
{
|
|
|
IsConfirm = false;
|
|
|
View.ShowDialog();
|
|
|
}
|
|
|
|
|
|
private void InitializeCommands()
|
|
|
{
|
|
|
CancelCommand = new DelegateCommand(OnCancelCommand);
|
|
|
SaveCommand = new DelegateCommand(OnSaveCommand);
|
|
|
ClearCommand = new DelegateCommand(OnClearCommand);
|
|
|
}
|
|
|
|
|
|
public override void InitializeParameters(object content = null)
|
|
|
{
|
|
|
WindowTitle = "";
|
|
|
}
|
|
|
|
|
|
~PasswordEditViewModule()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
public void LoadDefaultValue()
|
|
|
{
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region Binding Properties
|
|
|
public string WindowTitle { get; private set; }
|
|
|
public string UserId { get; set; }
|
|
|
public string RoleId { get; set; }
|
|
|
public string UserName { get; set; }
|
|
|
private string _PasswordText;
|
|
|
public string PasswordText
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _PasswordText;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_PasswordText = value;
|
|
|
OnPropertyChanged("PasswordText");
|
|
|
}
|
|
|
}
|
|
|
private string _PasswordText2;
|
|
|
public string PasswordText2
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _PasswordText2;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_PasswordText2 = value;
|
|
|
OnPropertyChanged("PasswordText2");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region Binding Commands
|
|
|
|
|
|
private ICommand _CancelCommand;
|
|
|
public ICommand CancelCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _CancelCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_CancelCommand = value;
|
|
|
OnPropertyChanged("CancelCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _SaveCommand;
|
|
|
public ICommand SaveCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SaveCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SaveCommand = value;
|
|
|
OnPropertyChanged("SaveCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _ClearCommand;
|
|
|
public ICommand ClearCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _ClearCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_ClearCommand = value;
|
|
|
OnPropertyChanged("ClearCommand");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region Private Methods
|
|
|
|
|
|
private void OnCancelCommand(object sender)
|
|
|
{
|
|
|
View.DialogResult = true;
|
|
|
}
|
|
|
|
|
|
private void OnSaveCommand(object sender)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(UserName))
|
|
|
{
|
|
|
ShowErrorBox("<22>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
return;
|
|
|
}
|
|
|
if (string.IsNullOrWhiteSpace(PasswordText))
|
|
|
{
|
|
|
ShowErrorBox("<22><><EFBFBD>벻<EFBFBD><EBB2BB>Ϊ<EFBFBD><CEAA>");
|
|
|
return;
|
|
|
}
|
|
|
if (PasswordText2 != PasswordText)
|
|
|
{
|
|
|
ShowErrorBox("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벻һ<EBB2BB><D2BB>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
SysUserEntity user = new SysUserEntity();
|
|
|
user.RecId = UserId;
|
|
|
user.UserCode = UserName;
|
|
|
user.UserName = UserName;
|
|
|
user.RoleId = RoleId;
|
|
|
user.Password = Encryption.Encrypt(PasswordText);
|
|
|
SysUserDA.Update(user);
|
|
|
|
|
|
IsConfirm = true;
|
|
|
View.DialogResult = true;
|
|
|
}
|
|
|
|
|
|
private void OnClearCommand(object sender)
|
|
|
{
|
|
|
Setting.Save("StyleDlg", "Password", "");
|
|
|
ShowErrorBox("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|