d8ecec8bb6
BillInventory Renamed. Refactored Bill to be more usable. Added Bill Detail Report. Added Open Bill and Bill Details Roles. Zero Rate Products have Yellow background Color. Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI, Cached the Products List. Product and Product Group Form Working.
75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NHibernate;
|
|
using NHibernate.Criterion;
|
|
using Tanshu.Accounts.Entities;
|
|
using System.Linq;
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
public class FoodTableBI : FluentBase<FoodTable>
|
|
{
|
|
public FoodTableBI()
|
|
: base()
|
|
{ }
|
|
|
|
public FoodTableBI(bool beginTransaction)
|
|
: base(beginTransaction)
|
|
{ }
|
|
|
|
public FoodTableBI(ISession session)
|
|
: base(session)
|
|
{ }
|
|
|
|
public FoodTableBI(ISession session, bool beginTransaction)
|
|
: base(session, beginTransaction)
|
|
{ }
|
|
|
|
public void UpdateStatus(string name, int voucherID, string status)
|
|
{
|
|
var table = Get(x => x.Name == name);
|
|
table.VoucherID = string.IsNullOrEmpty(status) ? 0 : voucherID;
|
|
table.Status = status;
|
|
Session.Update(table);
|
|
}
|
|
|
|
public int Move(string name, FoodTable foodTable)
|
|
{
|
|
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;
|
|
}
|
|
|
|
public void UpdateStatus(Voucher voucher)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
} |