narsil/Tanshu.Accounts.PointOfSale/Authentication/MsrLoginForm.cs

57 lines
1.5 KiB
C#

using System;
using System.Windows.Forms;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class MsrLoginForm : Form
{
private string _loginString;
private User _user;
private readonly bool register;
public MsrLoginForm(bool register)
{
InitializeComponent();
_user = null;
_loginString = string.Empty;
this.register = register;
this.btnLogin.Enabled = false;
}
private void btnLogin_Click(object sender, EventArgs e)
{
if (!register)
{
using (var bi = new UserBI())
{
var user = bi.MsrValidateUser(_loginString);
if (user != null)
{
this._user = user;
this.Close();
}
else
MessageBox.Show("Unrecognised Card");
}
}
else
{
this._user = new User() { MsrString = _loginString };
this.Close();
}
}
public User User()
{
return _user;
}
private void MsrLoginForm_KeyPress(object sender, KeyPressEventArgs e)
{
btnLogin.Enabled = true;
this._loginString += e.KeyChar.ToString();
}
}
}