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:
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
@ -12,6 +13,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
public FrmSaleDetail()
|
||||
{
|
||||
InitializeComponent();
|
||||
dgvSale.AutoGenerateColumns = false;
|
||||
}
|
||||
|
||||
private void dtpStart_ValueChanged(object sender, EventArgs e)
|
||||
@ -23,16 +25,18 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit"))
|
||||
return;
|
||||
_list = new ReportsBI().GetSaleDetail(dtpStart.Value, dtpFinish.Value);
|
||||
dgvSale.AutoGenerateColumns = true;
|
||||
var bi = new ReportsBI();
|
||||
_list = bi.SaleQuantity(dtpStart.Value, dtpFinish.Value);
|
||||
|
||||
foreach (var item in bi.NcQuantity(dtpStart.Value, dtpFinish.Value))
|
||||
{
|
||||
var old = _list.FirstOrDefault(x => x.ProductID == item.ProductID);
|
||||
if (old != null)
|
||||
old.NC = item.NC;
|
||||
else
|
||||
_list.Add(new SalesAnalysisDetail() { Name = item.Name, ProductID = item.ProductID, NC = item.NC });
|
||||
}
|
||||
dgvSale.DataSource = _list;
|
||||
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
||||
dgvSale.Columns[1].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
||||
dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
||||
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
||||
dgvSale.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
||||
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
||||
dgvSale.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
||||
}
|
||||
|
||||
private void dtpFinish_ValueChanged(object sender, EventArgs e)
|
||||
@ -65,10 +69,11 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
if (_list == null)
|
||||
return;
|
||||
var data = string.Format("{0}\t{1}\t{2}\t{3}\n", "Product", "Sale", "NC", "Staff");
|
||||
var data = string.Format("{0}\t{1}\t{2}\t{3}\n", "ProductID", "Product", "Sale", "NC");
|
||||
foreach (var item in _list)
|
||||
{
|
||||
data += string.Format("{0}\t{1}\t{2}\t{3}\n", item.Product, item.Sale, item.NC, item.Staff);
|
||||
|
||||
data += string.Format("{0}\t{1}\t{2}\t{3}\n", item.ProductID, item.Name, item.Sale, item.NC);
|
||||
}
|
||||
Clipboard.SetText(data, TextDataFormat.Text);
|
||||
}
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.dgvSale = new System.Windows.Forms.DataGridView();
|
||||
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
|
||||
this.dtpStart = new System.Windows.Forms.DateTimePicker();
|
||||
@ -35,6 +37,9 @@
|
||||
this.btnPrint = new System.Windows.Forms.Button();
|
||||
this.btnExport = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Sale = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.NC = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -46,7 +51,12 @@
|
||||
this.dgvSale.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.dgvSale.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
|
||||
this.dgvSale.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvSale.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.NameColumn,
|
||||
this.Sale,
|
||||
this.NC});
|
||||
this.dgvSale.Location = new System.Drawing.Point(12, 41);
|
||||
this.dgvSale.MultiSelect = false;
|
||||
this.dgvSale.Name = "dgvSale";
|
||||
@ -120,6 +130,34 @@
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// NameColumn
|
||||
//
|
||||
this.NameColumn.DataPropertyName = "Name";
|
||||
this.NameColumn.HeaderText = "Name";
|
||||
this.NameColumn.Name = "NameColumn";
|
||||
this.NameColumn.ReadOnly = true;
|
||||
this.NameColumn.Width = 60;
|
||||
//
|
||||
// Sale
|
||||
//
|
||||
this.Sale.DataPropertyName = "Sale";
|
||||
dataGridViewCellStyle1.Format = "#,##0.00;(#,##0.00);0";
|
||||
this.Sale.DefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.Sale.HeaderText = "Sale";
|
||||
this.Sale.Name = "Sale";
|
||||
this.Sale.ReadOnly = true;
|
||||
this.Sale.Width = 53;
|
||||
//
|
||||
// NC
|
||||
//
|
||||
this.NC.DataPropertyName = "NC";
|
||||
dataGridViewCellStyle2.Format = "#,##0.00;(#,##0.00);0";
|
||||
this.NC.DefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.NC.HeaderText = "NC";
|
||||
this.NC.Name = "NC";
|
||||
this.NC.ReadOnly = true;
|
||||
this.NC.Width = 47;
|
||||
//
|
||||
// FrmSaleDetail
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -152,5 +190,8 @@
|
||||
private System.Windows.Forms.Button btnPrint;
|
||||
private System.Windows.Forms.Button btnExport;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Sale;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn NC;
|
||||
}
|
||||
}
|
||||
@ -117,4 +117,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="NameColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Sale.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="NC.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user