narsil/Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.cs
tanshu 3d3c21b853 Fix: Sale Detail Report would not show the proper NC as it did not check of the product was Happy Hour and at times would overwrite the wrong value
Feature: Modifier form now resizes the buttons so that if there are more modifiers than can fit on the screen, the button size will reduce to a degree
Feature: The Final Sanction is also a background worker and reports progress.
2016-12-03 12:08:47 +05:30

82 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
public partial class SaleDetailForm : Form
{
IList<SalesAnalysisDetail> _list;
public SaleDetailForm()
{
InitializeComponent();
dgvSale.AutoGenerateColumns = false;
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void ShowStatement()
{
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit"))
return;
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 && x.IsHappyHour == item.IsHappyHour);
if (old != null)
old.NC = item.NC;
else
_list.Add(new SalesAnalysisDetail() { Name = item.Name, ProductID = item.ProductID, NC = item.NC });
}
dgvSale.DataSource = _list;
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void SaleDetailForm_Load(object sender, EventArgs e)
{
dtpStart.Value = DateTime.Today;
dtpFinish.Value = DateTime.Today;
ShowStatement();
}
private void btnPrint_Click(object sender, EventArgs e)
{
if (_list == null)
return;
var startDate = dtpStart.Value.Date.AddHours(6);
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5);
Print.Thermal.PrintSale(Session.User.Name, _list, startDate, finishDate);
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnExport_Click(object sender, EventArgs e)
{
if (_list == null)
return;
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.ProductID, item.Name, item.Sale, item.NC);
}
Clipboard.SetText(data, TextDataFormat.Text);
}
}
}