102 lines
3.1 KiB
C#
102 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using Tanshu.Accounts.Repository;
|
|
using Tanshu.Accounts.Contracts;
|
|
using System.Data;
|
|
using System.Collections.Specialized;
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
{
|
|
public partial class BeerConsumptionForm : Form
|
|
{
|
|
IList<BeerConsumptionDetail> _list;
|
|
public BeerConsumptionForm()
|
|
{
|
|
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;
|
|
_list = ReportsBI.BeerConsumption(dtpStart.Value, dtpFinish.Value);
|
|
dgvSale.DataSource = _list;
|
|
}
|
|
|
|
private void dtpFinish_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
ShowStatement();
|
|
}
|
|
|
|
private void BeerConsumptionForm_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 btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void btnExport_Click(object sender, EventArgs e)
|
|
{
|
|
var q = new decimal[_list.Select(x => x.Date.ToString("dd-MMM-yyyy")).Distinct().Count(), _list.Select(x => x.Name).Distinct().Count()];
|
|
var dates = new List<string>();
|
|
var names = new List<string>();
|
|
string data;
|
|
foreach (var item in _list)
|
|
{
|
|
var date = item.Date.ToString("dd-MMM-yyyy");
|
|
if (!dates.Contains(date))
|
|
{
|
|
dates.Add(date);
|
|
}
|
|
if (!names.Contains(item.Name))
|
|
{
|
|
names.Add(item.Name);
|
|
}
|
|
q[dates.IndexOf(date), names.IndexOf(item.Name)] += item.Quantity;
|
|
}
|
|
|
|
if (_list == null)
|
|
return;
|
|
data = "Date";
|
|
foreach (var item in names)
|
|
{
|
|
data += string.Format("\t{0}", item);
|
|
}
|
|
data += "\n";
|
|
|
|
for (int i = 0; i < dates.Count; i++)
|
|
{
|
|
data += dates[i];
|
|
for (int j = 0; j < names.Count; j++)
|
|
{
|
|
data += string.Format("\t{0}", q[i, j]);
|
|
}
|
|
data += "\n";
|
|
}
|
|
Clipboard.SetText(data, TextDataFormat.Text);
|
|
}
|
|
}
|
|
}
|