narsil/Tanshu.Accounts.PointOfSale/Sales/CheckoutForm.cs
2011-12-05 14:53:02 +05:30

90 lines
3.4 KiB
C#

using System;
using System.Windows.Forms;
using Tanshu.Accounts.BI;
using Tanshu.Accounts.Print;
namespace Tanshu.Accounts.PointOfSale
{
public partial class Cashier_Checkout_Form : Form
{
CheckoutBI _coProxy;
private static readonly Logging.SqlLogger Log = new Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public Cashier_Checkout_Form()
{
InitializeComponent();
}
private void Cashier_Checkout_Form_Load(object sender, EventArgs e)
{
dtpStart.Format = DateTimePickerFormat.Custom;
dtpStart.CustomFormat = "dd-MMM-yyyy HH:mm:ss";
dtpStart.Value = DateTime.Now;
dtpFinish.Format = DateTimePickerFormat.Custom;
dtpFinish.CustomFormat = "dd-MMM-yyyy HH:mm:ss";
dtpFinish.Value = DateTime.Now;
FillUsers();
}
private void FillUsers()
{
cmbCashier.DisplayMember = "Name";
cmbCashier.ValueMember = "UserID";
cmbCashier.DataSource = new UserBI().GetUsers();
}
private void cmbCashier_SelectedIndexChanged(object sender, EventArgs e)
{
EmployeeStatus();
Log.Warn(string.Format("User Checkout: {0} by {1}", _coProxy.Cashier, CurrentUser.user.Name));
}
private void EmployeeStatus()
{
if (cmbCashier.SelectedValue == null)
return;
dtpStart.Value = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
dtpFinish.Value = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
_coProxy = new CheckoutBI((Guid)cmbCashier.SelectedValue, dtpStart.Value, dtpFinish.Value);
txtOpening.Text = _coProxy.Opening.ToString();
txtReceipts.Text = _coProxy.Receipts.ToString();
txtAdvanceReceived.Text = _coProxy.AdvanceReceipts.ToString();
txtCCReceipts.Text = _coProxy.CreditCardReceipts.ToString();
txtStaffReceipts.Text = _coProxy.StaffReceipts.ToString();
txtCreditReceipts.Text = _coProxy.CreditReceipts.ToString();
txtAdvanceAdjusted.Text = _coProxy.AdvanceAdjusted.ToString();
txtPayments.Text = _coProxy.CashPayments.ToString();
txtAdditionalVoids.Text = _coProxy.AdditionalVoids.ToString();
txtVoidsInSystem.Text = _coProxy.VoidsInSystem.ToString();
txtPending.Text = _coProxy.PendingBills.ToString();
txtSales.Text = _coProxy.NetSales.ToString();
txtClosingCash.Text = _coProxy.ClosingBalance.ToString();
txtStatus.Text = _coProxy.Status;
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
{
EmployeeStatus();
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
{
EmployeeStatus();
}
private void btnCalculate_Click(object sender, EventArgs e)
{
decimal deposited;
if (!decimal.TryParse(txtDeposited.Text, out deposited))
deposited = 0;
_coProxy.Calculate(deposited, 0);
txtStatus.Text = _coProxy.Status;
}
private void btnPrint_Click(object sender, EventArgs e)
{
Thermal.PrintClosing(_coProxy);
}
}
}