Breaking Change: Changed Kot/Voucher Table Name to Guid Foreign key

Breaking Change: Renamed Discontinued to IsActive and added NA field to products.
Cleanup: Removed not used attributes
Change: RoleConstants changed to simple string
Feature: Table Create/Edit/Reorder and Modifier Create/Edit Form
Feature: Bills now show the Tax name from the database and not a hack
This commit is contained in:
tanshu
2014-10-16 16:41:55 +05:30
parent 69617949bd
commit da929ad036
76 changed files with 3472 additions and 1175 deletions

View File

@ -4,26 +4,26 @@ using System.Drawing;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Helpers;
using System.Diagnostics;
namespace Tanshu.Accounts.PointOfSale
{
public partial class MoveTableForm : Form
{
private readonly IList<FoodTable> _source;
private readonly IList<FoodTable> _tableList;
private readonly bool _allowMerge;
public MoveTableForm(IList<FoodTable> source, bool allowMerge)
public MoveTableForm(IList<FoodTable> tableList, bool allowMerge)
{
InitializeComponent();
_source = source;
_tableList = tableList;
Selection = null;
_allowMerge = allowMerge;
}
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), new ButtonClickDelegate(tablePage_Click));
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, _tableList, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click));
}
private void tableButton_Click(object sender, EventArgs e)
{
@ -47,7 +47,7 @@ namespace Tanshu.Accounts.PointOfSale
var start = (int)button.Tag;
if (start < 0)
start = 0;
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _source, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click));
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _tableList, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click));
}
}
}

View File

@ -0,0 +1,67 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class ReorderTableForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.flpTables = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// flpTables
//
this.flpTables.AllowDrop = true;
this.flpTables.AutoScroll = true;
this.flpTables.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flpTables.Dock = System.Windows.Forms.DockStyle.Fill;
this.flpTables.Location = new System.Drawing.Point(0, 0);
this.flpTables.Name = "flpTables";
this.flpTables.Size = new System.Drawing.Size(847, 492);
this.flpTables.TabIndex = 7;
this.flpTables.DragDrop += new System.Windows.Forms.DragEventHandler(this.flpTables_DragDrop);
this.flpTables.DragEnter += new System.Windows.Forms.DragEventHandler(this.flpTables_DragEnter);
//
// ReorderTableForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(847, 492);
this.Controls.Add(this.flpTables);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "ReorderTableForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Move Table / Kot";
this.Load += new System.EventHandler(this.MoveTableForm_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flpTables;
}
}

