Refactor: Instead of a concept of Price/FullPrice, happy hour is now a checkbox in the product.

This needed major refactor in all parts dealing with product or inventory.
This commit is contained in:
tanshu
2016-04-11 12:31:52 +05:30
parent 69cb7d8bce
commit 20eac3c216
35 changed files with 861 additions and 435 deletions

View File

@ -30,6 +30,7 @@
{
this.flpModifier = new System.Windows.Forms.FlowLayoutPanel();
this.btnClose = new System.Windows.Forms.Button();
this.flpModifier.SuspendLayout();
this.SuspendLayout();
//
// flpModifier
@ -61,11 +62,13 @@
this.ControlBox = false;
this.Controls.Add(this.btnClose);
this.Controls.Add(this.flpModifier);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.Name = "ModifierForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Modifier";
this.Load += new System.EventHandler(this.ModifierForm_Load);
this.flpModifier.ResumeLayout(false);
this.ResumeLayout(false);
}

View File

@ -28,11 +28,14 @@ namespace Tanshu.Accounts.PointOfSale
private void button_Click(object sender, EventArgs e)
{
CheckBox button = sender as CheckBox;
if (button == null)
return;
if (button.CheckState == CheckState.Checked)
selection.Add(new InventoryModifier() { Modifier = (Modifier)button.Tag });
else
selection.Remove(selection.First(x => x.Modifier.ModifierID == ((Modifier)button.Tag).ModifierID));
}
private void ModifierForm_Load(object sender, EventArgs e)
{
var size = new Point(75, 75);
@ -70,6 +73,5 @@ namespace Tanshu.Accounts.PointOfSale
{
this.Close();
}
}
}

View File

@ -218,7 +218,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
//
// quantityColumn
//
this.quantityColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
this.quantityColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
this.quantityColumn.DataPropertyName = "Quantity";
dgvCellStyleQuantity.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dgvCellStyleQuantity.Format = "N2";
@ -344,7 +344,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.btnPrice.Name = "btnPrice";
this.btnPrice.Size = new System.Drawing.Size(75, 75);
this.btnPrice.TabIndex = 146;
this.btnPrice.Text = "btnPrice";
this.btnPrice.Text = "Price";
this.btnPrice.UseVisualStyleBackColor = true;
this.btnPrice.Click += new System.EventHandler(this.btnPrice_Click);
//

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@ -355,7 +356,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
return;
_controller.AddProduct(item);
bindingSource.DataSource = _controller._bill.ToList();
bindingSource.CurrencyManager.Position = _controller._bill.IndexOfKey(new BillItemKey(item.ProductID, Guid.Empty));
bindingSource.CurrencyManager.Position = _controller._bill.IndexOfKey(new BillItemKey(item.ProductID, Guid.Empty, item.HasHappyHour));
var showModifier = false;
using (var bi = new ProductGroupModifierBI())

View File

@ -123,6 +123,12 @@
<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="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>81</value>
</metadata>

View File

@ -0,0 +1,119 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class VoidReasonListForm
{
/// <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.components = new System.ComponentModel.Container();
this.btnExit = new System.Windows.Forms.Button();
this.dgvVoidReasons = new System.Windows.Forms.DataGridView();
this.bsList = new System.Windows.Forms.BindingSource(this.components);
this.info = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dgvVoidReasons)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit();
this.SuspendLayout();
//
// btnExit
//
this.btnExit.AccessibleName = "Done";
this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnExit.Location = new System.Drawing.Point(575, 255);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(75, 75);
this.btnExit.TabIndex = 61;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// dgvVoidReasons
//
this.dgvVoidReasons.AllowUserToAddRows = false;
this.dgvVoidReasons.AllowUserToDeleteRows = false;
this.dgvVoidReasons.AllowUserToResizeRows = false;
this.dgvVoidReasons.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvVoidReasons.AutoGenerateColumns = false;
this.dgvVoidReasons.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dgvVoidReasons.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvVoidReasons.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.info});
this.dgvVoidReasons.DataSource = this.bsList;
this.dgvVoidReasons.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.dgvVoidReasons.Location = new System.Drawing.Point(12, 12);
this.dgvVoidReasons.MultiSelect = false;
this.dgvVoidReasons.Name = "dgvVoidReasons";
this.dgvVoidReasons.ReadOnly = true;
this.dgvVoidReasons.RowHeadersVisible = false;
this.dgvVoidReasons.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.dgvVoidReasons.RowTemplate.Height = 24;
this.dgvVoidReasons.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvVoidReasons.Size = new System.Drawing.Size(638, 237);
this.dgvVoidReasons.TabIndex = 74;
this.dgvVoidReasons.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvVoidReasons_CellDoubleClick);
this.dgvVoidReasons.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvVoidReasons_CellFormatting);
//
// bsList
//
this.bsList.DataSource = typeof(string);
//
// info
//
this.info.HeaderText = "Info";
this.info.Name = "info";
this.info.ReadOnly = true;
this.info.Width = 50;
//
// VoidReasonListForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(662, 342);
this.Controls.Add(this.dgvVoidReasons);
this.Controls.Add(this.btnExit);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "VoidReasonListForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Customers";
this.Load += new System.EventHandler(this.VoidReasonListForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvVoidReasons)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit();
this.ResumeLayout(false);
}
#endregion
internal System.Windows.Forms.Button btnExit;
private System.Windows.Forms.DataGridView dgvVoidReasons;
private System.Windows.Forms.BindingSource bsList;
private System.Windows.Forms.DataGridViewTextBoxColumn Password;
private System.Windows.Forms.DataGridViewTextBoxColumn CustomerGroups;
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn info;
}
}

View File

@ -0,0 +1,60 @@
using System;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Repository;
using System.Collections.Generic;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
public partial class VoidReasonListForm : Form
{
private string[] _list;
public VoidReasonListForm(string[] list)
{
_list = list;
InitializeComponent();
}
private void VoidReasonListForm_Load(object sender, EventArgs e)
{
bsList.DataSource = _list;
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
public string SelectedItem
{
get
{
if (bsList.Position >= 0)
{
var item = _list[bsList.Position];
if (item != null)
return item;
}
return null;
}
}
private void dgvVoidReasons_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
this.Close();
}
private void dgvVoidReasons_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
var data = dgvVoidReasons.Rows[e.RowIndex].DataBoundItem as string;
if (e.ColumnIndex == dgvVoidReasons.Columns["Info"].Index)
{
e.Value = data;
}
}
}
}

View File

@ -0,0 +1,126 @@
<?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>
<metadata name="info.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bsList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>