Feature: Added SortOrder to Inventory.

Chore: Settle Choices form greatly simplified.
Feature: Modifiers are now cached.
This commit is contained in:
tanshu
2014-11-10 16:36:49 +05:30
parent 3706d8eb1e
commit c52f382ec2
12 changed files with 247 additions and 130 deletions

View File

@ -88,22 +88,19 @@ namespace Tanshu.Accounts.PointOfSale
if (bi.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
{
var item = CurrentProduct;
ShowModifiers(product.ProductGroup.ProductGroupID, item);
ShowModifiers(item);
}
}
ShowAmount();
}
public void ShowModifiers(Guid productGroupID, BillItemValue item)
public void ShowModifiers(BillItemValue item)
{
if (item.Printed)
return;
using (var bi = new ProductGroupModifierBI())
using (var frm = new ModifierForm(Cache.ProductGroupModifiers(item.Product.ProductGroup.ProductGroupID), item.Modifiers))
{
using (var frm = new ModifierForm(bi.List(productGroupID), item.Modifiers))
{
frm.ShowDialog();
item.Modifiers = frm.Selection;
}
frm.ShowDialog();
item.Modifiers = frm.Selection;
}
ShowAmount();
}
@ -425,7 +422,7 @@ namespace Tanshu.Accounts.PointOfSale
{
using (var bi = new FoodTableBI())
{
using (var frm = new MoveTableForm(bi.List(x=>x.IsActive), allowMerge))
using (var frm = new MoveTableForm(bi.List(x => x.IsActive), allowMerge))
{
frm.ShowDialog();
if (frm.Selection != null)

View File

@ -35,6 +35,8 @@
this.btnCustomer = new System.Windows.Forms.Button();
this.btnProduct = new System.Windows.Forms.Button();
this.btnProductGroup = new System.Windows.Forms.Button();
this.btnReorderTables = new System.Windows.Forms.Button();
this.btnModifiers = new System.Windows.Forms.Button();
this.btnOpenBill = new System.Windows.Forms.Button();
this.btnCreateUser = new System.Windows.Forms.Button();
this.btnUserRoles = new System.Windows.Forms.Button();
@ -48,8 +50,6 @@
this.btnChangePassword = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnManagement = new System.Windows.Forms.Button();
this.btnReorderTables = new System.Windows.Forms.Button();
this.btnModifiers = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
@ -58,7 +58,7 @@
this.btnLogin.Location = new System.Drawing.Point(3, 3);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(150, 100);
this.btnLogin.TabIndex = 1;
this.btnLogin.TabIndex = 0;
this.btnLogin.Text = "&Login";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
@ -68,7 +68,7 @@
this.btnSale.Location = new System.Drawing.Point(315, 3);
this.btnSale.Name = "btnSale";
this.btnSale.Size = new System.Drawing.Size(150, 100);
this.btnSale.TabIndex = 3;
this.btnSale.TabIndex = 2;
this.btnSale.Text = "&Sale";
this.btnSale.UseVisualStyleBackColor = true;
this.btnSale.Click += new System.EventHandler(this.btnSale_Click);
@ -107,7 +107,7 @@
this.btnSwipeLogin.Location = new System.Drawing.Point(159, 3);
this.btnSwipeLogin.Name = "btnSwipeLogin";
this.btnSwipeLogin.Size = new System.Drawing.Size(150, 100);
this.btnSwipeLogin.TabIndex = 2;
this.btnSwipeLogin.TabIndex = 1;
this.btnSwipeLogin.Text = "Swipe Login";
this.btnSwipeLogin.UseVisualStyleBackColor = true;
this.btnSwipeLogin.Click += new System.EventHandler(this.btnSwipeLogin_Click);
@ -117,7 +117,7 @@
this.btnCustomer.Location = new System.Drawing.Point(471, 3);
this.btnCustomer.Name = "btnCustomer";
this.btnCustomer.Size = new System.Drawing.Size(150, 100);
this.btnCustomer.TabIndex = 4;
this.btnCustomer.TabIndex = 3;
this.btnCustomer.Text = "Customers";
this.btnCustomer.UseVisualStyleBackColor = true;
this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click);
@ -127,7 +127,7 @@
this.btnProduct.Location = new System.Drawing.Point(627, 3);
this.btnProduct.Name = "btnProduct";
this.btnProduct.Size = new System.Drawing.Size(150, 100);
this.btnProduct.TabIndex = 5;
this.btnProduct.TabIndex = 4;
this.btnProduct.Text = "Products";
this.btnProduct.UseVisualStyleBackColor = true;
this.btnProduct.Click += new System.EventHandler(this.btnProduct_Click);
@ -137,17 +137,37 @@
this.btnProductGroup.Location = new System.Drawing.Point(3, 109);
this.btnProductGroup.Name = "btnProductGroup";
this.btnProductGroup.Size = new System.Drawing.Size(150, 100);
this.btnProductGroup.TabIndex = 6;
this.btnProductGroup.TabIndex = 5;
this.btnProductGroup.Text = "Product Groups";
this.btnProductGroup.UseVisualStyleBackColor = true;
this.btnProductGroup.Click += new System.EventHandler(this.btnProductGroup_Click);
//
// btnReorderTables
//
this.btnReorderTables.Location = new System.Drawing.Point(159, 109);
this.btnReorderTables.Name = "btnReorderTables";
this.btnReorderTables.Size = new System.Drawing.Size(150, 100);
this.btnReorderTables.TabIndex = 6;
this.btnReorderTables.Text = "Reorder Tables";
this.btnReorderTables.UseVisualStyleBackColor = true;
this.btnReorderTables.Click += new System.EventHandler(this.btnReorderTables_Click);
//
// btnModifiers
//
this.btnModifiers.Location = new System.Drawing.Point(315, 109);
this.btnModifiers.Name = "btnModifiers";
this.btnModifiers.Size = new System.Drawing.Size(150, 100);
this.btnModifiers.TabIndex = 7;
this.btnModifiers.Text = "Product Modifiers";
this.btnModifiers.UseVisualStyleBackColor = true;
this.btnModifiers.Click += new System.EventHandler(this.btnModifiers_Click);
//
// btnOpenBill
//
this.btnOpenBill.Location = new System.Drawing.Point(471, 109);
this.btnOpenBill.Name = "btnOpenBill";
this.btnOpenBill.Size = new System.Drawing.Size(150, 100);
this.btnOpenBill.TabIndex = 7;
this.btnOpenBill.TabIndex = 8;
this.btnOpenBill.Text = "Open Bill";
this.btnOpenBill.UseVisualStyleBackColor = true;
this.btnOpenBill.Click += new System.EventHandler(this.btnOpenBill_Click);
@ -157,7 +177,7 @@
this.btnCreateUser.Location = new System.Drawing.Point(627, 109);
this.btnCreateUser.Name = "btnCreateUser";
this.btnCreateUser.Size = new System.Drawing.Size(150, 100);
this.btnCreateUser.TabIndex = 10;
this.btnCreateUser.TabIndex = 9;
this.btnCreateUser.Text = "Create User";
this.btnCreateUser.UseVisualStyleBackColor = true;
this.btnCreateUser.Click += new System.EventHandler(this.btnCreateUser_Click);
@ -167,7 +187,7 @@
this.btnUserRoles.Location = new System.Drawing.Point(3, 215);
this.btnUserRoles.Name = "btnUserRoles";
this.btnUserRoles.Size = new System.Drawing.Size(150, 100);
this.btnUserRoles.TabIndex = 11;
this.btnUserRoles.TabIndex = 10;
this.btnUserRoles.Text = "Manage User Roles";
this.btnUserRoles.UseVisualStyleBackColor = true;
this.btnUserRoles.Click += new System.EventHandler(this.btnUserRoles_Click);
@ -177,7 +197,7 @@
this.btnGroupRoles.Location = new System.Drawing.Point(159, 215);
this.btnGroupRoles.Name = "btnGroupRoles";
this.btnGroupRoles.Size = new System.Drawing.Size(150, 100);
this.btnGroupRoles.TabIndex = 12;
this.btnGroupRoles.TabIndex = 11;
this.btnGroupRoles.Text = "Manage Group Roles";
this.btnGroupRoles.UseVisualStyleBackColor = true;
this.btnGroupRoles.Click += new System.EventHandler(this.btnGroupRoles_Click);
@ -187,7 +207,7 @@
this.btnCashierCheckout.Location = new System.Drawing.Point(315, 215);
this.btnCashierCheckout.Name = "btnCashierCheckout";
this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100);
this.btnCashierCheckout.TabIndex = 13;
this.btnCashierCheckout.TabIndex = 12;
this.btnCashierCheckout.Text = "Cashier Checkout";
this.btnCashierCheckout.UseVisualStyleBackColor = true;
this.btnCashierCheckout.Click += new System.EventHandler(this.btnCashierCheckout_Click);
@ -197,7 +217,7 @@
this.btnSaleAnalysis.Location = new System.Drawing.Point(471, 215);
this.btnSaleAnalysis.Name = "btnSaleAnalysis";
this.btnSaleAnalysis.Size = new System.Drawing.Size(150, 100);
this.btnSaleAnalysis.TabIndex = 14;
this.btnSaleAnalysis.TabIndex = 13;
this.btnSaleAnalysis.Text = "Sale Analysis";
this.btnSaleAnalysis.UseVisualStyleBackColor = true;
this.btnSaleAnalysis.Click += new System.EventHandler(this.btnSaleAnalysis_Click);
@ -207,7 +227,7 @@
this.btnSaleDetail.Location = new System.Drawing.Point(627, 215);
this.btnSaleDetail.Name = "btnSaleDetail";
this.btnSaleDetail.Size = new System.Drawing.Size(150, 100);
this.btnSaleDetail.TabIndex = 15;
this.btnSaleDetail.TabIndex = 14;
this.btnSaleDetail.Text = "Sale Detail";
this.btnSaleDetail.UseVisualStyleBackColor = true;
this.btnSaleDetail.Click += new System.EventHandler(this.btnSaleDetail_Click);
@ -217,7 +237,7 @@
this.btnBillDetails.Location = new System.Drawing.Point(3, 321);
this.btnBillDetails.Name = "btnBillDetails";
this.btnBillDetails.Size = new System.Drawing.Size(150, 100);
this.btnBillDetails.TabIndex = 16;
this.btnBillDetails.TabIndex = 15;
this.btnBillDetails.Text = "Bill Details";
this.btnBillDetails.UseVisualStyleBackColor = true;
this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click);
@ -227,7 +247,7 @@
this.btnVoidOrReprints.Location = new System.Drawing.Point(159, 321);
this.btnVoidOrReprints.Name = "btnVoidOrReprints";
this.btnVoidOrReprints.Size = new System.Drawing.Size(150, 100);
this.btnVoidOrReprints.TabIndex = 19;
this.btnVoidOrReprints.TabIndex = 16;
this.btnVoidOrReprints.Text = "Voids or Reprints";
this.btnVoidOrReprints.UseVisualStyleBackColor = true;
this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click);
@ -237,7 +257,7 @@
this.btnDiscountReport.Location = new System.Drawing.Point(315, 321);
this.btnDiscountReport.Name = "btnDiscountReport";
this.btnDiscountReport.Size = new System.Drawing.Size(150, 100);
this.btnDiscountReport.TabIndex = 21;
this.btnDiscountReport.TabIndex = 17;
this.btnDiscountReport.Text = "Discount Report";
this.btnDiscountReport.UseVisualStyleBackColor = true;
this.btnDiscountReport.Click += new System.EventHandler(this.btnDiscountReport_Click);
@ -247,7 +267,7 @@
this.btnChangePassword.Location = new System.Drawing.Point(471, 321);
this.btnChangePassword.Name = "btnChangePassword";
this.btnChangePassword.Size = new System.Drawing.Size(150, 100);
this.btnChangePassword.TabIndex = 17;
this.btnChangePassword.TabIndex = 18;
this.btnChangePassword.Text = "Change Password";
this.btnChangePassword.UseVisualStyleBackColor = true;
this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click);
@ -257,7 +277,7 @@
this.btnExit.Location = new System.Drawing.Point(627, 321);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(150, 100);
this.btnExit.TabIndex = 18;
this.btnExit.TabIndex = 19;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
@ -272,26 +292,6 @@
this.btnManagement.UseVisualStyleBackColor = true;
this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click);
//
// btnReorderTables
//
this.btnReorderTables.Location = new System.Drawing.Point(159, 109);
this.btnReorderTables.Name = "btnReorderTables";
this.btnReorderTables.Size = new System.Drawing.Size(150, 100);
this.btnReorderTables.TabIndex = 22;
this.btnReorderTables.Text = "Reorder Tables";
this.btnReorderTables.UseVisualStyleBackColor = true;
this.btnReorderTables.Click += new System.EventHandler(this.btnReorderTables_Click);
//
// btnModifiers
//
this.btnModifiers.Location = new System.Drawing.Point(315, 109);
this.btnModifiers.Name = "btnModifiers";
this.btnModifiers.Size = new System.Drawing.Size(150, 100);
this.btnModifiers.TabIndex = 23;
this.btnModifiers.Text = "Product Modifiers";
this.btnModifiers.UseVisualStyleBackColor = true;
this.btnModifiers.Click += new System.EventHandler(this.btnModifiers_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -234,10 +234,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (item == null)
return;
Guid id;
using (var bi = new ProductGroupBI())
id = bi.GetProductGroupOfProduct(item.ProductID).ProductGroupID;
_billController.ShowModifiers(id, item);
_billController.ShowModifiers(item);
}
private void btnDelete_Click(object sender, EventArgs e)

