2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using System.Drawing;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
using System.Windows.Forms;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
using Tanshu.Accounts.Entities.Auth;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Repository;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
using Tanshu.Common.KeyboardControl;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
|
|
|
|
public partial class LoginForm : Form
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
private User _user;
|
|
|
|
|
private IKeyboardControl _keyboardControl;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
public LoginForm(IKeyboardControl keyboardControl)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2011-03-11 18:49:48 +00:00
|
|
|
|
_user = null;
|
|
|
|
|
this._keyboardControl = keyboardControl;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
|
|
|
|
|
var control = keyboardControl as UserControl;
|
|
|
|
|
if (control != null)
|
|
|
|
|
{
|
|
|
|
|
control.Location = new System.Drawing.Point(6, 87);
|
|
|
|
|
this.Controls.Add(control);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
this.Size = this.SizeFromClientSize(new Size(6 + control.Width + 6, 87 + control.Height + 6));
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
_user = UserBI.ValidateUser(txtUserName.Text.Trim(), Tanshu.Common.Md5.Hash(txtPassword.Text, "v2"));
|
|
|
|
|
if (_user != null)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
this.Close();
|
|
|
|
|
else
|
|
|
|
|
MessageBox.Show("Username or password is not valid");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UserName(out string userName)
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
userName = this._user == null ? "" : this._user.Name;
|
|
|
|
|
return this._user != null;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|