using HMI.Core.Entity;
|
using HMI.Core.Util;
|
using HMI.UI.Util;
|
using Panuon.WPF.UI;
|
using System.ComponentModel;
|
|
namespace HMI.Base
|
{
|
/// <summary>
|
/// RequirePasswordWindow.xaml 的交互逻辑
|
/// </summary>
|
public partial class RequirePasswordByUser : WindowX
|
{
|
public RequirePasswordByUser(string username)
|
{
|
this.Username = username;
|
this.DataContext = this;
|
InitializeComponent();
|
}
|
|
private string username;
|
public string Username
|
{
|
get => username;
|
set
|
{
|
Set(ref username, value);
|
}
|
}
|
|
protected override void OnClosing(CancelEventArgs e)
|
{
|
//Press Continue Button
|
if (DialogResult == true)
|
{
|
try
|
{
|
using (var helper = new Sqlite3Helper(PathHelper.DatabasePath))
|
{
|
if (!helper.HasData($"SELECT 1 FROM user WHERE username = '{Username}' AND password = '{PwdPassword.Password}';"))
|
{
|
ToastHelper.Error(this, "密码错误");
|
e.Cancel = true;
|
}
|
}
|
}
|
catch (System.Exception ex)
|
{
|
ToastHelper.Error(this, $"验证用户信息失败: {ex.Message}");
|
e.Cancel = true;
|
}
|
}
|
base.OnClosing(e);
|
}
|
|
private void WindowX_Loaded(object sender, System.Windows.RoutedEventArgs e)
|
{
|
Username = UserInfo.User.Username;
|
PwdPassword.Password = string.Empty;
|
}
|
}
|
}
|