57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
|
using System;
|
|||
|
using System.Threading;
|
|||
|
using System.Windows.Forms;
|
|||
|
using Tanshu.Accounts.BI;
|
|||
|
using Tanshu.Accounts.Helpers;
|
|||
|
|
|||
|
namespace Tanshu.Accounts.PointOfSale
|
|||
|
{
|
|||
|
public partial class LoginForm : Form
|
|||
|
{
|
|||
|
private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|||
|
private bool isAuthenticated;
|
|||
|
private string userName;
|
|||
|
public LoginForm()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
isAuthenticated = false;
|
|||
|
userName = null;
|
|||
|
}
|
|||
|
|
|||
|
private void txtUserName_KeyDown(object sender, KeyEventArgs e)
|
|||
|
{
|
|||
|
if (e.KeyCode == Keys.Return)
|
|||
|
txtPassword.Focus();
|
|||
|
}
|
|||
|
|
|||
|
private void txtPassword_KeyDown(object sender, KeyEventArgs e)
|
|||
|
{
|
|||
|
if (e.KeyCode == Keys.Return)
|
|||
|
btnLogin_Click(sender, e);
|
|||
|
}
|
|||
|
|
|||
|
private void btnLogin_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
userName = txtUserName.Text.Trim();
|
|||
|
isAuthenticated = new MembershipBI().ValidateUser(userName, Tanshu.Common.Md5.Hash(txtPassword.Text, "Salt"));
|
|||
|
|
|||
|
if (isAuthenticated)
|
|||
|
this.Close();
|
|||
|
else
|
|||
|
MessageBox.Show("Username or password is not valid");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public bool UserName(out string userName)
|
|||
|
{
|
|||
|
userName = this.userName;
|
|||
|
return isAuthenticated;
|
|||
|
}
|
|||
|
|
|||
|
private void btnExit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|