Merge branch 'master' into management

This commit is contained in:
Tanshu 2012-12-01 19:44:09 +05:30
commit a938a9e693
8 changed files with 68 additions and 43 deletions

View File

@ -5,7 +5,9 @@ namespace Tanshu.Accounts.Contracts
public enum BillItemType
{
Product,
Kot
Kot,
Information,
Total
}
public class BillItemKey
{

View File

@ -1,8 +1,4 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
namespace Tanshu.Accounts.Entities
namespace Tanshu.Accounts.Entities
{
public class FoodTable
{

View File

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using System.Collections;
using Tanshu.Accounts.Repository;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.Helpers
@ -20,7 +16,7 @@ namespace Tanshu.Accounts.Helpers
{
IList<FoodTable> list = new List<FoodTable>();
int pageLength, stop;
PageSetup(ref panel, start, inList as IList, out pageLength, out stop);
PageSetup(panel, start, inList as IList, size, out pageLength, out stop);
if (start != 0)
list.Add(new FoodTable() { FoodTableID = start - pageLength, Name = "Previous" });
for (int i = start; i < stop; i++)
@ -34,7 +30,7 @@ namespace Tanshu.Accounts.Helpers
{
var item = list[i];
var status = item.Status;
var control = GetButton(string.Format("g{0}", i), item.Name, size.X, size.Y, item, bcDelegate);
var control = GetButton(string.Format("g{0}", i), item.Name, size, item, bcDelegate);
if (status == "printed")
control.BackColor = Color.Green;
else if (status == "running")
@ -46,7 +42,7 @@ namespace Tanshu.Accounts.Helpers
{
IList<Product> list = new List<Product>();
int pageLength, stop;
PageSetup(ref panel, start, inList as IList, out pageLength, out stop);
PageSetup(panel, start, inList as IList, size, out pageLength, out stop);
if (start != 0)
list.Add(new Product() { ProductID = start - pageLength, Name = "Previous" });
for (int i = start; i < stop; i++)
@ -59,7 +55,7 @@ namespace Tanshu.Accounts.Helpers
for (var i = 0; i < list.Count; i++)
{
var item = list[i];
var control = GetButton(string.Format("p{0}", i), item.Units == string.Empty ? item.Name : string.Format("{0} ({1})", item.Name, item.Units), size.X, size.Y, item, bcDelegate);
var control = GetButton(string.Format("p{0}", i), item.Units == string.Empty ? item.Name : string.Format("{0} ({1})", item.Name, item.Units), size, item, bcDelegate);
if (item.Price == 0)
control.BackColor = Color.Yellow;
panel.Controls.Add(control);
@ -72,7 +68,7 @@ namespace Tanshu.Accounts.Helpers
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
var control = GetUnselectableCheckbox(i.ToString(), item, size.X, size.Y, item, bcDelegate);
var control = GetUnselectableCheckbox(i.ToString(), item, size, item, bcDelegate);
panel.Controls.Add(control);
}
}
@ -81,7 +77,7 @@ namespace Tanshu.Accounts.Helpers
{
IList<ProductGroup> list = new List<ProductGroup>();
int pageLength, stop;
PageSetup(ref panel, start, inList as IList, out pageLength, out stop);
PageSetup(panel, start, inList as IList, size, out pageLength, out stop);
if (start != 0)
list.Add(new ProductGroup() { ProductGroupID = start - pageLength, Name = "Previous" });
for (int i = start; i < stop; i++)
@ -94,7 +90,7 @@ namespace Tanshu.Accounts.Helpers
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
var control = GetButton(string.Format("g{0}", i), item.Name, size.X, size.Y, item, bcDelegate);
var control = GetButton(string.Format("g{0}", i), item.Name, size, item, bcDelegate);
panel.Controls.Add(control);
}
}
@ -113,18 +109,20 @@ namespace Tanshu.Accounts.Helpers
for (int i = 0; i < count; i++)
{
var item = list[i];
var control = GetCheckbox(i.ToString(), item.Name, size.X, size.Y, item, bcDelegate);
var control = GetCheckbox(i.ToString(), item.Name, size, item, bcDelegate);
control.Checked = selection.Contains(item);
panel.Controls.Add(control);
controlList.Add(control);
}
}
private static void PageSetup(ref FlowLayoutPanel panel, int start, IList inList, out int pageLength, out int stop)
private static void PageSetup(FlowLayoutPanel panel, int start, ICollection inList, Point size, out int pageLength, out int stop)
{
panel.Controls.Clear();
pageLength = (panel.Height / (3 + 75 + 3));
pageLength *= (panel.Width / (3 + 75 + 3));
var marginWidth = panel.Margin.Right + panel.Margin.Left;
var marginHeight = panel.Margin.Top + panel.Margin.Bottom;
pageLength = (panel.ClientSize.Height / (marginHeight + size.Y));
pageLength *= (panel.ClientSize.Width / (marginWidth + size.X));
pageLength -= 2;
if (inList.Count <= pageLength)
start = 0;
@ -135,28 +133,28 @@ namespace Tanshu.Accounts.Helpers
stop = inList.Count;
}
private static Button GetButton(string name, string text, int width, int height, object tag, ButtonClickDelegate bcDelegate)
private static Button GetButton(string name, string text, Point size, object tag, ButtonClickDelegate bcDelegate)
{
Button control = new Button()
var control = new Button()
{
Name = name,
Text = text,
Width = width,
Height = height,
Width = size.X,
Height = size.Y,
Tag = tag,
};
if (bcDelegate != null)
control.Click += new EventHandler(bcDelegate);
return control;
}
private static UnselectableCheckbox GetUnselectableCheckbox(string name, string text, int width, int height, object tag, ButtonClickDelegate bcDelegate)
private static UnselectableCheckbox GetUnselectableCheckbox(string name, string text, Point size, object tag, ButtonClickDelegate bcDelegate)
{
UnselectableCheckbox control = new UnselectableCheckbox()
var control = new UnselectableCheckbox()
{
Name = name,
Text = text,
Width = width,
Height = height,
Width = size.X,
Height = size.Y,
Tag = tag,
Appearance = Appearance.Button,
@ -165,14 +163,14 @@ namespace Tanshu.Accounts.Helpers
control.Click += new EventHandler(bcDelegate);
return control;
}
private static CheckBox GetCheckbox(string name, string text, int width, int height, object tag, ButtonClickDelegate bcDelegate)
private static CheckBox GetCheckbox(string name, string text, Point size, object tag, ButtonClickDelegate bcDelegate)
{
CheckBox control = new CheckBox()
var control = new CheckBox()
{
Name = name,
Text = text,
Width = width,
Height = height,
Width = size.X,
Height = size.Y,
Tag = tag,
Appearance = Appearance.Button,

View File

@ -12,7 +12,7 @@ namespace Tanshu.Accounts.PointOfSale
{
public class BillController
{
private readonly OrderedDictionary<BillItemKey, BillItemValue> _bill;
private readonly BillDict _bill;
private Voucher _billInfo;
@ -31,7 +31,7 @@ namespace Tanshu.Accounts.PointOfSale
{
this._editVoucherID = editVoucherID;
_print = print;
_bill = new OrderedDictionary<BillItemKey, BillItemValue>();
_bill = new BillDict();
_billInfo = new Voucher(Session.User);
using (var bi = new CustomerBI(false))
_billInfo.Customer = bi.Get(x => x.CustomerID == 1);
@ -80,9 +80,7 @@ namespace Tanshu.Accounts.PointOfSale
else
{
var billItemValue = new BillItemValue(product);
var old =
_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID).
FirstOrDefault();
var old = _bill.FirstOrDefault(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID);
if (old.Key != null)
{
billItemValue.Discount = old.Value.Discount;
@ -908,13 +906,28 @@ namespace Tanshu.Accounts.PointOfSale
using (var trans = session.BeginTransaction())
{
int? kotID;
bool tableExists = false;
using (var bi = new VoucherBI(session, false))
kotID = bi.Insert(_billInfo);
if (updateTable)
using (var ft = new FoodTableBI(session, false))
{
tableExists = ft.Get(x => x.Name == _billInfo.TableID).VoucherID != 0;
ft.UpdateStatus(_billInfo);
trans.Commit();
return kotID;
}
if (tableExists)
{
MessageBox.Show("A bill exists on this table, cannot overrite", "Bill Open",
MessageBoxButtons.OK, MessageBoxIcon.Error);
trans.Rollback();
return null;
}
else
{
trans.Commit();
return kotID;
}
}
}
}

View File

@ -0,0 +1,12 @@
using Tanshu.Accounts.Contracts;
using Tanshu.Common;
namespace Tanshu.Accounts.PointOfSale
{
public class BillDict : OrderedDictionary<BillItemKey, BillItemValue>
{
public delegate void ItemChangedHandler();
public event ItemChangedHandler ItemChanged;
}
}

View File

@ -21,9 +21,12 @@ namespace Tanshu.Accounts.PointOfSale
private void ShowStatement()
{
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 &&
!Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
return;
_list = new SalesAnalysisBI().GetSale(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

View File

@ -103,6 +103,7 @@ namespace Tanshu.Accounts.Print
billText += "\n\r" + "SCO 358, Sector 9, Panchkula".Center42();
billText += "\n\r" + "A Unit of Peitho Foods Pvt. Ltd.".Center42();
billText += "\n\r" + "TIN: 06592507323".Center42();
billText += "\n\r" + "Service Tax: AAFCP5097GSD001".Center42();
switch (voucher.VoucherType)
{
case VoucherType.Regular:

View File

@ -49,9 +49,9 @@ namespace Tanshu.Accounts.Repository
public void UpdateStatus(Voucher voucher)
{
string status;
if (!voucher.Printed)
if (!voucher.Printed && !voucher.Void)
status = "running";
else if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) != 0 && voucher.Void == false)
else if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) != 0 && !voucher.Void)
status = "printed";
else
status = null;