View File

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Helpers;
using System.Diagnostics;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class ReorderTableForm : Form
{
private readonly IList<FoodTable> _tableList;
public ReorderTableForm()
{
InitializeComponent();
using (var bi = new FoodTableBI())
{
_tableList = bi.List();
}
Selection = null;
}
private void button_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
var button = (Button)sender;
button.DoDragDrop(button, DragDropEffects.Move);
}
}
private void flpTables_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void flpTables_DragDrop(object sender, DragEventArgs e)
{
Button button = (Button)e.Data.GetData(typeof(Button));
Point p = flpTables.PointToClient(new Point(e.X, e.Y));
var item = flpTables.GetChildAtPoint(p);
int index = flpTables.Controls.GetChildIndex(item, false);
flpTables.Controls.SetChildIndex(button, index);
flpTables.Invalidate();
var foodTable = (FoodTable)button.Tag;
var listIndex = _tableList.IndexOf(foodTable);
var newIndex = _tableList.IndexOf((FoodTable)((Button)item).Tag);
_tableList.Remove(foodTable);
_tableList.Insert(index - 1, foodTable);
}
public FoodTable Selection { get; private set; }
private void MoveTableForm_Load(object sender, EventArgs e)
{
GenerateTables(new Point(75, 75));
}
private void tableButton_Click(object sender, EventArgs e)
{
var button = sender as Button;
if (button == null)
return;
var item = button.Tag as FoodTable;
Selection = item;
using (var frm = new TableForm(item.FoodTableID))
{
frm.ShowDialog();
}
}
private void GenerateTables(Point size)
{
var saveButton = new Button()
{
Name = "saveButton",
Text = "Save",
Width = size.X,
Height = size.Y,
};
saveButton.Click += saveButton_Click;
flpTables.Controls.Add(saveButton);
for (int i = 0; i < _tableList.Count; i++)
{
var item = _tableList[i];
var control = new Button()
{
Name = string.Format("g{0}", i),
Text = item.Name,
Width = size.X,
Height = size.Y,
Tag = item,
BackColor = item.IsActive ? Color.Green : Color.Red
};
control.MouseDown += button_MouseDown;
control.Click += tableButton_Click;
flpTables.Controls.Add(control);
}
var addButton = new Button()
{
Name = "addButton",
Text = "Add Table",
Width = size.X,
Height = size.Y,
};
addButton.Click += addButton_Click;
flpTables.Controls.Add(addButton);
}
private void addButton_Click(object sender, EventArgs e)
{
using (var frm = new TableForm())
{
frm.ShowDialog();
}
}
private void saveButton_Click(object sender, EventArgs e)
{
using (var bi = new FoodTableBI())
{
bi.UpdateSortOrder(_tableList);
bi.SaveChanges();
}
MessageBox.Show("Order Updated");
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -47,6 +47,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
this.pnlBilling = new System.Windows.Forms.Panel();
this.label10 = new System.Windows.Forms.Label();
this.txtPax = new System.Windows.Forms.TextBox();
this.flpMain = new System.Windows.Forms.FlowLayoutPanel();
this.flpGroup = new System.Windows.Forms.FlowLayoutPanel();
this.flpActions = new System.Windows.Forms.FlowLayoutPanel();
@ -81,15 +83,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.txtKotID = new System.Windows.Forms.TextBox();
this.btnCustomer = new System.Windows.Forms.Button();
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
this.label10 = new System.Windows.Forms.Label();
this.txtPax = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
this.pnlBilling.SuspendLayout();
this.flpActions.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsPending)).BeginInit();
this.SuspendLayout();
//
// label7
@ -276,6 +274,23 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.pnlBilling.Size = new System.Drawing.Size(982, 688);
this.pnlBilling.TabIndex = 121;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(804, 12);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(25, 13);
this.label10.TabIndex = 161;
this.label10.Text = "Pax";
//
// txtPax
//
this.txtPax.Location = new System.Drawing.Point(807, 28);
this.txtPax.Name = "txtPax";
this.txtPax.ReadOnly = true;
this.txtPax.Size = new System.Drawing.Size(88, 20);
this.txtPax.TabIndex = 160;
//
// flpMain
//
this.flpMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -605,27 +620,6 @@ namespace Tanshu.Accounts.PointOfSale.Sales
//
this.bsWaiter.DataSource = typeof(Tanshu.Accounts.Entities.Waiter);
//
// bsPending
//
this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBills);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(804, 12);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(25, 13);
this.label10.TabIndex = 161;
this.label10.Text = "Pax";
//
// txtPax
//
this.txtPax.Location = new System.Drawing.Point(807, 28);
this.txtPax.Name = "txtPax";
this.txtPax.ReadOnly = true;
this.txtPax.Size = new System.Drawing.Size(88, 20);
this.txtPax.TabIndex = 160;
//
// SalesForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -646,7 +640,6 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.pnlBilling.PerformLayout();
this.flpActions.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsPending)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -656,7 +649,6 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private System.Windows.Forms.BindingSource bindingSource;
private System.Windows.Forms.BindingSource bsWaiter;
private System.Windows.Forms.BindingSource bsPending;
internal System.Windows.Forms.Label label7;
internal System.Windows.Forms.TextBox txtDiscount;
internal System.Windows.Forms.Label Label12;

View File

@ -23,10 +23,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this._billController = billController;
billController.InitGui(this);
using (var bi = new ProductGroupBI())
_productGroupList = bi.List(x => x.Discontinued == false);
_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.Discontinued == false));
_productDictionary.Add(item.ProductGroupID, bi.List(x => x.ProductGroup.ProductGroupID == item.ProductGroupID && x.IsActive));
}
#region ISaleForm Members
@ -50,7 +50,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
{
if (voucher.VoucherID == Guid.Empty)
{
txtTableID.Text = voucher.TableID;
txtTableID.Text = voucher.Table.Name;
txtPax.Text = voucher.Pax.ToString();
}
else
@ -61,7 +61,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
txtDate.Text = voucher.Date.Value.ToString("HH:mm dd-MMM-yyyy");
txtLastEditDate.Text = voucher.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
btnCustomer.Text = voucher.Customer.Name;
txtTableID.Text = voucher.TableID;
txtTableID.Text = voucher.Table.Name;
txtPax.Text = voucher.Pax.ToString();
btnWaiter.Text = string.Format("{0} - F5", voucher.Waiter.Name);
}
@ -337,11 +337,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, _productGroupList, productTypeButton_Click, productTypePage_Click);
else
using (var bi = new FoodTableBI())
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(), tableButton_Click, tablePage_Click);
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(x => x.IsActive), tableButton_Click, tablePage_Click);
}
}
private void productTypeButton_Click(object sender, EventArgs e)
{
var button = sender as Button;
@ -372,6 +371,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (button == null)
return;
var item = button.Tag as Product;
if (item.IsNotAvailable)
return;
_billController.AddProduct(item);
}
@ -407,7 +408,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (start < 0)
start = 0;
using (var bi = new FoodTableBI())
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, bi.List(), tableButton_Click, tablePage_Click);
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, bi.List(x => x.IsActive), tableButton_Click, tablePage_Click);
}
private void btnPrintBill_Click(object sender, EventArgs e)
{

View File

@ -126,9 +126,6 @@
<metadata name="bsWaiter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>148, 17</value>
</metadata>
<metadata name="bsPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>248, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>81</value>
</metadata>