Moved numpad control to Tanshu.Common. Billing feature complete. Delete not working as expected

Signed-off-by: unknown <tanshu@.(none)>
This commit is contained in:
unknown
2011-02-01 02:03:22 +05:30
parent eb05811868
commit 0f323f8fab
64 changed files with 2029 additions and 1382 deletions

View File

@ -10,6 +10,7 @@ using Tanshu.Common;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.SqlDAO;
using System.Collections.ObjectModel;
namespace Tanshu.Accounts.PointOfSale
@ -17,6 +18,8 @@ namespace Tanshu.Accounts.PointOfSale
public class BillController
{
private SaleVoucher billInfo;
// private KeyedCollection<BillItemKey, BillInventory> b1 = new KeyedCollection<BillItemKey, BillInventory>();
private OrderedDictionary<BillItemKey, BillInventory> bill = new OrderedDictionary<BillItemKey, BillInventory>();
int? newBillID;
@ -58,12 +61,36 @@ namespace Tanshu.Accounts.PointOfSale
public void ShowModifiers(int productGroupID, BillInventory item)
{
if (item.Printed > 0)
return;
var list = ProductGroupModifierBI.GetProductGroupModifiers(productGroupID);
using (var frm = new ModifierForm(list, item.Modifiers))
{
frm.ShowDialog();
item.Modifiers = frm.Selection;
}
ShowAmount();
}
public void ShowDiscount()
{
var list = new ProductGroupBI().GetProductGroups();
using (var frm = new DiscountForm(list))
{
if (frm.ShowDialog() == DialogResult.OK)
{
IList<int> outList;
decimal discount = frm.Selection(out outList);
discount = discount / 100;
foreach (var item in bill)
{
var pg = new ProductGroupBI().GetProductGroupOfProduct(item.Value.ProductID);
if (outList.Contains(pg.ProductGroupID))
item.Value.Discount = discount;
}
}
}
ShowAmount();
}
public void ShowCustomerList(bool reset)
@ -100,7 +127,7 @@ namespace Tanshu.Accounts.PointOfSale
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_EDIT_BILL))
{
if ((billInfo != null) && (new SaleVoucherBI().IsBillPrinted(billInfo.VoucherID)) && (!roleBI.IsAllowed))
if ((billInfo != null) && (SaleVoucherBI.IsBillPrinted(billInfo.VoucherID)) && (!roleBI.IsAllowed))
{
throw new PermissionException("You do not have the permission to reprint a bill.");
}
@ -151,7 +178,7 @@ namespace Tanshu.Accounts.PointOfSale
#region Inventories
IList<Inventory> iList = GetInventoryForBill(bill.Values);
#endregion
new SaleVoucherBI().Insert(saleVoucher, iList);
SaleVoucherBI.Insert(saleVoucher, iList);
return saleVoucher.VoucherID;
}
@ -172,7 +199,7 @@ namespace Tanshu.Accounts.PointOfSale
#region Inventory
IList<Inventory> iList = GetInventoryForBill(bill.Values);
#endregion
new SaleVoucherBI().Update(billInfo, iList);
SaleVoucherBI.Update(billInfo, iList);
return billInfo.VoucherID;
}
private IList<Inventory> GetInventoryForBill(ICollection<BillInventory> list)
@ -185,6 +212,8 @@ namespace Tanshu.Accounts.PointOfSale
{
temp = localList[item.ProductID];
temp.Quantity += item.Quantity;
foreach (var mod in item.Modifiers)
temp.InventoryModifier.Add(new InventoryModifier() { Modifier = mod });
}
else
{
@ -193,6 +222,8 @@ namespace Tanshu.Accounts.PointOfSale
temp.Quantity = item.Quantity;
temp.Rate = item.Price;
temp.Tax = item.Tax;
foreach (var mod in item.Modifiers)
temp.InventoryModifier.Add(new InventoryModifier() { Modifier = mod });
localList.Add(item.ProductID, temp);
}
}
@ -201,7 +232,7 @@ namespace Tanshu.Accounts.PointOfSale
public decimal GetInput(string type, decimal basic)
{
decimal value;
InputBoxResult result = InputBox.Show(type, type, basic.ToString(), InputBox_Validating);
InputBoxResult result = InputBox.Show(type, basic.ToString(), InputBox_Validating);
if (result.OK)
{
if (!decimal.TryParse(result.Text, out value))
@ -213,34 +244,31 @@ namespace Tanshu.Accounts.PointOfSale
#endregion
public void VoidBill()
{
if (billInfo != null)
if (billInfo == null)
return;
if (!billInfo.Printed)
return;
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_VOID_BILL))
{
if (billInfo.Printed)
if (roleBI.IsAllowed)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_VOID_BILL))
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
if (roleBI.IsAllowed)
SelectVoidReason voidReason = new SelectVoidReason(GetVoidReason, true);
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
{
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
SelectVoidReason voidReason = new SelectVoidReason(GetVoidReason, true);
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
{
new SaleVoucherBI().VoidBill(billInfo.VoucherID, voidReason.SelectedItem.Description);
ClearBill();
}
else
{
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
SaleVoucherBI.VoidBill(billInfo.VoucherID, voidReason.SelectedItem.Description);
ClearBill();
}
else
throw new PermissionException("You do not have the permission to void a bill.");
{
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
}
else
throw new PermissionException("You do not have the permission to void a bill.");
}
}
Customer selectCustomer_customerEvent(object sender, CustomerEventArgs e)
@ -357,7 +385,7 @@ namespace Tanshu.Accounts.PointOfSale
if (item != null)
{
decimal rate = 0;
InputBoxResult result = InputBox.Show("Enter Rate", "Rate", item.Price.ToString(), InputBox_Validating);
InputBoxResult result = InputBox.Show("Rate", item.Price.ToString(), InputBox_Validating);
if (result.OK)
rate = Convert.ToDecimal(result.Text);
if (rate != 0)
@ -374,19 +402,20 @@ namespace Tanshu.Accounts.PointOfSale
{
ClearBill();
IList<Inventory> iList = new List<Inventory>();
new SaleVoucherBI().GetSaleVoucher(voucherID, out billInfo, out iList);
SaleVoucherBI.GetSaleVoucher(voucherID, out billInfo, out iList);
this.customer = billInfo.Customer;
saleForm.ShowInfo(billInfo.BillID, billInfo.KotID, billInfo.CreationDate, billInfo.Date.Value, billInfo.LastEditDate, customer.Name, billInfo.TableID, billInfo.Waiter.WaiterID, billInfo.Waiter.Name);
foreach (Inventory inventory in iList)
{
BillItemKey key = new BillItemKey(inventory.Product.ProductID, inventory.Quantity == 0);
BillItemKey key = new BillItemKey(inventory.Product.ProductID, false);
var product = ProductBI.GetProduct(inventory.Product.ProductID);
var item = new BillInventory
{
ProductID = inventory.Product.ProductID,
ProductID = product.ProductID,
Discount = inventory.Discount,
Name = inventory.Product.Name + " (" + inventory.Product.Units + ")",
Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")",
Price = inventory.Rate,
Printed = inventory.Quantity,
Quantity = inventory.Quantity,
@ -394,9 +423,7 @@ namespace Tanshu.Accounts.PointOfSale
ServiceCharge = inventory.ServiceCharge,
};
foreach (var mod in inventory.InventoryModifier)
{
item.Modifiers.Add(mod.Modifier);
}
bill.Add(key, item);
}
ShowAmount();
@ -406,7 +433,7 @@ namespace Tanshu.Accounts.PointOfSale
{
if (!string.IsNullOrEmpty(tableName))
{
SaleVoucher voucher = new SaleVoucherBI().GetPendingVoucherID(tableName);
SaleVoucher voucher = SaleVoucherBI.GetPendingVoucherID(tableName);
if (voucher != null)
{
LoadBill(voucher.VoucherID);
@ -415,13 +442,13 @@ namespace Tanshu.Accounts.PointOfSale
}
else
{
InputBoxResult result = InputBox.Show("Enter Table Number", "Table", "0", InputBox_Validating);
InputBoxResult result = InputBox.Show("Table Number", "0", InputBox_Validating);
if (result.OK)
{
string tableID = result.Text.Trim();
if ((tableID != "C") && (tableID != "") && (!tableID.Contains(".")))
{
SaleVoucher voucher = new SaleVoucherBI().GetPendingVoucherID(tableName);
SaleVoucher voucher = SaleVoucherBI.GetPendingVoucherID(tableName);
if (voucher != null)
{
LoadBill(voucher.VoucherID);
@ -460,6 +487,8 @@ namespace Tanshu.Accounts.PointOfSale
{
if (billInfo == null)
return;
if (!billInfo.Printed)
return;
int option = SettleOptionFactory.Unsettled;
using (BillSettleForm frm = new BillSettleForm())
{
@ -468,7 +497,7 @@ namespace Tanshu.Accounts.PointOfSale
}
if (option != SettleOptionFactory.Unsettled)
{
new SaleVoucherBI().SettleVoucher(Session.User, billInfo.VoucherID, option);
SaleVoucherBI.SettleVoucher(Session.User, billInfo.VoucherID, option);
ClearBill();
}
}