narsil/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs

78 lines
2.5 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
using System;
using System.Linq;
2010-03-02 17:56:21 +00:00
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
2010-03-02 17:56:21 +00:00
using Tanshu.Accounts.Print;
using Tanshu.Accounts.Entities;
using System.Collections.Generic;
2010-03-02 17:56:21 +00:00
namespace Tanshu.Accounts.PointOfSale
{
public partial class CashierCheckoutForm : Form
2010-03-02 17:56:21 +00:00
{
CheckoutBI _coProxy;
bool _loading;
public CashierCheckoutForm()
2010-03-02 17:56:21 +00:00
{
_loading = true;
2010-03-02 17:56:21 +00:00
InitializeComponent();
}
private void CashierCheckoutForm_Load(object sender, EventArgs e)
2010-03-02 17:56:21 +00:00
{
dtpStart.Format = DateTimePickerFormat.Custom;
dtpStart.CustomFormat = "dd-MMM-yyyy";
dtpStart.Value = DateTime.Now.Date;
2010-03-02 17:56:21 +00:00
dtpFinish.Format = DateTimePickerFormat.Custom;
dtpFinish.CustomFormat = "dd-MMM-yyyy";
dtpFinish.Value = DateTime.Now.Date;
_loading = false;
FillUsers();
2010-03-02 17:56:21 +00:00
}
private void FillUsers()
{
_loading = true;
2010-03-02 17:56:21 +00:00
cmbCashier.DisplayMember = "Name";
cmbCashier.ValueMember = "UserID";
using (var bi = new UserBI())
cmbCashier.DataSource = bi.ListActive(dtpStart.Value.Date.AddHours(7), dtpFinish.Value.Date.AddDays(1).AddHours(7));
_loading = false;
2010-03-02 17:56:21 +00:00
}
private void CmbCashierSelectedIndexChanged(object sender, EventArgs e)
2010-03-02 17:56:21 +00:00
{
ShowStatement();
2010-03-02 17:56:21 +00:00
}
private void ShowStatement()
2010-03-02 17:56:21 +00:00
{
if (_loading || cmbCashier.SelectedValue == null)
2010-03-02 17:56:21 +00:00
return;
_coProxy = new CheckoutBI((Guid)cmbCashier.SelectedValue, dtpStart.Value, dtpFinish.Value);
var list = _coProxy.amounts.ToList() ;
dgvSale.DataSource = list;
dgvSale.AutoGenerateColumns = true;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[0].HeaderText = "Item";
dgvSale.Columns[1].HeaderText = "Amount";
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 DtpStartValueChanged(object sender, EventArgs e)
2010-03-02 17:56:21 +00:00
{
FillUsers();
2010-03-02 17:56:21 +00:00
}
private void DtpFinishValueChanged(object sender, EventArgs e)
2010-03-02 17:56:21 +00:00
{
FillUsers();
2010-03-02 17:56:21 +00:00
}
private void BtnPrintClick(object sender, EventArgs e)
2010-03-02 17:56:21 +00:00
{
Thermal.PrintClosing(_coProxy);
2010-03-02 17:56:21 +00:00
}
}
}