Major refactor of the Sales Form and Bill controller to make code more readable and less error prone.

The functions now only do one thing.
This commit is contained in:
tanshu 2016-03-31 12:27:39 +05:30
parent bb2db24837
commit 51d518d2a0
17 changed files with 615 additions and 396 deletions

@ -15,17 +15,17 @@ namespace Tanshu.Accounts.Entities
Settlements = new List<VoucherSettlement>();
}
public Voucher(User user)
public Voucher(User user, Customer customer)
: this()
{
this.User = user;
VoucherType = VoucherType.Regular;
Customer = customer;
}
public Voucher(User user, Customer customer, FoodTable table, bool printed, bool isVoid, string narration)
: this(user)
: this(user, customer)
{
Customer = customer;
Table = table;
Printed = printed;
Void = isVoid;

@ -1,102 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Tanshu.Data;
using Tanshu.Accounts.Entities;
namespace Tanshu.Accounts.Helpers
{
public class SelectCustomer : Tanshu.Data.BaseSelector<Customer>
{
public event CustomerEventHandler CustomerEvent;
public SelectCustomer(GetData<Customer> getData, bool autoClose) : base(getData, true, "List of Products")
{
var filters = new List<string> {"Universal"};
SetFilterColumns(filters);
grid.Columns["CustomerID"].Visible = false;
}
protected override void FilterChanged(Dictionary<string, string> filter)
{
//data = new CustomerBI().GetFilteredCustomers(filter["Universal"].Split(' ')).ToList();
data = getData(filter);
bindingSource.DataSource = data;
}
protected override void UpdateDisplay(Customer item)
{
DisplayLabel = item == null ? "" : string.Format("Chosen Customer is {0} with phone number {1}", item.Name, item.Phone);
}
protected override Customer HandleKeydown(object sender, ExtendedKeyEventArgs e)
{
var customer = bindingSource.Current as Customer;
if (CustomerEvent == null)
{
e.Handled = false;
return customer;
}
Guid? id = null;
if ((customer != null) && (e.KeyCode == Keys.F2))
id = customer.CustomerID;
if ((e.KeyCode == Keys.F1) || (e.KeyCode == Keys.F2))
{
customer = CustomerEvent(sender, new CustomerEventArgs(id, base.filterColumns["Universal"]));
e.Handled = customer != null;
}
return customer;
}
#region Designer Code
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
}
#endregion
#endregion
}
public delegate Customer CustomerEventHandler(object sender, CustomerEventArgs e);
public class CustomerEventArgs : EventArgs
{
public CustomerEventArgs(Guid? customerID, string phone)
{
CustomerID = customerID;
Phone = phone;
}
public Guid? CustomerID
{
get;
private set;
}
public string Phone
{
get;
private set;
}
}
}

@ -70,9 +70,6 @@
<Compile Include="SelectVoidReason.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SelectCustomer.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

