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

56 lines
1.4 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 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)
{
var user = UserBI.MsrValidateUser(loginString);
if (user != null)
{
this.user = user;
this.Close();
}
else
MessageBox.Show("Unrecognised Card");
}
else
{
this.user = new User() { Name = loginString };
this.Close();
}
}
public bool UserName(out string userName)
{
userName = this.user == null ? "" : this.user.Name;
return this.user != null;
}
private void MsrLoginForm_KeyPress(object sender, KeyPressEventArgs e)
{
btnLogin.Enabled = true;
this.loginString += e.KeyChar.ToString();
}
}
}