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 public enum BillItemType
{ {
Product, Product,
Kot Kot,
Information,
Total
} }
public class BillItemKey public class BillItemKey
{ {

View File

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

View File

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

View File

@ -12,7 +12,7 @@ namespace Tanshu.Accounts.PointOfSale
{ {
public class BillController public class BillController
{ {
private readonly OrderedDictionary<BillItemKey, BillItemValue> _bill; private readonly BillDict _bill;
private Voucher _billInfo; private Voucher _billInfo;
@ -31,7 +31,7 @@ namespace Tanshu.Accounts.PointOfSale
{ {
this._editVoucherID = editVoucherID; this._editVoucherID = editVoucherID;
_print = print; _print = print;
_bill = new OrderedDictionary<BillItemKey, BillItemValue>(); _bill = new BillDict();
_billInfo = new Voucher(Session.User); _billInfo = new Voucher(Session.User);
using (var bi = new CustomerBI(false)) using (var bi = new CustomerBI(false))
_billInfo.Customer = bi.Get(x => x.CustomerID == 1); _billInfo.Customer = bi.Get(x => x.CustomerID == 1);
@ -80,9 +80,7 @@ namespace Tanshu.Accounts.PointOfSale
else else
{ {
var billItemValue = new BillItemValue(product); var billItemValue = new BillItemValue(product);
var old = var old = _bill.FirstOrDefault(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID);
_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;
@ -908,16 +906,31 @@ namespace Tanshu.Accounts.PointOfSale
using (var trans = session.BeginTransaction()) using (var trans = session.BeginTransaction())
{ {
int? kotID; int? kotID;
bool tableExists = false;
using (var bi = new VoucherBI(session, false)) using (var bi = new VoucherBI(session, false))
kotID = bi.Insert(_billInfo); kotID = bi.Insert(_billInfo);
if (updateTable) if (updateTable)
using (var ft = new FoodTableBI(session, false)) using (var ft = new FoodTableBI(session, false))
{
tableExists = ft.Get(x => x.Name == _billInfo.TableID).VoucherID != 0;
ft.UpdateStatus(_billInfo); ft.UpdateStatus(_billInfo);
}
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(); trans.Commit();
return kotID; return kotID;
} }
} }
} }
}
private int? UpdateVoucher(bool finalBill, bool updateTable) private int? UpdateVoucher(bool finalBill, bool updateTable)
{ {
_billInfo.User = Session.User; _billInfo.User = Session.User;

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() 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; return;
_list = new SalesAnalysisBI().GetSale(dtpStart.Value, dtpFinish.Value); _list = new SalesAnalysisBI().GetSale(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true; dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list; dgvSale.DataSource = _list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; 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" + "SCO 358, Sector 9, Panchkula".Center42();
billText += "\n\r" + "A Unit of Peitho Foods Pvt. Ltd.".Center42(); billText += "\n\r" + "A Unit of Peitho Foods Pvt. Ltd.".Center42();
billText += "\n\r" + "TIN: 06592507323".Center42(); billText += "\n\r" + "TIN: 06592507323".Center42();
billText += "\n\r" + "Service Tax: AAFCP5097GSD001".Center42();
switch (voucher.VoucherType) switch (voucher.VoucherType)
{ {
case VoucherType.Regular: case VoucherType.Regular:

View File

@ -49,9 +49,9 @@ namespace Tanshu.Accounts.Repository
public void UpdateStatus(Voucher voucher) public void UpdateStatus(Voucher voucher)
{ {
string status; string status;
if (!voucher.Printed) if (!voucher.Printed && !voucher.Void)
status = "running"; 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"; status = "printed";
else else
status = null; status = null;