View File

@ -35,7 +35,8 @@
//
// txtAmount
//
this.txtAmount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.txtAmount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtAmount.Location = new System.Drawing.Point(3, 3);
this.txtAmount.Name = "txtAmount";
this.txtAmount.ReadOnly = true;

View File

@ -11,74 +11,20 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class SettleChoicesForm : Form
{
private readonly IDictionary<Button, int> _list;
private decimal _amount;
private decimal _totalAmount;
private readonly VoucherType _voucherType;
public SettleChoicesForm(decimal amount, VoucherType voucherType)
private IDictionary<SettleOption, decimal> _optionsChosen;
public SettleChoicesForm(decimal totalAmount, VoucherType voucherType)
{
InitializeComponent();
_amount = amount;
_totalAmount = totalAmount;
_voucherType = voucherType;
OptionsChosen = new Dictionary<SettleOption, decimal>();
_list = new Dictionary<Button, int>();
}
private void ButtonClick(object sender, EventArgs e)
{
var button = sender as Button;
if (button == null || button.Tag == null)
return;
if (button.Tag is SettleOption)
{
var settleOption = (SettleOption)button.Tag;
using (var frm = new SettleAmountsForm(new NumpadControl(), settleOption, _amount))
{
frm.ShowDialog();
UpdateChoice(settleOption, frm.AmountSettled, _list[button]);
}
}
else
{
if ((string)button.Tag == "Cancel")
_optionsChosen.Clear();
this.Close();
}
}
private void UpdateChoice(SettleOption settleOption, decimal amount, int group)
{
var oldAmount = _optionsChosen.ContainsKey(settleOption) ? _optionsChosen[settleOption] : 0;
if (amount == 0 && _optionsChosen.ContainsKey(settleOption))
_optionsChosen.Remove(settleOption);
else if (_optionsChosen.ContainsKey(settleOption))
_optionsChosen[settleOption] = amount;
else if (amount != 0)
_optionsChosen.Add(settleOption, amount);
_amount += oldAmount - amount;
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", _amount);
if (_optionsChosen.Count == 0)
foreach (var item in _list)
item.Key.Enabled = true;
else
foreach (var item in _list.Where(item => item.Value != group))
item.Key.Enabled = false;
}
private IDictionary<SettleOption, decimal> _optionsChosen;
public IDictionary<SettleOption, decimal> OptionsChosen
{
get
{
return _amount == 0 ? _optionsChosen : new Dictionary<SettleOption, decimal>();
}
private set { _optionsChosen = value; }
_optionsChosen = new Dictionary<SettleOption, decimal>();
}
private void SettleChoicesFormLoad(object sender, EventArgs e)
{
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", _amount);
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", PendingAmount);
var count = 0;
foreach (SettleOption item in Enum.GetValues(typeof(SettleOption)))
{
@ -86,17 +32,16 @@ namespace Tanshu.Accounts.PointOfSale
if (!attribute.ShowInChoices || attribute.Group != _voucherType.Attribute().Group)
continue;
var button = new Button
{
Name = item.ToString(),
Text = attribute.Name,
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = item
};
{
Name = item.ToString(),
Text = attribute.Name,
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = item,
};
button.Click += new EventHandler(ButtonClick);
flpSettlement.Controls.Add(button);
_list.Add(button, attribute.Group);
count++;
}
var controlButton = new Button
@ -108,9 +53,8 @@ namespace Tanshu.Accounts.PointOfSale
UseVisualStyleBackColor = true,
Tag = "OK"
};
controlButton.Click += new EventHandler(ButtonClick);
controlButton.Click += new EventHandler(OkClick);
flpSettlement.Controls.Add(controlButton);
// _list.Add(controlButton); --- Do not add to list
count++;
controlButton = new Button
{
@ -121,9 +65,8 @@ namespace Tanshu.Accounts.PointOfSale
UseVisualStyleBackColor = true,
Tag = "Cancel"
};
controlButton.Click += new EventHandler(ButtonClick);
controlButton.Click += new EventHandler(CancelClick);
flpSettlement.Controls.Add(controlButton);
// _list.Add(controlButton); --- Do not add to list
count++;
txtAmount.TabIndex = count;
@ -131,5 +74,55 @@ namespace Tanshu.Accounts.PointOfSale
txtAmount.Width = flpSettlement.Width - 6;
}
private void ButtonClick(object sender, EventArgs e)
{
var settleOption = (SettleOption)((sender as Button).Tag);
using (var frm = new SettleAmountsForm(new NumpadControl(), settleOption, PendingAmount))
{
frm.ShowDialog();
UpdateChoice(settleOption, frm.AmountSettled);
}
}
private void UpdateChoice(SettleOption settleOption, decimal amount)
{
if (amount == 0 && _optionsChosen.ContainsKey(settleOption))
_optionsChosen.Remove(settleOption);
else if (amount != 0 && _optionsChosen.ContainsKey(settleOption))
_optionsChosen[settleOption] = amount;
else if (amount != 0 && !_optionsChosen.ContainsKey(settleOption))
_optionsChosen.Add(settleOption, amount);
else if (_totalAmount == 0 && amount == 0 && !_optionsChosen.ContainsKey(settleOption))
_optionsChosen.Add(settleOption, amount);
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", PendingAmount);
}
private decimal PendingAmount
{
get
{
decimal amount = _totalAmount;
foreach (var item in _optionsChosen)
{
amount -= item.Value;
}
return amount;
}
}
public IDictionary<SettleOption, decimal> OptionsChosen
{
get
{
return PendingAmount == 0 ? _optionsChosen : new Dictionary<SettleOption, decimal>();
}
}
private void OkClick(object sender, EventArgs e)
{
this.Close();
}
private void CancelClick(object sender, EventArgs e)
{
_optionsChosen.Clear();
this.Close();
}
}
}