2011-02-09 12:03:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-04-11 07:01:52 +00:00
|
|
|
|
using System.Linq;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Repository;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2016-07-04 06:21:39 +00:00
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Specialized;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
2016-07-04 06:21:39 +00:00
|
|
|
|
public partial class BeerConsumptionForm : Form
|
2011-02-09 12:03:22 +00:00
|
|
|
|
{
|
2016-07-04 06:21:39 +00:00
|
|
|
|
IList<BeerConsumptionDetail> _list;
|
|
|
|
|
public BeerConsumptionForm()
|
2011-02-09 12:03:22 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-04-11 07:01:52 +00:00
|
|
|
|
dgvSale.AutoGenerateColumns = false;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dtpStart_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowStatement()
|
|
|
|
|
{
|
2014-10-16 11:11:55 +00:00
|
|
|
|
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit"))
|
2011-12-05 09:41:02 +00:00
|
|
|
|
return;
|
2016-04-11 07:01:52 +00:00
|
|
|
|
var bi = new ReportsBI();
|
2016-07-04 06:21:39 +00:00
|
|
|
|
_list = bi.BeerConsumption(dtpStart.Value, dtpFinish.Value);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
dgvSale.DataSource = _list;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dtpFinish_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-04 06:21:39 +00:00
|
|
|
|
private void BeerConsumptionForm_Load(object sender, EventArgs e)
|
2011-02-09 12:03:22 +00:00
|
|
|
|
{
|
|
|
|
|
dtpStart.Value = DateTime.Today;
|
|
|
|
|
dtpFinish.Value = DateTime.Today;
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (_list == null)
|
|
|
|
|
return;
|
|
|
|
|
var startDate = dtpStart.Value.Date.AddHours(6);
|
|
|
|
|
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5);
|
2016-07-04 06:21:39 +00:00
|
|
|
|
//Print.Thermal.PrintSale(Session.User.Name, _list, startDate, finishDate);
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
|
2016-07-04 06:21:39 +00:00
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnExport_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-07-04 06:21:39 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
if (_list == null)
|
|
|
|
|
return;
|
2016-07-04 06:21:39 +00:00
|
|
|
|
data = "Date";
|
|
|
|
|
foreach (var item in names)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{
|
2016-07-04 06:21:39 +00:00
|
|
|
|
data += string.Format("\t{0}", item);
|
|
|
|
|
}
|
|
|
|
|
data += "\n";
|
2016-04-11 07:01:52 +00:00
|
|
|
|
|
2016-07-04 06:21:39 +00:00
|
|
|
|
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";
|
2011-06-23 12:47:48 +00:00
|
|
|
|
}
|
2011-12-05 09:41:02 +00:00
|
|
|
|
Clipboard.SetText(data, TextDataFormat.Text);
|
2011-06-23 12:47:48 +00:00
|
|
|
|
}
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|