You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.0 KiB

using EC.AutoWeightServer.Center;
using EC.Entity.Organization;
using System;
using System.Windows.Forms;
namespace EC.AutoWeightServer.UI
{
public partial class FrmPwdVerify : Form
{
private string title;
internal UserEntity user { get; set; }
public FrmPwdVerify()
{
InitializeComponent();
}
public FrmPwdVerify(string title)
{
this.title = title;
InitializeComponent();
}
public void LockAccount(UserEntity tempUser)
{
if (tempUser == null)
return;
txtUserName.Text = tempUser.F_Account;
txtUserName.Enabled = false;
}
#region 监听事件
private void button1_Click(object sender, EventArgs e)
{
var username = txtUserName.Text.Trim();
var password = txtPassword.Text.Trim();
if (string.IsNullOrEmpty(username))
{
MessageBox.Show("用户名不能为空!", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtUserName.Focus();
return;
}
if (string.IsNullOrEmpty(password))
{
MessageBox.Show("密码不能为空!", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtPassword.Focus();
return;
}
if (!ServiceCenter.UserService.CheckLogin(username, password))
{
MessageBox.Show("用户名或密码错误!", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtPassword.Focus();
txtPassword.SelectAll();
return;
}
user = ServiceCenter.UserService.SelectEntityByWhere($"F_Account='{username}'");
DialogResult = DialogResult.Yes;
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.No;
}
private void txtUserName_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')//如果输入的是回车键
{
e.Handled = true;
button1_Click(sender, e);//触发button事件
}
}
private void txtPassword_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')//如果输入的是回车键
{
e.Handled = true;
button1_Click(sender, e);//触发button事件
}
}
#endregion 监听事件
}
}