narsil/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs
unknown d8ecec8bb6 Added inverse Attribute to ProductGroup.
BillInventory Renamed.
Refactored Bill to be more usable.
Added Bill Detail Report.
Added Open Bill and Bill Details Roles.
Zero Rate Products have Yellow background Color.
Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI,
Cached the Products List.
Product and Product Group Form Working.
2011-06-23 18:17:48 +05:30

63 lines
1.9 KiB
C#

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