narsil/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs
tanshu 3ca8b29e04 Regression: BillItemKey added the compare methods back
Regression: PrintLocation added the compare methods back
Breaking: Kot.Code is now integers
Breaking: Kot Update is now via Stored Procedure to get DB Values
Breaking: Reprints Insert is now via Stored Procedure to get DV Values
Breaking: Voucher.BillID and KotID are now integers
Breaking: Voucher Insert/Update is now via Stored Procedures to get DV Values also Dirty Checking for Voucher has been overwritten to set dirty for LastEditDate update
Fix: Login forms simplified
Feature: PrintLocation and Products are cached application wide.
2014-11-02 13:33:31 +05:30

62 lines
1.7 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 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(), txtPassword.Text);
if (_user != null)
this.Close();
else
MessageBox.Show("Username or password is not valid");
}
public User User()
{
return _user;
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}