73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using Aurora.Api;
|
|
using Aurora.Api.Control;
|
|
using Aurora.View;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
namespace WeldingCommon.Views.DoorInterlock
|
|
{
|
|
|
|
public class WinDoorInterlockEditViewModel : NotifyPropertyChangedBase
|
|
{
|
|
private readonly string _settingId;
|
|
private readonly ISettingEntry _settingManager;
|
|
|
|
public ICommand CMD_Ok { get; }
|
|
public ICommand CMD_Cancel { get; }
|
|
|
|
public string PhoneNumber { get; set; } = string.Empty;
|
|
public string Name { get; set; } = string.Empty;
|
|
public string Password { get; set; } = string.Empty;
|
|
public string PasswordCheck { get; set; } = string.Empty;
|
|
|
|
public WinDoorInterlockEditViewModel(ISettingEntry setingManager, string settingId)
|
|
{
|
|
_settingId = settingId;
|
|
|
|
_settingManager = setingManager;
|
|
|
|
CMD_Ok = new DelegateCommand(BtnOK);
|
|
CMD_Cancel = new DelegateCommand(BtnCancel);
|
|
}
|
|
|
|
private void BtnOK(object obj)
|
|
{
|
|
Window win = obj as Window;
|
|
int password = 0;
|
|
if (!int.TryParse(Password, out password)) {
|
|
MessageDialog.Show(win, "Fail", "Password parsing fail");
|
|
return;
|
|
}
|
|
int passwordCheck = 0;
|
|
if (!int.TryParse(PasswordCheck, out passwordCheck)) {
|
|
MessageDialog.Show(win, "Fail", "PasswordCheck parsing fail");
|
|
return;
|
|
}
|
|
|
|
if (Password == PasswordCheck) {
|
|
var setting = _settingManager[_settingId] as DoorInterlockSetting;
|
|
setting.PhoneNumber = PhoneNumber;
|
|
setting.UserName = Name;
|
|
setting.Password = password;
|
|
setting.PasswordCheck = passwordCheck;
|
|
|
|
_settingManager.Save(_settingId, setting, string.Empty);
|
|
|
|
win.DialogResult = true;
|
|
win.Close();
|
|
} else {
|
|
MessageDialog.Show(win, "Fail", "Password Maching Fail.");
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
private void BtnCancel(object obj)
|
|
{
|
|
Window win = obj as Window;
|
|
win.DialogResult = false;
|
|
win.Close();
|
|
}
|
|
}
|
|
}
|