Added inverse Attribute to ProductGroup.

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.
This commit is contained in:
unknown
2011-06-23 18:17:48 +05:30
parent 0cb7d3cf09
commit d8ecec8bb6
85 changed files with 3520 additions and 2264 deletions

View File

@ -14,52 +14,42 @@ namespace Tanshu.Accounts.PointOfSale
{
public class BillController
{
private readonly OrderedDictionary<BillItemKey, BillInventory> bill =
new OrderedDictionary<BillItemKey, BillInventory>();
private readonly OrderedDictionary<BillItemKey, BillItemValue> _bill;
private Voucher _billInfo;
private Customer _customer = new CustomerBI().GetCustomer(1);
private int? _editVoucherID;
private readonly bool _print;
private ISaleForm _saleForm;
public BillController(int? editVoucherID)
public BillController(int? editVoucherID, bool print)
{
this._editVoucherID = editVoucherID;
_print = print;
_bill = new OrderedDictionary<BillItemKey, BillItemValue>();
}
public BillInventory CurrentProduct
public BillItemValue CurrentProduct
{
get
{
if (_saleForm.BindingSource.Position == -1)
return null;
else
{
var item = bill.ElementAt(_saleForm.BindingSource.Position);
if (item.Key.KotID == -1)
return null;
return item.Value;
}
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
return item.Key.BillItemType == BillItemType.Product ? item.Value : null;
}
}
public BillInventory CurrentKot
public BillItemKey CurrentKot
{
get
{
if (_saleForm.BindingSource.Position == -1)
return null;
else
{
KeyValuePair<BillItemKey, BillInventory> item = bill.ElementAt(_saleForm.BindingSource.Position);
if (item.Key.KotID != -1)
return null;
if (item.Key.ProductID == 0)
return null;
return item.Value;
}
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
return item.Key.BillItemType == BillItemType.Kot ? item.Key : null;
}
}
@ -86,10 +76,9 @@ namespace Tanshu.Accounts.PointOfSale
throw new NotImplementedException();
}
public void AddProductToGrid(int productID)
public void AddProductToGrid(Product product)
{
new BillHelperFunctions(_saleForm.BindingSource, bill, productID).AddProduct();
var product = ProductBI.GetProduct(productID);
AddProduct(product);
if (ProductGroupModifierBI.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
{
var item = CurrentProduct;
@ -98,7 +87,43 @@ namespace Tanshu.Accounts.PointOfSale
ShowAmount();
}
public void ShowModifiers(int productGroupID, BillInventory item)
private void AddProduct(Product product)
{
var newKey = new BillItemKey(product.ProductID, 0);
if (_bill.ContainsKey(newKey))
{
_saleForm.BindingSource.CurrencyManager.Position = _bill.IndexOfKey(newKey);
_bill[newKey].Quantity += 1;
}
else
{
var billItemValue = new BillItemValue(product)
{
ProductID = product.ProductID,
Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")",
Price = product.SalePrice,
Tax = product.Tax.Rate,
ServiceCharge = product.ServiceCharge,
Discount = 0,
Printed = false,
Quantity = 1,
};
var old = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID).SingleOrDefault();
if (old.Key != null)
{
billItemValue.Discount = old.Value.Discount;
billItemValue.Price = old.Value.Price;
}
_bill.Add(newKey, billItemValue);
_saleForm.BindingSource.DataSource = _bill.Values.ToList();
_saleForm.BindingSource.CurrencyManager.Position = _saleForm.BindingSource.CurrencyManager.Count - 1;
}
}
public void ShowModifiers(int productGroupID, BillItemValue item)
{
if (item.Printed)
return;
@ -116,28 +141,32 @@ namespace Tanshu.Accounts.PointOfSale
if (!Session.IsAllowed(RoleConstants.DISCOUNT))
return;
var list = new ProductGroupBI().GetProductGroupTypes();
using (var frm = new DiscountForm(list))
using (var bi = new ProductGroupBI())
{
if (frm.ShowDialog() == DialogResult.OK)
using (var frm = new DiscountForm(bi.GetProductGroupTypes()))
{
HashSet<string> outList;
var discount = frm.Selection(out outList);
discount = discount / 100;
foreach (var item in bill)
if (frm.ShowDialog() == DialogResult.OK)
{
if (item.Key.KotID == -1)
continue;
ProductGroup pg = new ProductGroupBI().GetProductGroupOfProduct(item.Value.ProductID);
if (outList.Contains(pg.GroupType))
new BillHelperFunctions(_saleForm.BindingSource, bill, item.Value.ProductID).SetDiscount(
item.Value.Name, discount);
HashSet<string> outList;
var discount = frm.Selection(out outList);
discount = discount / 100;
if (discount > 1 || discount < 0)
return;
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && outList.Contains(x.Value.Product.ProductGroup.GroupType)))
{
var product = item.Value.Product;
var maxDiscount = product.ProductGroup.DiscountLimit;
if (discount > item.Value.Product.ProductGroup.DiscountLimit)
MessageBox.Show(string.Format("Maximum discount for {0} is {1:P}", product.Name, maxDiscount),
"Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
item.Value.Discount = discount;
}
}
}
}
ShowAmount();
}
public void ShowCustomerList(bool reset)
{
if ((_customer.CustomerID == 1) && (!reset))
@ -198,14 +227,6 @@ namespace Tanshu.Accounts.PointOfSale
}
}
private static void PrintBill(int voucherID, int kotID)
{
if (kotID == 0)
Thermal.PrintBill(voucherID);
else
Thermal.PrintKot(voucherID, kotID);
}
private static List<StringType> GetVoidReason(Dictionary<string, string> filter)
{
var list = new List<StringType>
@ -226,14 +247,14 @@ namespace Tanshu.Accounts.PointOfSale
{
//saleForm.BindingSource.CurrencyManager.Position = 1;
var taxAmount = bill.Values.Sum(b => b.TaxAmount);
var discountAmount = bill.Values.Sum(b => b.DiscountAmount);
var grossAmount = bill.Values.Sum(b => b.GrossAmount);
var valueAmount = bill.Values.Sum(b => b.Value);
var serviceChargeAmount = bill.Values.Sum(b => b.ServiceChargeAmount);
var taxAmount = _bill.Values.Sum(b => b.TaxAmount);
var discountAmount = _bill.Values.Sum(b => b.DiscountAmount);
var grossAmount = _bill.Values.Sum(b => b.GrossAmount);
var valueAmount = _bill.Values.Sum(b => b.Value);
var serviceChargeAmount = _bill.Values.Sum(b => b.ServiceChargeAmount);
//bill.Values.ToList();
_saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount,
bill.Values.ToList());
_bill.Values.ToList());
}
public void ProductRemove()
@ -243,8 +264,8 @@ namespace Tanshu.Accounts.PointOfSale
return;
if (item.Printed)
return;
bill.Remove(new BillItemKey(item.ProductID, 0));
bill.ReCompact();
_bill.Remove(new BillItemKey(item.ProductID, 0));
_bill.ReCompact();
ShowAmount();
}
@ -253,28 +274,45 @@ namespace Tanshu.Accounts.PointOfSale
var item = CurrentProduct;
if (!Allowed(item))
return;
new BillHelperFunctions(_saleForm.BindingSource, bill, CurrentProduct.ProductID).SetQuantity(item, quantity,
prompt);
if (item.Printed)
return;
if (prompt && !GetInput("Quantity", ref quantity))
return;
if (!prompt)
quantity += item.Quantity;
if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
return;
var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product).Sum(x => x.Value.Quantity);
if (total < 0)
quantity -= total;
item.Quantity = quantity;
ShowAmount();
}
public void ChangeRate()
{
var item = CurrentProduct;
if (!Allowed(item))
if (!Allowed(item, RoleConstants.CHANGE_RATE))
return;
new BillHelperFunctions(_saleForm.BindingSource, bill, CurrentProduct.ProductID).SetPrice(CurrentProduct);
var rate = item.Price;
if (!GetInput("Price", ref rate))
return;
if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE))
return;
foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.ProductID))
sub.Value.Price = rate;
ShowAmount();
}
private bool Allowed(BillInventory item, RoleConstants role)
private bool Allowed(BillItemValue item, RoleConstants role)
{
if (item == null)
return false;
return Session.IsAllowed(role);
}
private bool Allowed(BillInventory item)
private bool Allowed(BillItemValue item)
{
return item != null;
}
@ -286,7 +324,7 @@ namespace Tanshu.Accounts.PointOfSale
private void LoadBill(int voucherID)
{
ClearBill();
bill.Clear();
_bill.Clear();
_billInfo = null;
_billInfo = VoucherBI.Get(voucherID);
@ -297,23 +335,23 @@ namespace Tanshu.Accounts.PointOfSale
foreach (var kot in _billInfo.Kots)
{
var kotKey = new BillItemKey(kot.KotID, -1);
var kotItem = new BillInventory
var kotKey = new BillItemKey(kot.KotID);
var kotItem = new BillItemValue(null)
{
ProductID = kot.KotID,
Discount = 0,
Name = string.Format("Kot No.: {0} / KotID {1}", kot.KotID, kot.Code),
Name = string.Format("Kot: {0} / {1:dd-MMM HH:mm} ({2})", kot.Code, kot.Date, kot.User.Name),
Price = 0,
Printed = true,
Quantity = 0,
Tax = -1,
ServiceCharge = 0,
};
bill.Add(kotKey, kotItem);
_bill.Add(kotKey, kotItem);
foreach (var inv in kot.Inventories)
{
var key = new BillItemKey(inv.Product.ProductID, kot.KotID);
var item = new BillInventory
var item = new BillItemValue(inv.Product)
{
ProductID = inv.Product.ProductID,
Discount = inv.Discount,
@ -329,11 +367,11 @@ namespace Tanshu.Accounts.PointOfSale
};
foreach (var mod in inv.InventoryModifier)
item.Modifiers.Add(mod.Modifier);
bill.Add(key, item);
_bill.Add(key, item);
}
}
var newKotKey = new BillItemKey(0, -1);
var newKotItem = new BillInventory
var newKotKey = new BillItemKey(0);
var newKotItem = new BillItemValue(null)
{
ProductID = 0,
Discount = 0,
@ -344,7 +382,7 @@ namespace Tanshu.Accounts.PointOfSale
Tax = -1,
ServiceCharge = 0,
};
bill.Add(newKotKey, newKotItem);
_bill.Add(newKotKey, newKotItem);
ShowAmount();
}
@ -352,7 +390,9 @@ namespace Tanshu.Accounts.PointOfSale
{
if (!string.IsNullOrEmpty(tableName))
{
var table = new FoodTableBI().Get(tableName);
FoodTable table;
using (var bi = new FoodTableBI())
table = bi.Get(x => x.Name == tableName);
if (table != null && table.VoucherID != 0)
{
LoadBill(table.VoucherID);
@ -360,31 +400,20 @@ namespace Tanshu.Accounts.PointOfSale
}
else
{
var result = InputBox.Show("Table Number", "0", InputBox_Validating);
if (result.OK)
{
var tableID = result.Text.Trim();
if ((tableID != "C") && (tableID != "") && (!tableID.Contains(".")))
{
var table = new FoodTableBI().Get(tableName);
if (table != null && table.VoucherID != 0)
{
LoadBill(table.VoucherID);
}
}
else
ClearBill();
}
var result = "0";
if (GetInput("Table Number", ref result))
LoadBillFromTable(result);
else
ClearBill();
}
}
public void CancelBillChanges()
{
if (bill.Count != 0 && bill.Values.Any(i => i.Printed == false))
if (
MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
return;
if (_bill.Values.Any(i => i.Printed == false) &&
MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
return;
ClearBill();
}
@ -392,9 +421,9 @@ namespace Tanshu.Accounts.PointOfSale
{
_billInfo = null;
ShowCustomerList(true);
bill.Clear();
var newKotKey = new BillItemKey(0, -1);
var newKotItem = new BillInventory
_bill.Clear();
var newKotKey = new BillItemKey(0);
var newKotItem = new BillItemValue(null)
{
ProductID = 0,
Discount = 0,
@ -405,8 +434,8 @@ namespace Tanshu.Accounts.PointOfSale
Tax = -1,
ServiceCharge = 0,
};
bill.Add(newKotKey, newKotItem);
_saleForm.ClearBill(bill);
_bill.Add(newKotKey, newKotItem);
_saleForm.ClearBill(_bill);
}
public void FormLoad()
@ -427,7 +456,10 @@ namespace Tanshu.Accounts.PointOfSale
if (!Session.IsAllowed(RoleConstants.SETTLE_BILL))
return;
IDictionary<SettleOption, decimal> options;
using (var frm = new SettleChoicesForm(_billInfo))
var amount = (_billInfo.Settlements.Single(x => x.Settled == SettleOption.Amount).Amount +
_billInfo.Settlements.Single(x => x.Settled == SettleOption.RoundOff).Amount) * -1;
using (var frm = new SettleChoicesForm(amount))
{
frm.ShowDialog();
options = frm.OptionsChosen;
@ -438,76 +470,19 @@ namespace Tanshu.Accounts.PointOfSale
ClearBill();
}
internal void MoveTable()
{
if (_billInfo == null)
return;
if (VoucherBI.IsBillPrinted(_billInfo.VoucherID) && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL))
return;
var table = GetTableForMove(true);
if (table == null)
return;
LoadBill(table.VoucherID == 0 ? MoveTable(table) : MergeTable(table));
}
private int MoveTable(FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MOVE_TABLE))
return 0;
return new FoodTableBI().Move(_billInfo.TableID, table);
}
private int MergeTable(FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MERGE_TABLE))
return 0;
var kots = bill.Where(x => x.Key.KotID == -1 && x.Key.ProductID != 0);
foreach (var item in kots)
MergeKot(item.Value, table);
VoucherBI.Delete(_billInfo.VoucherID);
return table.VoucherID;
}
private static int MergeKot(BillInventory kot, FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MERGE_KOT))
return 0;
return VoucherBI.MoveKot(kot.ProductID, table);
}
private int MoveKot(BillInventory kot, FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MOVE_KOT))
return 0;
CreateNewVoucherForKotMove(kot, table);
return MergeKot(kot, table);
}
private void CreateNewVoucherForKotMove(BillInventory kot, FoodTable table)
{
var voucher = new Voucher
{
Customer = _billInfo.Customer,
TableID = table.Name,
Waiter = _billInfo.Waiter,
Printed = false,
Void = false,
Date = DateTime.Now,
Narration = "",
User = Session.User
};
VoucherBI.Insert(voucher);
}
#region Move Table(s) / Kot(s)
private static FoodTable GetTableForMove(bool allowMerge)
{
using (var frm = new frmMoveTable(new FoodTableBI().List(), allowMerge))
using (var bi = new FoodTableBI())
{
frm.ShowDialog();
if (frm.Selection != null)
return frm.Selection;
using (var frm = new MoveTableForm(bi.List(), allowMerge))
{
frm.ShowDialog();
if (frm.Selection != null)
return frm.Selection;
}
return null;
}
return null;
}
internal void MergeKot()
@ -522,70 +497,124 @@ namespace Tanshu.Accounts.PointOfSale
var table = GetTableForMove(true);
if (table == null)
return;
var count = bill.Keys.Count(x => x.KotID == -1 && x.ProductID != 0);
var kotCount = _bill.Keys.Count(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
var voucherID = 0;
if (table.VoucherID == 0 && count > 1)
if (table.VoucherID == 0 && kotCount > 1)
//Move Kot
voucherID = MoveKot(kot, table);
else if (table.VoucherID == 0 && count == 1)
else if (table.VoucherID == 0 && kotCount == 1)
//Move Table
voucherID = MoveTable(table);
else if (table.VoucherID != 0 && count > 1)
else if (table.VoucherID != 0 && kotCount > 1)
//Merge Kot
voucherID = MergeKot(kot, table);
else if (table.VoucherID != 0 && count == 1)
else if (table.VoucherID != 0 && kotCount == 1)
//Merge Table
voucherID = MergeTable(table);
if (voucherID != 0)
LoadBill(voucherID);
}
internal void MoveTable()
{
if (_billInfo == null)
return;
if (VoucherBI.IsBillPrinted(_billInfo.VoucherID) && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL))
return;
var table = GetTableForMove(true);
if (table == null)
return;
LoadBill(table.VoucherID == 0 ? MoveTable(table) : MergeTable(table));
}
private int MoveKot(BillItemKey kot, FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MOVE_KOT))
return 0;
var voucher = new Voucher
{
Customer = _billInfo.Customer,
TableID = table.Name,
Waiter = _billInfo.Waiter,
Printed = false,
Void = false,
Date = DateTime.Now,
Narration = "",
User = Session.User
};
VoucherBI.Insert(voucher, true);
return VoucherBI.MergeKot(kot.KotID, voucher);
}
private static int MergeKot(BillItemKey kot, FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MERGE_KOT))
return 0;
return VoucherBI.MergeKot(kot.KotID, table);
}
private int MoveTable(FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MOVE_TABLE))
return 0;
using (var ft = new FoodTableBI())
return ft.Move(_billInfo.TableID, table);
}
private int MergeTable(FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MERGE_TABLE))
return 0;
var kots = _bill.Keys.Where(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
foreach (var item in kots)
MergeKot(item, table);
VoucherBI.Delete(_billInfo.VoucherID);
return table.VoucherID;
}
#endregion
#region Save
// if (btnWaiter.Tag == null)
//btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
public void Save(bool print, int waiterID, string tableID)
public void SaveBill(int waiterID, string tableID)
{
if (print && !Session.IsAllowed(RoleConstants.PRINT_BILL))
return;
if (!print && !Session.IsAllowed(RoleConstants.PRINT_KOT))
if (!Session.IsAllowed(RoleConstants.PRINT_BILL))
return;
if ((_billInfo != null) && (VoucherBI.IsBillPrinted(_billInfo.VoucherID)) &&
(!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
return;
if (bill.Count == 1) //new kot only
if (_bill.Count == 1) //new kot only
return;
if (print)
ShowDiscount();
int? saved;
if (_billInfo == null)
saved = InsertVoucher(print, waiterID, tableID);
else
saved = UpdateSale(print, waiterID, tableID);
ShowDiscount();
var saved = _billInfo == null ? InsertVoucher(true, waiterID, tableID, !_editVoucherID.HasValue) : UpdateVoucher(true, waiterID, tableID, !_editVoucherID.HasValue);
if (!_editVoucherID.HasValue || _print)
Thermal.PrintBill(_billInfo.VoucherID);
if (_editVoucherID.HasValue)
_saleForm.CloseWindow();
else
{
int kotID = 0;
if (!print && saved.HasValue)
kotID = saved.Value;
if (print || kotID != 0)
PrintBill(_billInfo.VoucherID, kotID);
}
ClearBill();
}
private int? InsertVoucher(bool finalBill, int waiterID, string tableID)
public void SaveKot(int waiterID, string tableID)
{
if (!Session.IsAllowed(RoleConstants.PRINT_KOT))
return;
if ((_billInfo != null) && (VoucherBI.IsBillPrinted(_billInfo.VoucherID)) &&
(!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
return;
if (_bill.Count == 1) //new kot only
return;
var saved = _billInfo == null ? InsertVoucher(false, waiterID, tableID, !_editVoucherID.HasValue) : UpdateVoucher(false, waiterID, tableID, !_editVoucherID.HasValue);
if ((!_editVoucherID.HasValue || _print) && saved.HasValue)
Thermal.PrintKot(_billInfo.VoucherID, saved.Value);
if (_editVoucherID.HasValue)
_saleForm.CloseWindow();
ClearBill();
}
private int? InsertVoucher(bool finalBill, int waiterID, string tableID, bool updateTable)
{
if (_billInfo != null)
{
MessageBox.Show("Error in InsertVoucher, there is a previous sale in memory", "Error");
return null;
}
#region Voucher
_billInfo = new Voucher
{
Customer = _customer,
@ -598,24 +627,15 @@ namespace Tanshu.Accounts.PointOfSale
Narration = "",
User = Session.User
};
#endregion
#region Inventories
Kot kot = GetKotForBill();
UpdateKots();
var kot = GetKotForBill();
if (kot != null)
_billInfo.Kots.Add(kot);
#endregion
return VoucherBI.Insert(_billInfo);
return VoucherBI.Insert(_billInfo, updateTable);
}
private int? UpdateSale(bool finalBill, int waiterID, string tableID)
private int? UpdateVoucher(bool finalBill, int waiterID, string tableID, bool updateTable)
{
#region Voucher
_billInfo.User = Session.User;
_billInfo.Customer = _customer;
if (!_billInfo.Printed && finalBill)
@ -623,51 +643,62 @@ namespace Tanshu.Accounts.PointOfSale
_billInfo.Printed = _billInfo.Printed || finalBill;
_billInfo.TableID = tableID;
_billInfo.Waiter = WaiterBI.GetWaiter(waiterID);
Kot kot = GetKotForBill();
UpdateKots();
var kot = GetKotForBill();
if (kot != null)
_billInfo.Kots.Add(kot);
#endregion
#region Inventory
#endregion
return VoucherBI.Update(_billInfo);
return VoucherBI.Update(_billInfo, updateTable);
}
private void UpdateKots()
{
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0))
{
var i = _billInfo.Kots.Single(x => x.KotID == item.Key.KotID).Inventories.Single(x => x.Product.ProductID == item.Key.ProductID);
i.Discount = item.Value.Discount;
i.Rate = item.Value.Price;
}
}
private Kot GetKotForBill()
{
var kot = new Kot();
foreach (var item in bill)
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == 0 && x.Value.Quantity != 0))
{
if (item.Key.KotID == -1 || item.Value.Quantity == 0)
continue;
else if (item.Key.KotID != 0)
{
Kot oldKot = _billInfo.Kots.Where(x => x.KotID == item.Key.KotID).Single();
Inventory inv = oldKot.Inventories.Where(x => x.Product.ProductID == item.Key.ProductID).Single();
inv.Rate = item.Value.Price;
inv.Discount = item.Value.Discount;
}
else
{
var temp = new Inventory();
temp.Product = ProductBI.GetProduct(item.Key.ProductID);
temp.Quantity = item.Value.Quantity;
temp.Rate = item.Value.Price;
temp.Discount = item.Value.Discount;
temp.ServiceCharge = item.Value.ServiceCharge;
temp.Tax = item.Value.Tax;
foreach (Modifier mod in item.Value.Modifiers)
temp.InventoryModifier.Add(new InventoryModifier { Modifier = mod });
kot.Inventories.Add(temp);
}
var inv = new Inventory
{
Product = item.Value.Product,
Quantity = item.Value.Quantity,
Rate = item.Value.Price,
Discount = item.Value.Discount,
ServiceCharge = item.Value.ServiceCharge,
Tax = item.Value.Tax
};
foreach (var mod in item.Value.Modifiers)
inv.InventoryModifier.Add(new InventoryModifier { Modifier = mod });
kot.Inventories.Add(inv);
}
if (kot.Inventories.Count == 0)
return null;
else
return kot;
return kot.Inventories.Count == 0 ? null : kot;
}
#endregion
#region InputBox
private bool GetInput(string prompt, ref decimal amount)
{
var result = InputBox.Show(prompt, amount.ToString(), InputBox_Validating);
if (!result.OK)
return false;
if (!decimal.TryParse(result.Text, out amount))
return false;
return true;
}
private bool GetInput(string prompt, ref string info)
{
var result = InputBox.Show(prompt, info, InputBox_Validating);
if (!result.OK)
return false;
info = result.Text.Trim();
if (string.IsNullOrEmpty(info))
return false;
return true;
}
#endregion

View File

@ -10,10 +10,10 @@ namespace Tanshu.Accounts.PointOfSale
{
public interface ISaleForm
{
void ClearBill(OrderedDictionary<BillItemKey, BillInventory> bill);
void ClearBill(OrderedDictionary<BillItemKey, BillItemValue> bill);
void SetCustomerDisplay(string name);
void CloseWindow();
void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List<BillInventory> bill);
void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List<BillItemValue> bill);
void ShowInfo(string billID, string kotID, DateTime creationDate, DateTime date, DateTime lastEditDate, string customer, string tableID, int waiterID, string waiter);
void SetUserName(string name);
BindingSource BindingSource { get; }