2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.BI;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
|
|
|
|
public partial class frmSaleAnalysisForm : Form
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
Guid? _details;
|
|
|
|
|
List<SalesAnalysisBO> _analysis;
|
|
|
|
|
List<SalesAnalysisDetailBO> _analysisDetail;
|
|
|
|
|
private static readonly Tanshu.Logging.SqlLogger Log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public frmSaleAnalysisForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2013-11-16 06:01:58 +00:00
|
|
|
|
Log.Warn(string.Format("Sales Analysis by: {0}", CurrentUser.user.Name));
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dtpStart_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowStatement()
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
var startDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
|
|
|
|
|
var finishDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2013-11-16 06:01:58 +00:00
|
|
|
|
if (_details.HasValue)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
_analysisDetail = new SalesAnalysisBI().GetSaleDetail(startDate, finishDate, _details.Value);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
dgvSale.AutoGenerateColumns = true;
|
2013-11-16 06:01:58 +00:00
|
|
|
|
dgvSale.DataSource = _analysisDetail;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
|
|
|
|
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
|
|
|
|
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
_analysis = new SalesAnalysisBI().GetSale(startDate, finishDate);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
dgvSale.AutoGenerateColumns = true;
|
2013-11-16 06:01:58 +00:00
|
|
|
|
dgvSale.DataSource = _analysis;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
|
|
|
|
dgvSale.Columns[0].Visible = false;
|
|
|
|
|
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
|
|
|
|
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 dgvSale_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
if (!_details.HasValue)
|
2013-11-28 10:39:33 +00:00
|
|
|
|
_details = ((SalesAnalysisBO)dgvSale.SelectedRows[0].DataBoundItem).ProductGroupID;
|
2013-11-16 06:01:58 +00:00
|
|
|
|
else
|
|
|
|
|
_details = null;
|
|
|
|
|
ShowStatement();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
if (!_details.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var startDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
|
|
|
|
|
var finishDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
|
|
|
|
|
Print.Thermal.PrintSale(_analysis, startDate, finishDate);
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
var startDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
|
|
|
|
|
var finishDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
|
|
|
|
|
Print.Thermal.PrintSale(_analysisDetail, startDate, finishDate);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-07 21:14:31 +00:00
|
|
|
|
|
|
|
|
|
private void btnCopy_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_analysisDetail == null)
|
|
|
|
|
return;
|
|
|
|
|
var data = string.Format("{0}\t{1}\t{2}\t{3}\n", "Group", "Product", "Quantity", "Amount");
|
|
|
|
|
foreach (var item in _analysisDetail)
|
|
|
|
|
{
|
|
|
|
|
data += string.Format("{0}\t{1}\t{2}\t{3}\n", item.Section, item.Product, item.Quantity, item.Amount);
|
|
|
|
|
}
|
|
|
|
|
Clipboard.SetText(data, TextDataFormat.Text);
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|