2011-02-09 12:03:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Repository;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
public partial class FrmSaleDetail : Form
|
2011-02-09 12:03:22 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
IList<SalesAnalysisDetail> _list;
|
|
|
|
|
public FrmSaleDetail()
|
2011-02-09 12:03:22 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
_list = new SalesAnalysisBI().GetSaleDetail(dtpStart.Value, dtpFinish.Value);
|
2011-02-09 12:03:22 +00:00
|
|
|
|
dgvSale.AutoGenerateColumns = true;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
dgvSale.DataSource = _list;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
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;
|
2011-12-05 09:41:02 +00:00
|
|
|
|
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
|
|
|
|
dgvSale.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dtpFinish_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnExport_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_list == null)
|
|
|
|
|
return;
|
2011-12-05 09:41:02 +00:00
|
|
|
|
var data = string.Format("{0}\t{1}\t{2}\t{3}\n", "Product", "Sale", "NC", "Staff");
|
2011-06-23 12:47:48 +00:00
|
|
|
|
foreach (var item in _list)
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
data += string.Format("{0}\t{1}\t{2}\t{3}\n", item.Product, item.Sale, item.NC, item.Staff);
|
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
|
|
|
|
}
|
|
|
|
|
}
|