2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Repository;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
|
|
|
|
public partial class frmSaleAnalysisForm : Form
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
IList<SalesAnalysis> _list;
|
2014-11-06 10:39:11 +00:00
|
|
|
|
bool _loading;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public frmSaleAnalysisForm()
|
|
|
|
|
{
|
2014-11-06 10:39:11 +00:00
|
|
|
|
_loading = true;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-06 10:39:11 +00:00
|
|
|
|
private void SaleAnalysisForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
dtpStart.Format = DateTimePickerFormat.Custom;
|
|
|
|
|
dtpStart.CustomFormat = "dd-MMM-yyyy";
|
|
|
|
|
dtpStart.Value = DateTime.Now.Date;
|
|
|
|
|
dtpFinish.Format = DateTimePickerFormat.Custom;
|
|
|
|
|
dtpFinish.CustomFormat = "dd-MMM-yyyy";
|
|
|
|
|
dtpFinish.Value = DateTime.Now.Date;
|
|
|
|
|
_loading = false;
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
private void dtpStart_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowStatement()
|
|
|
|
|
{
|
2014-11-06 10:39:11 +00:00
|
|
|
|
if (_loading)
|
|
|
|
|
return;
|
2012-12-01 09:49:33 +00:00
|
|
|
|
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 &&
|
2014-10-16 11:11:55 +00:00
|
|
|
|
!Session.IsAllowed("Accounts Audit"))
|
2011-12-05 09:41:02 +00:00
|
|
|
|
return;
|
2016-01-04 05:22:01 +00:00
|
|
|
|
var start = dtpStart.Value.Date.AddHours(6);
|
|
|
|
|
var finish = dtpFinish.Value.Date.AddDays(1).AddHours(5);
|
|
|
|
|
_list = new List<SalesAnalysis>();
|
|
|
|
|
if (finish > start)
|
|
|
|
|
{
|
|
|
|
|
var list = new List<SalesAnalysis>();
|
2018-08-24 10:41:33 +00:00
|
|
|
|
list.AddRange(SalesAnalysisBI.GetSale(start, finish));
|
2016-01-04 05:22:01 +00:00
|
|
|
|
list.Add(new SalesAnalysis() { GroupType = " -- ", Amount = 0 });
|
2018-08-24 10:41:33 +00:00
|
|
|
|
list.AddRange(SalesAnalysisBI.GetSettlements(start, finish));
|
2016-01-04 05:22:01 +00:00
|
|
|
|
list.Add(new SalesAnalysis() { GroupType = " -- ", Amount = 0 });
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var sc = SalesAnalysisBI.GetServiceCharge(start, finish);
|
2016-01-04 05:22:01 +00:00
|
|
|
|
if (sc != null)
|
|
|
|
|
list.Add(sc);
|
|
|
|
|
|
2018-08-24 10:41:33 +00:00
|
|
|
|
foreach (var item in SalesAnalysisBI.GetServiceTax(start, finish))
|
2016-01-04 05:22:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (item.TaxAmount != 0)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new SalesAnalysis() { GroupType = item.Name, Amount = item.TaxAmount });
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
foreach (var item in SalesAnalysisBI.GetVat(start, finish))
|
2016-01-04 05:22:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (item.TaxAmount != 0)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new SalesAnalysis() { GroupType = item.Name, Amount = item.TaxAmount });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_list = list;
|
|
|
|
|
}
|
2012-12-01 09:49:33 +00:00
|
|
|
|
|
|
|
|
|
|
2011-02-09 12:03:22 +00:00
|
|
|
|
dgvSale.AutoGenerateColumns = true;
|
2011-12-05 09:41:02 +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;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dtpFinish_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ShowStatement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
if (_list != null)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
var startDate = dtpStart.Value.Date.AddHours(6);
|
|
|
|
|
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5);
|
2011-12-05 09:41:02 +00:00
|
|
|
|
Accounts.Print.Thermal.PrintSale(Session.User.Name, _list, startDate, finishDate);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|