Merge branch 'master' into management

This commit is contained in:
Tanshu
2012-12-01 19:44:09 +05:30
8 changed files with 68 additions and 43 deletions

View File

@ -12,7 +12,7 @@ namespace Tanshu.Accounts.PointOfSale
{
public class BillController
{
private readonly OrderedDictionary<BillItemKey, BillItemValue> _bill;
private readonly BillDict _bill;
private Voucher _billInfo;
@ -31,7 +31,7 @@ namespace Tanshu.Accounts.PointOfSale
{
this._editVoucherID = editVoucherID;
_print = print;
_bill = new OrderedDictionary<BillItemKey, BillItemValue>();
_bill = new BillDict();
_billInfo = new Voucher(Session.User);
using (var bi = new CustomerBI(false))
_billInfo.Customer = bi.Get(x => x.CustomerID == 1);
@ -80,9 +80,7 @@ namespace Tanshu.Accounts.PointOfSale
else
{
var billItemValue = new BillItemValue(product);
var old =
_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID).
FirstOrDefault();
var old = _bill.FirstOrDefault(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID);
if (old.Key != null)
{
billItemValue.Discount = old.Value.Discount;
@ -908,13 +906,28 @@ namespace Tanshu.Accounts.PointOfSale
using (var trans = session.BeginTransaction())
{
int? kotID;
bool tableExists = false;
using (var bi = new VoucherBI(session, false))
kotID = bi.Insert(_billInfo);
if (updateTable)
using (var ft = new FoodTableBI(session, false))
{
tableExists = ft.Get(x => x.Name == _billInfo.TableID).VoucherID != 0;
ft.UpdateStatus(_billInfo);
trans.Commit();
return kotID;
}
if (tableExists)
{
MessageBox.Show("A bill exists on this table, cannot overrite", "Bill Open",
MessageBoxButtons.OK, MessageBoxIcon.Error);
trans.Rollback();
return null;
}
else
{
trans.Commit();
return kotID;
}
}
}
}

View File

@ -0,0 +1,12 @@
using Tanshu.Accounts.Contracts;
using Tanshu.Common;
namespace Tanshu.Accounts.PointOfSale
{
public class BillDict : OrderedDictionary<BillItemKey, BillItemValue>
{
public delegate void ItemChangedHandler();
public event ItemChangedHandler ItemChanged;
}
}

View File

@ -21,9 +21,12 @@ namespace Tanshu.Accounts.PointOfSale
private void ShowStatement()
{
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 &&
!Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
return;
_list = new SalesAnalysisBI().GetSale(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;