@ -13,8 +13,8 @@ namespace Tanshu.Accounts.PointOfSale
{
public class BillController
{
private readonly BillDict _bill;
private Voucher _voucher;
public readonly BillDict _bill;
public Voucher _voucher;
private Guid? _editVoucherID;
private ISaleForm _saleForm;
@ -22,45 +22,13 @@ namespace Tanshu.Accounts.PointOfSale
{
this._editVoucherID = editVoucherID;
_bill = new BillDict();
_voucher = new Voucher(Session.User);
using (var bi = new CustomerBI())
_voucher.Customer = bi.Get(x => x.CustomerID == Constants.CASH_CUSTOMER);
}
public BillItemValue CurrentProduct
{
get
{
if (_saleForm.BindingSource.Position == -1)
return null;
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
return item.Key.BillItemType != BillItemType.Kot ? item.Value : null;
}
}
public BillItemKey CurrentKey
{
get
{
if (_saleForm.BindingSource.Position == -1)
return null;
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
return item.Key;
}
}
public BillItemKey CurrentKot
{
get
{
if (_saleForm.BindingSource.Position == -1)
return null;
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
return item.Key.BillItemType == BillItemType.Kot ? item.Key : null;
}
_voucher = new Voucher(Session.User, bi.Get(x => x.CustomerID == Constants.CASH_CUSTOMER));
}
public void InitGui(ISaleForm saleForm)
{
this._saleForm = saleForm;
this._saleForm.SetCustomerDisplay(_voucher.Customer.Name);
this._saleForm.SetUserName(Session.User.Name);
}
public void AddProduct(Product product)
@ -69,7 +37,6 @@ namespace Tanshu.Accounts.PointOfSale
if (_bill.ContainsKey(newKey))
{
_saleForm.BindingSource.CurrencyManager.Position = _bill.IndexOfKey(newKey);
_bill[newKey].inventory.Quantity += 1;
}
else
@ -82,32 +49,20 @@ namespace Tanshu.Accounts.PointOfSale
billItemValue.inventory.Price = old.Value.inventory.Price;
}
_bill.Add(newKey, billItemValue);
_saleForm.BindingSource.DataSource = _bill.ToList();
_saleForm.BindingSource.CurrencyManager.Position = _saleForm.BindingSource.CurrencyManager.Count - 1;
using (var bi = new ProductGroupModifierBI())
if (bi.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
{
ShowModifiers();
}
}
ShowAmount();
}
public void ShowModifiers()
public void ShowModifiers(BillItemValue item)
{
var item = CurrentProduct;
if (item == null || CurrentKey.KotID != Guid.Empty)
return; // No Product or Old Product
using (var frm = new ModifierForm(Cache.ProductGroupModifiers(item.inventory.Product.ProductGroup.ProductGroupID), item.inventory.InventoryModifier))
{
frm.ShowDialog();
}
ShowAmount();
}
public void SetDiscount()
{
if (!Session.IsAllowed("Discount"))
return; // throw new PermissionException("Not Allowed to give Discount");
return;
using (var bi = new ProductGroupBI())
{
@ -119,7 +74,7 @@ namespace Tanshu.Accounts.PointOfSale
var discount = frm.Selection(out outList);
discount = discount / 100;
if (discount > 1 || discount < 0)
return; // throw new ValidationException("Invalid Discount Amount");
return;
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && outList.Contains(x.Value.inventory.Product.ProductGroup.GroupType)))
{
@ -133,12 +88,9 @@ namespace Tanshu.Accounts.PointOfSale
}
}
}
ShowAmount();
}
public void SetQuantity(decimal quantity, bool prompt)
public void SetQuantity(BillItemKey key, BillItemValue item, decimal quantity, bool prompt)
{
var item = CurrentProduct;
var key = CurrentKey;
if (item == null || key.KotID != Guid.Empty)
return; // No Product or Old Product
if (prompt && !GetInput("Quantity", ref quantity))
@ -147,21 +99,14 @@ namespace Tanshu.Accounts.PointOfSale
quantity += item.inventory.Quantity;
if (quantity < 0 && !Session.IsAllowed("Edit Printed Product"))
return;
//TODO: check if he kotid of the item is not null
//var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product && x.Value.Printed).Sum(x => x.Value.Quantity);
var total = quantity + _bill.Where(x => x.Key.ProductID == key.ProductID && x.Key.BillItemType == key.BillItemType).Sum(x => x.Value.inventory.Quantity);
if (total < 0)
quantity -= total;
var total = quantity + _bill.Where(x => x.Key.ProductID == key.ProductID && x.Key.KotID != Guid.Empty && x.Key.BillItemType == key.BillItemType).Sum(x => x.Value.inventory.Quantity);
quantity = Math.Max(quantity, 0);
item.inventory.Quantity = quantity;
ShowAmount();
}
public void SetPrice()
public void SetPrice(BillItemValue item)
{
var item = CurrentProduct;
if (item == null)
throw new ValidationException("No Product Selected");
if (!Session.IsAllowed("Change Rate"))
throw new PermissionException("Price Change not Allowed");
return;
var price = item.inventory.Price;
if (!GetInput("Price", ref price))
return;
@ -169,46 +114,14 @@ namespace Tanshu.Accounts.PointOfSale
throw new PermissionException("NC of Product is not Allowed");
foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.inventory.Product.ProductID))
sub.Value.inventory.Price = price;
ShowAmount();
}
public void ShowCustomers(bool reset)
public void ShowCustomers()
{
if (!reset && ((_voucher.Customer == null) || _voucher.Customer.CustomerID == Constants.CASH_CUSTOMER))
using (var frm = new CustomerListForm())
{
using (var selectCustomer = new SelectCustomer(CustomerBI.StaticList, true))
{
selectCustomer.CustomerEvent += selectCustomer_customerEvent;
selectCustomer.ShowDialog();
if (selectCustomer.SelectedItem != null)
{
_voucher.Customer = selectCustomer.SelectedItem;
}
else
{
using (var bi = new CustomerBI())
_voucher.Customer = bi.Get(x => x.CustomerID == Constants.CASH_CUSTOMER);
}
}
frm.ShowDialog();
_voucher.Customer = frm.SelectedItem;
}
else
{
using (var bi = new CustomerBI())
_voucher.Customer = bi.Get(x => x.CustomerID == Constants.CASH_CUSTOMER);
}
_saleForm.SetCustomerDisplay(_voucher.Customer.Name);
}
private Customer selectCustomer_customerEvent(object sender, CustomerEventArgs e)
{
using (var form = new CustomersForm(e.CustomerID, e.Phone))
{
form.ShowDialog();
return form.Customer;
}
}
private void ShowAmount()
{
_saleForm.ShowAmount(_bill.Discount, _bill.NetAmount, _bill.ServiceCharge, _bill.Tax, _bill.Amount, _bill);
}
private static bool IsPrintedOrVoid(Voucher voucher)
{
@ -236,13 +149,10 @@ namespace Tanshu.Accounts.PointOfSale
{
_voucher = bi.Get(x => x.VoucherID == voucherID);
_bill.Clear();
_saleForm.ShowInfo(_voucher);
_bill.Load(_voucher);
var newKotKey = new BillItemKey(Guid.Empty);
var newKotItem = new BillItemValue();
_bill.Add(newKotKey, newKotItem);
ShowAmount();
_saleForm.FormState = SaleFormState.Billing;
}
}
public void LoadBill(string tableName)
@ -261,37 +171,37 @@ namespace Tanshu.Accounts.PointOfSale
frm.ShowDialog();
_voucher.Table = table;
_voucher.Pax = frm.Pax;
_saleForm.ShowInfo(_voucher);
}
}
}
public void CancelBillChanges()
public bool CancelBillChanges()
{
if (_bill.Any(x => x.Key.BillItemType != BillItemType.Kot) &&
MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
return;
return false;
ClearBill();
return true;
}
public void ClearBill()
{
_voucher = new Voucher(Session.User);
ShowCustomers(true);
using (var bi = new CustomerBI())
_voucher = new Voucher(Session.User, bi.Get(x => x.CustomerID == Constants.CASH_CUSTOMER));
_bill.Clear();
var newKotKey = new BillItemKey(Guid.Empty);
var newKotItem = new BillItemValue();
_bill.Add(newKotKey, newKotItem);
_saleForm.ClearBill(_bill);
}
public SaleFormState FormLoad()
{
ClearBill();
if (_editVoucherID.HasValue)
{
FoodTable ft = new FoodTableBI().Get(x => x.VoucherID == _editVoucherID.Value);
if (ft == null)
{
LoadBill(_editVoucherID.Value);
}
else
{
_editVoucherID = null;
@ -301,10 +211,10 @@ namespace Tanshu.Accounts.PointOfSale
}
return SaleFormState.Waiting;
}
internal void SettleBill()
internal bool SettleBill()
{
if (_voucher.VoucherID == Guid.Empty || !_voucher.Printed || !Session.IsAllowed("Settle Bill"))
return;
return false;
IDictionary<SettleOption, decimal> options;
var amount = -1 * _voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
using (var frm = new SettleChoicesForm(Math.Round(amount) * -1, _voucher.VoucherType))
@ -313,7 +223,7 @@ namespace Tanshu.Accounts.PointOfSale
options = frm.OptionsChosen;
}
if (options.Count == 0)
return;
return false;
using (var bi = new VoucherBI())
{
bi.SettleVoucher(Session.User, _voucher.VoucherID, options);
@ -322,6 +232,7 @@ namespace Tanshu.Accounts.PointOfSale
bi.SaveChanges();
}
ClearBill();
return true;
}
#region Move Table(s) / Kot(s)
@ -338,11 +249,11 @@ namespace Tanshu.Accounts.PointOfSale
return null;
}
}
internal void MoveKot()
internal void MoveKot(BillItemKey currentKot)
{
if (_voucher.VoucherID == Guid.Empty || IsPrintedOrVoid(_voucher))
return;
var kot = CurrentKot;
var kot = currentKot;
if (kot == null)
return;
var table = GetTableForMove(true);
@ -368,7 +279,9 @@ namespace Tanshu.Accounts.PointOfSale
//Merge Table
voucherID = MergeTable(table);
if (voucherID != Guid.Empty)
{
LoadBill(voucherID);
}
}
internal void MoveTable()
{
@ -439,15 +352,31 @@ namespace Tanshu.Accounts.PointOfSale
#endregion
#region Save
public void SaveKot()
public bool SaveAndPrintKot()
{
#region Check if Allowed
if (!Session.IsAllowed("Print Kot"))
return;
if (!Session.IsAllowed("Print Kot") || _bill.Count(x => x.Key.BillItemType == BillItemType.Product) == 0)
return false;
bool isPrinted = false, isVoid = false;
if (_voucher.VoucherID != Guid.Empty)
using (var bi = new VoucherBI())
{
var dbVoucher = bi.Get(x => x.VoucherID == _voucher.VoucherID);
isPrinted = dbVoucher.Printed;
isVoid = dbVoucher.Void;
}
if (isVoid)
{
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _voucher.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
if (isPrinted)
{
MessageBox.Show(string.Format("This Bill is already printed and a kot cannot be added", _voucher.VoidReason), "Bill already Printed", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
if (_voucher.VoucherID != Guid.Empty && IsPrintedOrVoid(_voucher))
return;
if (_bill.Count == 1) //new kot only
return;
return false;
#endregion
//Save
@ -461,15 +390,16 @@ namespace Tanshu.Accounts.PointOfSale
if (_editVoucherID.HasValue)
_saleForm.CloseWindow();
else
{
ClearBill();
}
return true;
}
public void SaveBill()
public bool SaveAndPrintBill()
{
#region Check if Allowed
if (!Session.IsAllowed("Print Bill"))
return;
if (_bill.Count == 1) //new kot only
return;
if (!Session.IsAllowed("Print Bill") || _bill.Count(x => x.Key.BillItemType == BillItemType.Product) == 0)
return false;
bool isPrinted = false, isVoid = false;
if (_voucher.VoucherID != Guid.Empty)
using (var bi = new VoucherBI())
@ -481,10 +411,10 @@ namespace Tanshu.Accounts.PointOfSale
if (isVoid)
{
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _voucher.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
return false;
}
if (isPrinted && !Session.IsAllowed("Edit Printed Bill"))
return;
return false;
#endregion
var amount = _bill.NetAmount;
@ -501,15 +431,19 @@ namespace Tanshu.Accounts.PointOfSale
{
frm.ShowDialog();
if (!frm.Selection.HasValue)
return;
return false;
_voucher.VoucherType = frm.Selection.Value;
}
var saved = _voucher.VoucherID == Guid.Empty ? InsertVoucher(true, !_editVoucherID.HasValue) : UpdateVoucher(true, !_editVoucherID.HasValue);
if (_voucher.VoucherID == Guid.Empty)
InsertVoucher(true, !_editVoucherID.HasValue);
else
UpdateVoucher(true, !_editVoucherID.HasValue);
}
Thermal.PrintBill(_voucher.VoucherID);
if (_editVoucherID.HasValue)
_saleForm.CloseWindow();
ClearBill();
return true;
}
public void SplitBill()
{
@ -559,9 +493,8 @@ namespace Tanshu.Accounts.PointOfSale
return;
#region new voucherFirst
var voucherFirst = new Voucher(Session.User)
var voucherFirst = new Voucher(Session.User, _voucher.Customer)
{
Customer = _voucher.Customer,
Table = table,
Printed = isPrinted,
Void = false,
@ -575,9 +508,8 @@ namespace Tanshu.Accounts.PointOfSale
#endregion
#region new voucherSecond
var voucherSecond = new Voucher(Session.User)
var voucherSecond = new Voucher(Session.User, _voucher.Customer)
{
Customer = _voucher.Customer,
Table = _voucher.Table,
Printed = isPrinted,
Void = false,
@ -604,36 +536,31 @@ namespace Tanshu.Accounts.PointOfSale
}
LoadBill(voucherFirst.VoucherID);
}
public void VoidBill()
public bool VoidBill()
{
#region Check conditions and Permissions
if (_voucher.VoucherID == Guid.Empty)
return;
if (_voucher.Void)
return;
if (!Session.IsAllowed("Void Bill"))
return;
if (_voucher.VoucherID == Guid.Empty || _voucher.Void || !Session.IsAllowed("Void Bill"))
return false;
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
return;
return false;
#endregion
var voidReason = new SelectVoidReason(GetVoidReason, true);
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
{
using (var bi = new VoucherBI())
{
bi.VoidBill(_voucher.VoucherID, voidReason.SelectedItem.Description);
if (!_editVoucherID.HasValue)
bi.UpdateTable(x => x.FoodTableID == _voucher.Table.FoodTableID && x.VoucherID == _voucher.VoucherID, null, null);
bi.SaveChanges();
}
ClearBill();
}
else
{
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return false;
}
using (var bi = new VoucherBI())
{
bi.VoidBill(_voucher.VoucherID, voidReason.SelectedItem.Description);
if (!_editVoucherID.HasValue)
bi.UpdateTable(x => x.FoodTableID == _voucher.Table.FoodTableID && x.VoucherID == _voucher.VoucherID, null, null);
bi.SaveChanges();
}
ClearBill();
return true;
}
private static List<StringType> GetVoidReason(Dictionary<string, string> filter)
{
@ -658,9 +585,8 @@ namespace Tanshu.Accounts.PointOfSale
if (amountChanged || itemsChanged) // Discount or Products changed
{
#region new voucherFirst
var newVoucher = new Voucher(Session.User)
var newVoucher = new Voucher(Session.User, _voucher.Customer)
{
Customer = _voucher.Customer,
Table = _voucher.Table,
Printed = true,
Void = false,

@ -2,6 +2,7 @@
using Tanshu.Accounts.Contracts;
using Tanshu.Common;
using Tanshu.Accounts.Entities;
using System;
namespace Tanshu.Accounts.PointOfSale
{
@ -55,7 +56,7 @@ namespace Tanshu.Accounts.PointOfSale
{
get
{
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.Amount);
return Math.Round(this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.Amount));
}
}
}

@ -11,13 +11,7 @@ namespace Tanshu.Accounts.PointOfSale
{
public interface ISaleForm
{
void ClearBill(BillDict bill);
void SetCustomerDisplay(string name);
void CloseWindow();
void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, BillDict bill);
void ShowInfo(Voucher voucher);
void SetUserName(string name);
BindingSource BindingSource { get; }
SaleFormState FormState { set; }
}
}

@ -55,7 +55,7 @@ namespace Tanshu.Accounts.PointOfSale
private void btnCustomer_Click(object sender, EventArgs e)
{
using (var frm = new CustomersForm(null, ""))
using (var frm = new CustomerListForm())
frm.ShowDialog();
}

@ -1,6 +1,6 @@
 namespace Tanshu.Accounts.PointOfSale
{
partial class CustomersForm
partial class CustomerForm
{
/// <summary>
/// Required designer variable.
@ -180,7 +180,7 @@
this.txtUniqueID.Text = "UniqueID";
this.txtUniqueID.WordWrap = false;
//
// CustomersForm
// CustomerForm
//
this.AcceptButton = this.btnSave;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -204,10 +204,10 @@
this.Controls.Add(this.txtName);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CustomersForm";
this.Name = "CustomerForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Customers";
this.Load += new System.EventHandler(this.CustomersForm_Load);
this.Text = "Customer";
this.Load += new System.EventHandler(this.CustomerForm_Load);
this.ResumeLayout(false);
this.PerformLayout();

@ -7,19 +7,24 @@ using Tanshu.Accounts.Entities.Auth;
namespace Tanshu.Accounts.PointOfSale
{
public partial class CustomersForm : Form
public partial class CustomerForm : Form
{
private Guid? _customerID;
private Customer _customer;
private readonly string phone;
#region Form Load
public CustomersForm(Guid? customerID, string phone)
public CustomerForm(Guid? customerID)
{
InitializeComponent();
this._customerID = customerID;
}
public CustomerForm(Guid? customerID, string phone)
{
InitializeComponent();
this._customerID = customerID;
this.phone = phone;
}
private void CustomersForm_Load(object sender, EventArgs e)
private void CustomerForm_Load(object sender, EventArgs e)
{
if (_customerID.HasValue)
{

@ -0,0 +1,167 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class CustomerListForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.btnAdd = new System.Windows.Forms.Button();
this.btnEdit = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.dgvCustomers = new System.Windows.Forms.DataGridView();
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.phone = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.address = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bsList = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.dgvCustomers)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit();
this.SuspendLayout();
//
// btnAdd
//
this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnAdd.Location = new System.Drawing.Point(12, 255);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(75, 75);
this.btnAdd.TabIndex = 68;
this.btnAdd.Text = "&Add";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// btnEdit
//
this.btnEdit.AccessibleName = "Done";
this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnEdit.Location = new System.Drawing.Point(93, 255);
this.btnEdit.Name = "btnEdit";
this.btnEdit.Size = new System.Drawing.Size(75, 75);
this.btnEdit.TabIndex = 62;
this.btnEdit.Text = "&Edit";
this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
//
// btnExit
//
this.btnExit.AccessibleName = "Done";
this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnExit.Location = new System.Drawing.Point(575, 255);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(75, 75);
this.btnExit.TabIndex = 61;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// dgvCustomers
//
this.dgvCustomers.AllowUserToAddRows = false;
this.dgvCustomers.AllowUserToDeleteRows = false;
this.dgvCustomers.AllowUserToResizeRows = false;
this.dgvCustomers.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvCustomers.AutoGenerateColumns = false;
this.dgvCustomers.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dgvCustomers.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvCustomers.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.nameDataGridViewTextBoxColumn,
this.phone,
this.address});
this.dgvCustomers.DataSource = this.bsList;
this.dgvCustomers.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.dgvCustomers.Location = new System.Drawing.Point(12, 12);
this.dgvCustomers.MultiSelect = false;
this.dgvCustomers.Name = "dgvCustomers";
this.dgvCustomers.ReadOnly = true;
this.dgvCustomers.RowHeadersVisible = false;
this.dgvCustomers.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.dgvCustomers.RowTemplate.Height = 24;
this.dgvCustomers.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvCustomers.Size = new System.Drawing.Size(638, 237);
this.dgvCustomers.TabIndex = 74;
this.dgvCustomers.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvCustomers_CellDoubleClick);
//
// nameDataGridViewTextBoxColumn
//
this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name";
this.nameDataGridViewTextBoxColumn.HeaderText = "Name";
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
this.nameDataGridViewTextBoxColumn.ReadOnly = true;
this.nameDataGridViewTextBoxColumn.Width = 60;
//
// phone
//
this.phone.DataPropertyName = "Phone";
this.phone.HeaderText = "Phone";
this.phone.Name = "phone";
this.phone.ReadOnly = true;
this.phone.Width = 63;
//
// address
//
this.address.DataPropertyName = "Address";
this.address.HeaderText = "Address";
this.address.Name = "address";
this.address.ReadOnly = true;
this.address.Width = 70;
//
// bsList
//
this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.Customer);
//
// CustomerListForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(662, 342);
this.Controls.Add(this.dgvCustomers);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.btnEdit);
this.Controls.Add(this.btnExit);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CustomerListForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Customers";
this.Load += new System.EventHandler(this.CustomerListForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvCustomers)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit();
this.ResumeLayout(false);
}
#endregion
internal System.Windows.Forms.Button btnAdd;
internal System.Windows.Forms.Button btnEdit;
internal System.Windows.Forms.Button btnExit;
private System.Windows.Forms.DataGridView dgvCustomers;
private System.Windows.Forms.BindingSource bsList;
private System.Windows.Forms.DataGridViewTextBoxColumn Password;
private System.Windows.Forms.DataGridViewTextBoxColumn CustomerGroups;
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn phone;
private System.Windows.Forms.DataGridViewTextBoxColumn address;
}
}

@ -0,0 +1,74 @@
using System;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Repository;
using System.Collections.Generic;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
public partial class CustomerListForm : Form
{
private IList<Customer> _list;
public CustomerListForm()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
using (var frm = new CustomerForm(null))
frm.ShowDialog();
using (var bi = new CustomerBI())
_list = bi.List();
bsList.DataSource = _list;
}
private void CustomerListForm_Load(object sender, EventArgs e)
{
ShowGrid();
}
private void ShowGrid()
{
using (var bi = new CustomerBI())
_list = bi.List();
bsList.DataSource = _list;
}
private void btnEdit_Click(object sender, EventArgs e)
{
var id = ((Customer)bsList.Current).CustomerID;
using (var frm = new CustomerForm(id))
frm.ShowDialog();
using (var bi = new CustomerBI())
_list = bi.List();
bsList.DataSource = _list;
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
public Customer SelectedItem
{
get
{
if (bsList.Position >= 0)
{
var item = _list[bsList.Position];
if (item != null)
return item;
}
return _list.First(x => x.CustomerID == Constants.CASH_CUSTOMER);
}
}
private void dgvCustomers_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
this.Close();
}
}
}

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="phone.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="address.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bsList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

