2011-01-30 07:14:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-02-04 19:30:55 +00:00
|
|
|
|
using NHibernate;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
using NHibernate.Criterion;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
2011-04-11 12:55:45 +00:00
|
|
|
|
using System.Linq;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public class FoodTableBI : FluentBase<FoodTable>
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-02-04 19:30:55 +00:00
|
|
|
|
public FoodTableBI()
|
2011-06-23 12:47:48 +00:00
|
|
|
|
: base()
|
|
|
|
|
{ }
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public FoodTableBI(bool beginTransaction)
|
|
|
|
|
: base(beginTransaction)
|
|
|
|
|
{ }
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public FoodTableBI(ISession session)
|
|
|
|
|
: base(session)
|
|
|
|
|
{ }
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public FoodTableBI(ISession session, bool beginTransaction)
|
|
|
|
|
: base(session, beginTransaction)
|
|
|
|
|
{ }
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public void UpdateStatus(string name, int voucherID, string status)
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
var table = Get(x => x.Name == name);
|
|
|
|
|
table.VoucherID = string.IsNullOrEmpty(status) ? 0 : voucherID;
|
|
|
|
|
table.Status = status;
|
|
|
|
|
Session.Update(table);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Move(string name, FoodTable foodTable)
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
var oldTable = Get(x => x.Name == name);
|
|
|
|
|
foodTable.Status = oldTable.Status;
|
|
|
|
|
foodTable.VoucherID = oldTable.VoucherID;
|
|
|
|
|
oldTable.Status = null;
|
|
|
|
|
oldTable.VoucherID = 0;
|
|
|
|
|
Session.Update(foodTable);
|
|
|
|
|
Session.Update(oldTable);
|
|
|
|
|
|
|
|
|
|
var voucher = Session.Get<Voucher>(foodTable.VoucherID);
|
|
|
|
|
voucher.TableID = foodTable.Name;
|
|
|
|
|
Session.Update(voucher);
|
|
|
|
|
return voucher.VoucherID;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-04-11 12:55:45 +00:00
|
|
|
|
|
|
|
|
|
public void UpdateStatus(Voucher voucher)
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
string status;
|
|
|
|
|
if (!voucher.Printed)
|
|
|
|
|
status = "running";
|
|
|
|
|
else if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) != 0 && voucher.Void == false)
|
|
|
|
|
status = "printed";
|
|
|
|
|
else
|
|
|
|
|
status = null;
|
|
|
|
|
UpdateStatus(voucher.TableID, voucher.VoucherID, status);
|
|
|
|
|
}
|
|
|
|
|
public void TableSettled(Voucher voucher)
|
|
|
|
|
{
|
|
|
|
|
if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) != 0 && voucher.Void == false)
|
|
|
|
|
return;
|
|
|
|
|
var table = Get(x => x.Name == voucher.TableID && x.VoucherID == voucher.VoucherID);
|
|
|
|
|
if (table == null)
|
|
|
|
|
return;
|
|
|
|
|
table.VoucherID = 0;
|
|
|
|
|
table.Status = null;
|
|
|
|
|
Session.Update(table);
|
2011-04-11 12:55:45 +00:00
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|