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.
This commit is contained in:
@ -15,16 +15,17 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
return LoginUser(true);
|
||||
}
|
||||
bool LoginUser(bool setThreadPrincipal)
|
||||
bool LoginUser(bool setSession)
|
||||
{
|
||||
using (LoginForm login = new LoginForm(new KeyboardControl()))
|
||||
using (LoginForm frm = new LoginForm(new KeyboardControl()))
|
||||
{
|
||||
string userName;
|
||||
login.ShowDialog();
|
||||
bool authenticated = login.UserName(out userName);
|
||||
if (authenticated && setThreadPrincipal)
|
||||
SetThreadPrincipal(userName);
|
||||
return authenticated;
|
||||
frm.ShowDialog();
|
||||
var user = frm.User();
|
||||
if (user != null && setSession)
|
||||
{
|
||||
Session.User = user;
|
||||
}
|
||||
return user != null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -34,14 +35,5 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
Session.User = null;
|
||||
return true;
|
||||
}
|
||||
static void SetThreadPrincipal(string userName)
|
||||
{
|
||||
if (userName.Contains(":"))
|
||||
userName = userName.Substring(userName.IndexOf(":") + 1);
|
||||
|
||||
using (var bi = new UserBI())
|
||||
Session.User = bi.Get(x => x.Name == userName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,17 +41,16 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private void btnLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var bi = new UserBI())
|
||||
_user = bi.ValidateUser(txtUserName.Text.Trim(), Common.Md5.Hash(txtPassword.Text, "v2"));
|
||||
_user = bi.ValidateUser(txtUserName.Text.Trim(), txtPassword.Text);
|
||||
if (_user != null)
|
||||
this.Close();
|
||||
else
|
||||
MessageBox.Show("Username or password is not valid");
|
||||
}
|
||||
|
||||
public bool UserName(out string userName)
|
||||
public User User()
|
||||
{
|
||||
userName = this._user == null ? "" : this._user.Name;
|
||||
return this._user != null;
|
||||
return _user;
|
||||
}
|
||||
|
||||
private void btnExit_Click(object sender, EventArgs e)
|
||||
|
||||
@ -11,19 +11,17 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
return LoginUser(true);
|
||||
}
|
||||
|
||||
static bool LoginUser(bool setThreadPrincipal)
|
||||
static bool LoginUser(bool setSession)
|
||||
{
|
||||
using (var frm = new MsrLoginForm(false))
|
||||
{
|
||||
string userName;
|
||||
frm.ShowDialog();
|
||||
var authenticated = frm.UserName(out userName);
|
||||
if (authenticated && setThreadPrincipal)
|
||||
using (var bi = new UserBI())
|
||||
{
|
||||
Session.User = bi.Get(x => x.Name == userName);
|
||||
}
|
||||
return authenticated;
|
||||
var user = frm.User();
|
||||
if (user != null && setSession)
|
||||
{
|
||||
Session.User = user;
|
||||
}
|
||||
return user != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
using (var bi = new UserBI())
|
||||
{
|
||||
var user = bi.MsrValidateUser(_loginString);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
this._user = user;
|
||||
@ -38,15 +37,14 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
else
|
||||
{
|
||||
this._user = new User() { Name = _loginString };
|
||||
this._user = new User() { MsrString = _loginString };
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public bool UserName(out string userName)
|
||||
public User User()
|
||||
{
|
||||
userName = this._user == null ? "" : this._user.Name;
|
||||
return this._user != null;
|
||||
return _user;
|
||||
}
|
||||
|
||||
private void MsrLoginForm_KeyPress(object sender, KeyPressEventArgs e)
|
||||
|
||||
@ -773,7 +773,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
using (var bi = new ReprintBI())
|
||||
{
|
||||
bi.Insert(new Reprint() { Date = DbValues.Date, User = Session.User, Voucher = _billInfo });
|
||||
bi.Insert(new Reprint() { User = Session.User, Voucher = _billInfo });
|
||||
bi.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,11 +15,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
public enum LoginType
|
||||
{
|
||||
Keyboard,
|
||||
Msr
|
||||
}
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public MainForm()
|
||||
@ -49,14 +44,18 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
private void btnLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoginUser(LoginType.Keyboard);
|
||||
LoginUser(new KeyboardLogin());
|
||||
}
|
||||
|
||||
private void btnSale_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Session.IsAllowed("Sales"))
|
||||
using (var frmSale = new SalesForm(new BillController(null, true)))
|
||||
{
|
||||
frmSale.ShowDialog();
|
||||
Cache.Invalidate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnProduct_Click(object sender, EventArgs e)
|
||||
@ -182,24 +181,11 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
private void btnSwipeLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoginUser(LoginType.Msr);
|
||||
LoginUser(new MsrLogin());
|
||||
}
|
||||
|
||||
private void LoginUser(LoginType loginType)
|
||||
private void LoginUser(ILogin login)
|
||||
{
|
||||
ILogin login;
|
||||
switch (loginType)
|
||||
{
|
||||
case LoginType.Keyboard:
|
||||
login = new KeyboardLogin();
|
||||
break;
|
||||
case LoginType.Msr:
|
||||
login = new MsrLogin();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Session.IsAuthenticated)
|
||||
{
|
||||
if (login.LoginUser())
|
||||
@ -226,9 +212,10 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
var result = InputBox.Show("Bill Number", "0", InputBox_Validating);
|
||||
if (!result.OK)
|
||||
return;
|
||||
var billID = int.Parse(result.Text.Replace("-",""));
|
||||
Voucher voucher;
|
||||
using (var bi = new VoucherBI())
|
||||
voucher = bi.Get(x => x.BillID == result.Text);
|
||||
voucher = bi.Get(x => x.BillID == billID);
|
||||
if (Session.IsAllowed("Sales"))
|
||||
using (var frmSale = new SalesForm(new BillController(voucher.VoucherID, true)))
|
||||
frmSale.ShowDialog();
|
||||
|
||||
@ -12,25 +12,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
{
|
||||
public partial class SalesForm : Form, ISaleForm
|
||||
{
|
||||
private readonly IDictionary<Guid, IList<Product>> _productDictionary;
|
||||
private readonly IList<ProductGroup> _productGroupList;
|
||||
private ProductGroup _currentProductGroup;
|
||||
public SalesForm(BillController billController)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productDictionary = new Dictionary<Guid, IList<Product>>();
|
||||
|
||||
this._billController = billController;
|
||||
_billController = billController;
|
||||
billController.InitGui(this);
|
||||
using (var bi = new ProductGroupBI())
|
||||
_productGroupList = bi.List(x => x.IsActive);
|
||||
using (var bi = new ProductBI())
|
||||
foreach (var item in _productGroupList)
|
||||
_productDictionary.Add(item.ProductGroupID, bi.List(x => x.ProductGroup.ProductGroupID == item.ProductGroupID && x.IsActive));
|
||||
}
|
||||
|
||||
#region ISaleForm Members
|
||||
|
||||
public void SetUserName(string name)
|
||||
{
|
||||
Text = name;
|
||||
@ -55,8 +45,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
}
|
||||
else
|
||||
{
|
||||
txtBillID.Text = voucher.BillID;
|
||||
txtKotID.Text = voucher.KotID;
|
||||
if (voucher.BillID.HasValue)
|
||||
{
|
||||
txtBillID.Text = voucher.BillID.Value.ToString();
|
||||
}
|
||||
txtKotID.Text = "K-" + voucher.KotID.ToString();
|
||||
txtCreationDate.Text = voucher.CreationDate.ToString("HH:mm dd-MMM-yyyy");
|
||||
txtDate.Text = voucher.Date.Value.ToString("HH:mm dd-MMM-yyyy");
|
||||
txtLastEditDate.Text = voucher.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
|
||||
@ -334,7 +327,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
flpGroup.Controls.Clear();
|
||||
flpMain.Controls.Clear();
|
||||
if (value == SaleFormState.Billing)
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, _productGroupList, productTypeButton_Click, productTypePage_Click);
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, Cache.ProductGroups(), productTypeButton_Click, productTypePage_Click);
|
||||
else
|
||||
using (var bi = new FoodTableBI())
|
||||
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(x => x.IsActive), tableButton_Click, tablePage_Click);
|
||||
@ -351,7 +344,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
return;
|
||||
_currentProductGroup = item;
|
||||
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), 0,
|
||||
_productDictionary[item.ProductGroupID], productButton_Click, productPage_Click);
|
||||
item.Products, productButton_Click, productPage_Click);
|
||||
}
|
||||
|
||||
private void productTypePage_Click(object sender, EventArgs e)
|
||||
@ -362,7 +355,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
var start = (int)button.Tag;
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, _productGroupList, productTypeButton_Click, productTypePage_Click);
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, Cache.ProductGroups(), productTypeButton_Click, productTypePage_Click);
|
||||
}
|
||||
|
||||
private void productButton_Click(object sender, EventArgs e)
|
||||
@ -385,7 +378,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
var start = (int)button.Tag;
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), start, _productDictionary[_currentProductGroup.ProductGroupID], productButton_Click, productPage_Click);
|
||||
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), start, _currentProductGroup.Products, productButton_Click, productPage_Click);
|
||||
}
|
||||
|
||||
private void tableButton_Click(object sender, EventArgs e)
|
||||
|
||||
@ -320,6 +320,7 @@
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Reports\BillDetailsForm.resx">
|
||||
<DependentUpon>BillDetailsForm.cs</DependentUpon>
|
||||
|
||||
@ -36,8 +36,8 @@
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtConfirmPassword = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.btnCreateUSer = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnChangePassword = new System.Windows.Forms.Button();
|
||||
this.btnMsr = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -113,25 +113,25 @@
|
||||
this.label4.Text = "Confirm Password";
|
||||
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// button2
|
||||
// btnCancel
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(211, 116);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(55, 23);
|
||||
this.button2.TabIndex = 5;
|
||||
this.button2.Text = "Ca&ncel";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
this.btnCancel.Location = new System.Drawing.Point(211, 116);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(55, 23);
|
||||
this.btnCancel.TabIndex = 5;
|
||||
this.btnCancel.Text = "Ca&ncel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// btnCreateUSer
|
||||
// btnChangePassword
|
||||
//
|
||||
this.btnCreateUSer.Location = new System.Drawing.Point(84, 116);
|
||||
this.btnCreateUSer.Name = "btnCreateUSer";
|
||||
this.btnCreateUSer.Size = new System.Drawing.Size(121, 23);
|
||||
this.btnCreateUSer.TabIndex = 4;
|
||||
this.btnCreateUSer.Text = "&Change Password";
|
||||
this.btnCreateUSer.UseVisualStyleBackColor = true;
|
||||
this.btnCreateUSer.Click += new System.EventHandler(this.btnCreateUSer_Click);
|
||||
this.btnChangePassword.Location = new System.Drawing.Point(84, 116);
|
||||
this.btnChangePassword.Name = "btnChangePassword";
|
||||
this.btnChangePassword.Size = new System.Drawing.Size(121, 23);
|
||||
this.btnChangePassword.TabIndex = 4;
|
||||
this.btnChangePassword.Text = "&Change Password";
|
||||
this.btnChangePassword.UseVisualStyleBackColor = true;
|
||||
this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click);
|
||||
//
|
||||
// btnMsr
|
||||
//
|
||||
@ -149,8 +149,8 @@
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(287, 185);
|
||||
this.Controls.Add(this.btnMsr);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.btnCreateUSer);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnChangePassword);
|
||||
this.Controls.Add(this.txtConfirmPassword);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.txtnewPassword);
|
||||
@ -179,8 +179,8 @@
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox txtConfirmPassword;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Button btnCreateUSer;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Button btnChangePassword;
|
||||
private System.Windows.Forms.Button btnMsr;
|
||||
}
|
||||
}
|
||||
@ -32,12 +32,12 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
txtUsername.Text = Session.User.Name;
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnCreateUSer_Click(object sender, EventArgs e)
|
||||
private void btnChangePassword_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (txtPassword.Text.Trim() == "")
|
||||
MessageBox.Show("Old password can not be blank", "Blank not allowed");
|
||||
@ -53,7 +53,6 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
if (ChangeUserPassword())
|
||||
{
|
||||
MessageBox.Show("Password changed", "Confirm");
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
@ -65,43 +64,38 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
private bool ChangeUserPassword()
|
||||
{
|
||||
var userEntity = new User();
|
||||
userEntity.Name = txtUsername.Text.Trim();
|
||||
userEntity.Password = Tanshu.Common.Md5.Hash(txtPassword.Text.Trim(), "v2");
|
||||
|
||||
using (var bi = new UserBI())
|
||||
if (bi.ValidateUser(userEntity.Name, userEntity.Password) != null)
|
||||
return bi.ChangePassword(userEntity, Tanshu.Common.Md5.Hash(txtnewPassword.Text.Trim(), "v2"));
|
||||
else
|
||||
{
|
||||
var user = bi.ValidateUser(Session.User.Name, txtPassword.Text.Trim());
|
||||
if (user == null)
|
||||
return false;
|
||||
bi.ChangePassword(user, txtnewPassword.Text.Trim());
|
||||
bi.SaveChanges();
|
||||
MessageBox.Show("Password changed", "Confirm");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnMsr_Click(object sender, EventArgs e)
|
||||
{
|
||||
var user = new User();
|
||||
user.Name = txtUsername.Text.Trim();
|
||||
user.Password = Common.Md5.Hash(txtPassword.Text.Trim(), "v2");
|
||||
|
||||
using (var bi = new UserBI())
|
||||
if (bi.ValidateUser(user.Name, user.Password) == null)
|
||||
return;
|
||||
using (var frm = new MsrLoginForm(true))
|
||||
{
|
||||
frm.ShowDialog();
|
||||
string userName;
|
||||
frm.UserName(out userName);
|
||||
if (MessageBox.Show("Update Msr Card", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
|
||||
DialogResult.Yes)
|
||||
var user = bi.ValidateUser(Session.User.Name, txtPassword.Text.Trim());
|
||||
if (user == null)
|
||||
return;
|
||||
using (var bi = new UserBI())
|
||||
using (var frm = new MsrLoginForm(true))
|
||||
{
|
||||
user = bi.Get(x => x.Name == user.Name);
|
||||
user.MsrString = userName;
|
||||
frm.ShowDialog();
|
||||
var msrString = frm.User().MsrString;
|
||||
if (MessageBox.Show("Update Msr Card", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
|
||||
DialogResult.Yes)
|
||||
return;
|
||||
user.MsrString = msrString;
|
||||
bi.Update(user);
|
||||
bi.SaveChanges();
|
||||
MessageBox.Show("Msr Card Updated");
|
||||
this.Close();
|
||||
}
|
||||
MessageBox.Show("Msr Card Updated");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user