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.
This commit is contained in:
@ -1,142 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using Tanshu.Common;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
{
|
||||
public class BillHelperFunctions
|
||||
{
|
||||
private readonly OrderedDictionary<BillItemKey, BillInventory> bill;
|
||||
private readonly BindingSource _bindingSource;
|
||||
private readonly BillItemKey _newKey;
|
||||
|
||||
public BillHelperFunctions(BindingSource bindingSource, OrderedDictionary<BillItemKey, BillInventory> bill,
|
||||
int productID)
|
||||
{
|
||||
this._bindingSource = bindingSource;
|
||||
this.bill = bill;
|
||||
_newKey = new BillItemKey(productID, 0);
|
||||
}
|
||||
|
||||
public void SetDiscount(string name, decimal discount)
|
||||
{
|
||||
if (discount > 1 || discount < 0)
|
||||
return;
|
||||
decimal maxDiscount = VoucherBI.GetProductDiscountLimit(_newKey.ProductID);
|
||||
if (discount > maxDiscount)
|
||||
MessageBox.Show(string.Format("Maximum discount for {0} is {1:P}", name, maxDiscount),
|
||||
"Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
foreach (var item in bill)
|
||||
{
|
||||
if (item.Value.ProductID == _newKey.ProductID)
|
||||
item.Value.Discount = discount;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPrice(BillInventory product)
|
||||
{
|
||||
if (!Allowed(product, RoleConstants.CHANGE_RATE))
|
||||
return;
|
||||
decimal rate = product.Price;
|
||||
if (!GetInput("Price", ref rate))
|
||||
return;
|
||||
if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE))
|
||||
return;
|
||||
foreach (var item in bill)
|
||||
{
|
||||
if (item.Value.ProductID == _newKey.ProductID)
|
||||
item.Value.Price = rate;
|
||||
}
|
||||
}
|
||||
|
||||
private void InputBox_Validating(object sender, InputBoxValidatingArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private bool Allowed(BillInventory item, RoleConstants role)
|
||||
{
|
||||
if (item == null)
|
||||
return false;
|
||||
if (!Session.IsAllowed(role))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool GetInput(string prompt, ref decimal amount)
|
||||
{
|
||||
InputBoxResult result = InputBox.Show(prompt, amount.ToString(), InputBox_Validating);
|
||||
if (!result.OK)
|
||||
return false;
|
||||
if (!decimal.TryParse(result.Text, out amount))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#region Add Product
|
||||
|
||||
public BillInventory AddProduct()
|
||||
{
|
||||
BillInventory product;
|
||||
if (bill.ContainsKey(_newKey))
|
||||
{
|
||||
_bindingSource.CurrencyManager.Position = bill.IndexOfKey(_newKey);
|
||||
product = bill[_newKey];
|
||||
product.Quantity += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Has only old
|
||||
product = VoucherBI.GetDefaultSaleBillItem(_newKey.ProductID);
|
||||
foreach (var item in bill)
|
||||
{
|
||||
if (item.Key.ProductID == _newKey.ProductID)
|
||||
{
|
||||
product.Discount = item.Value.Discount;
|
||||
product.Price = item.Value.Price;
|
||||
}
|
||||
}
|
||||
product = AddProduct(product);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
private BillInventory AddProduct(BillInventory product)
|
||||
{
|
||||
bill.Add(new BillItemKey(product.ProductID, 0), product);
|
||||
_bindingSource.DataSource = bill.Values.ToList();
|
||||
_bindingSource.CurrencyManager.Position = _bindingSource.CurrencyManager.Count - 1;
|
||||
return product;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Quantity
|
||||
|
||||
public void SetQuantity(BillInventory product, decimal quantity, bool prompt)
|
||||
{
|
||||
if (product.Printed)
|
||||
return;
|
||||
if (prompt && !GetInput("Price", ref quantity))
|
||||
return;
|
||||
|
||||
if (!prompt)
|
||||
quantity += product.Quantity;
|
||||
SetQuantity(product, quantity);
|
||||
}
|
||||
|
||||
private void SetQuantity(BillInventory product, decimal quantity)
|
||||
{
|
||||
if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
|
||||
return;
|
||||
var total = quantity + bill.Where(item => item.Value.ProductID == _newKey.ProductID).Sum(item => item.Value.Quantity);
|
||||
|
||||
if (total < 0)
|
||||
quantity -= total;
|
||||
product.Quantity = quantity;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
partial class frmMoveTable
|
||||
partial class MoveTableForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -40,7 +40,7 @@
|
||||
this.flpTables.Size = new System.Drawing.Size(847, 492);
|
||||
this.flpTables.TabIndex = 7;
|
||||
//
|
||||
// frmMoveTable
|
||||
// MoveTableForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
@ -48,10 +48,10 @@
|
||||
this.Controls.Add(this.flpTables);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "frmMoveTable";
|
||||
this.Name = "MoveTableForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Move Table / Kot";
|
||||
this.Load += new System.EventHandler(this.frmMoveTable_Load);
|
||||
this.Load += new System.EventHandler(this.MoveTableForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -59,7 +59,5 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.FlowLayoutPanel flpTables;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,66 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using Tanshu.Accounts.SqlDAO;
|
||||
using Tanshu.Accounts.Helpers;
|
||||
using Tanshu.Common.KeyboardControl;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
public partial class frmMoveTable : Form
|
||||
public partial class MoveTableForm : Form
|
||||
{
|
||||
private IList<FoodTable> source;
|
||||
private FoodTable selection;
|
||||
private bool allowMerge;
|
||||
public frmMoveTable(IList<FoodTable> source, bool allowMerge)
|
||||
private readonly IList<FoodTable> _source;
|
||||
private readonly bool _allowMerge;
|
||||
public MoveTableForm(IList<FoodTable> source, bool allowMerge)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.source = source;
|
||||
selection = null;
|
||||
this.allowMerge = allowMerge;
|
||||
}
|
||||
public FoodTable Selection
|
||||
{
|
||||
get
|
||||
{
|
||||
return selection;
|
||||
}
|
||||
|
||||
_source = source;
|
||||
Selection = null;
|
||||
_allowMerge = allowMerge;
|
||||
}
|
||||
|
||||
private void frmMoveTable_Load(object sender, EventArgs e)
|
||||
public FoodTable Selection { get; private set; }
|
||||
|
||||
private void MoveTableForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, source, new ButtonClickDelegate(tableButton_Click));
|
||||
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, _source, new ButtonClickDelegate(tableButton_Click));
|
||||
}
|
||||
private void tableButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Button button = sender as Button;
|
||||
var button = sender as Button;
|
||||
if (button == null)
|
||||
return;
|
||||
var item = button.Tag as FoodTable;
|
||||
if (item.Name == "Previous" || item.Name == "Next")
|
||||
{
|
||||
int start = item.FoodTableID;
|
||||
var start = item.FoodTableID;
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, source, new ButtonClickDelegate(tableButton_Click));
|
||||
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _source, new ButtonClickDelegate(tableButton_Click));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Status != null && item.Status != string.Empty && !allowMerge)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Status) && !_allowMerge)
|
||||
MessageBox.Show("Cannot move to a running table", "Cannot Move", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else if (MessageBox.Show(string.Format("Move selected table to table {0}", item.Name), "Move", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
selection = item;
|
||||
Selection = item;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
119
Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs
generated
119
Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs
generated
@ -1,4 +1,7 @@
|
||||
namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
using System.Collections.Generic;
|
||||
using Tanshu.Accounts.Entities;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
{
|
||||
partial class SalesForm
|
||||
{
|
||||
@ -29,8 +32,8 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.txtDiscount = new System.Windows.Forms.TextBox();
|
||||
this.Label12 = new System.Windows.Forms.Label();
|
||||
@ -41,6 +44,8 @@
|
||||
this.txtGrossTax = new System.Windows.Forms.TextBox();
|
||||
this.dgvProducts = new System.Windows.Forms.DataGridView();
|
||||
this.Display = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.pnlBilling = new System.Windows.Forms.Panel();
|
||||
this.flpMain = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.flpGroup = new System.Windows.Forms.FlowLayoutPanel();
|
||||
@ -51,12 +56,14 @@
|
||||
this.btnDiscount = new System.Windows.Forms.Button();
|
||||
this.btnModifier = new System.Windows.Forms.Button();
|
||||
this.btnWaiter = new System.Windows.Forms.Button();
|
||||
this.btnMoveTable = new System.Windows.Forms.Button();
|
||||
this.btnPrintKot = new System.Windows.Forms.Button();
|
||||
this.btnMoveTable = new System.Windows.Forms.Button();
|
||||
this.btnPrintBill = new System.Windows.Forms.Button();
|
||||
this.btnClear = new System.Windows.Forms.Button();
|
||||
this.btnVoid = new System.Windows.Forms.Button();
|
||||
this.btnSettle = new System.Windows.Forms.Button();
|
||||
this.btnMore = new System.Windows.Forms.Button();
|
||||
this.btnMoveKot = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.txtServiceCharge = new System.Windows.Forms.TextBox();
|
||||
this.txtTableID = new System.Windows.Forms.TextBox();
|
||||
@ -72,16 +79,12 @@
|
||||
this.txtBillID = new System.Windows.Forms.TextBox();
|
||||
this.txtKotID = new System.Windows.Forms.TextBox();
|
||||
this.btnCustomer = new System.Windows.Forms.Button();
|
||||
this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.btnMore = new System.Windows.Forms.Button();
|
||||
this.btnMoveKot = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
|
||||
this.pnlBilling.SuspendLayout();
|
||||
this.flpActions.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bsPending)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -208,14 +211,30 @@
|
||||
//
|
||||
this.Display.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||
this.Display.DataPropertyName = "Display";
|
||||
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.Display.DefaultCellStyle = dataGridViewCellStyle3;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.Display.DefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.Display.HeaderText = "Display";
|
||||
this.Display.MinimumWidth = 250;
|
||||
this.Display.Name = "Display";
|
||||
this.Display.ReadOnly = true;
|
||||
this.Display.Width = 250;
|
||||
//
|
||||
// printedDataGridViewTextBoxColumn
|
||||
//
|
||||
this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||
this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
|
||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
|
||||
dataGridViewCellStyle2.Format = "N2";
|
||||
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.printedDataGridViewTextBoxColumn.HeaderText = "Printed";
|
||||
this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn";
|
||||
this.printedDataGridViewTextBoxColumn.ReadOnly = true;
|
||||
this.printedDataGridViewTextBoxColumn.Width = 65;
|
||||
//
|
||||
// bindingSource
|
||||
//
|
||||
this.bindingSource.DataSource = typeof(Tanshu.Accounts.Contracts.BillItemValue);
|
||||
//
|
||||
// pnlBilling
|
||||
//
|
||||
this.pnlBilling.AutoSize = true;
|
||||
@ -353,16 +372,6 @@
|
||||
this.btnWaiter.UseVisualStyleBackColor = true;
|
||||
this.btnWaiter.Click += new System.EventHandler(this.btnWaiter_Click);
|
||||
//
|
||||
// btnMoveTable
|
||||
//
|
||||
this.btnMoveTable.Location = new System.Drawing.Point(570, 3);
|
||||
this.btnMoveTable.Name = "btnMoveTable";
|
||||
this.btnMoveTable.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnMoveTable.TabIndex = 158;
|
||||
this.btnMoveTable.Text = "Move Table";
|
||||
this.btnMoveTable.UseVisualStyleBackColor = true;
|
||||
this.btnMoveTable.Click += new System.EventHandler(this.btnMoveTable_Click);
|
||||
//
|
||||
// btnPrintKot
|
||||
//
|
||||
this.btnPrintKot.Location = new System.Drawing.Point(489, 3);
|
||||
@ -373,6 +382,16 @@
|
||||
this.btnPrintKot.UseVisualStyleBackColor = true;
|
||||
this.btnPrintKot.Click += new System.EventHandler(this.btnPrintKot_Click);
|
||||
//
|
||||
// btnMoveTable
|
||||
//
|
||||
this.btnMoveTable.Location = new System.Drawing.Point(570, 3);
|
||||
this.btnMoveTable.Name = "btnMoveTable";
|
||||
this.btnMoveTable.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnMoveTable.TabIndex = 158;
|
||||
this.btnMoveTable.Text = "Move Table";
|
||||
this.btnMoveTable.UseVisualStyleBackColor = true;
|
||||
this.btnMoveTable.Click += new System.EventHandler(this.btnMoveTable_Click);
|
||||
//
|
||||
// btnPrintBill
|
||||
//
|
||||
this.btnPrintBill.Location = new System.Drawing.Point(651, 3);
|
||||
@ -413,6 +432,26 @@
|
||||
this.btnSettle.UseVisualStyleBackColor = true;
|
||||
this.btnSettle.Click += new System.EventHandler(this.btnSettle_Click);
|
||||
//
|
||||
// btnMore
|
||||
//
|
||||
this.btnMore.Location = new System.Drawing.Point(3, 84);
|
||||
this.btnMore.Name = "btnMore";
|
||||
this.btnMore.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnMore.TabIndex = 159;
|
||||
this.btnMore.Text = "More";
|
||||
this.btnMore.UseVisualStyleBackColor = true;
|
||||
this.btnMore.Click += new System.EventHandler(this.btnMore_Click);
|
||||
//
|
||||
// btnMoveKot
|
||||
//
|
||||
this.btnMoveKot.Location = new System.Drawing.Point(84, 84);
|
||||
this.btnMoveKot.Name = "btnMoveKot";
|
||||
this.btnMoveKot.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnMoveKot.TabIndex = 160;
|
||||
this.btnMoveKot.Text = "Move Kot";
|
||||
this.btnMoveKot.UseVisualStyleBackColor = true;
|
||||
this.btnMoveKot.Click += new System.EventHandler(this.btnMoveKot_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
@ -547,22 +586,6 @@
|
||||
this.btnCustomer.UseVisualStyleBackColor = true;
|
||||
this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click);
|
||||
//
|
||||
// printedDataGridViewTextBoxColumn
|
||||
//
|
||||
this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||
this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
|
||||
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
|
||||
dataGridViewCellStyle4.Format = "N2";
|
||||
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4;
|
||||
this.printedDataGridViewTextBoxColumn.HeaderText = "Printed";
|
||||
this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn";
|
||||
this.printedDataGridViewTextBoxColumn.ReadOnly = true;
|
||||
this.printedDataGridViewTextBoxColumn.Width = 65;
|
||||
//
|
||||
// bindingSource
|
||||
//
|
||||
this.bindingSource.DataSource = typeof(Tanshu.Accounts.Contracts.BillInventory);
|
||||
//
|
||||
// bsWaiter
|
||||
//
|
||||
this.bsWaiter.DataSource = typeof(Tanshu.Accounts.Entities.Waiter);
|
||||
@ -571,26 +594,6 @@
|
||||
//
|
||||
this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBills);
|
||||
//
|
||||
// btnMore
|
||||
//
|
||||
this.btnMore.Location = new System.Drawing.Point(3, 84);
|
||||
this.btnMore.Name = "btnMore";
|
||||
this.btnMore.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnMore.TabIndex = 159;
|
||||
this.btnMore.Text = "More";
|
||||
this.btnMore.UseVisualStyleBackColor = true;
|
||||
this.btnMore.Click += new System.EventHandler(this.btnMore_Click);
|
||||
//
|
||||
// btnMoveKot
|
||||
//
|
||||
this.btnMoveKot.Location = new System.Drawing.Point(84, 84);
|
||||
this.btnMoveKot.Name = "btnMoveKot";
|
||||
this.btnMoveKot.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnMoveKot.TabIndex = 160;
|
||||
this.btnMoveKot.Text = "Move Kot";
|
||||
this.btnMoveKot.UseVisualStyleBackColor = true;
|
||||
this.btnMoveKot.Click += new System.EventHandler(this.btnMoveKot_Click);
|
||||
//
|
||||
// SalesForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -606,10 +609,10 @@
|
||||
this.Load += new System.EventHandler(this.SalesForm_Load);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SalesForm_KeyDown);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
|
||||
this.pnlBilling.ResumeLayout(false);
|
||||
this.pnlBilling.PerformLayout();
|
||||
this.flpActions.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bsPending)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@ -13,11 +13,21 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
{
|
||||
public partial class SalesForm : Form, ISaleForm
|
||||
{
|
||||
private readonly IDictionary<int, IList<Product>> productDictionary;
|
||||
private readonly IList<ProductGroup> _productGroupList;
|
||||
private ProductGroup _currentProductGroup;
|
||||
public SalesForm(BillController billController)
|
||||
{
|
||||
InitializeComponent();
|
||||
productDictionary = new Dictionary<int, IList<Product>>();
|
||||
|
||||
this._billController = billController;
|
||||
billController.InitGui(this);
|
||||
using (var bi = new ProductGroupBI())
|
||||
_productGroupList = bi.List();
|
||||
using (var bi = new ProductBI())
|
||||
foreach (var item in _productGroupList)
|
||||
productDictionary.Add(item.ProductGroupID, bi.List(x => x.ProductGroup.ProductGroupID == item.ProductGroupID));
|
||||
}
|
||||
|
||||
#region ISaleForm Members
|
||||
@ -85,12 +95,12 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
}
|
||||
case Keys.F7:
|
||||
{
|
||||
using (var selectProduct = new SelectProduct(ProductBI.GetFilteredProducts, true))
|
||||
{
|
||||
selectProduct.ShowDialog();
|
||||
if (selectProduct.SelectedItem != null)
|
||||
_billController.AddProductToGrid(selectProduct.SelectedItem.ProductID);
|
||||
}
|
||||
//using (var selectProduct = new SelectProduct(ProductBI.GetFilteredProducts, true))
|
||||
//{
|
||||
// selectProduct.ShowDialog();
|
||||
// if (selectProduct.SelectedItem != null)
|
||||
// _billController.AddProductToGrid(selectProduct.SelectedItem.ProductID);
|
||||
//}
|
||||
break;
|
||||
}
|
||||
case Keys.F8:
|
||||
@ -179,7 +189,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
||||
{
|
||||
var dgv = sender as DataGridView;
|
||||
var data = dgv.Rows[e.RowIndex].DataBoundItem as BillInventory;
|
||||
var data = dgv.Rows[e.RowIndex].DataBoundItem as BillItemValue;
|
||||
|
||||
if (data.Tax == -1)
|
||||
{
|
||||
@ -248,10 +258,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
|
||||
private void btnModifier_Click(object sender, EventArgs e)
|
||||
{
|
||||
BillInventory item = _billController.CurrentProduct;
|
||||
var item = _billController.CurrentProduct;
|
||||
if (item == null)
|
||||
return;
|
||||
int id = new ProductGroupBI().GetProductGroupOfProduct(item.ProductID).ProductGroupID;
|
||||
|
||||
int id;
|
||||
using (var bi = new ProductGroupBI())
|
||||
id = bi.GetProductGroupOfProduct(item.ProductID).ProductGroupID;
|
||||
_billController.ShowModifiers(id, item);
|
||||
}
|
||||
|
||||
@ -296,7 +309,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
|
||||
#region Helper Functions
|
||||
|
||||
public void ClearBill(OrderedDictionary<BillItemKey, BillInventory> bill)
|
||||
public void ClearBill(OrderedDictionary<BillItemKey, BillItemValue> bill)
|
||||
{
|
||||
txtBillID.Text = "";
|
||||
txtKotID.Text = "";
|
||||
@ -317,7 +330,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
}
|
||||
|
||||
public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount,
|
||||
decimal taxAmount, decimal valueAmount, List<BillInventory> bill)
|
||||
decimal taxAmount, decimal valueAmount, List<BillItemValue> bill)
|
||||
{
|
||||
txtGrossTax.Text = string.Format("{0:#0.00}", taxAmount);
|
||||
txtDiscount.Text = string.Format("{0:#0.00}", discountAmount);
|
||||
@ -333,15 +346,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
flpGroup.Controls.Clear();
|
||||
flpMain.Controls.Clear();
|
||||
if (state == SaleFormState.Billing)
|
||||
{
|
||||
IList<ProductGroup> list = new ProductGroupBI().GetProductGroups();
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, list, productTypeButton_Click);
|
||||
}
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, _productGroupList, productTypeButton_Click);
|
||||
else
|
||||
{
|
||||
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, new FoodTableBI().List(),
|
||||
tableButton_Click);
|
||||
}
|
||||
using (var bi = new FoodTableBI())
|
||||
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(), tableButton_Click);
|
||||
}
|
||||
|
||||
private void productTypeButton_Click(object sender, EventArgs e)
|
||||
@ -355,13 +363,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
int start = item.ProductGroupID;
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
IList<ProductGroup> list = new ProductGroupBI().GetProductGroups();
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, list, productTypeButton_Click);
|
||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, _productGroupList, productTypeButton_Click);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentProductGroup = item;
|
||||
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), 0,
|
||||
ProductBI.GetProducts(item.ProductGroupID), productButton_Click);
|
||||
productDictionary[item.ProductGroupID], productButton_Click);
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,12 +384,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
int start = item.ProductID;
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
IList<Product> list = ProductBI.GetProducts();
|
||||
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), start, list, productButton_Click);
|
||||
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), start, productDictionary[_currentProductGroup.ProductGroupID], productButton_Click);
|
||||
}
|
||||
else
|
||||
{
|
||||
_billController.AddProductToGrid(item.ProductID);
|
||||
_billController.AddProductToGrid(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -393,11 +400,12 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
var item = button.Tag as FoodTable;
|
||||
if (item.Name == "Previous" || item.Name == "Next")
|
||||
{
|
||||
int start = item.FoodTableID;
|
||||
var start = item.FoodTableID;
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
IList<FoodTable> list = new FoodTableBI().List();
|
||||
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, list, tableButton_Click);
|
||||
|
||||
using (var bi = new FoodTableBI())
|
||||
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, bi.List(), tableButton_Click);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -412,14 +420,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||
{
|
||||
if (btnWaiter.Tag == null)
|
||||
btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
|
||||
_billController.Save(true, (int) btnWaiter.Tag, txtTableID.Text);
|
||||
_billController.SaveBill((int)btnWaiter.Tag, txtTableID.Text);
|
||||
|
||||
}
|
||||
|
||||
private void btnPrintKot_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (btnWaiter.Tag == null)
|
||||
btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
|
||||
_billController.Save(false, (int) btnWaiter.Tag, txtTableID.Text);
|
||||
_billController.SaveKot((int)btnWaiter.Tag, txtTableID.Text);
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
|
||||
@ -123,12 +123,6 @@
|
||||
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="Display.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="bsWaiter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>148, 17</value>
|
||||
</metadata>
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using System.Linq;
|
||||
using Tanshu.Common.Helpers;
|
||||
using Tanshu.Common.KeyboardControl;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
@ -14,12 +14,10 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private readonly IDictionary<Button, int> _list;
|
||||
private decimal _amount;
|
||||
|
||||
public SettleChoicesForm(Voucher voucher)
|
||||
public SettleChoicesForm(decimal amount)
|
||||
{
|
||||
InitializeComponent();
|
||||
_amount = voucher.Settlements.Single(x => x.Settled == SettleOption.Amount).Amount +
|
||||
voucher.Settlements.Single(x => x.Settled == SettleOption.RoundOff).Amount;
|
||||
_amount *= -1;
|
||||
_amount = amount;
|
||||
OptionsChosen = new Dictionary<SettleOption, decimal>();
|
||||
_list = new Dictionary<Button, int>();
|
||||
}
|
||||
@ -83,7 +81,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
var count = 0;
|
||||
foreach (SettleOption item in Enum.GetValues(typeof(SettleOption)))
|
||||
{
|
||||
var attribute = (DisplayAttribute)item.GetType().GetField(item.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0];
|
||||
var attribute = item.Attribute();
|
||||
if (!attribute.ShowInChoices)
|
||||
continue;
|
||||
var button = new Button
|
||||
|
||||
Reference in New Issue
Block a user