Feature: Added a Tax Management form and a beer consumption report.
Chore: Fixed some Form_Load function names as they were copied from old forms and were not neat. Feature: Management BI Improved and should be pretty much solid by now.
This commit is contained in:
102
Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.cs
Normal file
102
Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.cs
Normal file
@ -0,0 +1,102 @@
|
||||
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;
|
||||
var bi = new ReportsBI();
|
||||
_list = bi.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user