Reprint and Printed bill editing logged.
Printed bill can no longer be changed, any changes voids the bill and prints a new one. Added option to Split Bill. Kot printed with right time. Numerous bug fixes.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -77,8 +77,9 @@ namespace Tanshu.Accounts.Contracts
|
|||||||
var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
|
var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
|
||||||
if (_discount != 0)
|
if (_discount != 0)
|
||||||
output += string.Format(" - {0:#.##%}", _discount);
|
output += string.Format(" - {0:#.##%}", _discount);
|
||||||
foreach (var item in Modifiers)
|
if (Modifiers != null)
|
||||||
output += string.Format("\n\r -- {0}", item.Name);
|
foreach (var item in Modifiers)
|
||||||
|
output += string.Format("\n\r -- {0}", item.Name);
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
//if (Price == 0)
|
//if (Price == 0)
|
||||||
@ -96,10 +97,45 @@ namespace Tanshu.Accounts.Contracts
|
|||||||
public IList<Modifier> Modifiers { get; set; }
|
public IList<Modifier> Modifiers { get; set; }
|
||||||
public BillItemValue(Product product)
|
public BillItemValue(Product product)
|
||||||
{
|
{
|
||||||
Quantity = 1;
|
|
||||||
Printed = false;
|
|
||||||
Modifiers = new List<Modifier>();
|
Modifiers = new List<Modifier>();
|
||||||
Product = product;
|
if (product != null)
|
||||||
|
{
|
||||||
|
Product = product;
|
||||||
|
ProductID = product.ProductID;
|
||||||
|
Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")";
|
||||||
|
Quantity = 1;
|
||||||
|
Price = product.SalePrice;
|
||||||
|
Tax = product.Tax.Rate;
|
||||||
|
ServiceCharge = product.ServiceCharge;
|
||||||
|
Discount = 0;
|
||||||
|
Printed = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
public BillItemValue()
|
||||||
|
{
|
||||||
|
Product = null;
|
||||||
|
ProductID = 0;
|
||||||
|
Discount = 0;
|
||||||
|
Name = "== New Kot ==";
|
||||||
|
Price = 0;
|
||||||
|
Printed = true;
|
||||||
|
Quantity = 0;
|
||||||
|
Tax = -1;
|
||||||
|
ServiceCharge = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BillItemValue(Kot kot)
|
||||||
|
{
|
||||||
|
Product = null;
|
||||||
|
ProductID = kot.KotID;
|
||||||
|
Discount = 0;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
13
Tanshu.Accounts.Contracts/Data Contracts/ReprintBO.cs
Normal file
13
Tanshu.Accounts.Contracts/Data Contracts/ReprintBO.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using Tanshu.Accounts.Entities.Auth;
|
||||||
|
|
||||||
|
namespace Tanshu.Accounts.Entities
|
||||||
|
{
|
||||||
|
public class Reprint
|
||||||
|
{
|
||||||
|
public virtual int ReprintID { get; set; }
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
public virtual DateTime Date { get; set; }
|
||||||
|
public virtual Voucher Voucher { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,27 +8,56 @@ namespace Tanshu.Accounts.Entities
|
|||||||
{
|
{
|
||||||
public class Voucher
|
public class Voucher
|
||||||
{
|
{
|
||||||
public Voucher()
|
protected Voucher()
|
||||||
{
|
{
|
||||||
Kots = new List<Kot>();
|
Kots = new List<Kot>();
|
||||||
Settlements = new List<VoucherSettlement>();
|
Settlements = new List<VoucherSettlement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int VoucherID { get; set; }
|
public Voucher(User user)
|
||||||
public virtual DateTime? Date { get; set; }
|
: this()
|
||||||
|
{
|
||||||
|
this._date = null;
|
||||||
|
this.User = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int _voucherID;
|
||||||
|
public virtual int VoucherID
|
||||||
|
{
|
||||||
|
get { return _voucherID; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DateTime? _date;
|
||||||
|
public virtual DateTime? Date
|
||||||
|
{
|
||||||
|
get { return _date; }
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string Narration { get; set; }
|
public virtual string Narration { get; set; }
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
|
protected DateTime _creationDate;
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public virtual DateTime CreationDate { get; set; }
|
public virtual DateTime CreationDate
|
||||||
|
{
|
||||||
|
get { return _creationDate; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DateTime _lastEditDate;
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public virtual DateTime LastEditDate { get; set; }
|
public virtual DateTime LastEditDate
|
||||||
|
{
|
||||||
|
get { return _lastEditDate; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected string _billID;
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public virtual string BillID { get; set; }
|
public virtual string BillID
|
||||||
|
{
|
||||||
|
get { return _billID; }
|
||||||
|
}
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public virtual string TableID { get; set; }
|
public virtual string TableID { get; set; }
|
||||||
@ -48,11 +77,33 @@ namespace Tanshu.Accounts.Entities
|
|||||||
[AllowNull]
|
[AllowNull]
|
||||||
public virtual string VoidReason { get; set; }
|
public virtual string VoidReason { get; set; }
|
||||||
|
|
||||||
[NotNull]
|
protected bool _printed;
|
||||||
public virtual bool Printed { get; set; }
|
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public virtual string KotID { get; set; }
|
public virtual bool Printed
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{ return _printed; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_printed)
|
||||||
|
return;
|
||||||
|
if (value == false)
|
||||||
|
return;
|
||||||
|
_date = null;
|
||||||
|
_printed = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
|
private string _kotID;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
|
[NotNull]
|
||||||
|
public virtual string KotID
|
||||||
|
{
|
||||||
|
get { return _kotID; }
|
||||||
|
}
|
||||||
|
|
||||||
[Cascade]
|
[Cascade]
|
||||||
public virtual IList<Kot> Kots { get; set; }
|
public virtual IList<Kot> Kots { get; set; }
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using Tanshu.Accounts.Entities;
|
||||||
|
|
||||||
|
namespace Tanshu.Common.Helpers
|
||||||
|
{
|
||||||
|
public enum VoucherFields
|
||||||
|
{
|
||||||
|
CreationDate,
|
||||||
|
LastEditDate,
|
||||||
|
Date,
|
||||||
|
BillID,
|
||||||
|
KotID
|
||||||
|
}
|
||||||
|
public static class ReflectionHelper
|
||||||
|
{
|
||||||
|
public static void SetValue(this Voucher voucher, VoucherFields field, object value)
|
||||||
|
{
|
||||||
|
var fi = typeof(Voucher).GetField(ConvertToCamelCaseUnderscore(field.ToString()), BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
if (fi != null)
|
||||||
|
fi.SetValue(voucher, value);
|
||||||
|
}
|
||||||
|
private static string ConvertToCamelCaseUnderscore(string propertyName)
|
||||||
|
{
|
||||||
|
return "_" + propertyName[0].ToString().ToLower() + propertyName.Substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -39,6 +39,7 @@ namespace Tanshu.Accounts.Contracts
|
|||||||
public static RoleConstants BILL_DETAILS = new RoleConstants("Sales/BillDetails");
|
public static RoleConstants BILL_DETAILS = new RoleConstants("Sales/BillDetails");
|
||||||
public static RoleConstants SALE_ANALYSIS = new RoleConstants("Sales/SaleAnalysis");
|
public static RoleConstants SALE_ANALYSIS = new RoleConstants("Sales/SaleAnalysis");
|
||||||
public static RoleConstants SALE_DETAIL = new RoleConstants("Sales/SaleDetail");
|
public static RoleConstants SALE_DETAIL = new RoleConstants("Sales/SaleDetail");
|
||||||
|
public static RoleConstants SPLIT_BILL = new RoleConstants("Split Bill");
|
||||||
public static RoleConstants VOID_BILL = new RoleConstants("Sales/VoidPrintedBill");
|
public static RoleConstants VOID_BILL = new RoleConstants("Sales/VoidPrintedBill");
|
||||||
public static RoleConstants ZERO_RATE = new RoleConstants("Sales/ZeroRate");
|
public static RoleConstants ZERO_RATE = new RoleConstants("Sales/ZeroRate");
|
||||||
public static RoleConstants SETTLE_BILL = new RoleConstants("Sales/SettleBill");
|
public static RoleConstants SETTLE_BILL = new RoleConstants("Sales/SettleBill");
|
||||||
|
|||||||
@ -93,6 +93,7 @@
|
|||||||
<Compile Include="Data Contracts\Auth\RoleGroup.cs" />
|
<Compile Include="Data Contracts\Auth\RoleGroup.cs" />
|
||||||
<Compile Include="Data Contracts\Auth\Group.cs" />
|
<Compile Include="Data Contracts\Auth\Group.cs" />
|
||||||
<Compile Include="Data Contracts\Auth\Role.cs" />
|
<Compile Include="Data Contracts\Auth\Role.cs" />
|
||||||
|
<Compile Include="Data Contracts\ReprintBO.cs" />
|
||||||
<Compile Include="Data Contracts\VoucherSettlementBO.cs" />
|
<Compile Include="Data Contracts\VoucherSettlementBO.cs" />
|
||||||
<Compile Include="Data Contracts\KotBO.cs" />
|
<Compile Include="Data Contracts\KotBO.cs" />
|
||||||
<Compile Include="Data Contracts\PaymentGroupBO.cs" />
|
<Compile Include="Data Contracts\PaymentGroupBO.cs" />
|
||||||
@ -114,6 +115,7 @@
|
|||||||
<Compile Include="Data Contracts Display\ProductDisplayBO.cs" />
|
<Compile Include="Data Contracts Display\ProductDisplayBO.cs" />
|
||||||
<Compile Include="Data Contracts Display\ProductDisplaySmallBO.cs" />
|
<Compile Include="Data Contracts Display\ProductDisplaySmallBO.cs" />
|
||||||
<Compile Include="Data Contracts\ProductGroupBO.cs" />
|
<Compile Include="Data Contracts\ProductGroupBO.cs" />
|
||||||
|
<Compile Include="Helper Functions\ReflectionHelper.cs" />
|
||||||
<Compile Include="Helper Functions\EnumHelper.cs" />
|
<Compile Include="Helper Functions\EnumHelper.cs" />
|
||||||
<Compile Include="nHibernate\IAuditable.cs" />
|
<Compile Include="nHibernate\IAuditable.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Tanshu.Accounts.Contracts;
|
using Tanshu.Accounts.Contracts;
|
||||||
using Tanshu.Accounts.Entities;
|
using Tanshu.Accounts.Entities;
|
||||||
using Tanshu.Accounts.Helpers;
|
using Tanshu.Accounts.Helpers;
|
||||||
using Tanshu.Accounts.PointOfSale.Sales;
|
|
||||||
using Tanshu.Accounts.Print;
|
using Tanshu.Accounts.Print;
|
||||||
using Tanshu.Accounts.Repository;
|
using Tanshu.Accounts.Repository;
|
||||||
using Tanshu.Common;
|
using Tanshu.Common;
|
||||||
@ -62,35 +60,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
this._saleForm.SetUserName(Session.User.Name);
|
this._saleForm.SetUserName(Session.User.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitComponents()
|
public void AddProduct(Product product)
|
||||||
{
|
|
||||||
InitModel();
|
|
||||||
InitView();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitView()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitModel()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddProductToGrid(Product product)
|
|
||||||
{
|
|
||||||
AddProduct(product);
|
|
||||||
using (var bi = new ProductGroupModifierBI(false))
|
|
||||||
if (bi.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
|
|
||||||
{
|
|
||||||
var item = CurrentProduct;
|
|
||||||
ShowModifiers(product.ProductGroup.ProductGroupID, item);
|
|
||||||
}
|
|
||||||
ShowAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddProduct(Product product)
|
|
||||||
{
|
{
|
||||||
var newKey = new BillItemKey(product.ProductID, 0);
|
var newKey = new BillItemKey(product.ProductID, 0);
|
||||||
|
|
||||||
@ -101,19 +71,10 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var billItemValue = new BillItemValue(product)
|
var billItemValue = new BillItemValue(product);
|
||||||
{
|
var old =
|
||||||
ProductID = product.ProductID,
|
_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID).
|
||||||
Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")",
|
FirstOrDefault();
|
||||||
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).FirstOrDefault();
|
|
||||||
if (old.Key != null)
|
if (old.Key != null)
|
||||||
{
|
{
|
||||||
billItemValue.Discount = old.Value.Discount;
|
billItemValue.Discount = old.Value.Discount;
|
||||||
@ -122,9 +83,16 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
_bill.Add(newKey, billItemValue);
|
_bill.Add(newKey, billItemValue);
|
||||||
_saleForm.BindingSource.DataSource = _bill.Values.ToList();
|
_saleForm.BindingSource.DataSource = _bill.Values.ToList();
|
||||||
_saleForm.BindingSource.CurrencyManager.Position = _saleForm.BindingSource.CurrencyManager.Count - 1;
|
_saleForm.BindingSource.CurrencyManager.Position = _saleForm.BindingSource.CurrencyManager.Count - 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
using (var bi = new ProductGroupModifierBI(false))
|
||||||
|
if (bi.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
|
||||||
|
{
|
||||||
|
var item = CurrentProduct;
|
||||||
|
ShowModifiers(product.ProductGroup.ProductGroupID, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ShowAmount();
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowModifiers(int productGroupID, BillItemValue item)
|
public void ShowModifiers(int productGroupID, BillItemValue item)
|
||||||
{
|
{
|
||||||
@ -172,6 +140,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
ShowAmount();
|
ShowAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowCustomerList(bool reset)
|
public void ShowCustomerList(bool reset)
|
||||||
{
|
{
|
||||||
if ((_customer.CustomerID == 1) && (!reset))
|
if ((_customer.CustomerID == 1) && (!reset))
|
||||||
@ -200,17 +169,30 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Customer selectCustomer_customerEvent(object sender, CustomerEventArgs e)
|
||||||
|
{
|
||||||
|
using (var form = new CustomersForm(e.CustomerID, e.Phone))
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
return form.Customer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void VoidBill()
|
public void VoidBill()
|
||||||
{
|
{
|
||||||
|
#region Check conditions and Permissions
|
||||||
if (_billInfo == null)
|
if (_billInfo == null)
|
||||||
return;
|
return;
|
||||||
if (!_billInfo.Printed)
|
//if (!_billInfo.Printed)
|
||||||
|
// return;
|
||||||
|
if (_billInfo.Void)
|
||||||
return;
|
return;
|
||||||
if (!Session.IsAllowed(RoleConstants.VOID_BILL))
|
if (!Session.IsAllowed(RoleConstants.VOID_BILL))
|
||||||
return;
|
return;
|
||||||
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo,
|
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
|
||||||
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
|
|
||||||
return;
|
return;
|
||||||
|
#endregion
|
||||||
|
|
||||||
var voidReason = new SelectVoidReason(GetVoidReason, true);
|
var voidReason = new SelectVoidReason(GetVoidReason, true);
|
||||||
voidReason.ShowDialog();
|
voidReason.ShowDialog();
|
||||||
if (voidReason.SelectedItem != null)
|
if (voidReason.SelectedItem != null)
|
||||||
@ -230,17 +212,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided",
|
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Customer selectCustomer_customerEvent(object sender, CustomerEventArgs e)
|
|
||||||
{
|
|
||||||
using (var form = new CustomersForm(e.CustomerID, e.Phone))
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
return form.Customer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,29 +234,26 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
|
|
||||||
private void ShowAmount()
|
private void ShowAmount()
|
||||||
{
|
{
|
||||||
//saleForm.BindingSource.CurrencyManager.Position = 1;
|
|
||||||
|
|
||||||
var taxAmount = _bill.Values.Sum(b => b.TaxAmount);
|
var taxAmount = _bill.Values.Sum(b => b.TaxAmount);
|
||||||
var discountAmount = _bill.Values.Sum(b => b.DiscountAmount);
|
var discountAmount = _bill.Values.Sum(b => b.DiscountAmount);
|
||||||
var grossAmount = _bill.Values.Sum(b => b.GrossAmount);
|
var grossAmount = _bill.Values.Sum(b => b.GrossAmount);
|
||||||
var valueAmount = _bill.Values.Sum(b => b.Value);
|
var valueAmount = _bill.Values.Sum(b => b.Value);
|
||||||
var serviceChargeAmount = _bill.Values.Sum(b => b.ServiceChargeAmount);
|
var serviceChargeAmount = _bill.Values.Sum(b => b.ServiceChargeAmount);
|
||||||
//bill.Values.ToList();
|
|
||||||
_saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount,
|
_saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount,
|
||||||
_bill.Values.ToList());
|
_bill.Values.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProductRemove()
|
//public void ProductRemove()
|
||||||
{
|
//{
|
||||||
var item = CurrentProduct;
|
// var item = CurrentProduct;
|
||||||
if (!Allowed(item))
|
// if (!Allowed(item))
|
||||||
return;
|
// return;
|
||||||
if (item.Printed)
|
// if (item.Printed)
|
||||||
return;
|
// return;
|
||||||
_bill.Remove(new BillItemKey(item.ProductID, 0));
|
// _bill.Remove(new BillItemKey(item.ProductID, 0));
|
||||||
_bill.ReCompact();
|
// _bill.ReCompact();
|
||||||
ShowAmount();
|
// ShowAmount();
|
||||||
}
|
//}
|
||||||
|
|
||||||
public void SetQuantity(decimal quantity, bool prompt)
|
public void SetQuantity(decimal quantity, bool prompt)
|
||||||
{
|
{
|
||||||
@ -324,9 +293,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
|
|
||||||
private bool Allowed(BillItemValue item, RoleConstants role)
|
private bool Allowed(BillItemValue item, RoleConstants role)
|
||||||
{
|
{
|
||||||
if (item == null)
|
return item != null && Session.IsAllowed(role);
|
||||||
return false;
|
|
||||||
return Session.IsAllowed(role);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Allowed(BillItemValue item)
|
private bool Allowed(BillItemValue item)
|
||||||
@ -344,67 +311,50 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
_bill.Clear();
|
_bill.Clear();
|
||||||
_billInfo = null;
|
_billInfo = null;
|
||||||
using (var bi = new VoucherBI(false))
|
using (var bi = new VoucherBI(false))
|
||||||
|
{
|
||||||
_billInfo = bi.Get(voucherID);
|
_billInfo = bi.Get(voucherID);
|
||||||
|
|
||||||
_customer = _billInfo.Customer;
|
_customer = _billInfo.Customer;
|
||||||
_saleForm.ShowInfo(_billInfo.BillID, _billInfo.KotID, _billInfo.CreationDate, _billInfo.Date.Value,
|
_saleForm.ShowInfo(_billInfo.BillID, _billInfo.KotID, _billInfo.CreationDate, _billInfo.Date.Value,
|
||||||
_billInfo.LastEditDate, _customer.Name, _billInfo.TableID, _billInfo.Waiter.WaiterID,
|
_billInfo.LastEditDate, _customer.Name, _billInfo.TableID, _billInfo.Waiter.WaiterID,
|
||||||
_billInfo.Waiter.Name);
|
_billInfo.Waiter.Name);
|
||||||
|
|
||||||
foreach (var kot in _billInfo.Kots)
|
foreach (var kot in _billInfo.Kots)
|
||||||
{
|
|
||||||
var kotKey = new BillItemKey(kot.KotID);
|
|
||||||
var kotItem = new BillItemValue(null)
|
|
||||||
{
|
|
||||||
ProductID = kot.KotID,
|
|
||||||
Discount = 0,
|
|
||||||
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);
|
|
||||||
foreach (var inv in kot.Inventories)
|
|
||||||
{
|
{
|
||||||
var key = new BillItemKey(inv.Product.ProductID, kot.KotID);
|
var kotKey = new BillItemKey(kot.KotID);
|
||||||
var item = new BillItemValue(inv.Product)
|
var kotItem = new BillItemValue(kot);
|
||||||
{
|
_bill.Add(kotKey, kotItem);
|
||||||
ProductID = inv.Product.ProductID,
|
foreach (var inv in kot.Inventories)
|
||||||
Discount = inv.Discount,
|
{
|
||||||
Name =
|
var key = new BillItemKey(inv.Product.ProductID, kot.KotID);
|
||||||
inv.Product.Units == string.Empty
|
var item = new BillItemValue(inv.Product)
|
||||||
? inv.Product.Name
|
{
|
||||||
: inv.Product.Name + " (" + inv.Product.Units + ")",
|
ProductID = inv.Product.ProductID,
|
||||||
Price = inv.Rate,
|
Discount = inv.Discount,
|
||||||
Printed = true,
|
Name =
|
||||||
Quantity = inv.Quantity,
|
inv.Product.Units == string.Empty
|
||||||
Tax = inv.Tax,
|
? inv.Product.Name
|
||||||
ServiceCharge = inv.ServiceCharge,
|
: inv.Product.Name + " (" + inv.Product.Units + ")",
|
||||||
};
|
Price = inv.Rate,
|
||||||
foreach (var mod in inv.InventoryModifier)
|
Printed = true,
|
||||||
item.Modifiers.Add(mod.Modifier);
|
Quantity = inv.Quantity,
|
||||||
_bill.Add(key, item);
|
Tax = inv.Tax,
|
||||||
|
ServiceCharge = inv.ServiceCharge,
|
||||||
|
};
|
||||||
|
foreach (var mod in inv.InventoryModifier)
|
||||||
|
item.Modifiers.Add(mod.Modifier);
|
||||||
|
_bill.Add(key, item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
var newKotKey = new BillItemKey(0);
|
||||||
|
var newKotItem = new BillItemValue();
|
||||||
|
_bill.Add(newKotKey, newKotItem);
|
||||||
|
ShowAmount();
|
||||||
|
_saleForm.FormState = SaleFormState.Billing;
|
||||||
}
|
}
|
||||||
var newKotKey = new BillItemKey(0);
|
|
||||||
var newKotItem = new BillItemValue(null)
|
|
||||||
{
|
|
||||||
ProductID = 0,
|
|
||||||
Discount = 0,
|
|
||||||
Name = "== New Kot ==",
|
|
||||||
Price = 0,
|
|
||||||
Printed = true,
|
|
||||||
Quantity = 0,
|
|
||||||
Tax = -1,
|
|
||||||
ServiceCharge = 0,
|
|
||||||
};
|
|
||||||
_bill.Add(newKotKey, newKotItem);
|
|
||||||
ShowAmount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadBillFromTable(string tableName)
|
public void LoadBill(string tableName)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(tableName))
|
if (!string.IsNullOrEmpty(tableName))
|
||||||
{
|
{
|
||||||
@ -420,7 +370,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
var result = "0";
|
var result = "0";
|
||||||
if (GetInput("Table Number", ref result))
|
if (GetInput("Table Number", ref result))
|
||||||
LoadBillFromTable(result);
|
LoadBill(result);
|
||||||
else
|
else
|
||||||
ClearBill();
|
ClearBill();
|
||||||
}
|
}
|
||||||
@ -441,19 +391,9 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
ShowCustomerList(true);
|
ShowCustomerList(true);
|
||||||
_bill.Clear();
|
_bill.Clear();
|
||||||
var newKotKey = new BillItemKey(0);
|
var newKotKey = new BillItemKey(0);
|
||||||
var newKotItem = new BillItemValue(null)
|
var newKotItem = new BillItemValue();
|
||||||
{
|
|
||||||
ProductID = 0,
|
|
||||||
Discount = 0,
|
|
||||||
Name = "== New Kot ==",
|
|
||||||
Price = 0,
|
|
||||||
Printed = true,
|
|
||||||
Quantity = 0,
|
|
||||||
Tax = -1,
|
|
||||||
ServiceCharge = 0,
|
|
||||||
};
|
|
||||||
_bill.Add(newKotKey, newKotItem);
|
_bill.Add(newKotKey, newKotItem);
|
||||||
_saleForm.ClearBill(_bill);
|
_saleForm.ClearBill(_bill.Values.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SaleFormState FormLoad()
|
public SaleFormState FormLoad()
|
||||||
@ -519,6 +459,8 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
var table = GetTableForMove(true);
|
var table = GetTableForMove(true);
|
||||||
if (table == null)
|
if (table == null)
|
||||||
return;
|
return;
|
||||||
|
if (_billInfo.TableID == table.Name)
|
||||||
|
return;
|
||||||
var kotCount = _bill.Keys.Count(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
|
var kotCount = _bill.Keys.Count(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
|
||||||
var voucherID = 0;
|
var voucherID = 0;
|
||||||
if (table.VoucherID == 0 && kotCount > 1)
|
if (table.VoucherID == 0 && kotCount > 1)
|
||||||
@ -553,16 +495,14 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
if (!Session.IsAllowed(RoleConstants.MOVE_KOT))
|
if (!Session.IsAllowed(RoleConstants.MOVE_KOT))
|
||||||
return 0;
|
return 0;
|
||||||
var voucher = new Voucher
|
var voucher = new Voucher(Session.User)
|
||||||
{
|
{
|
||||||
Customer = _billInfo.Customer,
|
Customer = _billInfo.Customer,
|
||||||
TableID = table.Name,
|
TableID = table.Name,
|
||||||
Waiter = _billInfo.Waiter,
|
Waiter = _billInfo.Waiter,
|
||||||
Printed = false,
|
Printed = _billInfo.Printed,
|
||||||
Void = false,
|
Void = false,
|
||||||
Date = DateTime.Now,
|
|
||||||
Narration = "",
|
Narration = "",
|
||||||
User = Session.User
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using (var session = SessionManager.Session)
|
using (var session = SessionManager.Session)
|
||||||
@ -600,6 +540,8 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
if (!Session.IsAllowed(RoleConstants.MERGE_TABLE))
|
if (!Session.IsAllowed(RoleConstants.MERGE_TABLE))
|
||||||
return 0;
|
return 0;
|
||||||
|
if (_billInfo.Printed)
|
||||||
|
return 0;
|
||||||
var kots = _bill.Keys.Where(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
|
var kots = _bill.Keys.Where(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
|
||||||
foreach (var item in kots)
|
foreach (var item in kots)
|
||||||
MergeKot(item, table);
|
MergeKot(item, table);
|
||||||
@ -614,13 +556,26 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
if (!Session.IsAllowed(RoleConstants.PRINT_BILL))
|
if (!Session.IsAllowed(RoleConstants.PRINT_BILL))
|
||||||
return;
|
return;
|
||||||
using (var bi = new VoucherBI(false))
|
|
||||||
if ((_billInfo != null) && (bi.IsVoucherPrinted(_billInfo.VoucherID)) && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
|
|
||||||
return;
|
|
||||||
if (_bill.Count == 1) //new kot only
|
if (_bill.Count == 1) //new kot only
|
||||||
return;
|
return;
|
||||||
|
if (_billInfo.Void) //voided bills not allowed
|
||||||
|
{
|
||||||
|
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _billInfo.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var printed = false;
|
||||||
|
if (_billInfo != null)
|
||||||
|
using (var bi = new VoucherBI(false))
|
||||||
|
printed = bi.IsVoucherPrinted(_billInfo.VoucherID);
|
||||||
|
if (printed && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
|
||||||
|
return;
|
||||||
|
var amount = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0).Sum(x => x.Value.GrossAmount);
|
||||||
ShowDiscount();
|
ShowDiscount();
|
||||||
var saved = _billInfo == null ? InsertVoucher(true, waiterID, tableID, !_editVoucherID.HasValue) : UpdateVoucher(true, waiterID, tableID, !_editVoucherID.HasValue);
|
if (printed)
|
||||||
|
SaveReprintOrDiscountBill(waiterID, tableID, amount);
|
||||||
|
else
|
||||||
|
SaveNewBill(waiterID, tableID);
|
||||||
|
|
||||||
if (!_editVoucherID.HasValue || _print)
|
if (!_editVoucherID.HasValue || _print)
|
||||||
Thermal.PrintBill(_billInfo.VoucherID);
|
Thermal.PrintBill(_billInfo.VoucherID);
|
||||||
@ -628,13 +583,72 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
_saleForm.CloseWindow();
|
_saleForm.CloseWindow();
|
||||||
ClearBill();
|
ClearBill();
|
||||||
}
|
}
|
||||||
|
public void SaveNewBill(int waiterID, string tableID)
|
||||||
|
{
|
||||||
|
var saved = _billInfo == null
|
||||||
|
? InsertVoucher(true, waiterID, tableID, !_editVoucherID.HasValue)
|
||||||
|
: UpdateVoucher(true, waiterID, tableID, !_editVoucherID.HasValue);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void SaveReprintOrDiscountBill(int waiterID, string tableID, decimal oldAmount)
|
||||||
|
{
|
||||||
|
var amountChanged = oldAmount != _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0).Sum(x => x.Value.GrossAmount);
|
||||||
|
var itemsChanged = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == 0).Count() != 0;
|
||||||
|
if (amountChanged || itemsChanged) // Discount or Products changed
|
||||||
|
{
|
||||||
|
#region new voucherFirst
|
||||||
|
var voucherNew = new Voucher(Session.User)
|
||||||
|
{
|
||||||
|
Customer = _billInfo.Customer,
|
||||||
|
TableID = _billInfo.TableID,
|
||||||
|
Waiter = _billInfo.Waiter,
|
||||||
|
Printed = true,
|
||||||
|
Void = false,
|
||||||
|
Narration = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
var kotNew = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product));
|
||||||
|
if (kotNew != null)
|
||||||
|
voucherNew.Kots.Add(kotNew);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Old Voucher
|
||||||
|
_billInfo.User = Session.User;
|
||||||
|
_billInfo.Void = true;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
using (var session = SessionManager.Session)
|
||||||
|
{
|
||||||
|
using (var trans = session.BeginTransaction())
|
||||||
|
{
|
||||||
|
using (var bi = new VoucherBI(session, false))
|
||||||
|
{
|
||||||
|
bi.Insert(voucherNew);
|
||||||
|
_billInfo.VoidReason = string.Format("Bill Discounted / Changed. New Bill ID is {0}", voucherNew.BillID);
|
||||||
|
bi.Update(_billInfo);
|
||||||
|
}
|
||||||
|
using (var ft = new FoodTableBI(session, false))
|
||||||
|
ft.UpdateStatus(voucherNew);
|
||||||
|
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LoadBill(voucherNew.VoucherID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (var bi = new ReprintBI())
|
||||||
|
bi.Insert(new Reprint() { Date = DbValues.Date, User = Session.User, Voucher = _billInfo });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveKot(int waiterID, string tableID)
|
public void SaveKot(int waiterID, string tableID)
|
||||||
{
|
{
|
||||||
if (!Session.IsAllowed(RoleConstants.PRINT_KOT))
|
if (!Session.IsAllowed(RoleConstants.PRINT_KOT))
|
||||||
return;
|
return;
|
||||||
using (var bi = new VoucherBI(false))
|
using (var bi = new VoucherBI(false)) // Kot on printed bill not allowed
|
||||||
if ((_billInfo != null) && (bi.IsVoucherPrinted(_billInfo.VoucherID)) && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
|
if ((_billInfo != null) && (bi.IsVoucherPrinted(_billInfo.VoucherID)))
|
||||||
return;
|
return;
|
||||||
if (_bill.Count == 1) //new kot only
|
if (_bill.Count == 1) //new kot only
|
||||||
return;
|
return;
|
||||||
@ -655,7 +669,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
MessageBox.Show("Error in InsertVoucher, there is a previous sale in memory", "Error");
|
MessageBox.Show("Error in InsertVoucher, there is a previous sale in memory", "Error");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_billInfo = new Voucher
|
_billInfo = new Voucher(Session.User)
|
||||||
{
|
{
|
||||||
Customer = _customer,
|
Customer = _customer,
|
||||||
//Paid = finalBill,
|
//Paid = finalBill,
|
||||||
@ -663,12 +677,10 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
Waiter = WaiterBI.GetWaiter(waiterID),
|
Waiter = WaiterBI.GetWaiter(waiterID),
|
||||||
Printed = finalBill,
|
Printed = finalBill,
|
||||||
Void = false,
|
Void = false,
|
||||||
Date = DateTime.Now,
|
|
||||||
Narration = "",
|
Narration = "",
|
||||||
User = Session.User
|
|
||||||
};
|
};
|
||||||
UpdateKots();
|
UpdateKots();
|
||||||
var kot = GetKotForBill();
|
var kot = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == 0 && x.Value.Quantity != 0));
|
||||||
if (kot != null)
|
if (kot != null)
|
||||||
_billInfo.Kots.Add(kot);
|
_billInfo.Kots.Add(kot);
|
||||||
using (var session = SessionManager.Session)
|
using (var session = SessionManager.Session)
|
||||||
@ -691,15 +703,20 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
_billInfo.User = Session.User;
|
_billInfo.User = Session.User;
|
||||||
_billInfo.Customer = _customer;
|
_billInfo.Customer = _customer;
|
||||||
if (!_billInfo.Printed && finalBill)
|
|
||||||
_billInfo.Date = null;
|
|
||||||
_billInfo.Printed = _billInfo.Printed || finalBill;
|
|
||||||
_billInfo.TableID = tableID;
|
_billInfo.TableID = tableID;
|
||||||
_billInfo.Waiter = WaiterBI.GetWaiter(waiterID);
|
_billInfo.Waiter = WaiterBI.GetWaiter(waiterID);
|
||||||
|
|
||||||
UpdateKots();
|
UpdateKots();
|
||||||
var kot = GetKotForBill();
|
if (!_billInfo.Printed)
|
||||||
if (kot != null)
|
{
|
||||||
_billInfo.Kots.Add(kot);
|
var kot = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == 0 && x.Value.Quantity != 0));
|
||||||
|
if (kot != null)
|
||||||
|
_billInfo.Kots.Add(kot);
|
||||||
|
}
|
||||||
|
|
||||||
|
_billInfo.Printed = finalBill;
|
||||||
|
|
||||||
using (var session = SessionManager.Session)
|
using (var session = SessionManager.Session)
|
||||||
{
|
{
|
||||||
using (var trans = session.BeginTransaction())
|
using (var trans = session.BeginTransaction())
|
||||||
@ -725,24 +742,35 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
i.Rate = item.Value.Price;
|
i.Rate = item.Value.Price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private Kot GetKotForBill()
|
private static Kot GetKot(IEnumerable<KeyValuePair<BillItemKey, BillItemValue>> list)
|
||||||
{
|
{
|
||||||
var kot = new Kot();
|
var kot = new Kot();
|
||||||
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == 0 && x.Value.Quantity != 0))
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
var inv = new Inventory
|
var oldInv = kot.Inventories.SingleOrDefault(x => x.Product.ProductID == item.Key.ProductID);
|
||||||
{
|
if (oldInv != null)
|
||||||
Product = item.Value.Product,
|
{
|
||||||
Quantity = item.Value.Quantity,
|
oldInv.Quantity += item.Value.Quantity;
|
||||||
Rate = item.Value.Price,
|
if (oldInv.Quantity == 0)
|
||||||
Discount = item.Value.Discount,
|
kot.Inventories.Remove(oldInv);
|
||||||
ServiceCharge = item.Value.ServiceCharge,
|
}
|
||||||
Tax = item.Value.Tax
|
else
|
||||||
};
|
{
|
||||||
foreach (var mod in item.Value.Modifiers)
|
var inv = new Inventory
|
||||||
inv.InventoryModifier.Add(new InventoryModifier { Modifier = mod });
|
{
|
||||||
kot.Inventories.Add(inv);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return kot.Inventories.Count == 0 ? null : kot;
|
return kot.Inventories.Count == 0 ? null : kot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,5 +797,108 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void SplitBill()
|
||||||
|
{
|
||||||
|
#region Permissions
|
||||||
|
if (_billInfo == null || _billInfo.VoucherID == 0 || _billInfo.Void == true)
|
||||||
|
return; // must be existing non void bill
|
||||||
|
|
||||||
|
if (!Session.IsAllowed(RoleConstants.SPLIT_BILL))
|
||||||
|
return;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
bool printed;
|
||||||
|
using (var bi = new VoucherBI(false))
|
||||||
|
printed = bi.IsVoucherPrinted(_billInfo.VoucherID);
|
||||||
|
|
||||||
|
#region Get Move List
|
||||||
|
HashSet<string> splitList = null;
|
||||||
|
using (var bi = new ProductGroupBI())
|
||||||
|
{
|
||||||
|
using (var frm = new DiscountForm(bi.GetProductGroupTypes()))
|
||||||
|
if (frm.ShowDialog() == DialogResult.OK)
|
||||||
|
frm.Selection(out splitList);
|
||||||
|
}
|
||||||
|
if (splitList == null || splitList.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var listFirst = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0 && splitList.Contains(x.Value.Product.ProductGroup.GroupType));
|
||||||
|
var listSecond = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0 && !splitList.Contains(x.Value.Product.ProductGroup.GroupType));
|
||||||
|
|
||||||
|
if (listFirst.Count() == 0 || listSecond.Count() == 0)
|
||||||
|
return; // all or none items selected to be moved
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
var table = GetTableForMove(false);
|
||||||
|
if (table == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#region new voucherFirst
|
||||||
|
var voucherFirst = new Voucher(Session.User)
|
||||||
|
{
|
||||||
|
Customer = _billInfo.Customer,
|
||||||
|
TableID = table.Name,
|
||||||
|
Waiter = _billInfo.Waiter,
|
||||||
|
Printed = printed,
|
||||||
|
Void = false,
|
||||||
|
Narration = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
var kotFirst = GetKot(listFirst);
|
||||||
|
if (kotFirst != null)
|
||||||
|
voucherFirst.Kots.Add(kotFirst);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region new voucherFirst
|
||||||
|
var voucherSecond = new Voucher(Session.User)
|
||||||
|
{
|
||||||
|
Customer = _billInfo.Customer,
|
||||||
|
TableID = _billInfo.TableID,
|
||||||
|
Waiter = _billInfo.Waiter,
|
||||||
|
Printed = printed,
|
||||||
|
Void = false,
|
||||||
|
Narration = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
var kotSecond = GetKot(listSecond);
|
||||||
|
if (kotSecond != null)
|
||||||
|
voucherSecond.Kots.Add(kotSecond);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Old Voucher
|
||||||
|
_billInfo.User = Session.User;
|
||||||
|
_billInfo.Void = true;
|
||||||
|
_billInfo.VoidReason = "Printed bill Split";
|
||||||
|
#endregion
|
||||||
|
using (var session = SessionManager.Session)
|
||||||
|
{
|
||||||
|
var trans = session.BeginTransaction();
|
||||||
|
using (var bi = new VoucherBI(session, false))
|
||||||
|
bi.Insert(voucherFirst);
|
||||||
|
trans.Commit();
|
||||||
|
trans = session.BeginTransaction();
|
||||||
|
using (var bi = new VoucherBI(session, false))
|
||||||
|
bi.Insert(voucherSecond);
|
||||||
|
trans.Commit();
|
||||||
|
trans = session.BeginTransaction();
|
||||||
|
using (var bi = new VoucherBI(session, false))
|
||||||
|
bi.Update(_billInfo);
|
||||||
|
trans.Commit();
|
||||||
|
trans = session.BeginTransaction();
|
||||||
|
using (var ft = new FoodTableBI(session, false))
|
||||||
|
ft.UpdateStatus(voucherFirst);
|
||||||
|
using (var ft = new FoodTableBI(session, false))
|
||||||
|
ft.UpdateStatus(voucherSecond);
|
||||||
|
trans.Commit();
|
||||||
|
trans.Dispose();
|
||||||
|
}
|
||||||
|
if (printed)
|
||||||
|
{
|
||||||
|
Thermal.PrintBill(voucherFirst.VoucherID);
|
||||||
|
Thermal.PrintBill(voucherSecond.VoucherID);
|
||||||
|
}
|
||||||
|
LoadBill(voucherFirst.VoucherID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,12 +10,13 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
public interface ISaleForm
|
public interface ISaleForm
|
||||||
{
|
{
|
||||||
void ClearBill(OrderedDictionary<BillItemKey, BillItemValue> bill);
|
void ClearBill(List<BillItemValue> bill);
|
||||||
void SetCustomerDisplay(string name);
|
void SetCustomerDisplay(string name);
|
||||||
void CloseWindow();
|
void CloseWindow();
|
||||||
void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List<BillItemValue> 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 ShowInfo(string billID, string kotID, DateTime creationDate, DateTime date, DateTime lastEditDate, string customer, string tableID, int waiterID, string waiter);
|
||||||
void SetUserName(string name);
|
void SetUserName(string name);
|
||||||
BindingSource BindingSource { get; }
|
BindingSource BindingSource { get; }
|
||||||
|
SaleFormState FormState { set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -213,10 +213,10 @@
|
|||||||
internal System.Windows.Forms.Button btnExit;
|
internal System.Windows.Forms.Button btnExit;
|
||||||
private System.Windows.Forms.DataGridView dgvProductTypes;
|
private System.Windows.Forms.DataGridView dgvProductTypes;
|
||||||
private System.Windows.Forms.BindingSource bsList;
|
private System.Windows.Forms.BindingSource bsList;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn discountLimitDataGridViewTextBoxColumn;
|
//private System.Windows.Forms.DataGridViewTextBoxColumn discountLimitDataGridViewTextBoxColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn groupTypeDataGridViewTextBoxColumn;
|
//private System.Windows.Forms.DataGridViewTextBoxColumn groupTypeDataGridViewTextBoxColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn productGroupDataGridViewTextBoxColumn;
|
//private System.Windows.Forms.DataGridViewTextBoxColumn productGroupDataGridViewTextBoxColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn taxDataGridViewTextBoxColumn;
|
//private System.Windows.Forms.DataGridViewTextBoxColumn taxDataGridViewTextBoxColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
|
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn unitsDataGridViewTextBoxColumn;
|
private System.Windows.Forms.DataGridViewTextBoxColumn unitsDataGridViewTextBoxColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn Tax;
|
private System.Windows.Forms.DataGridViewTextBoxColumn Tax;
|
||||||
|
|||||||
@ -32,8 +32,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
this.label7 = new System.Windows.Forms.Label();
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
this.txtDiscount = new System.Windows.Forms.TextBox();
|
this.txtDiscount = new System.Windows.Forms.TextBox();
|
||||||
this.Label12 = new System.Windows.Forms.Label();
|
this.Label12 = new System.Windows.Forms.Label();
|
||||||
@ -81,6 +81,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.btnCustomer = new System.Windows.Forms.Button();
|
this.btnCustomer = new System.Windows.Forms.Button();
|
||||||
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
|
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
|
||||||
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
|
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
|
||||||
|
this.btnSplitBill = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
|
||||||
this.pnlBilling.SuspendLayout();
|
this.pnlBilling.SuspendLayout();
|
||||||
@ -204,15 +205,14 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.dgvProducts.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
this.dgvProducts.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||||
this.dgvProducts.Size = new System.Drawing.Size(372, 412);
|
this.dgvProducts.Size = new System.Drawing.Size(372, 412);
|
||||||
this.dgvProducts.TabIndex = 0;
|
this.dgvProducts.TabIndex = 0;
|
||||||
this.dgvProducts.VirtualMode = true;
|
|
||||||
this.dgvProducts.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvProducts_CellFormatting);
|
this.dgvProducts.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvProducts_CellFormatting);
|
||||||
//
|
//
|
||||||
// Display
|
// Display
|
||||||
//
|
//
|
||||||
this.Display.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
this.Display.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||||
this.Display.DataPropertyName = "Display";
|
this.Display.DataPropertyName = "Display";
|
||||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
this.Display.DefaultCellStyle = dataGridViewCellStyle1;
|
this.Display.DefaultCellStyle = dataGridViewCellStyle3;
|
||||||
this.Display.HeaderText = "Display";
|
this.Display.HeaderText = "Display";
|
||||||
this.Display.MinimumWidth = 250;
|
this.Display.MinimumWidth = 250;
|
||||||
this.Display.Name = "Display";
|
this.Display.Name = "Display";
|
||||||
@ -223,9 +223,9 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
//
|
//
|
||||||
this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||||
this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
|
this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
|
||||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
|
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
|
||||||
dataGridViewCellStyle2.Format = "N2";
|
dataGridViewCellStyle4.Format = "N2";
|
||||||
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2;
|
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4;
|
||||||
this.printedDataGridViewTextBoxColumn.HeaderText = "Printed";
|
this.printedDataGridViewTextBoxColumn.HeaderText = "Printed";
|
||||||
this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn";
|
this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn";
|
||||||
this.printedDataGridViewTextBoxColumn.ReadOnly = true;
|
this.printedDataGridViewTextBoxColumn.ReadOnly = true;
|
||||||
@ -306,6 +306,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.flpActions.Controls.Add(this.btnSettle);
|
this.flpActions.Controls.Add(this.btnSettle);
|
||||||
this.flpActions.Controls.Add(this.btnMore);
|
this.flpActions.Controls.Add(this.btnMore);
|
||||||
this.flpActions.Controls.Add(this.btnMoveKot);
|
this.flpActions.Controls.Add(this.btnMoveKot);
|
||||||
|
this.flpActions.Controls.Add(this.btnSplitBill);
|
||||||
this.flpActions.Dock = System.Windows.Forms.DockStyle.Bottom;
|
this.flpActions.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.flpActions.Location = new System.Drawing.Point(0, 607);
|
this.flpActions.Location = new System.Drawing.Point(0, 607);
|
||||||
this.flpActions.Name = "flpActions";
|
this.flpActions.Name = "flpActions";
|
||||||
@ -594,6 +595,16 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
//
|
//
|
||||||
this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBills);
|
this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBills);
|
||||||
//
|
//
|
||||||
|
// btnSplitBill
|
||||||
|
//
|
||||||
|
this.btnSplitBill.Location = new System.Drawing.Point(165, 84);
|
||||||
|
this.btnSplitBill.Name = "btnSplitBill";
|
||||||
|
this.btnSplitBill.Size = new System.Drawing.Size(75, 75);
|
||||||
|
this.btnSplitBill.TabIndex = 161;
|
||||||
|
this.btnSplitBill.Text = "Split Bill";
|
||||||
|
this.btnSplitBill.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSplitBill.Click += new System.EventHandler(this.btnSplitBill_Click);
|
||||||
|
//
|
||||||
// SalesForm
|
// SalesForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
@ -670,6 +681,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private System.Windows.Forms.Button btnMore;
|
private System.Windows.Forms.Button btnMore;
|
||||||
private System.Windows.Forms.Button btnMoveKot;
|
private System.Windows.Forms.Button btnMoveKot;
|
||||||
private readonly BillController _billController;
|
private readonly BillController _billController;
|
||||||
|
private System.Windows.Forms.Button btnSplitBill;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,13 +99,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
//{
|
//{
|
||||||
// selectProduct.ShowDialog();
|
// selectProduct.ShowDialog();
|
||||||
// if (selectProduct.SelectedItem != null)
|
// if (selectProduct.SelectedItem != null)
|
||||||
// _billController.AddProductToGrid(selectProduct.SelectedItem.ProductID);
|
// _billController.AddProduct(selectProduct.SelectedItem.ProductID);
|
||||||
//}
|
//}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Keys.F8:
|
case Keys.F8:
|
||||||
{
|
{
|
||||||
_billController.LoadBillFromTable(null);
|
_billController.LoadBill(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Keys.F11:
|
case Keys.F11:
|
||||||
@ -120,7 +120,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
}
|
}
|
||||||
case Keys.Delete:
|
case Keys.Delete:
|
||||||
{
|
{
|
||||||
_billController.ProductRemove();
|
_billController.SetQuantity(-1, false);
|
||||||
|
//_billController.ProductRemove();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Keys.Add:
|
case Keys.Add:
|
||||||
@ -156,7 +157,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private void SalesForm_Load(object sender, EventArgs e)
|
private void SalesForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_billController.FormLoad();
|
_billController.FormLoad();
|
||||||
ChangeFormState(SaleFormState.Waiting);
|
FormState = SaleFormState.Waiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCustomer_Click(object sender, EventArgs e)
|
private void btnCustomer_Click(object sender, EventArgs e)
|
||||||
@ -276,6 +277,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private void btnMoveTable_Click(object sender, EventArgs e)
|
private void btnMoveTable_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_billController.MoveTable();
|
_billController.MoveTable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnMore_Click(object sender, EventArgs e)
|
private void btnMore_Click(object sender, EventArgs e)
|
||||||
@ -300,6 +302,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
btnMoveTable.Visible = more;
|
btnMoveTable.Visible = more;
|
||||||
btnMoveKot.Visible = more;
|
btnMoveKot.Visible = more;
|
||||||
btnVoid.Visible = more;
|
btnVoid.Visible = more;
|
||||||
|
btnSplitBill.Visible = more;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnMoveKot_Click(object sender, EventArgs e)
|
private void btnMoveKot_Click(object sender, EventArgs e)
|
||||||
@ -309,7 +312,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
|
|
||||||
#region Helper Functions
|
#region Helper Functions
|
||||||
|
|
||||||
public void ClearBill(OrderedDictionary<BillItemKey, BillItemValue> bill)
|
public void ClearBill(List<BillItemValue> bill)
|
||||||
{
|
{
|
||||||
txtBillID.Text = "";
|
txtBillID.Text = "";
|
||||||
txtKotID.Text = "";
|
txtKotID.Text = "";
|
||||||
@ -324,9 +327,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
txtServiceCharge.Text = "0.00";
|
txtServiceCharge.Text = "0.00";
|
||||||
txtGrossAmount.Text = "0.00";
|
txtGrossAmount.Text = "0.00";
|
||||||
txtAmount.Text = "0.00";
|
txtAmount.Text = "0.00";
|
||||||
bindingSource.DataSource = bill.Values;
|
bindingSource.CurrencyManager.Position = 0; //Hack for Mono
|
||||||
|
bindingSource.DataSource = bill;
|
||||||
MoreButton(false);
|
MoreButton(false);
|
||||||
ChangeFormState(SaleFormState.Waiting);
|
FormState = SaleFormState.Waiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount,
|
public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount,
|
||||||
@ -341,15 +345,19 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
|
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeFormState(SaleFormState state)
|
public SaleFormState FormState
|
||||||
{
|
{
|
||||||
flpGroup.Controls.Clear();
|
set
|
||||||
flpMain.Controls.Clear();
|
{
|
||||||
if (state == SaleFormState.Billing)
|
flpGroup.Controls.Clear();
|
||||||
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, _productGroupList, productTypeButton_Click);
|
flpMain.Controls.Clear();
|
||||||
else
|
if (value == SaleFormState.Billing)
|
||||||
using (var bi = new FoodTableBI())
|
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, _productGroupList, productTypeButton_Click);
|
||||||
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(), tableButton_Click);
|
else
|
||||||
|
using (var bi = new FoodTableBI())
|
||||||
|
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(), tableButton_Click);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void productTypeButton_Click(object sender, EventArgs e)
|
private void productTypeButton_Click(object sender, EventArgs e)
|
||||||
@ -388,7 +396,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_billController.AddProductToGrid(item);
|
_billController.AddProduct(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,10 +417,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string tableName = item.Name;
|
var tableName = item.Name;
|
||||||
_billController.LoadBillFromTable(tableName);
|
_billController.LoadBill(tableName);
|
||||||
txtTableID.Text = tableName;
|
txtTableID.Text = tableName;
|
||||||
ChangeFormState(SaleFormState.Billing);
|
FormState = SaleFormState.Billing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,11 +439,6 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
_billController.SaveKot((int)btnWaiter.Tag, txtTableID.Text);
|
_billController.SaveKot((int)btnWaiter.Tag, txtTableID.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_billController.CancelBillChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnQuantity_Click(object sender, EventArgs e)
|
private void btnQuantity_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_billController.SetQuantity(0, true);
|
_billController.SetQuantity(0, true);
|
||||||
@ -444,11 +447,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private void btnDiscount_Click(object sender, EventArgs e)
|
private void btnDiscount_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_billController.ShowDiscount();
|
_billController.ShowDiscount();
|
||||||
|
|
||||||
//if (dgvProducts.Rows.Count > 0)
|
|
||||||
// billController.SetDiscount(billController.CurrentProduct, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private void btnSplitBill_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_billController.SplitBill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,6 +123,12 @@
|
|||||||
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="Display.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="bsWaiter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="bsWaiter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>148, 17</value>
|
<value>148, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
namespace Tanshu.Accounts.PointOfSale
|
namespace Tanshu.Accounts.PointOfSale
|
||||||
{
|
{
|
||||||
partial class FrmSettleAmounts
|
partial class SettleAmountsForm
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -52,7 +52,7 @@
|
|||||||
this.txtCurrentAmount.TabIndex = 0;
|
this.txtCurrentAmount.TabIndex = 0;
|
||||||
this.txtCurrentAmount.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtCurrentAmountKeyDown);
|
this.txtCurrentAmount.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtCurrentAmountKeyDown);
|
||||||
//
|
//
|
||||||
// FrmSettleAmounts
|
// SettleAmountsForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
@ -62,7 +62,7 @@
|
|||||||
this.Controls.Add(this.txtAmount);
|
this.Controls.Add(this.txtAmount);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "FrmSettleAmounts";
|
this.Name = "SettleAmountsForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Settle Bill";
|
this.Text = "Settle Bill";
|
||||||
this.Load += new System.EventHandler(this.SettleChoicesFormLoad);
|
this.Load += new System.EventHandler(this.SettleChoicesFormLoad);
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Tanshu.Accounts.Entities;
|
using Tanshu.Accounts.Entities;
|
||||||
@ -8,13 +7,13 @@ using Tanshu.Common.KeyboardControl;
|
|||||||
|
|
||||||
namespace Tanshu.Accounts.PointOfSale
|
namespace Tanshu.Accounts.PointOfSale
|
||||||
{
|
{
|
||||||
public partial class FrmSettleAmounts : Form
|
public partial class SettleAmountsForm : Form
|
||||||
{
|
{
|
||||||
private IKeyboardControl _keyboardControl;
|
private IKeyboardControl _keyboardControl;
|
||||||
private readonly decimal _amount;
|
private readonly decimal _amount;
|
||||||
private readonly SettleOption _settleOption;
|
private readonly SettleOption _settleOption;
|
||||||
private decimal _settleAmount;
|
private decimal _settleAmount;
|
||||||
public FrmSettleAmounts(IKeyboardControl keyboardControl, SettleOption settleOption, decimal amount)
|
public SettleAmountsForm(IKeyboardControl keyboardControl, SettleOption settleOption, decimal amount)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
if (button.Tag is SettleOption)
|
if (button.Tag is SettleOption)
|
||||||
{
|
{
|
||||||
var settleOption = (SettleOption)button.Tag;
|
var settleOption = (SettleOption)button.Tag;
|
||||||
using (var frm = new FrmSettleAmounts(new NumpadControl(), settleOption, _amount))
|
using (var frm = new SettleAmountsForm(new NumpadControl(), settleOption, _amount))
|
||||||
{
|
{
|
||||||
frm.ShowDialog();
|
frm.ShowDialog();
|
||||||
UpdateChoice(settleOption, frm.AmountSettled, _list[button]);
|
UpdateChoice(settleOption, frm.AmountSettled, _list[button]);
|
||||||
|
|||||||
@ -155,11 +155,11 @@
|
|||||||
<Compile Include="Reports\SaleDetail.designer.cs">
|
<Compile Include="Reports\SaleDetail.designer.cs">
|
||||||
<DependentUpon>SaleDetail.cs</DependentUpon>
|
<DependentUpon>SaleDetail.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Sales\frmSettleAmounts.cs">
|
<Compile Include="Sales\SettleAmountsForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Sales\frmSettleAmounts.Designer.cs">
|
<Compile Include="Sales\SettleAmountsForm.Designer.cs">
|
||||||
<DependentUpon>frmSettleAmounts.cs</DependentUpon>
|
<DependentUpon>SettleAmountsForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Sales\SettleChoicesForm.cs">
|
<Compile Include="Sales\SettleChoicesForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@ -282,8 +282,8 @@
|
|||||||
<DependentUpon>SaleDetail.cs</DependentUpon>
|
<DependentUpon>SaleDetail.cs</DependentUpon>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Sales\frmSettleAmounts.resx">
|
<EmbeddedResource Include="Sales\SettleAmountsForm.resx">
|
||||||
<DependentUpon>frmSettleAmounts.cs</DependentUpon>
|
<DependentUpon>SettleAmountsForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Sales\SettleChoicesForm.resx">
|
<EmbeddedResource Include="Sales\SettleChoicesForm.resx">
|
||||||
<DependentUpon>SettleChoicesForm.cs</DependentUpon>
|
<DependentUpon>SettleChoicesForm.cs</DependentUpon>
|
||||||
|
|||||||
@ -23,14 +23,13 @@ namespace Tanshu.Accounts.Print
|
|||||||
private const string DrawLine = "\n\r------------------------------------------";
|
private const string DrawLine = "\n\r------------------------------------------";
|
||||||
private const string DrawEqual = "\n\r==========================================";
|
private const string DrawEqual = "\n\r==========================================";
|
||||||
|
|
||||||
private static string DesignKot(Voucher trans, string kotCode, IEnumerable<Inventory> billItems, int copyNumber)
|
private static string DesignKot(Voucher trans, Kot kot, IEnumerable<Inventory> billItems, int copyNumber)
|
||||||
{
|
{
|
||||||
var waiter = trans.Waiter;
|
var waiter = trans.Waiter;
|
||||||
var billText = "\n\r" + FormatText("KOT / BOT", 42, false, Align.Centre);
|
var billText = "\n\r" + FormatText("KOT / BOT", 42, false, Align.Centre);
|
||||||
billText += "\n\r" + FormatText(string.Format("Copy No. {0}", copyNumber), 42, false, Align.Centre);
|
billText += "\n\r" + FormatText(string.Format("Copy No. {0}", copyNumber), 42, false, Align.Centre);
|
||||||
billText += DrawLine;
|
billText += DrawLine;
|
||||||
billText += string.Format("\n\rKOT ID : {0,-7}/{1,-7} {2:dd-MMM-yyyy HH:mm}", trans.KotID, kotCode,
|
billText += string.Format("\n\rKOT ID : {0,-7}/{1,-7} {2:dd-MMM-yyyy HH:mm}", trans.KotID, kot.Code, kot.Date);
|
||||||
trans.Date);
|
|
||||||
billText += string.Format("\n\rTable No.: {0} / {1}", trans.TableID, waiter.Name);
|
billText += string.Format("\n\rTable No.: {0} / {1}", trans.TableID, waiter.Name);
|
||||||
billText += DrawLine;
|
billText += DrawLine;
|
||||||
billText += "\n\r Qty. x Name ";
|
billText += "\n\r Qty. x Name ";
|
||||||
@ -355,18 +354,17 @@ namespace Tanshu.Accounts.Print
|
|||||||
using (var bi = new VoucherBI(false))
|
using (var bi = new VoucherBI(false))
|
||||||
voucher = bi.Get(voucherID);
|
voucher = bi.Get(voucherID);
|
||||||
var dict = new Dictionary<PrintLocation, List<Inventory>>();
|
var dict = new Dictionary<PrintLocation, List<Inventory>>();
|
||||||
foreach (var item in voucher.Kots.Where(x => x.KotID == kotID))
|
var kot = voucher.Kots.SingleOrDefault(x => x.KotID == kotID);
|
||||||
|
if (kot == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var inventory in kot.Inventories)
|
||||||
{
|
{
|
||||||
foreach (var inventory in item.Inventories)
|
var type = inventory.Product.ProductGroup.ProductGroupID;
|
||||||
{
|
var printer = PrintLocationBI.KotPrinter(type);
|
||||||
var type = inventory.Product.ProductGroup.ProductGroupID;
|
if (!dict.ContainsKey(printer))
|
||||||
var printer = PrintLocationBI.KotPrinter(type);
|
dict.Add(printer, new List<Inventory>());
|
||||||
if (!dict.ContainsKey(printer))
|
dict[printer].Add(inventory);
|
||||||
{
|
|
||||||
dict.Add(printer, new List<Inventory>());
|
|
||||||
}
|
|
||||||
dict[printer].Add(inventory);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
Trace.TraceWarning("kot and printers built in {0} ms", stopwatch.ElapsedMilliseconds);
|
Trace.TraceWarning("kot and printers built in {0} ms", stopwatch.ElapsedMilliseconds);
|
||||||
@ -376,9 +374,7 @@ namespace Tanshu.Accounts.Print
|
|||||||
for (var i = 0; i < item.Key.Copies; i++)
|
for (var i = 0; i < item.Key.Copies; i++)
|
||||||
{
|
{
|
||||||
stopwatch.Start();
|
stopwatch.Start();
|
||||||
PrintRaw(item.Key,
|
PrintRaw(item.Key, DesignKot(voucher, kot, item.Value, i), "KOT");
|
||||||
DesignKot(voucher, voucher.Kots.Where(x => x.KotID == kotID).Single().Code, item.Value, i),
|
|
||||||
"KOT");
|
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
Trace.TraceWarning("kot designed and printed in {0} ms", stopwatch.ElapsedMilliseconds);
|
Trace.TraceWarning("kot designed and printed in {0} ms", stopwatch.ElapsedMilliseconds);
|
||||||
stopwatch.Reset();
|
stopwatch.Reset();
|
||||||
|
|||||||
@ -4,12 +4,10 @@ namespace Tanshu.Accounts.Print
|
|||||||
{
|
{
|
||||||
internal class ThermalPrinter
|
internal class ThermalPrinter
|
||||||
{
|
{
|
||||||
private static readonly bool _runningOnLinux;
|
|
||||||
internal static PlatformPrinter Printer;
|
internal static PlatformPrinter Printer;
|
||||||
static ThermalPrinter()
|
static ThermalPrinter()
|
||||||
{
|
{
|
||||||
_runningOnLinux = RunningOnLinux();
|
Printer = RunningOnLinux() ? (PlatformPrinter)new PrinterLinux() : new PrinterWindows();
|
||||||
Printer = _runningOnLinux ? (PlatformPrinter)new PrinterLinux() : new PrinterWindows();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool RunningOnLinux()
|
internal static bool RunningOnLinux()
|
||||||
|
|||||||
23
Tanshu.Accounts.Repository/BusinessLayer/ReprintBI.cs
Normal file
23
Tanshu.Accounts.Repository/BusinessLayer/ReprintBI.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using NHibernate;
|
||||||
|
using Tanshu.Accounts.Entities;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tanshu.Accounts.Repository
|
||||||
|
{
|
||||||
|
public class ReprintBI : FluentGenericBase<Reprint>
|
||||||
|
{
|
||||||
|
public ReprintBI()
|
||||||
|
: base()
|
||||||
|
{ }
|
||||||
|
public ReprintBI(bool beginTransaction)
|
||||||
|
: base(beginTransaction)
|
||||||
|
{ }
|
||||||
|
public ReprintBI(ISession session)
|
||||||
|
: base(session)
|
||||||
|
{ }
|
||||||
|
public ReprintBI(ISession session, bool beginTransaction)
|
||||||
|
: base(session, beginTransaction)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -120,7 +120,7 @@ order by g.GroupType
|
|||||||
using (var session = SessionManager.Session)
|
using (var session = SessionManager.Session)
|
||||||
{
|
{
|
||||||
const string query = @"
|
const string query = @"
|
||||||
select v.Date, v.BillID, s.Settled, s.Amount
|
select v.Date, v.BillID, s.Settled, s.Amount, v.Void, v.VoidReason
|
||||||
from Voucher v
|
from Voucher v
|
||||||
inner join v.Settlements s
|
inner join v.Settlements s
|
||||||
where v.Date >= :startDate and v.Date <= :finishDate
|
where v.Date >= :startDate and v.Date <= :finishDate
|
||||||
@ -134,11 +134,14 @@ order by v.BillID, s.Settled
|
|||||||
var outList = new List<BillDetail>();
|
var outList = new List<BillDetail>();
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
|
var settlement = ((SettleOption)item[2]).Display();
|
||||||
|
if ((bool)item[4])
|
||||||
|
settlement = string.Format("Void: {0}", (string)item[5]);
|
||||||
outList.Add(new BillDetail()
|
outList.Add(new BillDetail()
|
||||||
{
|
{
|
||||||
Date = (DateTime)item[0],
|
Date = (DateTime)item[0],
|
||||||
BillID = (string)item[1],
|
BillID = (string)item[1],
|
||||||
Settlement = ((SettleOption)item[2]).Display(),
|
Settlement = settlement,
|
||||||
Amount = (decimal)item[3]
|
Amount = (decimal)item[3]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using NHibernate.Criterion;
|
using NHibernate.Criterion;
|
||||||
using Tanshu.Accounts.Entities;
|
using Tanshu.Accounts.Entities;
|
||||||
|
using Tanshu.Common.Helpers;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@ -27,11 +28,11 @@ namespace Tanshu.Accounts.Repository
|
|||||||
public int? Insert(Voucher voucher)
|
public int? Insert(Voucher voucher)
|
||||||
{
|
{
|
||||||
var dt = DbValues.Date;
|
var dt = DbValues.Date;
|
||||||
voucher.CreationDate = dt;
|
voucher.SetValue(VoucherFields.CreationDate, dt);
|
||||||
voucher.LastEditDate = dt;
|
voucher.SetValue(VoucherFields.LastEditDate, dt);
|
||||||
voucher.Date = dt;
|
voucher.SetValue(VoucherFields.Date, dt);
|
||||||
voucher.KotID = DbValues.KotID;
|
voucher.SetValue(VoucherFields.KotID, DbValues.KotID);
|
||||||
voucher.BillID = voucher.Printed ? DbValues.BillID : voucher.KotID;
|
voucher.SetValue(VoucherFields.BillID, voucher.Printed ? DbValues.BillID : voucher.KotID);
|
||||||
Kot addedKot = null;
|
Kot addedKot = null;
|
||||||
foreach (var item in voucher.Kots.Where(item => item.KotID == 0))
|
foreach (var item in voucher.Kots.Where(item => item.KotID == 0))
|
||||||
{
|
{
|
||||||
@ -47,7 +48,6 @@ namespace Tanshu.Accounts.Repository
|
|||||||
Session.Save(voucher);
|
Session.Save(voucher);
|
||||||
return addedKot == null ? (int?)null : addedKot.KotID;
|
return addedKot == null ? (int?)null : addedKot.KotID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(int voucherID)
|
public void Delete(int voucherID)
|
||||||
{
|
{
|
||||||
var voucher = Session.Get<Voucher>(voucherID);
|
var voucher = Session.Get<Voucher>(voucherID);
|
||||||
@ -55,18 +55,16 @@ namespace Tanshu.Accounts.Repository
|
|||||||
using (var ft = new FoodTableBI(Session, false))
|
using (var ft = new FoodTableBI(Session, false))
|
||||||
ft.UpdateStatus(voucher.TableID, voucherID, null);
|
ft.UpdateStatus(voucher.TableID, voucherID, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int? Update(Voucher voucher)
|
public int? Update(Voucher voucher)
|
||||||
{
|
{
|
||||||
var dt = DbValues.Date;
|
var dt = DbValues.Date;
|
||||||
voucher.LastEditDate = dt;
|
voucher.SetValue(VoucherFields.LastEditDate, dt);
|
||||||
if (voucher.Date == null)
|
if (voucher.Date == null)
|
||||||
{
|
{
|
||||||
voucher.Date = dt;
|
voucher.SetValue(VoucherFields.Date, dt);
|
||||||
voucher.BillID = DbValues.BillID;
|
voucher.SetValue(VoucherFields.BillID, DbValues.BillID );
|
||||||
}
|
}
|
||||||
if (!voucher.Printed)
|
|
||||||
voucher.Date = dt;
|
|
||||||
Kot addedKot = null;
|
Kot addedKot = null;
|
||||||
foreach (var item in voucher.Kots.Where(item => item.KotID == 0))
|
foreach (var item in voucher.Kots.Where(item => item.KotID == 0))
|
||||||
{
|
{
|
||||||
@ -80,10 +78,7 @@ namespace Tanshu.Accounts.Repository
|
|||||||
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
||||||
VoucherSettlementBI.UpdateSettlements(voucher.Settlements, amount);
|
VoucherSettlementBI.UpdateSettlements(voucher.Settlements, amount);
|
||||||
Session.Update(voucher);
|
Session.Update(voucher);
|
||||||
if (addedKot == null)
|
return addedKot == null ? (int?) null : addedKot.KotID;
|
||||||
return null;
|
|
||||||
else
|
|
||||||
return addedKot.KotID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Voucher Get(int voucherID)
|
public Voucher Get(int voucherID)
|
||||||
@ -109,7 +104,6 @@ namespace Tanshu.Accounts.Repository
|
|||||||
NHibernateUtil.Initialize(item);
|
NHibernateUtil.Initialize(item);
|
||||||
return voucher;
|
return voucher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Voucher Get(string billID)
|
public Voucher Get(string billID)
|
||||||
{
|
{
|
||||||
var voucher = Session.CreateCriteria<Voucher>()
|
var voucher = Session.CreateCriteria<Voucher>()
|
||||||
@ -141,5 +135,6 @@ namespace Tanshu.Accounts.Repository
|
|||||||
Session.Update(voucher);
|
Session.Update(voucher);
|
||||||
return voucher.VoucherID;
|
return voucher.VoucherID;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using Tanshu.Accounts.Entities;
|
|||||||
using Tanshu.Accounts.Entities.Auth;
|
using Tanshu.Accounts.Entities.Auth;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Tanshu.Common.Helpers;
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Repository
|
namespace Tanshu.Accounts.Repository
|
||||||
{
|
{
|
||||||
@ -71,7 +72,7 @@ namespace Tanshu.Accounts.Repository
|
|||||||
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
||||||
UpdateSettlements(voucher.Settlements, amount);
|
UpdateSettlements(voucher.Settlements, amount);
|
||||||
voucher.User = user;
|
voucher.User = user;
|
||||||
voucher.LastEditDate = DbValues.Date;
|
voucher.SetValue(VoucherFields.LastEditDate, DbValues.Date);
|
||||||
Session.Update(voucher);
|
Session.Update(voucher);
|
||||||
using (var ft = new FoodTableBI(Session, false))
|
using (var ft = new FoodTableBI(Session, false))
|
||||||
ft.TableSettled(voucher);
|
ft.TableSettled(voucher);
|
||||||
|
|||||||
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using FluentNHibernate.Conventions;
|
||||||
|
using FluentNHibernate.Conventions.Inspections;
|
||||||
|
using FluentNHibernate.Conventions.Instances;
|
||||||
|
|
||||||
|
namespace Tanshu.Accounts.Conventions
|
||||||
|
{
|
||||||
|
public class PropertyAccessConvention : IPropertyConvention
|
||||||
|
{
|
||||||
|
public void Apply(IPropertyInstance instance)
|
||||||
|
{
|
||||||
|
var entityType = instance.EntityType;
|
||||||
|
var camelCaseUnderscoreName = ConvertToCamelCaseUnderscore(instance.Name);
|
||||||
|
|
||||||
|
// Default is to use property setter, so only modify mapping
|
||||||
|
// if there is a backing field
|
||||||
|
|
||||||
|
if (HasField(entityType, camelCaseUnderscoreName))
|
||||||
|
instance.Access.CamelCaseField(CamelCasePrefix.Underscore);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ConvertToCamelCaseUnderscore(string propertyName)
|
||||||
|
{
|
||||||
|
return "_" + propertyName[0].ToString().ToLower() + propertyName.Substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool HasField(Type type, string fieldName)
|
||||||
|
{
|
||||||
|
var backingField = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
return backingField != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ namespace Tanshu.Accounts.Repository
|
|||||||
c.Add<NotNullConvention>();
|
c.Add<NotNullConvention>();
|
||||||
c.Add<FormulaConvention>();
|
c.Add<FormulaConvention>();
|
||||||
c.Add<InverseConvention>();
|
c.Add<InverseConvention>();
|
||||||
//c.Add<AllowNullConvention>();
|
c.Add<PropertyAccessConvention>();
|
||||||
c.Add<EnumConvention>();
|
c.Add<EnumConvention>();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -84,6 +84,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BusinessLayer\CheckoutBI.cs" />
|
<Compile Include="BusinessLayer\CheckoutBI.cs" />
|
||||||
|
<Compile Include="BusinessLayer\ReprintBI.cs" />
|
||||||
<Compile Include="BusinessLayer\FluentBasicBaseBI.cs" />
|
<Compile Include="BusinessLayer\FluentBasicBaseBI.cs" />
|
||||||
<Compile Include="BusinessLayer\VoucherSettlementBI.cs" />
|
<Compile Include="BusinessLayer\VoucherSettlementBI.cs" />
|
||||||
<Compile Include="BusinessLayer\FluentGenericBaseBI.cs" />
|
<Compile Include="BusinessLayer\FluentGenericBaseBI.cs" />
|
||||||
@ -95,6 +96,7 @@
|
|||||||
<Compile Include="Fluent\CascadeConvention.cs" />
|
<Compile Include="Fluent\CascadeConvention.cs" />
|
||||||
<Compile Include="Fluent\InverseConvention.cs" />
|
<Compile Include="Fluent\InverseConvention.cs" />
|
||||||
<Compile Include="Fluent\FormulaConvention.cs" />
|
<Compile Include="Fluent\FormulaConvention.cs" />
|
||||||
|
<Compile Include="Fluent\PropertyAccessConvention.cs" />
|
||||||
<Compile Include="Fluent\UniqueConvention.cs" />
|
<Compile Include="Fluent\UniqueConvention.cs" />
|
||||||
<Compile Include="Fluent\NotNullConvention.cs" />
|
<Compile Include="Fluent\NotNullConvention.cs" />
|
||||||
<Compile Include="Lifetime\Session.cs" />
|
<Compile Include="Lifetime\Session.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user