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

78 lines
2.5 KiB
C#

using System;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Print;
using Tanshu.Accounts.Entities;
using System.Collections.Generic;
namespace Tanshu.Accounts.PointOfSale
{
public partial class CashierCheckoutForm : Form
{
CheckoutBI _coProxy;
bool _loading;
public CashierCheckoutForm()
{
_loading = true;
InitializeComponent();
}
private void CashierCheckoutForm_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;
FillUsers();
}
private void FillUsers()
{
_loading = true;
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;
}
private void CmbCashierSelectedIndexChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void ShowStatement()
{
if (_loading || cmbCashier.SelectedValue == null)
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;
}
private void DtpStartValueChanged(object sender, EventArgs e)
{
FillUsers();
}
private void DtpFinishValueChanged(object sender, EventArgs e)
{
FillUsers();
}
private void BtnPrintClick(object sender, EventArgs e)
{
Thermal.PrintClosing(_coProxy);
}
}
}