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

92 lines
3.6 KiB
C#

using System;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Print;
using Tanshu.Accounts.Helpers;
namespace Tanshu.Accounts.PointOfSale
{
public partial class Cashier_Checkout_Form : Form
{
CheckoutBI coProxy;
bool loading;
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public Cashier_Checkout_Form()
{
loading = true;
InitializeComponent();
}
private void Cashier_Checkout_Form_Load(object sender, EventArgs e)
{
dtpStart.Format = DateTimePickerFormat.Custom;
dtpStart.CustomFormat = "dd-MMM-yyyy";
dtpStart.Value = DateTime.Now;
dtpFinish.Format = DateTimePickerFormat.Custom;
dtpFinish.CustomFormat = "dd-MMM-yyyy";
dtpFinish.Value = DateTime.Now;
FillUsers();
loading = false;
}
private void FillUsers()
{
cmbCashier.DisplayMember = "Name";
cmbCashier.ValueMember = "UserID";
cmbCashier.DataSource = UserBI.GetUsers();
}
private void cmbCashier_SelectedIndexChanged(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((int)cmbCashier.SelectedValue, dtpStart.Value, dtpFinish.Value);
txtOpening.Text = string.Format("{0:#,##0.00}", coProxy);
txtReceipts.Text = string.Format("{0:#,##0.00}", coProxy.Receipts);
txtAdvanceReceived.Text = string.Format("{0:#,##0.00}", coProxy.AdvanceReceipts);
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);
txtAdvanceAdjusted.Text = string.Format("{0:#,##0.00}", coProxy.AdvanceAdjusted);
txtPayments.Text = string.Format("{0:#,##0.00}", coProxy.CashPayments);
txtAdditionalVoids.Text = string.Format("{0:#,##0.00}", coProxy.AdditionalVoids);
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.NetSales);
txtClosingCash.Text = string.Format("{0:#,##0.00}", coProxy.ClosingBalance);
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 = 0;
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);
}
}
}