@ -44,7 +44,8 @@
// btnClose
//
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); this.btnClose.Location = new System.Drawing.Point(3, 3);
| System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.Location = new System.Drawing.Point(3, 3);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(480, 75);
this.btnClose.TabIndex = 7;
@ -66,6 +67,7 @@
this.Text = "Modifier";
this.Load += new System.EventHandler(this.ModifierForm_Load);
this.ResumeLayout(false);
}
#endregion

@ -27,17 +27,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales
Text = name;
}
public void SetCustomerDisplay(string name)
{
btnCustomer.Text = name;
}
public void ShowInfo(Voucher voucher)
private void ShowInfo(Voucher voucher, BillDict bill)
{
if (voucher.VoucherID == Guid.Empty)
{
txtTableID.Text = voucher.Table.Name;
txtPax.Text = voucher.Pax.ToString();
txtBillID.Text = "";
txtKotID.Text = "";
txtCreationDate.Text = "";
txtDate.Text = "";
txtLastEditDate.Text = "";
}
else
{
@ -46,15 +44,52 @@ namespace Tanshu.Accounts.PointOfSale.Sales
txtCreationDate.Text = voucher.CreationDate.ToString("HH:mm dd-MMM-yyyy");
txtDate.Text = voucher.Date.ToString("HH:mm dd-MMM-yyyy");
txtLastEditDate.Text = voucher.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
btnCustomer.Text = voucher.Customer.Name;
txtTableID.Text = voucher.Table.Name;
txtPax.Text = voucher.Pax.ToString();
}
btnCustomer.Text = voucher.Customer.Name;
txtTableID.Text = voucher.Table == null ? "" : voucher.Table.Name;
txtPax.Text = voucher.Pax.ToString();
bindingSource.CurrencyManager.Position = Math.Min(bindingSource.CurrencyManager.Position, bill.Count - 1);
txtGrossTax.Text = string.Format("{0:#0.00}", bill.Tax);
txtDiscount.Text = string.Format("{0:#0.00}", bill.Discount);
txtServiceCharge.Text = string.Format("{0:#0.00}", bill.ServiceCharge);
txtGrossAmount.Text = string.Format("{0:#0.00}", bill.NetAmount);
txtAmount.Text = string.Format("{0:#0.00}", bill.Amount);
bindingSource.DataSource = bill.ToList();
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
MoreButton(false);
}
public BillItemValue CurrentProduct
{
get
{
if (bindingSource.Position == -1)
return null;
var item = _billController._bill.ElementAt(bindingSource.Position);
return item.Key.BillItemType != BillItemType.Kot ? item.Value : null;
}
}
public BindingSource BindingSource
public BillItemKey CurrentKey
{
get { return bindingSource; }
get
{
if (bindingSource.Position == -1)
return null;
var item = _billController._bill.ElementAt(bindingSource.Position);
return item.Key;
}
}
public BillItemKey CurrentKot
{
get
{
if (bindingSource.Position == -1)
return null;
var item = _billController._bill.ElementAt(bindingSource.Position);
return item.Key.BillItemType == BillItemType.Kot ? item.Key : null;
}
}
public void CloseWindow()
@ -81,22 +116,17 @@ namespace Tanshu.Accounts.PointOfSale.Sales
case Keys.F4:
{
if (!e.Alt)
_billController.ShowCustomers(false);
break;
}
case Keys.F7:
{
//using (var selectProduct = new SelectProduct(ProductBI.GetFilteredProducts, true))
//{
// selectProduct.ShowDialog();
// if (selectProduct.SelectedItem != null)
// _billController.AddProduct(selectProduct.SelectedItem.ProductID);
//}
{
_billController.ShowCustomers();
ShowInfo(_billController._voucher, _billController._bill);
}
break;
}
case Keys.F8:
{
_billController.LoadBill(null);
ShowInfo(_billController._voucher, _billController._bill);
FormState = SaleFormState.Billing;
break;
}
case Keys.F11:
@ -111,18 +141,20 @@ namespace Tanshu.Accounts.PointOfSale.Sales
}
case Keys.Delete:
{
_billController.SetQuantity(-1, false);
//_billController.ProductRemove();
_billController.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_billController._voucher, _billController._bill);
break;
}
case Keys.Add:
{
_billController.SetQuantity(1, false);
_billController.SetQuantity(CurrentKey, CurrentProduct, 1, false);
ShowInfo(_billController._voucher, _billController._bill);
break;
}
case Keys.Subtract:
{
_billController.SetQuantity(-1, false);
_billController.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_billController._voucher, _billController._bill);
break;
}
case Keys.Up:
@ -139,7 +171,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
}
case Keys.Escape:
{
_billController.CancelBillChanges();
var canceled = _billController.CancelBillChanges();
ShowInfo(_billController._voucher, _billController._bill);
if (canceled)
FormState = SaleFormState.Waiting;
break;
}
}
@ -153,43 +188,41 @@ namespace Tanshu.Accounts.PointOfSale.Sales
txtServiceCharge.Visible = showSC;
lblServiceCharge.Visible = showSC;
}
_billController.FormLoad();
FormState = SaleFormState.Waiting;
_billController.ClearBill();
var state = _billController.FormLoad();
ShowInfo(_billController._voucher, _billController._bill);
FormState = state;
}
private void btnCustomer_Click(object sender, EventArgs e)
{
_billController.ShowCustomers(false);
_billController.ShowCustomers();
ShowInfo(_billController._voucher, _billController._bill);
}
private void btnVoid_Click(object sender, EventArgs e)
{
try
{
_billController.VoidBill();
}
catch (PermissionException ex)
{
MessageBox.Show(ex.Message);
}
var voided = _billController.VoidBill();
ShowInfo(_billController._voucher, _billController._bill);
if (voided)
FormState = SaleFormState.Waiting;
}
private void btnPrice_Click(object sender, EventArgs e)
{
try
{
_billController.SetPrice();
}
catch (Exception ex)
{
if (!(ex is ValidationException) && !(ex is PermissionException))
throw;
}
var item = CurrentProduct;
if (item == null)
return;
_billController.SetPrice(CurrentProduct);
ShowInfo(_billController._voucher, _billController._bill);
}
private void btnClear_Click(object sender, EventArgs e)
{
_billController.CancelBillChanges();
var canceled = _billController.CancelBillChanges();
ShowInfo(_billController._voucher, _billController._bill);
if (canceled)
FormState = SaleFormState.Waiting;
}
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
@ -225,22 +258,32 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnSettle_Click(object sender, EventArgs e)
{
_billController.SettleBill();
var settled = _billController.SettleBill();
ShowInfo(_billController._voucher, _billController._bill);
if (settled)
FormState = SaleFormState.Waiting;
}
private void btnModifier_Click(object sender, EventArgs e)
{
_billController.ShowModifiers();
var item = CurrentProduct;
if (item == null || CurrentKey.KotID != Guid.Empty)
return; // No Product or Old Product
_billController.ShowModifiers(item);
ShowInfo(_billController._voucher, _billController._bill);
}
private void btnDelete_Click(object sender, EventArgs e)
{
_billController.SetQuantity(-1, false);
_billController.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_billController._voucher, _billController._bill);
}
private void btnMoveTable_Click(object sender, EventArgs e)
{
_billController.MoveTable();
ShowInfo(_billController._voucher, _billController._bill);
}
private void btnMore_Click(object sender, EventArgs e)
@ -272,44 +315,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnMoveKot_Click(object sender, EventArgs e)
{
_billController.MoveKot();
_billController.MoveKot(CurrentKot);
ShowInfo(_billController._voucher, _billController._bill);
}
#region Helper Functions
public void ClearBill(BillDict bill)
{
txtBillID.Text = "";
txtKotID.Text = "";
txtCreationDate.Text = "";
txtDate.Text = "";
txtLastEditDate.Text = "";
txtTableID.Text = "";
txtPax.Text = "";
txtGrossTax.Text = "0.00";
txtDiscount.Text = "0.00";
txtServiceCharge.Text = "0.00";
txtGrossAmount.Text = "0.00";
txtAmount.Text = "0.00";
bindingSource.CurrencyManager.Position = 0; //Hack for Mono
bindingSource.DataSource = bill;
MoreButton(false);
FormState = SaleFormState.Waiting;
}
public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount,
decimal taxAmount, decimal valueAmount, BillDict bill)
{
txtGrossTax.Text = string.Format("{0:#0.00}", taxAmount);
txtDiscount.Text = string.Format("{0:#0.00}", discountAmount);
txtServiceCharge.Text = string.Format("{0:#0.00}", serviceChargeAmount);
txtGrossAmount.Text = string.Format("{0:#0.00}", grossAmount);
txtAmount.Text = string.Format("{0:#0.00}", Math.Round(valueAmount));
bindingSource.DataSource = bill.ToList();
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
}
public SaleFormState FormState
private SaleFormState FormState
{
set
{
@ -356,6 +368,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (item.IsNotAvailable)
return;
_billController.AddProduct(item);
bindingSource.DataSource = _billController._bill.ToList();
bindingSource.CurrencyManager.Position = _billController._bill.IndexOfKey(new BillItemKey(item.ProductID, Guid.Empty));
var showModifier = false;
using (var bi = new ProductGroupModifierBI())
showModifier = bi.HasCompulsoryModifier(CurrentProduct.inventory.Product.ProductGroup.ProductGroupID);
if (showModifier)
_billController.ShowModifiers(CurrentProduct);
ShowInfo(_billController._voucher, _billController._bill);
}
private void productPage_Click(object sender, EventArgs e)
@ -378,6 +399,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
var item = button.Tag as FoodTable;
var tableName = item.Name;
_billController.LoadBill(tableName);
ShowInfo(_billController._voucher, _billController._bill);
FormState = SaleFormState.Billing;
}
@ -394,30 +416,30 @@ namespace Tanshu.Accounts.PointOfSale.Sales
}
private void btnPrintBill_Click(object sender, EventArgs e)
{
_billController.SaveBill();
var printed = _billController.SaveAndPrintBill();
ShowInfo(_billController._voucher, _billController._bill);
if (printed)
FormState = SaleFormState.Waiting;
}
private void btnPrintKot_Click(object sender, EventArgs e)
{
_billController.SaveKot();
var printed = _billController.SaveAndPrintKot();
ShowInfo(_billController._voucher, _billController._bill);
if (printed)
FormState = SaleFormState.Waiting;
}
private void btnQuantity_Click(object sender, EventArgs e)
{
_billController.SetQuantity(0, true);
_billController.SetQuantity(CurrentKey, CurrentProduct, 0, true);
ShowInfo(_billController._voucher, _billController._bill);
}
private void btnDiscount_Click(object sender, EventArgs e)
{
try
{
_billController.SetDiscount();
}
catch (Exception ex)
{
if (!(ex is ValidationException) && !(ex is PermissionException))
throw;
}
_billController.SetDiscount();
ShowInfo(_billController._voucher, _billController._bill);
}
#endregion
@ -425,6 +447,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnSplitBill_Click(object sender, EventArgs e)
{
_billController.SplitBill();
ShowInfo(_billController._voucher, _billController._bill);
}
}
}

