narsil/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs
tanshu 69617949bd Important! : Need to update to new schema using SQL Scripts
Important! : This version will not work.  It is pre-alpha and saved in case of catastrophic failure
Refactor: Remove dependency on Fluent Nhibernate.
Refactor: All Primary keys are now Guids.
Refactor: Class Mappings changed from AutoMap to Explicit Mappings.
Breakage: All Cascading is now disabled and entities must be explicitly saved/updated/deleted
Breakage: Auto Commiting is now off and "SaveChanges()" needs to be called on all BIs.
Refactor: Changed the pattern where all relevant db code for an operation is basically in the same function.
Chore: Removed Advance and Payments options.
2014-10-12 15:11:45 +05:30

89 lines
3.2 KiB
C#

using System;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Print;
namespace Tanshu.Accounts.PointOfSale
{
public partial class CashierCheckoutForm : Form
{
CheckoutBI _coProxy;
bool _loading;
public CashierCheckoutForm()
{
_loading = true;
InitializeComponent();
}
private void CashierCheckoutFormLoad(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;
FillUsers();
_loading = false;
}
private void FillUsers()
{
var loading = _loading;
_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 = loading;
}
private void CmbCashierSelectedIndexChanged(object sender, EventArgs e)
{
EmployeeStatus();
//log.Warn(string.Format("User Checkout: {0} by {1}", coProxy.Cashier, Session.User.Name));
}
private void EmployeeStatus()
{
if (_loading || cmbCashier.SelectedValue == null)
return;
_coProxy = new CheckoutBI((Guid)cmbCashier.SelectedValue, dtpStart.Value, dtpFinish.Value);
txtCCReceipts.Text = string.Format("{0:#,##0.00}", _coProxy.CcReceipts);
txtNC.Text = string.Format("{0:#,##0.00}", _coProxy.NcReceipts);
txtBillToCompany.Text = string.Format("{0:#,##0.00}", _coProxy.BtcReceipts);
txtCashReceipts.Text = string.Format("{0:#,##0.00}", _coProxy.CashReceipts);
txtVoidsInSystem.Text = string.Format("{0:#,##0.00}", _coProxy.VoidsInSystem);
txtDiscounts.Text = string.Format("{0:#,##0.00}", _coProxy.Discount);
txtPending.Text = string.Format("{0:#,##0.00}", _coProxy.PendingBills);
txtSales.Text = string.Format("{0:#,##0.00}", _coProxy.CashReceipts);
txtClosingCash.Text = string.Format("{0:#,##0.00}", _coProxy.ClosingBalance);
txtStatus.Text = _coProxy.Status;
}
private void DtpStartValueChanged(object sender, EventArgs e)
{
FillUsers();
}
private void DtpFinishValueChanged(object sender, EventArgs e)
{
FillUsers();
}
private void BtnCalculateClick(object sender, EventArgs e)
{
decimal deposited = 0;
if (!decimal.TryParse(txtDeposited.Text, out deposited))
deposited = 0;
_coProxy.Calculate();
txtStatus.Text = _coProxy.Status;
}
private void BtnPrintClick(object sender, EventArgs e)
{
Thermal.PrintClosing(_coProxy);
}
}
}