@ -195,6 +195,12 @@
<Compile Include="Masters\ReorderTableForm.Designer.cs">
<DependentUpon>ReorderTableForm.cs</DependentUpon>
</Compile>
<Compile Include="Sales\CustomerListForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Sales\CustomerListForm.Designer.cs">
<DependentUpon>CustomerListForm.cs</DependentUpon>
</Compile>
<Compile Include="Sales\VoucherTypeForm.cs">
<SubType>Form</SubType>
</Compile>
@ -256,11 +262,11 @@
<DependentUpon>CheckoutForm.cs</DependentUpon>
</Compile>
<Compile Include="CustomEnums.cs" />
<Compile Include="Sales\CustomersForm.cs">
<Compile Include="Sales\CustomerForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Sales\CustomersForm.Designer.cs">
<DependentUpon>CustomersForm.cs</DependentUpon>
<Compile Include="Sales\CustomerForm.Designer.cs">
<DependentUpon>CustomerForm.cs</DependentUpon>
</Compile>
<Compile Include="Authentication\LoginForm.cs">
<SubType>Form</SubType>
@ -372,6 +378,10 @@
<EmbeddedResource Include="Masters\ReorderTableForm.resx">
<DependentUpon>ReorderTableForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Sales\CustomerListForm.resx">
<DependentUpon>CustomerListForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Sales\VoucherTypeForm.resx">
<DependentUpon>VoucherTypeForm.cs</DependentUpon>
</EmbeddedResource>
@ -405,8 +415,8 @@
<DependentUpon>CheckoutForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Sales\CustomersForm.resx">
<DependentUpon>CustomersForm.cs</DependentUpon>
<EmbeddedResource Include="Sales\CustomerForm.resx">
<DependentUpon>CustomerForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Authentication\LoginForm.resx">

@ -7,18 +7,11 @@ namespace Tanshu.Accounts.Repository
{
public class CustomerBI : UnitOfWork<Customer>
{
public IList<Customer> List(Dictionary<string, string> filter)
public new IList<Customer> List()
{
return _session.QueryOver<Customer>()
.WhereRestrictionOn(x => x.Name).IsLike(string.Format("%{0}%", filter["Universal"]))
.OrderBy(x => x.Name).Asc
.List();
}
public static IList<Customer> StaticList(Dictionary<string, string> filter)
{
using (var bi = new CustomerBI())
{
return bi.List(filter);
}
}
}
}