Added Basecode to Product

Added Voucher Type During Printing
Added Discount Report
Fixed Void bill table not getting cleared error
Added PAX to table
Removed Itital Setup button in MainForm as it was not doing anything
This commit is contained in:
unknown committed 2011-12-05 15:11:02 +05:30
1 parent 719dbd49d2
commit 964d0a78bf
54 files changed
+2285 -1028

No files matched your search

@@ -15,6 +15,7 @@ namespace Tanshu.Accounts.Contracts
public virtual string Product { get; set; }
public virtual decimal Sale { get; set; }
public virtual decimal NC { get; set; }
public virtual decimal Staff { get; set; }
}
public class BillDetail
{
@@ -18,5 +18,9 @@ namespace Tanshu.Accounts.Entities
public virtual decimal FullPrice { get; set; }
public virtual bool Discontinued { get; set; }
public virtual int SortOrder { get; set; }
[NotNull]
public virtual int BaseCode { get; set; }
[NotNull]
public virtual decimal Quantity { get; set; }
}
}
@@ -12,13 +12,17 @@ namespace Tanshu.Accounts.Entities
CreditCard = 3,
[Display("No Charge", true, 3)]
NoCharge = 4,
[Display("Bill To Company", true, 4)]
[Display("Bill To Company", true, 2)]
BillToCompany = 5,
[Display("Tip", true, 2)]
Tip = 6,
[Display("Round Off", false, 1)]
RoundOff = 7,
[Display("Amount", false, 1)]
Amount = 8
Amount = 8,
[Display("Settled", false, 1)]
Settled = 9,
[Display("Staff",true,4)]
Staff = 10
}
}
@@ -19,6 +19,19 @@ namespace Tanshu.Accounts.Entities
{
this._date = null;
this.User = user;
VoucherType = VoucherType.Regular;
}
public Voucher(User user, Customer customer, string table, Waiter waiter ,bool printed, bool isVoid, string narration )
: this(user)
{
Customer = customer;
TableID = table;
Waiter = waiter;
_printed = printed;
Void = isVoid;
Narration = narration;
VoucherType = VoucherType.Regular;
}
protected int _voucherID;
@@ -33,7 +46,7 @@ namespace Tanshu.Accounts.Entities
get { return _date; }
}
public virtual string Narration { get; set; }
public virtual int Pax { get; set; }
[NotNull]
public virtual User User { get; set; }
@@ -71,6 +84,8 @@ namespace Tanshu.Accounts.Entities
[Cascade]
public virtual IList<VoucherSettlement> Settlements { get; set; }
public virtual string Narration { get; set; }
[NotNull]
public virtual bool Void { get; set; }
@@ -95,9 +110,9 @@ namespace Tanshu.Accounts.Entities
}
}
#pragma warning disable 649
public virtual VoucherType VoucherType { get; set; }
private string _kotID;
#pragma warning restore 649
[NotNull]
public virtual string KotID
@@ -0,0 +1,16 @@
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.Entities
{
public enum VoucherType
{
[Display("Regular Bill", true, 2)]
Regular = 1,
[Display("No Charge", true, 3)]
NoCharge = 2,
[Display("Take Away", true, 2)]
TakeAway = 3,
[Display("Staff Bill", true, 4)]
Staff = 4,
}
}
@@ -20,5 +20,10 @@ namespace Tanshu.Common.Helpers
var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0];
return attribute;
}
public static DisplayAttribute Attribute(this VoucherType settleOption)
{
var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0];
return attribute;
}
}
}
@@ -0,0 +1,26 @@
namespace Tanshu.Common.Helpers
{
public enum Align
{
Left = 1,
Centre = 2,
Right = 4
}
public static class StringHelper
{
public static string Center(this string input, int width)
{
if (input.Length > width)
return input;
var left = ((width - input.Length) / 2) + input.Length;
input = string.Format("{0,-" + left + "}", input);
return string.Format("{0," + width + "}", input);
}
public static string Center42(this string input)
{
return Center(input, 42);
}
}
}
@@ -37,10 +37,12 @@ namespace Tanshu.Accounts.Contracts
public static RoleConstants PRINT_KOT = new RoleConstants("Sales/PrintKOT");
public static RoleConstants SALES = new RoleConstants("Sales/SalesBill");
public static RoleConstants DISCOUNT_REPORT = new RoleConstants("Discount Report");
public static RoleConstants VOID_OR_REPRINTED_BILL_REPORT = new RoleConstants("Void or Reprinted Bill Report");
public static RoleConstants BILL_DETAILS = new RoleConstants("Sales/BillDetails");
public static RoleConstants SALE_ANALYSIS = new RoleConstants("Sales/SaleAnalysis");
public static RoleConstants SALE_DETAIL = new RoleConstants("Sales/SaleDetail");
public static RoleConstants ACCOUNTS_AUDIT = new RoleConstants("Accounts Audit");
public static RoleConstants SPLIT_BILL = new RoleConstants("Split Bill");
public static RoleConstants VOID_BILL = new RoleConstants("Sales/VoidPrintedBill");
@@ -100,6 +100,7 @@
<Compile Include="Data Contracts\Auth\RoleGroup.cs" />
<Compile Include="Data Contracts\Auth\Group.cs" />
<Compile Include="Data Contracts\Auth\Role.cs" />
<Compile Include="Data Contracts\VoucherType.cs" />
<Compile Include="Data Contracts\ReprintBO.cs" />
<Compile Include="Data Contracts\VoucherSettlementBO.cs" />
<Compile Include="Data Contracts\KotBO.cs" />
@@ -120,6 +121,7 @@
<Compile Include="Data Contracts Display\PendingBillsBO.cs" />
<Compile Include="Data Contracts\ProductBO.cs" />
<Compile Include="Data Contracts\ProductGroupBO.cs" />
<Compile Include="Helper Functions\StringHelper.cs" />
<Compile Include="Helper Functions\ReflectionHelper.cs" />
<Compile Include="Helper Functions\EnumHelper.cs" />
<Compile Include="nHibernate\IAuditable.cs" />
+7 -17
View File
@@ -1,13 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Repository;
using Tanshu.Data;
using Tanshu.Accounts.Entities;
@@ -15,11 +8,10 @@ namespace Tanshu.Accounts.Helpers
{
public class SelectCustomer : Tanshu.Data.BaseSelector<Customer>
{
public event CustomerEventHandler customerEvent;
public event CustomerEventHandler CustomerEvent;
public SelectCustomer(GetData<Customer> getData, bool autoClose) : base(getData, true, "List of Products")
{
List<string> filters = new List<string>();
filters.Add("Universal");
var filters = new List<string> {"Universal"};
SetFilterColumns(filters);
grid.Columns["CustomerID"].Visible = false;
}
@@ -32,16 +24,14 @@ namespace Tanshu.Accounts.Helpers
}
protected override void UpdateDisplay(Customer item)
{
if (item == null)
DisplayLabel = "";
else
DisplayLabel = string.Format("Chosen Customer is {0} with phone number {1}", item.Name, item.Phone);
DisplayLabel = item == null ? "" : string.Format("Chosen Customer is {0} with phone number {1}", item.Name, item.Phone);
}
protected override Customer HandleKeydown(object sender, ExtendedKeyEventArgs e)
{
Customer customer = bindingSource.Current as Customer;
var customer = bindingSource.Current as Customer;
if (customerEvent == null)
if (CustomerEvent == null)
{
e.Handled = false;
return customer;
@@ -52,7 +42,7 @@ namespace Tanshu.Accounts.Helpers
if ((e.KeyCode == Keys.F1) || (e.KeyCode == Keys.F2))
{
customer = customerEvent(sender, new CustomerEventArgs(id, base.filterColumns["Universal"]));
customer = CustomerEvent(sender, new CustomerEventArgs(id, base.filterColumns["Universal"]));
e.Handled = customer != null;
}
return customer;
+4 -15
View File
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
using Tanshu.Data;
@@ -16,9 +9,7 @@ namespace Tanshu.Accounts.Helpers
public SelectProduct(GetData<ProductDisplaySmall> getData, bool autoClose)
: base(getData, true, "List of Products")
{
List<string> filters = new List<string>();
filters.Add("Name");
filters.Add("Type");
var filters = new List<string> {"Name", "Type"};
SetFilterColumns(filters);
grid.Columns["ProductID"].Visible = false;
}
@@ -31,11 +22,9 @@ namespace Tanshu.Accounts.Helpers
protected override void UpdateDisplay(ProductDisplaySmall item)
{
if (item == null)
DisplayLabel = "";
else
DisplayLabel = string.Format("Chosen Product {0} with rate Rs. {1}", item.Name, item.Price);
DisplayLabel = item == null ? "" : string.Format("Chosen Product {0} with rate Rs. {1}", item.Name, item.Price);
}
protected override ProductDisplaySmall HandleKeydown(object sender, ExtendedKeyEventArgs e)
{
e.Handled = false;
+8 -11
View File
@@ -14,11 +14,10 @@ namespace Tanshu.Accounts.Helpers
{
public class SelectUser : Tanshu.Data.BaseSelector<User>
{
public event UserEventHandler userEvent;
public event UserEventHandler UserEvent;
public SelectUser(GetData<User> getData, bool autoClose) : base (getData, true, "Select a User")
{
IList<string> filters = new List<string>();
filters.Add("Name");
var filters = new List<string> {"Name"};
SetFilterColumns(filters);
grid.Columns["UserID"].Visible = false;
}
@@ -31,16 +30,14 @@ namespace Tanshu.Accounts.Helpers
}
protected override void UpdateDisplay(User item)
{
if (item == null)
DisplayLabel = "";
else
DisplayLabel = string.Format("User Name: {0}", item.Name);
DisplayLabel = item == null ? "" : string.Format("User Name: {0}", item.Name);
}
protected override User HandleKeydown(object sender, ExtendedKeyEventArgs e)
{
User user = bindingSource.Current as User;
var user = bindingSource.Current as User;
if (userEvent == null)
if (UserEvent == null)
{
e.Handled = false;
return user;
@@ -58,8 +55,8 @@ namespace Tanshu.Accounts.Helpers
if (e.KeyCode == Keys.F1)
user = new User();
UserEventArgs userEventArgs = new UserEventArgs(user);
user = userEvent(sender, userEventArgs);
var userEventArgs = new UserEventArgs(user);
user = UserEvent(sender, userEventArgs);
e.Handled = userEventArgs.Handled;
return user;
+12 -42
View File
@@ -14,11 +14,10 @@ namespace Tanshu.Accounts.Helpers
{
public class SelectWaiter : Tanshu.Data.BaseSelector<Waiter>
{
public event WaiterEventHandler waiterEvent;
public event WaiterEventHandler WaiterEvent;
public SelectWaiter(GetData<Waiter> getData, bool autoClose) : base(getData, true, "Select a Waiter")
{
List<string> filters = new List<string>();
filters.Add("Name");
var filters = new List<string> {"Name"};
SetFilterColumns(filters);
grid.Columns["WaiterID"].Visible = false;
}
@@ -31,46 +30,44 @@ namespace Tanshu.Accounts.Helpers
}
protected override void UpdateDisplay(Waiter item)
{
if (item == null)
DisplayLabel = "";
else
DisplayLabel = string.Format("Waiter Name: {0}", item.Name);
DisplayLabel = item == null ? "" : string.Format("Waiter Name: {0}", item.Name);
}
protected override Waiter HandleKeydown(object sender, ExtendedKeyEventArgs e)
{
Waiter waiter = bindingSource.Current as Waiter;
var waiter = bindingSource.Current as Waiter;
if (waiterEvent == null)
if (WaiterEvent == null)
{
e.Handled = false;
return waiter;
}
WaiterEventArgs eventArgs = new WaiterEventArgs(null, 1);
var eventArgs = new SelectorEventArgs<Waiter>(null,SelectorAction.Insert);
switch (e.KeyCode)
{
case Keys.F1:
{
waiter = new Waiter { Name = base.filterColumns["Name"].Trim() };
eventArgs = new WaiterEventArgs(waiter, 1);
eventArgs = new SelectorEventArgs<Waiter>(waiter,SelectorAction.Insert);
break;
}
case Keys.F2:
{
if (waiter != null)
waiter.Name = base.filterColumns["Name"].Trim();
eventArgs = new WaiterEventArgs(waiter, 2);
eventArgs = new SelectorEventArgs<Waiter>(waiter, SelectorAction.Update);
break;
}
case Keys.F8:
{
if (waiter != null)
eventArgs = new WaiterEventArgs(waiter, 3);
eventArgs = new SelectorEventArgs<Waiter>(waiter, SelectorAction.Delete);
break;
}
}
if ((waiter != null) && ((e.KeyCode == Keys.F1) || (e.KeyCode == Keys.F2) || (e.KeyCode == Keys.F8)))
waiter = waiterEvent(sender, eventArgs);
waiter = WaiterEvent(sender, eventArgs);
e.Handled = eventArgs.Handled;
return waiter;
@@ -108,32 +105,5 @@ namespace Tanshu.Accounts.Helpers
#endregion
#endregion
}
public delegate Waiter WaiterEventHandler(object sender, WaiterEventArgs e);
public class WaiterEventArgs : EventArgs
{
public WaiterEventArgs(Waiter waiter, int action)
{
Waiter = waiter;
Action = action;
Handled = false;
}
public Waiter Waiter
{
get;
private set;
}
public int Action
{
get;
private set;
}
public bool Handled
{
get;
set;
}
}
public delegate Waiter WaiterEventHandler(object sender, SelectorEventArgs<Waiter> e);
}
+38
View File
@@ -0,0 +1,38 @@
using System;
namespace Tanshu.Accounts.Helpers
{
public enum SelectorAction
{
Insert = 1,
Update = 2,
Delete = 3
}
public class SelectorEventArgs<T> : EventArgs
{
public SelectorEventArgs(T item, SelectorAction action)
{
Item = item;
Action = action;
Handled = false;
}
public T Item
{
get;
private set;
}
public SelectorAction Action
{
get;
private set;
}
public bool Handled
{
get;
set;
}
}
}
@@ -63,6 +63,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ControlFactory.cs" />
<Compile Include="SelectorEvent.cs" />
<Compile Include="SelectUser.cs">
<SubType>Form</SubType>
</Compile>
@@ -20,7 +20,7 @@ namespace Tanshu.Accounts.PointOfSale
var control = keyboardControl as UserControl;
if (control != null)
{
control.Location = new System.Drawing.Point(6, 87);
control.Location = new Point(6, 87);
this.Controls.Add(control);
this.Size = this.SizeFromClientSize(new Size(6 + control.Width + 6, 87 + control.Height + 6));
}
@@ -41,7 +41,7 @@ namespace Tanshu.Accounts.PointOfSale
private void btnLogin_Click(object sender, EventArgs e)
{
using (var bi = new UserBI())
_user = bi.ValidateUser(txtUserName.Text.Trim(), Tanshu.Common.Md5.Hash(txtPassword.Text, "v2"));
_user = bi.ValidateUser(txtUserName.Text.Trim(), Common.Md5.Hash(txtPassword.Text, "v2"));
if (_user != null)
this.Close();
else
@@ -15,20 +15,28 @@ namespace Tanshu.Accounts.PointOfSale
private readonly OrderedDictionary<BillItemKey, BillItemValue> _bill;
private Voucher _billInfo;
private Customer _customer;
private int? _editVoucherID;
private readonly bool _print;
private ISaleForm _saleForm;
public Waiter Waiter
{
get { return _billInfo.Waiter; }
set { _billInfo.Waiter = value; }
}
public BillController(int? editVoucherID, bool print)
{
this._editVoucherID = editVoucherID;
_print = print;
_bill = new OrderedDictionary<BillItemKey, BillItemValue>();
_billInfo = new Voucher(Session.User);
using (var bi = new CustomerBI(false))
_customer = bi.Get(x => x.CustomerID == 1);
_billInfo.Customer = bi.Get(x => x.CustomerID == 1);
using (var bi = new WaiterBI(false))
_billInfo.Waiter = bi.Get(x => x.WaiterID == 1);
}
public BillItemValue CurrentProduct
@@ -56,7 +64,7 @@ namespace Tanshu.Accounts.PointOfSale
public void InitGui(ISaleForm saleForm)
{
this._saleForm = saleForm;
this._saleForm.SetCustomerDisplay(_customer.Name);
this._saleForm.SetCustomerDisplay(_billInfo.Customer.Name);
this._saleForm.SetUserName(Session.User.Name);
}
@@ -109,7 +117,7 @@ namespace Tanshu.Accounts.PointOfSale
ShowAmount();
}
public void ShowDiscount()
public void SetDiscount()
{
if (!Session.IsAllowed(RoleConstants.DISCOUNT))
return;
@@ -141,32 +149,67 @@ namespace Tanshu.Accounts.PointOfSale
ShowAmount();
}
public void ShowCustomerList(bool reset)
public void SetQuantity(decimal quantity, bool prompt)
{
if ((_customer.CustomerID == 1) && (!reset))
var item = CurrentProduct;
if (!Allowed(item))
return;
if (item.Printed)
return;
if (prompt && !GetInput("Quantity", ref quantity))
return;
if (!prompt)
quantity += item.Quantity;
if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
return;
var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product && x.Value.Printed).Sum(x => x.Value.Quantity);
if (total < 0)
quantity -= total;
item.Quantity = quantity;
ShowAmount();
}
public void SetRate()
{
var item = CurrentProduct;
if (!Allowed(item, RoleConstants.CHANGE_RATE))
return;
var rate = item.Price;
if (!GetInput("Price", ref rate))
return;
if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE))
return;
foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.ProductID))
sub.Value.Price = rate;
ShowAmount();
}
public void ShowCustomers(bool reset)
{
if (!reset && ((_billInfo.Customer == null) || _billInfo.Customer.CustomerID == 1))
{
using (var selectCustomer = new SelectCustomer(CustomerBI.List, true))
{
selectCustomer.customerEvent += selectCustomer_customerEvent;
selectCustomer.CustomerEvent += selectCustomer_customerEvent;
selectCustomer.ShowDialog();
if (selectCustomer.SelectedItem != null)
{
_customer = selectCustomer.SelectedItem;
_saleForm.SetCustomerDisplay(_customer.Name);
_billInfo.Customer = selectCustomer.SelectedItem;
}
else
{
using (var bi = new CustomerBI(false))
_customer = bi.Get(x => x.CustomerID == 1);
_billInfo.Customer = bi.Get(x => x.CustomerID == 1);
}
}
}
else
{
using (var bi = new CustomerBI(false))
_customer = bi.Get(x => x.CustomerID == 1);
_saleForm.SetCustomerDisplay(_customer.Name);
_billInfo.Customer = bi.Get(x => x.CustomerID == 1);
}
_saleForm.SetCustomerDisplay(_billInfo.Customer.Name);
}
private Customer selectCustomer_customerEvent(object sender, CustomerEventArgs e)
@@ -178,58 +221,61 @@ namespace Tanshu.Accounts.PointOfSale
}
}
public void VoidBill()
public void ShowWaiters(bool reset)
{
#region Check conditions and Permissions
if (_billInfo == null)
return;
//if (!_billInfo.Printed)
// return;
if (_billInfo.Void)
return;
if (!Session.IsAllowed(RoleConstants.VOID_BILL))
return;
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
return;
#endregion
var voidReason = new SelectVoidReason(GetVoidReason, true);
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
if (reset)
{
using (var session = SessionManager.Session)
{
using (var trans = session.BeginTransaction())
{
using (var bi = new VoucherBI(session, false))
bi.VoidBill(_billInfo.VoucherID, voidReason.SelectedItem.Description);
using (var ft = new FoodTableBI(session, false))
ft.UpdateStatus(_billInfo);
trans.Commit();
}
}
ClearBill();
using (var bi = new WaiterBI(false))
_billInfo.Waiter = bi.Get(x => x.WaiterID == 1);
}
else
{
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
using (var selectWaiter = new SelectWaiter(WaiterBI.List, true))
{
selectWaiter.WaiterEvent += selectWaiter_waiterEvent;
selectWaiter.ShowDialog();
if (selectWaiter.SelectedItem != null)
{
_billInfo.Waiter = selectWaiter.SelectedItem;
}
else
{
using (var bi = new WaiterBI(false))
_billInfo.Waiter = bi.Get(x => x.WaiterID == 1);
}
}
}
_saleForm.SetWaiterDisplay(_billInfo.Waiter.Name);
}
private static List<StringType> GetVoidReason(Dictionary<string, string> filter)
private Waiter selectWaiter_waiterEvent(object sender, SelectorEventArgs<Waiter> e)
{
var list = new List<StringType>
{
new StringType("Discount"),
new StringType("Printing Fault"),
new StringType("Item Changed"),
new StringType("Quantity Reduced"),
new StringType("Costing Bill for Party"),
new StringType("Cashier Mistake"),
new StringType("Management Freesale"),
new StringType("Other")
};
return list.Where(i => i.Description.ToLower().Contains(filter["Name"].ToLower().Trim())).ToList();
var waiter = e.Item;
//if (!Thread.CurrentPrincipal.IsInRole("Waiter/Master"))
// return waiter;
using (var bi = new WaiterBI())
{
switch (e.Action)
{
case SelectorAction.Insert: // Add
bi.Insert(waiter);
e.Handled = true;
return waiter;
case SelectorAction.Update: // Edit
bi.Update(waiter);
e.Handled = true;
return waiter;
case SelectorAction.Delete: // Delete
bi.Delete(x => x.WaiterID == waiter.WaiterID);
e.Handled = true;
return bi.Get(x => x.WaiterID == 1);
default:
e.Handled = true;
return bi.Get(x => x.WaiterID == 1);
}
}
}
private void ShowAmount()
@@ -255,52 +301,67 @@ namespace Tanshu.Accounts.PointOfSale
// ShowAmount();
//}
public void SetQuantity(decimal quantity, bool prompt)
{
var item = CurrentProduct;
if (!Allowed(item))
return;
if (item.Printed)
return;
if (prompt && !GetInput("Quantity", ref quantity))
return;
if (!prompt)
quantity += item.Quantity;
if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
return;
var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product).Sum(x => x.Value.Quantity);
if (total < 0)
quantity -= total;
item.Quantity = quantity;
ShowAmount();
}
public void ChangeRate()
{
var item = CurrentProduct;
if (!Allowed(item, RoleConstants.CHANGE_RATE))
return;
var rate = item.Price;
if (!GetInput("Price", ref rate))
return;
if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE))
return;
foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.ProductID))
sub.Value.Price = rate;
ShowAmount();
}
private bool Allowed(BillItemValue item, RoleConstants role)
private static bool Allowed(BillItemValue item, RoleConstants role)
{
return item != null && Session.IsAllowed(role);
}
private bool Allowed(BillItemValue item)
private static bool Allowed(BillItemValue item)
{
return item != null;
}
private static void IsPrintedOrVoid(Voucher voucher, out bool isPrinted, out bool isVoid)
{
using (var bi = new VoucherBI(false))
{
var dbVoucher = bi.Get(x => x.VoucherID == voucher.VoucherID);
isPrinted = dbVoucher.Printed;
isVoid = dbVoucher.Void;
}
}
private static bool IsPrintedOrVoid(Voucher voucher)
{
using (var bi = new VoucherBI(false))
{
var dbVoucher = bi.Get(x => x.VoucherID == voucher.VoucherID);
return dbVoucher.Printed || dbVoucher.Void;
}
}
private static bool IsPrintedOrVoid(int voucherID)
{
using (var bi = new VoucherBI(false))
{
var dbVoucher = bi.Get(x => x.VoucherID == voucherID);
return dbVoucher.Printed || dbVoucher.Void;
}
}
private bool? IsReprint(out decimal amount)
{
amount = 0;
if (_billInfo.VoucherID == 0)
return false;
bool isPrinted, isVoid;
IsPrintedOrVoid(_billInfo, out isPrinted, out isVoid);
if (isVoid)
{
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _billInfo.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
if (isPrinted && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
return null;
amount = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0).Sum(x => x.Value.GrossAmount);
return isPrinted;
}
private void InputBox_Validating(object sender, InputBoxValidatingArgs e)
{
}
@@ -308,16 +369,11 @@ namespace Tanshu.Accounts.PointOfSale
private void LoadBill(int voucherID)
{
ClearBill();
_bill.Clear();
_billInfo = null;
using (var bi = new VoucherBI(false))
{
_billInfo = bi.Get(voucherID);
_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);
_billInfo = bi.Get(x => x.VoucherID == voucherID);
_bill.Clear();
_saleForm.ShowInfo(_billInfo);
foreach (var kot in _billInfo.Kots)
{
@@ -365,6 +421,16 @@ namespace Tanshu.Accounts.PointOfSale
{
LoadBill(table.VoucherID);
}
else
{
using (var frm = new PaxForm())
{
frm.ShowDialog();
_billInfo.TableID = tableName;
_billInfo.Pax = frm.Pax;
_saleForm.ShowInfo(_billInfo);
}
}
}
else
{
@@ -387,8 +453,9 @@ namespace Tanshu.Accounts.PointOfSale
public void ClearBill()
{
_billInfo = null;
ShowCustomerList(true);
_billInfo = new Voucher(Session.User);
ShowCustomers(true);
ShowWaiters(true);
_bill.Clear();
var newKotKey = new BillItemKey(0);
var newKotItem = new BillItemValue();
@@ -409,7 +476,7 @@ namespace Tanshu.Accounts.PointOfSale
internal void SettleBill()
{
if (_billInfo == null)
if (_billInfo.VoucherID == 0)
return;
if (!_billInfo.Printed)
return;
@@ -419,7 +486,7 @@ namespace Tanshu.Accounts.PointOfSale
var amount = (_billInfo.Settlements.Single(x => x.Settled == SettleOption.Amount).Amount +
_billInfo.Settlements.Single(x => x.Settled == SettleOption.RoundOff).Amount) * -1;
using (var frm = new SettleChoicesForm(amount))
using (var frm = new SettleChoicesForm(amount, _billInfo.VoucherType))
{
frm.ShowDialog();
options = frm.OptionsChosen;
@@ -446,32 +513,34 @@ namespace Tanshu.Accounts.PointOfSale
}
}
internal void MergeKot()
internal void MoveKot()
{
if (_billInfo == null)
if (_billInfo.VoucherID == 0)
return;
if (IsPrintedOrVoid(_billInfo))
return;
using (var bi = new VoucherBI(false))
if (bi.IsVoucherPrinted(_billInfo.VoucherID) && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL))
return;
var kot = CurrentKot;
if (kot == null)
return;
var table = GetTableForMove(true);
if (table == null)
return;
if (_billInfo.TableID == table.Name)
if (table.Name == _billInfo.TableID)
return;
if (table.VoucherID != 0)
if (IsPrintedOrVoid(table.VoucherID))
return;
var kotCount = _bill.Keys.Count(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
var voucherID = 0;
if (table.VoucherID == 0 && kotCount > 1)
//Move Kot
voucherID = MoveKot(kot, table);
else if (table.VoucherID == 0 && kotCount == 1)
//Move Table
voucherID = MoveTable(table);
else if (table.VoucherID != 0 && kotCount > 1)
//Merge Kot
voucherID = MergeKot(kot, table);
else if (table.VoucherID == 0 && kotCount == 1)
//Move Table
voucherID = MoveTable(table);
else if (table.VoucherID != 0 && kotCount == 1)
//Merge Table
voucherID = MergeTable(table);
@@ -480,14 +549,20 @@ namespace Tanshu.Accounts.PointOfSale
}
internal void MoveTable()
{
if (_billInfo == null)
if (_billInfo.VoucherID == 0)
return;
using (var bi = new VoucherBI(false))
if (bi.IsVoucherPrinted(_billInfo.VoucherID) && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL))
return;
var table = GetTableForMove(true);
var allowMerge = !IsPrintedOrVoid(_billInfo);
var table = GetTableForMove(allowMerge);
if (table == null)
return;
if (table.Name == _billInfo.TableID)
return;
if (table.VoucherID != 0)
if (IsPrintedOrVoid(table.VoucherID))
return;
LoadBill(table.VoucherID == 0 ? MoveTable(table) : MergeTable(table));
}
@@ -495,15 +570,7 @@ namespace Tanshu.Accounts.PointOfSale
{
if (!Session.IsAllowed(RoleConstants.MOVE_KOT))
return 0;
var voucher = new Voucher(Session.User)
{
Customer = _billInfo.Customer,
TableID = table.Name,
Waiter = _billInfo.Waiter,
Printed = _billInfo.Printed,
Void = false,
Narration = "",
};
var voucher = new Voucher(Session.User, _billInfo.Customer, table.Name, _billInfo.Waiter, _billInfo.Printed, false, "");
using (var session = SessionManager.Session)
{
@@ -540,60 +607,239 @@ namespace Tanshu.Accounts.PointOfSale
{
if (!Session.IsAllowed(RoleConstants.MERGE_TABLE))
return 0;
if (_billInfo.Printed)
return 0;
var kots = _bill.Keys.Where(x => x.BillItemType == BillItemType.Kot && x.KotID != 0);
foreach (var item in kots)
MergeKot(item, table);
int voucherID;
using (var bi = new VoucherBI())
voucherID = bi.MergeTables(_billInfo.VoucherID, table);
using (var bi = new VoucherBI())
bi.Delete(_billInfo.VoucherID);
return table.VoucherID;
return voucherID;
}
#endregion
#region Save
public void SaveBill(int waiterID, string tableID)
public void SaveKot()
{
#region Check if Allowed
if (!Session.IsAllowed(RoleConstants.PRINT_KOT))
return;
if (_billInfo.VoucherID != 0 && IsPrintedOrVoid(_billInfo))
return;
if (_bill.Count == 1) //new kot only
return;
#endregion
//Save
var saved = _billInfo.VoucherID == 0 ? InsertVoucher(false, !_editVoucherID.HasValue) : UpdateVoucher(false, !_editVoucherID.HasValue);
//Print
if ((!_editVoucherID.HasValue || _print) && saved.HasValue)
Thermal.PrintKot(_billInfo.VoucherID, saved.Value);
//Cleanup
if (_editVoucherID.HasValue)
_saleForm.CloseWindow();
else
ClearBill();
}
public void SaveBill()
{
#region Check if Allowed
if (!Session.IsAllowed(RoleConstants.PRINT_BILL))
return;
if (_bill.Count == 1) //new kot only
return;
var printed = false;
if (_billInfo != null)
using (var bi = new VoucherBI(false))
{
var voucher = bi.Get(_billInfo.VoucherID);
if (voucher.Void)
{
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _billInfo.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
printed = voucher.Printed;
}
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();
if (printed)
SaveReprintOrDiscountBill(waiterID, tableID, amount);
else
SaveNewBill(waiterID, tableID);
#endregion
decimal amount;
var isReprint = IsReprint(out amount);
if (!isReprint.HasValue)
return;
else if (isReprint.Value)
{
SetDiscount();
SaveReprintOrDiscountBill(amount);
}
else
{
SetDiscount();
// Ask for VoucherType only for new bill, if none, then cancel
VoucherType? voucherType;
using (var frm = new VoucherTypeForm())
{
frm.ShowDialog();
voucherType = frm.Selection;
}
if (!voucherType.HasValue)
return;
_billInfo.VoucherType = voucherType.Value;
var saved = _billInfo.VoucherID == 0 ? InsertVoucher(true, !_editVoucherID.HasValue) : UpdateVoucher(true, !_editVoucherID.HasValue);
}
if (!_editVoucherID.HasValue || _print)
Thermal.PrintBill(_billInfo.VoucherID);
if (_editVoucherID.HasValue)
_saleForm.CloseWindow();
ClearBill();
}
public void SaveNewBill(int waiterID, string tableID)
public void SplitBill()
{
var saved = _billInfo == null
? InsertVoucher(true, waiterID, tableID, !_editVoucherID.HasValue)
: UpdateVoucher(true, waiterID, tableID, !_editVoucherID.HasValue);
#region Permissions
bool isPrinted, isVoid;
IsPrintedOrVoid(_billInfo, out isPrinted, out isVoid);
if (_billInfo.VoucherID == 0 || isVoid)
return; // must be existing non void bill
if (!Session.IsAllowed(RoleConstants.SPLIT_BILL))
return;
#endregion
#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 = isPrinted,
Void = false,
Narration = "",
VoucherType = _billInfo.VoucherType
};
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 = isPrinted,
Void = false,
Narration = "",
VoucherType = _billInfo.VoucherType
};
var kotSecond = GetKot(listSecond);
if (kotSecond != null)
voucherSecond.Kots.Add(kotSecond);
#endregion
#region Old Voucher
_billInfo.User = Session.User;
_billInfo.Void = true;
_billInfo.VoidReason = "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 (isPrinted)
{
Thermal.PrintBill(voucherFirst.VoucherID);
Thermal.PrintBill(voucherSecond.VoucherID);
}
LoadBill(voucherFirst.VoucherID);
}
public void SaveReprintOrDiscountBill(int waiterID, string tableID, decimal oldAmount)
public void VoidBill()
{
#region Check conditions and Permissions
if (_billInfo.VoucherID == 0)
return;
//if (!_billInfo.Printed)
// return;
if (_billInfo.Void)
return;
if (!Session.IsAllowed(RoleConstants.VOID_BILL))
return;
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
return;
#endregion
var voidReason = new SelectVoidReason(GetVoidReason, true);
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
{
using (var session = SessionManager.Session)
{
using (var trans = session.BeginTransaction())
{
using (var bi = new VoucherBI(session, false))
bi.VoidBill(_billInfo.VoucherID, voidReason.SelectedItem.Description);
_billInfo.Void = true;
_billInfo.VoidReason = voidReason.SelectedItem.Description;
using (var ft = new FoodTableBI(session, false))
ft.UpdateStatus(_billInfo);
trans.Commit();
}
}
ClearBill();
}
else
{
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
private static List<StringType> GetVoidReason(Dictionary<string, string> filter)
{
var list = new List<StringType>
{
new StringType("Discount"),
new StringType("Printing Fault"),
new StringType("Item Changed"),
new StringType("Quantity Reduced"),
new StringType("Costing Bill for Party"),
new StringType("Cashier Mistake"),
new StringType("Management Freesale"),
new StringType("Other")
};
return list.Where(i => i.Description.ToLower().Contains(filter["Name"].ToLower().Trim())).ToList();
}
private void SaveReprintOrDiscountBill(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;
@@ -607,7 +853,8 @@ namespace Tanshu.Accounts.PointOfSale
Waiter = _billInfo.Waiter,
Printed = true,
Void = false,
Narration = ""
Narration = "",
VoucherType = _billInfo.VoucherType
};
var kotNew = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product));
@@ -644,47 +891,16 @@ namespace Tanshu.Accounts.PointOfSale
bi.Insert(new Reprint() { Date = DbValues.Date, User = Session.User, Voucher = _billInfo });
}
}
public void SaveKot(int waiterID, string tableID)
private int? InsertVoucher(bool finalBill, bool updateTable)
{
if (!Session.IsAllowed(RoleConstants.PRINT_KOT))
return;
using (var bi = new VoucherBI(false)) // Kot on printed bill not allowed
if ((_billInfo != null) && (bi.IsVoucherPrinted(_billInfo.VoucherID)))
return;
if (_bill.Count == 1) //new kot only
return;
var saved = _billInfo == null ? InsertVoucher(false, waiterID, tableID, !_editVoucherID.HasValue) : UpdateVoucher(false, waiterID, tableID, !_editVoucherID.HasValue);
if ((!_editVoucherID.HasValue || _print) && saved.HasValue)
Thermal.PrintKot(_billInfo.VoucherID, saved.Value);
if (_editVoucherID.HasValue)
_saleForm.CloseWindow();
ClearBill();
}
private int? InsertVoucher(bool finalBill, int waiterID, string tableID, bool updateTable)
{
if (_billInfo != null)
{
MessageBox.Show("Error in InsertVoucher, there is a previous sale in memory", "Error");
return null;
}
_billInfo = new Voucher(Session.User)
{
Customer = _customer,
//Paid = finalBill,
TableID = tableID,
Waiter = WaiterBI.GetWaiter(waiterID),
Printed = finalBill,
Void = false,
Narration = "",
};
UpdateKots();
_billInfo.Printed = finalBill;
_billInfo.Void = false;
_billInfo.Narration = "";
//UpdateKots();
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);
if (kot == null)
return null;
_billInfo.Kots.Add(kot);
using (var session = SessionManager.Session)
{
using (var trans = session.BeginTransaction())
@@ -700,14 +916,9 @@ namespace Tanshu.Accounts.PointOfSale
}
}
}
private int? UpdateVoucher(bool finalBill, int waiterID, string tableID, bool updateTable)
private int? UpdateVoucher(bool finalBill, bool updateTable)
{
_billInfo.User = Session.User;
_billInfo.Customer = _customer;
_billInfo.TableID = tableID;
_billInfo.Waiter = WaiterBI.GetWaiter(waiterID);
UpdateKots();
if (!_billInfo.Printed)
@@ -734,7 +945,6 @@ namespace Tanshu.Accounts.PointOfSale
}
}
}
private void UpdateKots()
{
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0))
@@ -776,17 +986,15 @@ namespace Tanshu.Accounts.PointOfSale
return kot.Inventories.Count == 0 ? null : kot;
}
#endregion
#region InputBox
private bool GetInput(string prompt, ref decimal amount)
{
var result = InputBox.Show(prompt, amount.ToString(), InputBox_Validating);
if (!result.OK)
return false;
if (!decimal.TryParse(result.Text, out amount))
return false;
return true;
return decimal.TryParse(result.Text, out amount);
}
private bool GetInput(string prompt, ref string info)
{
@@ -794,114 +1002,8 @@ namespace Tanshu.Accounts.PointOfSale
if (!result.OK)
return false;
info = result.Text.Trim();
if (string.IsNullOrEmpty(info))
return false;
return true;
return !string.IsNullOrEmpty(info);
}
#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);
}
}
}
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using Tanshu.Accounts.Contracts;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Common;
namespace Tanshu.Accounts.PointOfSale
@@ -12,9 +13,10 @@ namespace Tanshu.Accounts.PointOfSale
{
void ClearBill(List<BillItemValue> bill);
void SetCustomerDisplay(string name);
void SetWaiterDisplay(string p);
void CloseWindow();
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(Voucher voucher);
void SetUserName(string name);
BindingSource BindingSource { get; }
SaleFormState FormState { set; }
+19 -20
View File
@@ -5,6 +5,7 @@ using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.Management;
using Tanshu.Accounts.PointOfSale.Sales;
using Tanshu.Accounts.Repository;
using Tanshu.Common;
@@ -75,17 +76,6 @@ namespace Tanshu.Accounts.PointOfSale
frm.ShowDialog();
}
private void btnInitial_Click(object sender, EventArgs e)
{
#if (DEBUG)
if (Session.IsAllowed(RoleConstants.MASTER_OWNER))
{
Fixtures.CreateSchema();
MessageBox.Show("Schema Recreated");
}
#endif
}
private void btnAdvanceReceive_Click(object sender, EventArgs e)
{
if (Session.IsAllowed(RoleConstants.SALES))
@@ -112,7 +102,7 @@ namespace Tanshu.Accounts.PointOfSale
{
using (var form = new SelectUser(bi.GetFilteredUsers, true))
{
form.userEvent += form_userEvent;
form.UserEvent += form_userEvent;
form.ShowDialog();
}
}
@@ -159,12 +149,6 @@ namespace Tanshu.Accounts.PointOfSale
private void CheckRoles()
{
#if (DEBUG)
btnInitial.Visible = Session.IsAllowed(RoleConstants.MASTER_OWNER);
#else
btnInitial.Visible = false;
#endif
btnSale.Visible = Session.IsAllowed(RoleConstants.SALES);
btnProduct.Visible = Session.IsAllowed(RoleConstants.PRODUCTS);
@@ -189,8 +173,10 @@ namespace Tanshu.Accounts.PointOfSale
btnBillDetails.Visible = Session.IsAllowed(RoleConstants.BILL_DETAILS);
btnVoidOrReprints.Visible = Session.IsAllowed(RoleConstants.VOID_OR_REPRINTED_BILL_REPORT);
btnDiscountReport.Visible = Session.IsAllowed(RoleConstants.VOID_OR_REPRINTED_BILL_REPORT);
btnChangePassword.Visible = Session.IsAuthenticated;
btnManagement.Visible = false;
}
private void btnGroupRoles_Click(object sender, EventArgs e)
@@ -248,7 +234,7 @@ namespace Tanshu.Accounts.PointOfSale
return;
Voucher voucher;
using (var bi = new VoucherBI(false))
voucher = bi.Get(result.Text);
voucher = bi.Get(x => x.BillID == result.Text);
if (Session.IsAllowed(RoleConstants.SALES))
using (var frmSale = new SalesForm(new BillController(voucher.VoucherID, true)))
frmSale.ShowDialog();
@@ -271,10 +257,23 @@ namespace Tanshu.Accounts.PointOfSale
private void btnVoidOrReprints_Click(object sender, EventArgs e)
{
if (Session.IsAllowed(RoleConstants.VOID_OR_REPRINTED_BILL_REPORT))
using (var frm = new VoidReprintedForm())
using (var frm = new VoidReprintedForm())
frm.ShowDialog();
}
private void btnManagement_Click(object sender, EventArgs e)
{
using (var frm = new QuantityForm())
frm.ShowDialog();
}
private void btnDiscountReport_Click(object sender, EventArgs e)
{
using (var frm = new DiscountReportForm())
frm.ShowDialog();
}
}
}
+51 -38
View File
@@ -30,7 +30,6 @@
{
this.btnLogin = new System.Windows.Forms.Button();
this.btnSale = new System.Windows.Forms.Button();
this.btnInitial = new System.Windows.Forms.Button();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnSwipeLogin = new System.Windows.Forms.Button();
this.btnCustomer = new System.Windows.Forms.Button();
@@ -46,15 +45,17 @@
this.btnSaleAnalysis = new System.Windows.Forms.Button();
this.btnSaleDetail = new System.Windows.Forms.Button();
this.btnBillDetails = new System.Windows.Forms.Button();
this.btnVoidOrReprints = new System.Windows.Forms.Button();
this.btnDiscountReport = new System.Windows.Forms.Button();
this.btnChangePassword = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnVoidOrReprints = new System.Windows.Forms.Button();
this.btnManagement = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// btnLogin
//
this.btnLogin.Location = new System.Drawing.Point(159, 3);
this.btnLogin.Location = new System.Drawing.Point(3, 3);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(150, 100);
this.btnLogin.TabIndex = 1;
@@ -64,7 +65,7 @@
//
// btnSale
//
this.btnSale.Location = new System.Drawing.Point(471, 3);
this.btnSale.Location = new System.Drawing.Point(315, 3);
this.btnSale.Name = "btnSale";
this.btnSale.Size = new System.Drawing.Size(150, 100);
this.btnSale.TabIndex = 3;
@@ -72,19 +73,8 @@
this.btnSale.UseVisualStyleBackColor = true;
this.btnSale.Click += new System.EventHandler(this.btnSale_Click);
//
// btnInitial
//
this.btnInitial.Location = new System.Drawing.Point(3, 3);
this.btnInitial.Name = "btnInitial";
this.btnInitial.Size = new System.Drawing.Size(150, 100);
this.btnInitial.TabIndex = 0;
this.btnInitial.Text = "Initial Data";
this.btnInitial.UseVisualStyleBackColor = true;
this.btnInitial.Click += new System.EventHandler(this.btnInitial_Click);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.btnInitial);
this.flowLayoutPanel1.Controls.Add(this.btnLogin);
this.flowLayoutPanel1.Controls.Add(this.btnSwipeLogin);
this.flowLayoutPanel1.Controls.Add(this.btnSale);
@@ -102,8 +92,10 @@
this.flowLayoutPanel1.Controls.Add(this.btnSaleDetail);
this.flowLayoutPanel1.Controls.Add(this.btnBillDetails);
this.flowLayoutPanel1.Controls.Add(this.btnVoidOrReprints);
this.flowLayoutPanel1.Controls.Add(this.btnDiscountReport);
this.flowLayoutPanel1.Controls.Add(this.btnChangePassword);
this.flowLayoutPanel1.Controls.Add(this.btnExit);
this.flowLayoutPanel1.Controls.Add(this.btnManagement);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
@@ -112,7 +104,7 @@
//
// btnSwipeLogin
//
this.btnSwipeLogin.Location = new System.Drawing.Point(315, 3);
this.btnSwipeLogin.Location = new System.Drawing.Point(159, 3);
this.btnSwipeLogin.Name = "btnSwipeLogin";
this.btnSwipeLogin.Size = new System.Drawing.Size(150, 100);
this.btnSwipeLogin.TabIndex = 2;
@@ -122,7 +114,7 @@
//
// btnCustomer
//
this.btnCustomer.Location = new System.Drawing.Point(627, 3);
this.btnCustomer.Location = new System.Drawing.Point(471, 3);
this.btnCustomer.Name = "btnCustomer";
this.btnCustomer.Size = new System.Drawing.Size(150, 100);
this.btnCustomer.TabIndex = 4;
@@ -132,7 +124,7 @@
//
// btnProduct
//
this.btnProduct.Location = new System.Drawing.Point(3, 109);
this.btnProduct.Location = new System.Drawing.Point(627, 3);
this.btnProduct.Name = "btnProduct";
this.btnProduct.Size = new System.Drawing.Size(150, 100);
this.btnProduct.TabIndex = 5;
@@ -142,7 +134,7 @@
//
// btnProductGroup
//
this.btnProductGroup.Location = new System.Drawing.Point(159, 109);
this.btnProductGroup.Location = new System.Drawing.Point(3, 109);
this.btnProductGroup.Name = "btnProductGroup";
this.btnProductGroup.Size = new System.Drawing.Size(150, 100);
this.btnProductGroup.TabIndex = 6;
@@ -152,7 +144,7 @@
//
// btnOpenBill
//
this.btnOpenBill.Location = new System.Drawing.Point(315, 109);
this.btnOpenBill.Location = new System.Drawing.Point(159, 109);
this.btnOpenBill.Name = "btnOpenBill";
this.btnOpenBill.Size = new System.Drawing.Size(150, 100);
this.btnOpenBill.TabIndex = 7;
@@ -162,7 +154,7 @@
//
// btnAdvanceReceive
//
this.btnAdvanceReceive.Location = new System.Drawing.Point(471, 109);
this.btnAdvanceReceive.Location = new System.Drawing.Point(315, 109);
this.btnAdvanceReceive.Name = "btnAdvanceReceive";
this.btnAdvanceReceive.Size = new System.Drawing.Size(150, 100);
this.btnAdvanceReceive.TabIndex = 8;
@@ -172,7 +164,7 @@
//
// btnAdvanceAdjust
//
this.btnAdvanceAdjust.Location = new System.Drawing.Point(627, 109);
this.btnAdvanceAdjust.Location = new System.Drawing.Point(471, 109);
this.btnAdvanceAdjust.Name = "btnAdvanceAdjust";
this.btnAdvanceAdjust.Size = new System.Drawing.Size(150, 100);
this.btnAdvanceAdjust.TabIndex = 9;
@@ -182,7 +174,7 @@
//
// btnCreateUser
//
this.btnCreateUser.Location = new System.Drawing.Point(3, 215);
this.btnCreateUser.Location = new System.Drawing.Point(627, 109);
this.btnCreateUser.Name = "btnCreateUser";
this.btnCreateUser.Size = new System.Drawing.Size(150, 100);
this.btnCreateUser.TabIndex = 10;
@@ -192,7 +184,7 @@
//
// btnUserRoles
//
this.btnUserRoles.Location = new System.Drawing.Point(159, 215);
this.btnUserRoles.Location = new System.Drawing.Point(3, 215);
this.btnUserRoles.Name = "btnUserRoles";
this.btnUserRoles.Size = new System.Drawing.Size(150, 100);
this.btnUserRoles.TabIndex = 11;
@@ -202,7 +194,7 @@
//
// btnGroupRoles
//
this.btnGroupRoles.Location = new System.Drawing.Point(315, 215);
this.btnGroupRoles.Location = new System.Drawing.Point(159, 215);
this.btnGroupRoles.Name = "btnGroupRoles";
this.btnGroupRoles.Size = new System.Drawing.Size(150, 100);
this.btnGroupRoles.TabIndex = 12;
@@ -212,7 +204,7 @@
//
// btnCashierCheckout
//
this.btnCashierCheckout.Location = new System.Drawing.Point(471, 215);
this.btnCashierCheckout.Location = new System.Drawing.Point(315, 215);
this.btnCashierCheckout.Name = "btnCashierCheckout";
this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100);
this.btnCashierCheckout.TabIndex = 13;
@@ -222,7 +214,7 @@
//
// btnSaleAnalysis
//
this.btnSaleAnalysis.Location = new System.Drawing.Point(627, 215);
this.btnSaleAnalysis.Location = new System.Drawing.Point(471, 215);
this.btnSaleAnalysis.Name = "btnSaleAnalysis";
this.btnSaleAnalysis.Size = new System.Drawing.Size(150, 100);
this.btnSaleAnalysis.TabIndex = 14;
@@ -232,7 +224,7 @@
//
// btnSaleDetail
//
this.btnSaleDetail.Location = new System.Drawing.Point(3, 321);
this.btnSaleDetail.Location = new System.Drawing.Point(627, 215);
this.btnSaleDetail.Name = "btnSaleDetail";
this.btnSaleDetail.Size = new System.Drawing.Size(150, 100);
this.btnSaleDetail.TabIndex = 15;
@@ -242,7 +234,7 @@
//
// btnBillDetails
//
this.btnBillDetails.Location = new System.Drawing.Point(159, 321);
this.btnBillDetails.Location = new System.Drawing.Point(3, 321);
this.btnBillDetails.Name = "btnBillDetails";
this.btnBillDetails.Size = new System.Drawing.Size(150, 100);
this.btnBillDetails.TabIndex = 16;
@@ -250,6 +242,26 @@
this.btnBillDetails.UseVisualStyleBackColor = true;
this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click);
//
// btnVoidOrReprints
//
this.btnVoidOrReprints.Location = new System.Drawing.Point(159, 321);
this.btnVoidOrReprints.Name = "btnVoidOrReprints";
this.btnVoidOrReprints.Size = new System.Drawing.Size(150, 100);
this.btnVoidOrReprints.TabIndex = 19;
this.btnVoidOrReprints.Text = "Voids or Reprints";
this.btnVoidOrReprints.UseVisualStyleBackColor = true;
this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click);
//
// btnDiscountReport
//
this.btnDiscountReport.Location = new System.Drawing.Point(315, 321);
this.btnDiscountReport.Name = "btnDiscountReport";
this.btnDiscountReport.Size = new System.Drawing.Size(150, 100);
this.btnDiscountReport.TabIndex = 21;
this.btnDiscountReport.Text = "Discount Report";
this.btnDiscountReport.UseVisualStyleBackColor = true;
this.btnDiscountReport.Click += new System.EventHandler(this.btnDiscountReport_Click);
//
// btnChangePassword
//
this.btnChangePassword.Location = new System.Drawing.Point(471, 321);
@@ -270,15 +282,15 @@
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnVoidOrReprints
// btnManagement
//
this.btnVoidOrReprints.Location = new System.Drawing.Point(315, 321);
this.btnVoidOrReprints.Name = "btnVoidOrReprints";
this.btnVoidOrReprints.Size = new System.Drawing.Size(150, 100);
this.btnVoidOrReprints.TabIndex = 19;
this.btnVoidOrReprints.Text = "Voids or Reprints";
this.btnVoidOrReprints.UseVisualStyleBackColor = true;
this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click);
this.btnManagement.Location = new System.Drawing.Point(3, 427);
this.btnManagement.Name = "btnManagement";
this.btnManagement.Size = new System.Drawing.Size(150, 100);
this.btnManagement.TabIndex = 20;
this.btnManagement.Text = "Mgt";
this.btnManagement.UseVisualStyleBackColor = true;
this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click);
//
// MainForm
//
@@ -300,7 +312,6 @@
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Button btnSale;
private System.Windows.Forms.Button btnInitial;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button btnProduct;
private System.Windows.Forms.Button btnProductGroup;
@@ -319,5 +330,7 @@
private System.Windows.Forms.Button btnOpenBill;
private System.Windows.Forms.Button btnBillDetails;
private System.Windows.Forms.Button btnVoidOrReprints;
private System.Windows.Forms.Button btnManagement;
private System.Windows.Forms.Button btnDiscountReport;
}
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
@@ -8,69 +9,108 @@ namespace Tanshu.Accounts.Management
{
public partial class QuantityForm : Form
{
IList<BillDetail> _list;
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public QuantityForm()
{
InitializeComponent();
//log.Warn(string.Format("Sales Analysis by: {0}", Session.User.Name));
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void ShowStatement()
{
_list = new SalesAnalysisBI().GetBillDetails(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[1].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
{
dtpStart.Value = DateTime.Today;
dtpFinish.Value = DateTime.Today;
ShowStatement();
}
private void btnGo_Click(object sender, EventArgs e)
{
string type = null;
int baseCode = 0;
if (rbLight.Checked)
{
type = "Light";
baseCode = 1;
}
else if (rbPremium.Checked)
{
type = "Premium";
baseCode = 2;
}
else if (rbWheat.Checked)
{
type = "Wheat";
baseCode = 3;
}
else if (rbDark.Checked)
{
type = "Dark";
baseCode = 4;
}
else if (rbFestival.Checked)
{
type = "Festival";
baseCode = 5;
}
dtpStart.Value = dtpStart.Value.Date.AddHours(7);
dtpFinish.Value = dtpFinish.Value.Date.AddDays(1).AddHours(7);
var quantity = GetQuantity(baseCode);
var newQuantity = Convert.ToDecimal(txtQuantity.Text);
if (MessageBox.Show(quantity.ToString(), "Quantity of Beer", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes && quantity > newQuantity)
{
MessageBox.Show(SetQuantity(baseCode, newQuantity).ToString());
}
MessageBox.Show(GetQuantity(type).ToString());
}
private decimal GetQuantity(string type)
private decimal GetQuantity(int baseCode)
{
""
using (var bi = new ManagementBI())
return bi.GetQuantity(baseCode, dtpStart.Value, dtpFinish.Value);
}
private decimal SetQuantity(int baseCode, decimal quantity)
{
using (var bi = new ManagementBI())
return bi.SetQuantity(baseCode, quantity, dtpStart.Value, dtpFinish.Value);
}
private void btnGetClipboard_Click(object sender, EventArgs e)
{
//Clipboard format -- Date,BaseCode,Quantity"
var fmtCsv = DataFormats.CommaSeparatedValue;
// read the CSV
var dataobject = Clipboard.GetDataObject();
if (dataobject == null)
{
MessageBox.Show(@"No Data in clipboard");
return;
}
var stream = (System.IO.Stream)dataobject.GetData(fmtCsv);
var enc = new System.Text.UTF8Encoding();
IFormatProvider culture = new CultureInfo("en-US", true);
using (var reader = new System.IO.StreamReader(stream, enc))
{
using (var bi = new ManagementBI())
{
string line;
while ((line = reader.ReadLine()) != null)
{
DateTime startDate;
int baseCode;
decimal quantity;
var data = line.Split(',');
if (!DateTime.TryParseExact(data[0], "dd-MMM-yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out startDate))
continue;
var finishDate = startDate.AddDays(1).AddHours(7);
startDate = startDate.AddHours(7);
if (!int.TryParse(data[1], out baseCode))
continue;
if (baseCode <=0)
continue;
if (!decimal.TryParse(data[2], out quantity))
continue;
bi.SetQuantity(baseCode, quantity, startDate, finishDate);
}
}
}
}
}
}
@@ -39,6 +39,7 @@
this.rbFestival = new System.Windows.Forms.RadioButton();
this.txtQuantity = new System.Windows.Forms.TextBox();
this.btnGo = new System.Windows.Forms.Button();
this.btnGetClipboard = new System.Windows.Forms.Button();
this.flpProducts.SuspendLayout();
this.SuspendLayout();
//
@@ -50,7 +51,6 @@
this.dtpFinish.Name = "dtpFinish";
this.dtpFinish.Size = new System.Drawing.Size(90, 20);
this.dtpFinish.TabIndex = 21;
this.dtpFinish.ValueChanged += new System.EventHandler(this.dtpFinish_ValueChanged);
//
// dtpStart
//
@@ -60,7 +60,6 @@
this.dtpStart.Name = "dtpStart";
this.dtpStart.Size = new System.Drawing.Size(90, 20);
this.dtpStart.TabIndex = 20;
this.dtpStart.ValueChanged += new System.EventHandler(this.dtpStart_ValueChanged);
//
// label10
//
@@ -152,17 +151,28 @@
//
this.btnGo.Location = new System.Drawing.Point(12, 207);
this.btnGo.Name = "btnGo";
this.btnGo.Size = new System.Drawing.Size(335, 23);
this.btnGo.Size = new System.Drawing.Size(150, 23);
this.btnGo.TabIndex = 24;
this.btnGo.Text = "Go";
this.btnGo.UseVisualStyleBackColor = true;
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
//
// btnGetClipboard
//
this.btnGetClipboard.Location = new System.Drawing.Point(168, 207);
this.btnGetClipboard.Name = "btnGetClipboard";
this.btnGetClipboard.Size = new System.Drawing.Size(179, 23);
this.btnGetClipboard.TabIndex = 25;
this.btnGetClipboard.Text = "Go Clipboard";
this.btnGetClipboard.UseVisualStyleBackColor = true;
this.btnGetClipboard.Click += new System.EventHandler(this.btnGetClipboard_Click);
//
// QuantityForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(359, 242);
this.Controls.Add(this.btnGetClipboard);
this.Controls.Add(this.btnGo);
this.Controls.Add(this.flpProducts);
this.Controls.Add(this.dtpFinish);
@@ -194,5 +204,6 @@
private System.Windows.Forms.RadioButton rbFestival;
private System.Windows.Forms.TextBox txtQuantity;
private System.Windows.Forms.Button btnGo;
private System.Windows.Forms.Button btnGetClipboard;
}
}
+17 -5
View File
@@ -50,6 +50,7 @@
this.btnOk = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.txtSortOrder = new System.Windows.Forms.TextBox();
this.txtFullPrice = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsTax)).BeginInit();
this.SuspendLayout();
@@ -57,11 +58,11 @@
// Label4
//
this.Label4.AutoSize = true;
this.Label4.Location = new System.Drawing.Point(22, 67);
this.Label4.Location = new System.Drawing.Point(12, 68);
this.Label4.Name = "Label4";
this.Label4.Size = new System.Drawing.Size(84, 13);
this.Label4.Size = new System.Drawing.Size(114, 13);
this.Label4.TabIndex = 15;
this.Label4.Text = "Sale Price / Tax";
this.Label4.Text = "Price / Full Price / Tax";
//
// bsProductGroups
//
@@ -143,9 +144,9 @@
// txtPrice
//
this.txtPrice.AccessibleName = "";
this.txtPrice.Location = new System.Drawing.Point(112, 64);
this.txtPrice.Location = new System.Drawing.Point(132, 64);
this.txtPrice.Name = "txtPrice";
this.txtPrice.Size = new System.Drawing.Size(189, 20);
this.txtPrice.Size = new System.Drawing.Size(84, 20);
this.txtPrice.TabIndex = 3;
this.txtPrice.Text = "0";
//
@@ -238,11 +239,21 @@
this.txtSortOrder.TabIndex = 6;
this.txtSortOrder.Text = "0";
//
// txtFullPrice
//
this.txtFullPrice.AccessibleName = "";
this.txtFullPrice.Location = new System.Drawing.Point(222, 64);
this.txtFullPrice.Name = "txtFullPrice";
this.txtFullPrice.Size = new System.Drawing.Size(79, 20);
this.txtFullPrice.TabIndex = 19;
this.txtFullPrice.Text = "0";
//
// ProductForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(415, 230);
this.Controls.Add(this.txtFullPrice);
this.Controls.Add(this.txtSortOrder);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnCancel);
@@ -298,5 +309,6 @@
private System.Windows.Forms.Button btnOk;
internal System.Windows.Forms.Label label1;
internal System.Windows.Forms.TextBox txtSortOrder;
internal System.Windows.Forms.TextBox txtFullPrice;
}
}
@@ -27,6 +27,7 @@ namespace Tanshu.Accounts.PointOfSale
txtName.Text = product.Name;
txtUnits.Text = product.Units;
txtPrice.Text = product.Price.ToString("#.##");
txtFullPrice.Text = product.FullPrice.ToString("#.##");
cmbTax.SelectedValue = product.Tax.TaxID;
txtServiceCharge.Text = product.ServiceCharge.ToString("#.##");
chkDiscontinued.Checked = product.Discontinued;
@@ -77,12 +78,18 @@ namespace Tanshu.Accounts.PointOfSale
// return null;
product.Units = txtUnits.Text.Trim();
decimal salePrice;
if (!decimal.TryParse(txtPrice.Text, out salePrice))
decimal price;
if (!decimal.TryParse(txtPrice.Text, out price))
return null;
if (salePrice < 0)
if (price < 0)
return null;
product.Price = salePrice;
product.Price = price;
if (!decimal.TryParse(txtFullPrice.Text, out price))
return null;
if (price < 0 || price < product.Price)
return null;
product.FullPrice = price;
// Tax
if (cmbTax.SelectedItem == null)
@@ -10,11 +10,9 @@ namespace Tanshu.Accounts.PointOfSale
public partial class BillDetailsForm : Form
{
IList<BillDetail> _list;
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public BillDetailsForm()
{
InitializeComponent();
//log.Warn(string.Format("Sales Analysis by: {0}", Session.User.Name));
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
@@ -24,6 +22,8 @@ namespace Tanshu.Accounts.PointOfSale
private void ShowStatement()
{
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
return;
_list = new SalesAnalysisBI().GetBillDetails(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list;
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
public partial class DiscountReportForm : Form
{
IList<SalesAnalysis> _list;
public DiscountReportForm()
{
InitializeComponent();
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void ShowStatement()
{
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
return;
_list = new SalesAnalysisBI().DiscountReport(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[1].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
{
dtpStart.Value = DateTime.Today;
dtpFinish.Value = DateTime.Today;
ShowStatement();
}
}
}
@@ -0,0 +1,114 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class DiscountReportForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgvSale = new System.Windows.Forms.DataGridView();
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
this.dtpStart = new System.Windows.Forms.DateTimePicker();
this.label10 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit();
this.SuspendLayout();
//
// dgvSale
//
this.dgvSale.AllowUserToAddRows = false;
this.dgvSale.AllowUserToDeleteRows = false;
this.dgvSale.AllowUserToResizeRows = false;
this.dgvSale.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvSale.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvSale.Location = new System.Drawing.Point(12, 41);
this.dgvSale.MultiSelect = false;
this.dgvSale.Name = "dgvSale";
this.dgvSale.ReadOnly = true;
this.dgvSale.RowHeadersVisible = false;
this.dgvSale.RowTemplate.Height = 19;
this.dgvSale.RowTemplate.ReadOnly = true;
this.dgvSale.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvSale.Size = new System.Drawing.Size(335, 466);
this.dgvSale.TabIndex = 14;
//
// dtpFinish
//
this.dtpFinish.CustomFormat = "dd-MMM-yyyy";
this.dtpFinish.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpFinish.Location = new System.Drawing.Point(168, 12);
this.dtpFinish.Name = "dtpFinish";
this.dtpFinish.Size = new System.Drawing.Size(90, 20);
this.dtpFinish.TabIndex = 21;
this.dtpFinish.ValueChanged += new System.EventHandler(this.dtpFinish_ValueChanged);
//
// dtpStart
//
this.dtpStart.CustomFormat = "dd-MMM-yyyy";
this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpStart.Location = new System.Drawing.Point(12, 12);
this.dtpStart.Name = "dtpStart";
this.dtpStart.Size = new System.Drawing.Size(90, 20);
this.dtpStart.TabIndex = 20;
this.dtpStart.ValueChanged += new System.EventHandler(this.dtpStart_ValueChanged);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(108, 16);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(54, 13);
this.label10.TabIndex = 22;
this.label10.Text = "<- Date ->";
//
// BillDetailsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(359, 519);
this.Controls.Add(this.dgvSale);
this.Controls.Add(this.dtpFinish);
this.Controls.Add(this.dtpStart);
this.Controls.Add(this.label10);
this.MaximizeBox = false;
this.Name = "BillDetailsForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sale Analysis Form";
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dgvSale;
private System.Windows.Forms.DateTimePicker dtpFinish;
private System.Windows.Forms.DateTimePicker dtpStart;
private System.Windows.Forms.Label label10;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -3,18 +3,15 @@ using System.Collections.Generic;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Helpers;
namespace Tanshu.Accounts.PointOfSale
{
public partial class frmSaleAnalysisForm : Form
{
IList<SalesAnalysis> list;
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
IList<SalesAnalysis> _list;
public frmSaleAnalysisForm()
{
InitializeComponent();
//log.Warn(string.Format("Sales Analysis by: {0}", Session.User.Name));
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
@@ -24,9 +21,11 @@ namespace Tanshu.Accounts.PointOfSale
private void ShowStatement()
{
list = new SalesAnalysisBI().GetSale(dtpStart.Value, dtpFinish.Value);
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.DataSource = _list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[1].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
@@ -46,11 +45,11 @@ namespace Tanshu.Accounts.PointOfSale
private void btnPrint_Click(object sender, EventArgs e)
{
if (list != null)
if (_list != null)
{
var startDate = dtpStart.Value.Date.AddHours(6);
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5);
Accounts.Print.Thermal.PrintSale(Session.User.Name, list, startDate, finishDate);
Accounts.Print.Thermal.PrintSale(Session.User.Name, _list, startDate, finishDate);
}
}
}
@@ -23,7 +23,9 @@ namespace Tanshu.Accounts.PointOfSale
private void ShowStatement()
{
_list = new SalesAnalysisBI().GetSaleDetail(dtpStart.Value, dtpFinish.Value).ToList();
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
return;
_list = new SalesAnalysisBI().GetSaleDetail(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
@@ -31,6 +33,8 @@ namespace Tanshu.Accounts.PointOfSale
dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
@@ -63,12 +67,12 @@ namespace Tanshu.Accounts.PointOfSale
{
if (_list == null)
return;
var data = string.Format("{0}\t{1}\t{2}\n", "Product", "Sale", "NC");
var data = string.Format("{0}\t{1}\t{2}\t{3}\n", "Product", "Sale", "NC", "Staff");
foreach (var item in _list)
{
data += string.Format("{0}\t{1}\t{2}\n", item.Product, item.Sale, item.NC);
data += string.Format("{0}\t{1}\t{2}\t{3}\n", item.Product, item.Sale, item.NC, item.Staff);
}
Clipboard.SetText(data,TextDataFormat.Text);
Clipboard.SetText(data, TextDataFormat.Text);
}
}
}
@@ -22,6 +22,8 @@ namespace Tanshu.Accounts.PointOfSale
private void ShowStatement()
{
if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT))
return;
_list = new SalesAnalysisBI().VoidOrReprintedBillsList(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = _list;
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
@@ -13,33 +9,33 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class CustomersForm : Form
{
private int? customerID;
private Customer customer;
private string phone;
private int? _customerID;
private Customer _customer;
private readonly string phone;
#region Form Load
public CustomersForm(int? customerID, string phone)
{
InitializeComponent();
this.customerID = customerID;
this._customerID = customerID;
this.phone = phone;
}
private void CustomersForm_Load(object sender, EventArgs e)
{
if (customerID.HasValue)
if (_customerID.HasValue)
{
using (var bi = new CustomerBI(false))
customer = bi.Get(x => x.CustomerID == customerID.Value);
_customer = bi.Get(x => x.CustomerID == _customerID.Value);
btnDelete.Enabled = true;
txtName.Text = customer.Name;
txtPhone.Text = customer.Phone;
txtAddress.Text = customer.Address;
txtRemarks.Text = customer.Remarks;
chkImportant.Checked = customer.Important;
txtName.Text = _customer.Name;
txtPhone.Text = _customer.Phone;
txtAddress.Text = _customer.Address;
txtRemarks.Text = _customer.Remarks;
chkImportant.Checked = _customer.Important;
}
else
txtPhone.Text = phone;
btnSave.Text = customerID.HasValue ? "&Update" : "&Save";
btnSave.Text = _customerID.HasValue ? "&Update" : "&Save";
}
#endregion
@@ -60,7 +56,7 @@ namespace Tanshu.Accounts.PointOfSale
private void btnDelete_Click(object sender, EventArgs e)
{
using (var bi = new CustomerBI())
bi.Delete(x => x.CustomerID == customer.CustomerID);
bi.Delete(x => x.CustomerID == _customer.CustomerID);
btnCancel_Click(sender, e);
}
private void btnCancel_Click(object sender, EventArgs e)
@@ -72,26 +68,24 @@ namespace Tanshu.Accounts.PointOfSale
#region Add / Edit / Delete
private bool ValidateValues()
{
bool returnType = true;
if (txtName.Text.Trim().Length == 0)
return false;
return returnType;
return txtName.Text.Trim().Length != 0;
}
private void Save()
{
if (customer == null)
customer = new Customer();
User user = Session.User;
customer.Name = txtName.Text;
customer.Phone = txtPhone.Text;
customer.Address = txtAddress.Text;
customer.Remarks = txtRemarks.Text;
customer.Important = chkImportant.Checked;
if (_customer == null)
_customer = new Customer();
_customer.Name = txtName.Text;
_customer.Phone = txtPhone.Text;
_customer.Address = txtAddress.Text;
_customer.Remarks = txtRemarks.Text;
_customer.Important = chkImportant.Checked;
using (var bi = new CustomerBI())
if (customer.CustomerID == 0)
bi.Insert(customer);
if (_customer.CustomerID == 0)
bi.Insert(_customer);
else
bi.Update(customer);
bi.Update(_customer);
}
private void Delete(int customerID)
{
@@ -102,7 +96,7 @@ namespace Tanshu.Accounts.PointOfSale
public Customer Customer
{
get { return customer; }
get { return _customer; }
}
}
}
@@ -1,46 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.SqlDAO;
using Tanshu.Accounts.Helpers;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.PointOfSale
{
public partial class DiscountForm : Form
{
private IList<string> source;
private HashSet<string> selection;
decimal discount;
private readonly IList<string> _source;
private readonly HashSet<string> _selection;
decimal _discount;
public DiscountForm(IList<string> source)
{
InitializeComponent();
this.source = source;
selection = new HashSet<string>();
this._source = source;
_selection = new HashSet<string>();
}
private void button_Click(object sender, EventArgs e)
{
CheckBox button = sender as CheckBox;
var button = sender as CheckBox;
if (button == null)
return;
var item = (string)button.Tag;
if (button.CheckState == CheckState.Checked)
selection.Add(item);
_selection.Add(item);
else
selection.Remove(item);
_selection.Remove(item);
}
public decimal Selection(out HashSet<string> list)
{
list = selection;
return discount;
list = _selection;
return _discount;
}
private void btnClose_Click(object sender, EventArgs e)
@@ -50,12 +42,12 @@ namespace Tanshu.Accounts.PointOfSale
private void DiscountForm_Load(object sender, EventArgs e)
{
ControlFactory.GenerateGroups(ref flpModifier, new Point(75, 75), source, new ButtonClickDelegate(button_Click));
ControlFactory.GenerateGroups(ref flpModifier, new Point(75, 75), _source, new ButtonClickDelegate(button_Click));
}
private void txtAmount_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return && decimal.TryParse(txtAmount.Text, out discount) && discount >= 0 && discount <= 100)
if (e.KeyCode == Keys.Return && decimal.TryParse(txtAmount.Text, out _discount) && _discount >= 0 && _discount <= 100)
{
this.DialogResult = DialogResult.OK;
this.Close();
+74
View File
@@ -0,0 +1,74 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class PaxForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.numpadControl1 = new Tanshu.Common.KeyboardControl.NumpadControl();
this.txtAmount = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// numpadControl1
//
this.numpadControl1.Location = new System.Drawing.Point(12, 38);
this.numpadControl1.Name = "numpadControl1";
this.numpadControl1.Size = new System.Drawing.Size(224, 224);
this.numpadControl1.TabIndex = 1;
//
// txtAmount
//
this.txtAmount.Location = new System.Drawing.Point(12, 12);
this.txtAmount.Name = "txtAmount";
this.txtAmount.Size = new System.Drawing.Size(224, 20);
this.txtAmount.TabIndex = 0;
this.txtAmount.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtAmount_KeyDown);
//
// PaxForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(248, 274);
this.ControlBox = false;
this.Controls.Add(this.txtAmount);
this.Controls.Add(this.numpadControl1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.Name = "PaxForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Pax";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Tanshu.Common.KeyboardControl.NumpadControl numpadControl1;
private System.Windows.Forms.TextBox txtAmount;
}
}
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
namespace Tanshu.Accounts.PointOfSale
{
public partial class PaxForm : Form
{
int _pax;
public PaxForm()
{
InitializeComponent();
}
public int Pax
{
get { return _pax; }
}
private void txtAmount_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return && int.TryParse(txtAmount.Text, out _pax))
{
this.DialogResult = DialogResult.OK;
this.Close();
}
else if (e.KeyCode == Keys.Escape)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+41 -18
View File
@@ -32,8 +32,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.label7 = new System.Windows.Forms.Label();
this.txtDiscount = new System.Windows.Forms.TextBox();
this.Label12 = new System.Windows.Forms.Label();
@@ -64,6 +64,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.btnSettle = new System.Windows.Forms.Button();
this.btnMore = new System.Windows.Forms.Button();
this.btnMoveKot = new System.Windows.Forms.Button();
this.btnSplitBill = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.txtServiceCharge = new System.Windows.Forms.TextBox();
this.txtTableID = new System.Windows.Forms.TextBox();
@@ -81,7 +82,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.btnCustomer = new System.Windows.Forms.Button();
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
this.btnSplitBill = new System.Windows.Forms.Button();
this.label10 = new System.Windows.Forms.Label();
this.txtPax = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
this.pnlBilling.SuspendLayout();
@@ -211,8 +213,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
//
this.Display.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
this.Display.DataPropertyName = "Display";
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.Display.DefaultCellStyle = dataGridViewCellStyle3;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.Display.DefaultCellStyle = dataGridViewCellStyle1;
this.Display.HeaderText = "Display";
this.Display.MinimumWidth = 250;
this.Display.Name = "Display";
@@ -223,9 +225,9 @@ namespace Tanshu.Accounts.PointOfSale.Sales
//
this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dataGridViewCellStyle4.Format = "N2";
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dataGridViewCellStyle2.Format = "N2";
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2;
this.printedDataGridViewTextBoxColumn.HeaderText = "Printed";
this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn";
this.printedDataGridViewTextBoxColumn.ReadOnly = true;
@@ -239,6 +241,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
//
this.pnlBilling.AutoSize = true;
this.pnlBilling.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.pnlBilling.Controls.Add(this.label10);
this.pnlBilling.Controls.Add(this.txtPax);
this.pnlBilling.Controls.Add(this.flpMain);
this.pnlBilling.Controls.Add(this.flpGroup);
this.pnlBilling.Controls.Add(this.flpActions);
@@ -453,6 +457,16 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.btnMoveKot.UseVisualStyleBackColor = true;
this.btnMoveKot.Click += new System.EventHandler(this.btnMoveKot_Click);
//
// 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);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -496,9 +510,9 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(259, 12);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(72, 13);
this.label9.Size = new System.Drawing.Size(55, 13);
this.label9.TabIndex = 136;
this.label9.Text = "Booking Time";
this.label9.Text = "Start Time";
//
// label8
//
@@ -595,15 +609,22 @@ namespace Tanshu.Accounts.PointOfSale.Sales
//
this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBills);
//
// btnSplitBill
// label10
//
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);
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(804, 12);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(25, 13);
this.label10.TabIndex = 161;
this.label10.Text = "Pax";
//
// txtPax
//
this.txtPax.Location = new System.Drawing.Point(807, 28);
this.txtPax.Name = "txtPax";
this.txtPax.ReadOnly = true;
this.txtPax.Size = new System.Drawing.Size(88, 20);
this.txtPax.TabIndex = 160;
//
// SalesForm
//
@@ -682,6 +703,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private System.Windows.Forms.Button btnMoveKot;
private readonly BillController _billController;
private System.Windows.Forms.Button btnSplitBill;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtPax;
}
}
+37 -67
View File
@@ -7,7 +7,6 @@ using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.Repository;
using Tanshu.Common;
namespace Tanshu.Accounts.PointOfSale.Sales
{
@@ -42,18 +41,30 @@ namespace Tanshu.Accounts.PointOfSale.Sales
btnCustomer.Text = name;
}
public void ShowInfo(string billID, string kotID, DateTime creationDate, DateTime date, DateTime lastEditDate,
string customer, string tableID, int waiterID, string waiter)
public void SetWaiterDisplay(string name)
{
txtBillID.Text = billID;
txtKotID.Text = kotID;
txtCreationDate.Text = creationDate.ToString("HH:mm dd-MMM-yyyy");
txtDate.Text = date.ToString("HH:mm dd-MMM-yyyy");
txtLastEditDate.Text = lastEditDate.ToString("HH:mm dd-MMM-yyyy");
btnCustomer.Text = customer;
txtTableID.Text = tableID;
btnWaiter.Tag = waiterID;
btnWaiter.Text = string.Format("{0} - F5", waiter);
btnWaiter.Text = string.Format("{0} - F5", name);
}
public void ShowInfo(Voucher voucher)
{
if (voucher.VoucherID == 0)
{
txtTableID.Text = voucher.TableID;
txtPax.Text = voucher.Pax.ToString();
}
else
{
txtBillID.Text = voucher.BillID;
txtKotID.Text = voucher.KotID;
txtCreationDate.Text = voucher.CreationDate.ToString("HH:mm dd-MMM-yyyy");
txtDate.Text = voucher.Date.Value.ToString("HH:mm dd-MMM-yyyy");
txtLastEditDate.Text = voucher.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
btnCustomer.Text = voucher.Customer.Name;
txtTableID.Text = voucher.TableID;
txtPax.Text = voucher.Pax.ToString();
btnWaiter.Text = string.Format("{0} - F5", voucher.Waiter.Name);
}
}
public BindingSource BindingSource
@@ -85,7 +96,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
case Keys.F4:
{
if (!e.Alt)
_billController.ShowCustomerList(false);
_billController.ShowCustomers(false);
break;
}
case Keys.F5:
@@ -162,7 +173,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnCustomer_Click(object sender, EventArgs e)
{
_billController.ShowCustomerList(false);
_billController.ShowCustomers(false);
}
private void btnVoid_Click(object sender, EventArgs e)
@@ -179,7 +190,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnRate_Click(object sender, EventArgs e)
{
_billController.ChangeRate();
_billController.SetRate();
}
private void btnClear_Click(object sender, EventArgs e)
@@ -211,45 +222,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnWaiter_Click(object sender, EventArgs e)
{
using (var selectWaiter = new SelectWaiter(WaiterBI.GetFilteredWaiters, true))
{
selectWaiter.waiterEvent += selectWaiter_waiterEvent;
selectWaiter.ShowDialog();
if (selectWaiter.SelectedItem != null)
{
btnWaiter.Text = string.Format("{0} - F5", selectWaiter.SelectedItem.Name);
btnWaiter.Tag = selectWaiter.SelectedItem.WaiterID;
}
else
{
btnWaiter.Text = "Select Waiter - F5";
btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
}
}
}
private Waiter selectWaiter_waiterEvent(object sender, WaiterEventArgs e)
{
Waiter waiter = e.Waiter;
if (!Thread.CurrentPrincipal.IsInRole("Waiter/Master"))
return waiter;
switch (e.Action)
{
case 1: // Add
WaiterBI.Insert(waiter);
e.Handled = true;
return waiter;
case 2: // Edit
WaiterBI.Update(waiter);
e.Handled = true;
return waiter;
case 3: // Delete
e.Handled = WaiterBI.Delete(waiter.WaiterID);
return WaiterBI.GetWaiter(1);
default:
throw new ArgumentException();
}
_billController.ShowWaiters(false);
}
private void btnSettle_Click(object sender, EventArgs e)
@@ -277,12 +250,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnMoveTable_Click(object sender, EventArgs e)
{
_billController.MoveTable();
}
private void btnMore_Click(object sender, EventArgs e)
{
var button = sender as Button;
if (button == null)
return;
if (button.Text == "More")
MoreButton(true);
else if (button.Text == "Less")
@@ -307,7 +281,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnMoveKot_Click(object sender, EventArgs e)
{
_billController.MergeKot();
_billController.MoveKot();
}
#region Helper Functions
@@ -320,8 +294,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
txtDate.Text = "";
txtLastEditDate.Text = "";
txtTableID.Text = "";
txtPax.Text = "";
btnWaiter.Text = "Waiter - F5";
btnWaiter.Tag = null;
txtGrossTax.Text = "0.00";
txtDiscount.Text = "0.00";
txtServiceCharge.Text = "0.00";
@@ -366,9 +340,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (button == null)
return;
var item = button.Tag as ProductGroup;
if (item == null)
return;
if (item.Name == "Previous" || item.Name == "Next")
{
int start = item.ProductGroupID;
var start = item.ProductGroupID;
if (start < 0)
start = 0;
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, _productGroupList, productTypeButton_Click);
@@ -419,24 +395,18 @@ namespace Tanshu.Accounts.PointOfSale.Sales
{
var tableName = item.Name;
_billController.LoadBill(tableName);
txtTableID.Text = tableName;
FormState = SaleFormState.Billing;
}
}
private void btnPrintBill_Click(object sender, EventArgs e)
{
if (btnWaiter.Tag == null)
btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
_billController.SaveBill((int)btnWaiter.Tag, txtTableID.Text);
_billController.SaveBill();
}
private void btnPrintKot_Click(object sender, EventArgs e)
{
if (btnWaiter.Tag == null)
btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
_billController.SaveKot((int)btnWaiter.Tag, txtTableID.Text);
_billController.SaveKot();
}
private void btnQuantity_Click(object sender, EventArgs e)
@@ -446,7 +416,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnDiscount_Click(object sender, EventArgs e)
{
_billController.ShowDiscount();
_billController.SetDiscount();
}
#endregion
@@ -123,12 +123,6 @@
<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="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">
<value>148, 17</value>
</metadata>
@@ -13,11 +13,12 @@ namespace Tanshu.Accounts.PointOfSale
{
private readonly IDictionary<Button, int> _list;
private decimal _amount;
public SettleChoicesForm(decimal amount)
private readonly VoucherType _voucherType;
public SettleChoicesForm(decimal amount, VoucherType voucherType)
{
InitializeComponent();
_amount = amount;
_voucherType = voucherType;
OptionsChosen = new Dictionary<SettleOption, decimal>();
_list = new Dictionary<Button, int>();
}
@@ -57,10 +58,10 @@ namespace Tanshu.Accounts.PointOfSale
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", _amount);
if (_optionsChosen.Count == 0)
foreach (var item in _list.Where(item => item.Value != 0))
foreach (var item in _list)
item.Key.Enabled = true;
else
foreach (var item in _list.Where(item => item.Value != group && item.Value != 0))
foreach (var item in _list.Where(item => item.Value != group))
item.Key.Enabled = false;
}
@@ -82,13 +83,13 @@ namespace Tanshu.Accounts.PointOfSale
foreach (SettleOption item in Enum.GetValues(typeof(SettleOption)))
{
var attribute = item.Attribute();
if (!attribute.ShowInChoices)
if (!attribute.ShowInChoices || attribute.Group != _voucherType.Attribute().Group)
continue;
var button = new Button
{
Name = item.ToString(),
Text = attribute.Name,
Size = new System.Drawing.Size(75, 75),
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = item
@@ -102,31 +103,31 @@ namespace Tanshu.Accounts.PointOfSale
{
Name = "btnOK",
Text = "OK",
Size = new System.Drawing.Size(75, 75),
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = "OK"
};
controlButton.Click += new EventHandler(ButtonClick);
flpSettlement.Controls.Add(controlButton);
_list.Add(controlButton, 0);
// _list.Add(controlButton); --- Do not add to list
count++;
controlButton = new Button
{
Name = "btnCancel",
Text = "Cancel",
Size = new System.Drawing.Size(75, 75),
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = "Cancel"
};
controlButton.Click += new EventHandler(ButtonClick);
flpSettlement.Controls.Add(controlButton);
_list.Add(controlButton, 0);
// _list.Add(controlButton); --- Do not add to list
count++;
txtAmount.TabIndex = count;
this.Size = this.SizeFromClientSize(new Size(_list.Count * (75 + 6), 3 + txtAmount.Height + 6 + 75 + 3));
this.Size = this.SizeFromClientSize(new Size(count * (75 + 6), 3 + txtAmount.Height + 6 + 75 + 3));
txtAmount.Width = flpSettlement.Width - 6;
}
@@ -0,0 +1,63 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class VoucherTypeForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.flpSettlement = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// flpSettlement
//
this.flpSettlement.Dock = System.Windows.Forms.DockStyle.Fill;
this.flpSettlement.Location = new System.Drawing.Point(0, 0);
this.flpSettlement.Name = "flpSettlement";
this.flpSettlement.Size = new System.Drawing.Size(604, 87);
this.flpSettlement.TabIndex = 7;
//
// VoucherTypeForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(604, 87);
this.ControlBox = false;
this.Controls.Add(this.flpSettlement);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.Name = "VoucherTypeForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Settle Bill";
this.Load += new System.EventHandler(this.SettleChoicesFormLoad);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flpSettlement;
}
}
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Common.Helpers;
namespace Tanshu.Accounts.PointOfSale
{
public partial class VoucherTypeForm : Form
{
private readonly IList<Button> _list;
public VoucherTypeForm()
{
InitializeComponent();
_list = new List<Button>();
Selection = null;
}
private void ButtonClick(object sender, EventArgs e)
{
var button = sender as Button;
if (button == null || button.Tag == null)
return;
if (button.Tag is VoucherType)
{
Selection = (VoucherType)button.Tag;
foreach (var item in _list)
item.Enabled = (VoucherType)item.Tag != Selection.Value;
}
else
{
if ((string)button.Tag == "Cancel")
Selection = null;
this.Close();
}
}
public VoucherType? Selection { get; private set; }
private void SettleChoicesFormLoad(object sender, EventArgs e)
{
var count = 0;
foreach (VoucherType item in Enum.GetValues(typeof(VoucherType)))
{
var attribute = item.Attribute();
if (!attribute.ShowInChoices)
continue;
var button = new Button
{
Name = item.ToString(),
Text = attribute.Name,
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = item
};
button.Click += new EventHandler(ButtonClick);
flpSettlement.Controls.Add(button);
_list.Add(button);
count++;
}
var controlButton = new Button
{
Name = "btnOK",
Text = "OK",
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = "OK"
};
controlButton.Click += new EventHandler(ButtonClick);
flpSettlement.Controls.Add(controlButton);
// _list.Add(controlButton); --- Do not add to list
count++;
controlButton = new Button
{
Name = "btnCancel",
Text = "Cancel",
Size = new System.Drawing.Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = "Cancel"
};
controlButton.Click += new EventHandler(ButtonClick);
flpSettlement.Controls.Add(controlButton);
//_list.Add(controlButton); --- Do not add to list
count++;
this.Size = this.SizeFromClientSize(new Size(count * (75 + 6), 3 + 75 + 3));
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -125,6 +125,12 @@
<Compile Include="CurrencyCounter.Designer.cs">
<DependentUpon>CurrencyCounter.cs</DependentUpon>
</Compile>
<Compile Include="Management\QuantityForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Management\QuantityForm.designer.cs">
<DependentUpon>QuantityForm.cs</DependentUpon>
</Compile>
<Compile Include="Products\ProductListForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -149,6 +155,12 @@
<Compile Include="Reports\BillDetailsForm.designer.cs">
<DependentUpon>BillDetailsForm.cs</DependentUpon>
</Compile>
<Compile Include="Reports\DiscountReportForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Reports\DiscountReportForm.designer.cs">
<DependentUpon>DiscountReportForm.cs</DependentUpon>
</Compile>
<Compile Include="Reports\VoidReprintedForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -161,6 +173,18 @@
<Compile Include="Reports\SaleDetail.designer.cs">
<DependentUpon>SaleDetail.cs</DependentUpon>
</Compile>
<Compile Include="Sales\VoucherTypeForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Sales\VoucherTypeForm.Designer.cs">
<DependentUpon>VoucherTypeForm.cs</DependentUpon>
</Compile>
<Compile Include="Sales\PaxForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Sales\PaxForm.Designer.cs">
<DependentUpon>PaxForm.cs</DependentUpon>
</Compile>
<Compile Include="Sales\SettleAmountsForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -268,6 +292,9 @@
<EmbeddedResource Include="CurrencyCounter.resx">
<DependentUpon>CurrencyCounter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Management\QuantityForm.resx">
<DependentUpon>QuantityForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Products\ProductListForm.resx">
<DependentUpon>ProductListForm.cs</DependentUpon>
<SubType>Designer</SubType>
@@ -284,6 +311,10 @@
<DependentUpon>BillDetailsForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Reports\DiscountReportForm.resx">
<DependentUpon>DiscountReportForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Reports\VoidReprintedForm.resx">
<DependentUpon>VoidReprintedForm.cs</DependentUpon>
<SubType>Designer</SubType>
@@ -292,6 +323,12 @@
<DependentUpon>SaleDetail.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Sales\VoucherTypeForm.resx">
<DependentUpon>VoucherTypeForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Sales\PaxForm.resx">
<DependentUpon>PaxForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Sales\SettleAmountsForm.resx">
<DependentUpon>SettleAmountsForm.cs</DependentUpon>
</EmbeddedResource>
@@ -427,9 +464,6 @@
<Name>Tanshu.Accounts.Repository</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Management\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -78,6 +78,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ThermalBill.cs" />
<Compile Include="PlatformPrinter.cs" />
<Compile Include="PrinterLinux.cs" />
<Compile Include="ThermalPrinter.cs" />
+48 -173
View File
@@ -4,33 +4,26 @@ using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Repository;
using System.Diagnostics;
using Tanshu.Common.Helpers;
namespace Tanshu.Accounts.Print
{
internal enum Align
{
None = 0,
Left = 1,
Centre = 2,
Right = 4
}
public static class Thermal
public static partial class Thermal
{
private const string DrawLine = "\n\r------------------------------------------";
private const string DrawEqual = "\n\r==========================================";
private static string DesignKot(Voucher trans, Kot kot, IEnumerable<Inventory> billItems, int copyNumber)
private static string DesignKot(Voucher voucher, Kot kot, IEnumerable<Inventory> billItems, int copyNumber)
{
var waiter = trans.Waiter;
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);
var waiter = voucher.Waiter;
var billText = "\n\r" + "KOT / BOT".Center42();
billText += "\n\r" + string.Format("Copy No. {0}", copyNumber).Center42();
billText += DrawLine;
billText += string.Format("\n\rKOT ID : {0,-7}/{1,-7} {2:dd-MMM-yyyy HH:mm}", trans.KotID, kot.Code, kot.Date);
billText += string.Format("\n\rTable No.: {0} / {1}", trans.TableID, waiter.Name);
billText += string.Format("\n\rKOT ID : {0,-7}/{1,-7} {2:dd-MMM-yyyy HH:mm}", voucher.KotID, kot.Code, kot.Date);
billText += string.Format("\n\rTable No.: {0} / {1}", voucher.TableID, waiter.Name);
billText += DrawLine;
billText += "\n\r Qty. x Name ";
billText += DrawLine;
@@ -41,9 +34,9 @@ namespace Tanshu.Accounts.Print
billText += string.Format("\n\r --- {0,-32}", mod.Modifier.Name);
}
billText += DrawLine;
if (trans.Narration != "")
if (voucher.Narration != "")
{
billText += "\n\r" + FormatText(trans.Narration, 42, false, Align.Centre);
billText += "\n\r" + FormatText(voucher.Narration, 42, Align.Centre);
billText += DrawLine;
}
return billText;
@@ -52,110 +45,15 @@ namespace Tanshu.Accounts.Print
private static string DesignBill(Voucher voucher)
{
var list = new Dictionary<int, Inventory>();
foreach (var kot in voucher.Kots)
foreach (var item in voucher.Kots.SelectMany(kot => kot.Inventories))
{
foreach (var item in kot.Inventories)
{
if (list.ContainsKey(item.Product.ProductID))
list[item.Product.ProductID].Quantity += item.Quantity;
else
list.Add(item.Product.ProductID, item);
}
if (list.ContainsKey(item.Product.ProductID))
list[item.Product.ProductID].Quantity += item.Quantity;
else
list.Add(item.Product.ProductID, item);
}
var cashier = voucher.User;
var waiter = voucher.Waiter;
var customer = voucher.Customer;
var billNo = voucher.BillID.Substring(voucher.BillID.IndexOf("-") + 1);
var billText = "";
billText = "\n\r" + FormatText("Hops n Grains", 42, false, Align.Centre);
billText += "\n\r" + FormatText("The Microbrewery", 42, false, Align.Centre);
billText += "\n\r" + FormatText("SCO 358, Sector 9, Panchkula", 42, false, Align.Centre);
billText += "\n\r" + FormatText("A Unit of Peitho Foods Pvt. Ltd.", 42, false, Align.Centre);
billText += "\n\r" + FormatText("TIN: 06592507323", 42, false, Align.Centre);
billText += "\n\r" + FormatText("Retail Invoice", 42, false, Align.Centre);
billText += "\n\r";
billText += "\n\r" + "Bill No: " + FormatText(billNo, 13, false, Align.Centre) +
string.Format("{0:dd-MMM-yyyy HH:mm:ss}", voucher.Date);
billText += "\n\r" + "Table No.: " + voucher.TableID;
billText += "\n\r" + "------------------------------------------";
billText += "\n\r" + "Qty. Particulars Price Amount";
billText += "\n\r" + "------------------------------------------";
foreach (var item in list.Values)
{
if (item.Quantity == 0)
continue;
billText += "\n\r" + FormatBillNum(item.Quantity, 5) + " ";
billText += FormatText(Name(item.Product), 22, false, Align.Left) + " ";
billText += FormatBillNum(item.FullPrice, 6) + " ";
billText += FormatBillNum(item.FullPrice * item.Quantity, 6);
}
billText += "\n\r" + "------------------------------------------";
decimal amount;
amount = Net(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Net : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
amount = HappyHourDiscount(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Happy Hour Discount : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
amount = Discount(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Discount : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
amount = ServiceCharge(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Service Charge : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
// Begin Service Tax and VAT Hack
decimal st = 0;
amount = list.Values.Where(x => x.Tax == 0.14741M).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax);
st = amount * 0.190564292M;
amount = amount * (1 - 0.190564292M);
if (amount != 0)
billText += "\n\r" + FormatText("VAT @ 12.5% + 5% Sur. : ", 33, false, Align.Right) +
FormatBillNum(amount, 9);
amount = list.Values.Where(x => x.Tax == 0.26673M).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax);
st += amount * 0.105316973M;
amount = amount * (1 - 0.105316973M);
if (amount != 0)
billText += "\n\r" + FormatText("VAT @ 25% + 5% Sur. : ", 33, false, Align.Right) +
FormatBillNum(amount, 9);
if (st != 0)
billText += "\n\r" + FormatText("Cental Govt. ST : ", 33, false, Align.Right) +
FormatBillNum(st, 9);
//// Original
//amount = Tax(list.Values);
//if (amount != 0)
// billText += "\n\r" + FormatText("VAT (incl. surcharge) : ", 33, false, Align.Right) +
// FormatBillNum(amount, 9);
// End Service Tax and VAT Hack
amount = Amount(list.Values);
if (amount != 0)
billText += string.Format("\n\r Final Amount : {0,9:#,##0.00;(#,##0.00);0}",
Math.Round(amount, 0));
billText += DrawLine;
if (voucher.Narration != "")
{
billText += "\n\r" + FormatText(voucher.Narration, 42, false, Align.Centre);
billText += DrawLine;
}
if (customer.CustomerID != 1)
{
billText += "\n\r" + customer.Name;
billText += string.Format("\n\r{0}\n\r{1}", customer.Phone, customer.Address);
billText += DrawLine;
}
billText += "\n\r" + "Cashier : " + cashier.Name + " / " + waiter.Name;
billText += "\n\r" + "Call: 0172-4026666, 8054923853, 8054923856";
return billText;
return DesignBill(voucher, list);
}
private static decimal Amount(IEnumerable<Inventory> list)
@@ -195,28 +93,16 @@ namespace Tanshu.Accounts.Print
: string.Format("{0} ({1})", product.Name, product.Units);
}
private static string FormatText(string inputString, int width, Boolean multiline, Align alignment)
private static string FormatText(string inputString, int width, Align alignment)
{
if ((multiline) && (inputString.Length > width))
{
var newString = "";
var lines = Convert.ToInt32(Math.Floor(Convert.ToDecimal(inputString.Length / width)));
for (var i = 0; i < lines; i++)
newString += inputString.Substring(i * width, width) + "\n\r";
newString += FormatText(inputString.Substring(lines * width), width, multiline, alignment);
return newString;
}
if (inputString.Length > width)
return inputString.Substring(0, width);
if (alignment == Align.None)
return inputString;
if (alignment == Align.Left)
return string.Format("{0,-" + width + "}", inputString);
if (alignment == Align.Centre)
{
int left;
left = Convert.ToInt32(Math.Ceiling(Convert.ToDouble((width - inputString.Length) / 2))) +
inputString.Length;
int left = Convert.ToInt32(Math.Ceiling(Convert.ToDouble((width - inputString.Length) / 2))) +
inputString.Length;
inputString = string.Format("{0,-" + left + "}", inputString);
return string.Format("{0," + width + "}", inputString);
}
@@ -246,18 +132,18 @@ namespace Tanshu.Accounts.Print
public static Boolean PrintAdvance(string user, string advance, string narration)
{
var billText = "\n\r" + FormatText("Hops n Grains", 42, false, Align.Centre);
billText += "\n\r" + FormatText("The Microbrewery", 42, false, Align.Centre);
billText += "\n\r" + FormatText("SCO 358, Sector 9, Panchkula", 42, false, Align.Centre);
billText += "\n\r" + FormatText("A Unit of Peitho Foods Pvt. Ltd.", 42, false, Align.Centre);
var billText = "\n\r" + FormatText("Hops n Grains", 42, Align.Centre);
billText += "\n\r" + FormatText("The Microbrewery", 42, Align.Centre);
billText += "\n\r" + FormatText("SCO 358, Sector 9, Panchkula", 42, Align.Centre);
billText += "\n\r" + FormatText("A Unit of Peitho Foods Pvt. Ltd.", 42, Align.Centre);
billText += DrawLine;
billText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
billText += "\n\r" + FormatText("Received Rs. " + advance + " as advance.", 42, false, Align.Centre);
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, Align.Centre);
billText += "\n\r" + FormatText("Received Rs. " + advance + " as advance.", 42, Align.Centre);
billText += DrawLine;
if (narration != "") billText += "\n\r" + FormatText(narration, 42, false, Align.Centre);
if (narration != "") billText += "\n\r" + FormatText(narration, 42, Align.Centre);
billText += DrawLine;
billText += "\n\r" + FormatText("Thanking you " + user, 42, false, Align.Left);
billText += "\n\r" + FormatText("Thanking you " + user, 42, Align.Left);
billText += "\n\r";
billText += "\n\r";
billText += "\n\r";
@@ -273,8 +159,7 @@ namespace Tanshu.Accounts.Print
{
try
{
var billText = FormatText(string.Format("{0} Checkout By {1}", details.Cashier.Name, details.Manager), 42,
false, Align.Centre);
var billText = FormatText(string.Format("{0} Checkout By {1}", details.Cashier.Name, details.Manager), 42, Align.Centre);
billText += string.Format("\n\r{0:dd-MMM-yy} To {1:dd-MMM-yy} @ {2:dd-MMM-yyyy HH:mm}",
details.StartDate, details.FinishDate, DateTime.Now);
billText += DrawLine;
@@ -299,7 +184,7 @@ namespace Tanshu.Accounts.Print
billText += string.Format("\n\rOld Receipts : {0,26:#,##0.00}", details.OldReceipts);
billText += string.Format("\n\rOld Voided : {0,26:#,##0.00}", details.OldVoided);
billText += DrawEqual;
billText += "\n\r" + FormatText(details.Status, 42, false, Align.Centre);
billText += "\n\r" + FormatText(details.Status, 42, Align.Centre);
billText += DrawEqual;
billText += string.Format("\n\rActive Cashiers : {0}", details.Cashiers);
@@ -333,7 +218,7 @@ namespace Tanshu.Accounts.Print
public static string FormatPrintNum(string inputString)
{
return inputString == "" ? "0.00" : FormatText(inputString, 24, false, Align.Right);
return inputString == "" ? "0.00" : FormatText(inputString, 24, Align.Right);
//return FormatText(FormatNumber(InputString.Trim, 2, TriState.UseDefault, TriState.True, TriState.True), 24, False, Align.Right);
}
@@ -341,7 +226,7 @@ namespace Tanshu.Accounts.Print
{
Voucher voucher;
using (var bi = new VoucherBI(false))
voucher = bi.Get(voucherID);
voucher = bi.Get(x => x.VoucherID == voucherID);
PrintRaw(PrintLocationBI.BasePrinter, DesignBill(voucher), "Bill");
}
@@ -351,7 +236,7 @@ namespace Tanshu.Accounts.Print
stopwatch.Start();
Voucher voucher;
using (var bi = new VoucherBI(false))
voucher = bi.Get(voucherID);
voucher = bi.Get(x => x.VoucherID == voucherID);
var dict = new Dictionary<PrintLocation, List<Inventory>>();
var kot = voucher.Kots.SingleOrDefault(x => x.KotID == kotID);
if (kot == null)
@@ -389,10 +274,10 @@ namespace Tanshu.Accounts.Print
int total = 0;
try
{
printText = FormatText(user, 42, false, Align.Centre);
printText = FormatText(user, 42, Align.Centre);
printText += DrawLine;
printText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, Align.Centre);
foreach (int key in amount.Keys.OrderByDescending(k => k))
{
printText += CashLine(amount, key);
@@ -411,40 +296,30 @@ namespace Tanshu.Accounts.Print
public static Boolean PrintSale(string user, IList<SalesAnalysis> det, DateTime startDate, DateTime endDate)
{
string printText;
try
var printText = FormatText(user, 42, Align.Centre);
printText += DrawLine;
printText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, Align.Centre);
printText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy} to {1:dd-MMM-yyyy}", startDate, endDate), 42, Align.Centre);
printText += DrawLine;
foreach (SalesAnalysis d in det)
{
printText = FormatText(user, 42, false, Align.Centre);
printText += DrawLine;
printText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
printText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy} to {1:dd-MMM-yyyy}", startDate, endDate), 42,
false, Align.Centre);
printText += DrawLine;
foreach (SalesAnalysis d in det)
{
printText += string.Format("\n\r {0,-22} {1,9:#,##0}", d.GroupType, d.Amount);
}
printText += DrawEqual;
return PrintRaw(PrintLocationBI.BasePrinter, printText, "Sale Detail " + user);
}
catch (Exception ex)
{
throw ex;
printText += string.Format("\n\r {0,-22} {1,9:#,##0}", d.GroupType, d.Amount);
}
printText += DrawEqual;
return PrintRaw(PrintLocationBI.BasePrinter, printText, "Sale Detail " + user);
}
public static Boolean PrintSale(string user, IList<SalesAnalysisDetail> list, DateTime startDate,
DateTime endDate)
{
var printText = FormatText(user, 42, false, Align.Centre);
var printText = FormatText(user, 42, Align.Centre);
printText += DrawLine;
printText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, Align.Centre);
printText += "\n\r" +
FormatText(string.Format("{0:dd-MMM-yyyy} to {1:dd-MMM-yyyy}", startDate, endDate), 42,
false, Align.Centre);
FormatText(string.Format("{0:dd-MMM-yyyy} to {1:dd-MMM-yyyy}", startDate, endDate), 42, Align.Centre);
printText += DrawLine;
foreach (var item in list)
{
+139
View File
@@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Tanshu.Accounts.Entities;
using Tanshu.Common.Helpers;
namespace Tanshu.Accounts.Print
{
public static partial class Thermal
{
private static string DesignBill(Voucher voucher, IDictionary<int, Inventory> list)
{
var billText = "";
billText += Header(voucher);
billText += Products(voucher, list);
decimal amount;
amount = Net(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Net : ", 33, Align.Right) + FormatBillNum(amount, 9);
amount = HappyHourDiscount(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Happy Hour Discount : ", 33, Align.Right) + FormatBillNum(amount, 9);
amount = Discount(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Discount : ", 33, Align.Right) + FormatBillNum(amount, 9);
amount = ServiceCharge(list.Values);
if (amount != 0)
billText += "\n\r" + FormatText("Service Charge : ", 33, Align.Right) + FormatBillNum(amount, 9);
// Begin Service Tax and VAT Hack
decimal st = 0;
amount = list.Values.Where(x => x.Tax == 0.14741M).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax);
st = amount * 0.190564292M;
amount = amount * (1 - 0.190564292M);
if (amount != 0)
billText += "\n\r" + FormatText("VAT on Food : ", 33, Align.Right) +
FormatBillNum(amount, 9);
amount = list.Values.Where(x => x.Tax == 0.26673M).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax);
st += amount * 0.105316973M;
amount = amount * (1 - 0.105316973M);
if (amount != 0)
billText += "\n\r" + FormatText("VAT on Liqour : ", 33, Align.Right) +
FormatBillNum(amount, 9);
if (st != 0)
billText += "\n\r" + FormatText("Cental Govt. ST : ", 33, Align.Right) +
FormatBillNum(st, 9);
//// Original
//amount = Tax(list.Values);
//if (amount != 0)
// billText += "\n\r" + FormatText("VAT (incl. surcharge) : ", 33, Align.Right) +
// FormatBillNum(amount, 9);
// End Service Tax and VAT Hack
amount = Amount(list.Values);
if (amount != 0)
billText += string.Format("\n\r{0,33}{1,9:#,##0.00;(#,##0.00);0}", "Final Amount : ", Math.Round(amount, 0));
billText += DrawLine;
if (voucher.VoucherType == VoucherType.NoCharge || voucher.VoucherType == VoucherType.Staff)
{
billText += "\n\r" + "THIS IS NOT A BILL - DON'T PAY".Center42();
billText += DrawLine;
}
if (voucher.Narration != "")
{
billText += "\n\r" + FormatText(voucher.Narration, 42, Align.Centre);
billText += DrawLine;
}
if (voucher.Customer.CustomerID != 1)
{
billText += "\n\r" + voucher.Customer.Name;
billText += string.Format("\n\r{0}\n\r{1}", voucher.Customer.Phone, voucher.Customer.Address);
billText += DrawLine;
}
billText += "\n\r" + "Cashier : " + voucher.User.Name + " / " + voucher.Waiter.Name;
billText += "\n\r" + "Call: 0172-4026666, 8054923853, 8054923856";
return billText;
}
private static string Products(Voucher voucher, IDictionary<int, Inventory> list)
{
var billNo = voucher.BillID.Substring(voucher.BillID.IndexOf("-") + 1);
var billText = "";
billText += "\n\r" + string.Format("Bill No: {0,-12} {1:dd-MMM-yyyy HH:mm:ss}", billNo, voucher.Date);
billText += "\n\r" + "Table No.: " + voucher.TableID;
billText += "\n\r" + "------------------------------------------";
billText += "\n\r" + "Qty. Particulars Price Amount";
billText += "\n\r" + "------------------------------------------";
foreach (var item in list.Values.Where(item => item.Quantity != 0))
{
billText += "\n\r" + FormatBillNum(item.Quantity, 5) + " ";
billText += FormatText(Name(item.Product), 22, Align.Left) + " ";
billText += FormatBillNum(item.FullPrice, 6) + " ";
billText += FormatBillNum(item.FullPrice * item.Quantity, 6);
}
billText += "\n\r" + "------------------------------------------";
return billText;
}
private static string Header(Voucher voucher)
{
var billText = "";
billText += "\n\r" + "Hops n Grains".Center42();
billText += "\n\r" + "The Microbrewery".Center42();
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();
switch (voucher.VoucherType)
{
case VoucherType.Regular:
billText += "\n\r" + "Retail Invoice".Center42();
billText += "\n\r";
break;
case VoucherType.NoCharge:
billText += "\n\r" + "NO CHARGE - THIS IS NOT A BILL - DON'T PAY".Center42();
billText += "\n\r";
break;
case VoucherType.TakeAway:
billText += "\n\r" + "Retail Invoice (Delivery)".Center42();
billText += "\n\r";
break;
case VoucherType.Staff:
billText += "\n\r" + "STAFF CONSUMPTION -- THIS IS NOT A BILL".Center42();
billText += "\n\r";
break;
}
return billText;
}
}
}
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using NHibernate;
namespace Tanshu.Accounts.Repository
{
public class InventoryBI : FluentGenericBase<Inventory>
{
public InventoryBI()
: base()
{ }
public InventoryBI(bool beginTransaction)
: base(beginTransaction)
{ }
public InventoryBI(ISession session)
: base(session)
{ }
public InventoryBI(ISession session, bool beginTransaction)
: base(session, beginTransaction)
{ }
}
}
@@ -1,85 +1,172 @@
//using System;
//using System.Collections.Generic;
//using System.Text;
//using System.Data.SqlClient;
//using Tanshu.Accounts.Contracts;
//using Tanshu.Data.DAO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using NHibernate;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using Tanshu.Data.DAO;
//namespace Tanshu.Accounts.Repository
//{
// public class ManagementBI
// {
// public decimal GetBalance(decimal? tax, DateTime startDate, DateTime endDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.GetBalance(tax);
// }
// }
// }
// public List<Guid> GetUpdateBillList(decimal tax, bool voided, bool paid, bool creditCard, DateTime startDate, DateTime endDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.GetUpdateBillList(tax, voided, paid, creditCard);
// }
// }
// }
// public decimal Update(Guid voucherID, decimal tax, DateTime startDate, DateTime endDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.Update(voucherID, tax);
// }
// }
// }
// public void Reorder(DateTime startDate, DateTime endDate, ShowProgessDelegate showProgressDelegate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// dao.Reorder(showProgressDelegate);
// }
// }
// }
// public bool MergeData(DateTime startDate, DateTime endDate, string sourceDB, string targetDB)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.MergeData(sourceDB, targetDB);
// }
// }
// }
// public List<PendingBills> GetPaidBills(DateTime startDate, DateTime finishDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, finishDate, connection))
// {
// return dao.GetPaidBills();
// }
// }
// }
// }
//}
namespace Tanshu.Accounts.Repository
{
public class ManagementBI : FluentBasicBase
{
public ManagementBI()
: base()
{ }
public ManagementBI(bool beginTransaction)
: base(beginTransaction)
{ }
public ManagementBI(ISession session)
: base(session)
{ }
public ManagementBI(ISession session, bool beginTransaction)
: base(session, beginTransaction)
{ }
public decimal GetQuantity(int baseCode, DateTime startDate, DateTime finishDate)
{
const string query = @"
select sum(i.Quantity * p.Quantity) as Quantity
from Voucher v
inner join v.Kots k
inner join k.Inventories i
inner join i.Product p
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and p.BaseCode = :baseCode
";
var qty = Session
.CreateQuery(query)
.SetParameter("startDate", startDate)
.SetParameter("finishDate", finishDate)
.SetParameter("baseCode", baseCode)
.UniqueResult();
return qty == null ? 0 : (decimal)qty;
}
public decimal SetQuantity(int baseCode, decimal quantity, DateTime startDate, DateTime finishDate)
{
var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false));
var current = GetQuantity(baseCode, startDate, finishDate);
foreach (var item in list)
{
if (current <= quantity)
continue;
foreach (var kot in item.Kots)
{
if (current <= quantity)
continue;
foreach (var inventory in kot.Inventories)
{
if (current <= quantity)
continue;
if (inventory.Product.BaseCode == baseCode)
{
using (var bi = new InventoryBI())
{
if (inventory.Quantity * inventory.Product.Quantity > current - quantity)
{
current = quantity;
inventory.Quantity = (current - quantity) / inventory.Product.Quantity;
var i = bi.Get(x => x.InventoryID == inventory.InventoryID);
i.Quantity = current - quantity;
bi.Update(i);
}
else
{
current -= inventory.Quantity * inventory.Product.Quantity;
bi.Delete(x => x.InventoryID == inventory.InventoryID);
}
}
}
}
}
}
return GetQuantity(baseCode, startDate, finishDate);
}
// public decimal GetBalance(decimal? tax, DateTime startDate, DateTime endDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.GetBalance(tax);
// }
// }
// }
// public List<Guid> GetUpdateBillList(decimal tax, bool voided, bool paid, bool creditCard, DateTime startDate, DateTime endDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.GetUpdateBillList(tax, voided, paid, creditCard);
// }
// }
// }
// public decimal Update(Guid voucherID, decimal tax, DateTime startDate, DateTime endDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.Update(voucherID, tax);
// }
// }
// }
// public void Reorder(DateTime startDate, DateTime endDate, ShowProgessDelegate showProgressDelegate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// dao.Reorder(showProgressDelegate);
// }
// }
// }
// public bool MergeData(DateTime startDate, DateTime endDate, string sourceDB, string targetDB)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, endDate, connection))
// {
// return dao.MergeData(sourceDB, targetDB);
// }
// }
// }
// public List<PendingBills> GetPaidBills(DateTime startDate, DateTime finishDate)
// {
// GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
// using (IConnectionDAO connection = factory.Connection)
// {
// using (IManagementDAO dao = factory.GetManagementDAO(startDate, finishDate, connection))
// {
// return dao.GetPaidBills();
// }
// }
// }
private static IList<T> Randomize<T>(IEnumerable<T> list)
{
var tList = list.ToArray();
var rand = new Random();
for (var i = tList.Length - 1; i > 0; i--)
{
var swapIndex = rand.Next(i + 1);
var tmp = tList[i];
tList[i] = tList[swapIndex];
tList[swapIndex] = tmp;
}
return tList.ToList();
}
}
}
@@ -10,7 +10,7 @@ namespace Tanshu.Accounts.Repository
{
public class SalesAnalysisBI
{
public ICollection<SalesAnalysisDetail> GetSaleDetail(DateTime startDate, DateTime finishDate)
public IList<SalesAnalysisDetail> GetSaleDetail(DateTime startDate, DateTime finishDate)
{
startDate = startDate.Date.AddHours(6);
@@ -20,6 +20,7 @@ namespace Tanshu.Accounts.Repository
using (var session = SessionManager.Session)
{
#region Sale
var query = @"
select concat(p.Name, ' ', p.Units) as Product, Sum(i.Quantity) as Amount
from Voucher v
@@ -28,7 +29,7 @@ inner join k.Inventories i
inner join i.Product p
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff)
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff and vs.Settled != :staff)
group by concat(p.Name, ' ', p.Units), p.ProductGroup
order by p.ProductGroup, concat(p.Name, ' ', p.Units)
";
@@ -40,11 +41,13 @@ order by p.ProductGroup, concat(p.Name, ' ', p.Units)
.SetParameter("unsettled", SettleOption.Unsettled)
.SetParameter("amount", SettleOption.Amount)
.SetParameter("roundoff", SettleOption.RoundOff)
.SetParameter("staff", SettleOption.Staff)
.List<object[]>();
var outList = new OrderedDictionary<string, SalesAnalysisDetail>();
foreach (var item in list)
outList.Add((string)item[0], new SalesAnalysisDetail() { Product = (string)item[0], Sale = (decimal)item[1] });
#endregion
#region NC
query = @"
select concat(p.Name, ' ', p.Units) as Product, Sum(i.Quantity) as Amount
from Voucher v
@@ -67,8 +70,32 @@ order by p.ProductGroup, concat(p.Name, ' ', p.Units)
outList[(string)item[0]].NC = (decimal)item[1];
else
outList.Add((string)item[0], new SalesAnalysisDetail() { Product = (string)item[0], NC = (decimal)item[1] });
return outList.Values;
#endregion
#region NC
query = @"
select concat(p.Name, ' ', p.Units) as Product, Sum(i.Quantity) as Amount
from Voucher v
inner join v.Kots k
inner join k.Inventories i
inner join i.Product p
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v and vs.Settled = :staff)
group by concat(p.Name, ' ', p.Units), p.ProductGroup
order by p.ProductGroup, concat(p.Name, ' ', p.Units)
";
list = session
.CreateQuery(query)
.SetParameter("startDate", startDate)
.SetParameter("finishDate", finishDate)
.SetParameter("staff", SettleOption.Staff)
.List<object[]>();
foreach (var item in list)
if (outList.ContainsKey((string)item[0]))
outList[(string)item[0]].Staff = (decimal)item[1];
else
outList.Add((string)item[0], new SalesAnalysisDetail() { Product = (string)item[0], Staff = (decimal)item[1] });
#endregion
return outList.Values.ToList();
}
}
public IList<SalesAnalysis> GetSale(DateTime startDate, DateTime finishDate)
@@ -88,7 +115,7 @@ inner join i.Product p
inner join p.ProductGroup g
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff)
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff and vs.Settled != :staff)
group by g.GroupType
order by g.GroupType
";
@@ -100,6 +127,7 @@ order by g.GroupType
.SetParameter("unsettled", SettleOption.Unsettled)
.SetParameter("amount", SettleOption.Amount)
.SetParameter("roundoff", SettleOption.RoundOff)
.SetParameter("staff", SettleOption.Staff)
.List<object[]>();
var outList = new List<SalesAnalysis>();
decimal amount = 0;
@@ -149,6 +177,40 @@ order by v.BillID, s.Settled
return outList;
}
}
public IList<SalesAnalysis> DiscountReport(DateTime startDate, DateTime finishDate)
{
startDate = startDate.Date.AddHours(6);
finishDate = finishDate.Date.AddDays(1).AddHours(5);
if (finishDate <= startDate)
return new List<SalesAnalysis>();
using (var session = SessionManager.Session)
{
const string query = @"
select pg.GroupType, sum(i.Quantity * i.Price * i.Discount)
from Inventory i
inner join i.Kot k
inner join k.Voucher v
inner join i.Product p
inner join p.ProductGroup pg
where v.Date >= :startDate and v.Date <= :finishDate and i.Discount != 0
and v not in (select Voucher from VoucherSettlement vs where vs.Voucher = v and (vs.Settled = :noCharge or vs.Settled = :staff))
group by pg.GroupType
order by pg.GroupType
";
var list = session
.CreateQuery(query)
.SetParameter("startDate", startDate)
.SetParameter("finishDate", finishDate)
.SetParameter("noCharge", SettleOption.NoCharge)
.SetParameter("staff", SettleOption.Staff)
.List<object[]>();
return list.Select(item => new SalesAnalysis()
{
GroupType = (string)item[0],
Amount = (decimal)item[1]
}).ToList();
}
}
public IList<BillDetail> VoidOrReprintedBillsList(DateTime startDate, DateTime finishDate)
{
startDate = startDate.Date.AddHours(6);
@@ -245,7 +307,7 @@ inner join v.Kots k
inner join k.Inventories i
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff)
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff and vs.Settled != :staff)
";
var amt = session
.CreateQuery(query)
@@ -255,6 +317,7 @@ and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amou
.SetParameter("unsettled", SettleOption.Unsettled)
.SetParameter("amount", SettleOption.Amount)
.SetParameter("roundoff", SettleOption.RoundOff)
.SetParameter("staff", SettleOption.Staff)
.UniqueResult() ?? 0M;
outList.Add(new SalesAnalysis() { GroupType = "Service Charge", Amount = (decimal)amt });
#endregion
@@ -266,7 +329,7 @@ inner join v.Kots k
inner join k.Inventories i
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff)
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff and vs.Settled != :staff)
group by i.Tax
";
var list = session
@@ -277,6 +340,7 @@ group by i.Tax
.SetParameter("unsettled", SettleOption.Unsettled)
.SetParameter("amount", SettleOption.Amount)
.SetParameter("roundoff", SettleOption.RoundOff)
.SetParameter("staff", SettleOption.Staff)
.List<object[]>();
foreach (var item in list)
outList.Add(new SalesAnalysis() { GroupType = string.Format("Tax {0:P}", (decimal)item[0]), Amount = (decimal)item[1] });
@@ -1,4 +1,7 @@
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using NHibernate.Criterion;
using Tanshu.Accounts.Entities;
using Tanshu.Common.Helpers;
using NHibernate;
@@ -21,13 +24,11 @@ namespace Tanshu.Accounts.Repository
: base(session, beginTransaction)
{ }
public bool IsVoucherPrinted(int voucherID)
public IList<Voucher> List(Expression<Func<Voucher, bool>> query)
{
return Session.Get<Voucher>(voucherID).Printed;
}
public bool IsVoucherVoid(int voucherID)
{
return Session.Get<Voucher>(voucherID).Void;
return Session.QueryOver<Voucher>()
.Where(query)
.List();
}
public int? Insert(Voucher voucher)
{
@@ -36,7 +37,7 @@ namespace Tanshu.Accounts.Repository
voucher.SetValue(VoucherFields.LastEditDate, dt);
voucher.SetValue(VoucherFields.Date, dt);
voucher.SetValue(VoucherFields.KotID, DbValues.KotID);
voucher.SetValue(VoucherFields.BillID, voucher.Printed ? DbValues.BillID : voucher.KotID);
voucher.SetValue(VoucherFields.BillID, voucher.Printed ? DbValues.BillID(voucher.VoucherType) : voucher.KotID);
Kot addedKot = null;
foreach (var item in voucher.Kots.Where(item => item.KotID == 0))
{
@@ -47,18 +48,13 @@ namespace Tanshu.Accounts.Repository
item.User = voucher.User;
item.Code = DbValues.KotCode;
}
UpdateBill(voucher);
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
VoucherSettlementBI.UpdateSettlements(voucher.Settlements, amount);
Session.Save(voucher);
return addedKot == null ? (int?)null : addedKot.KotID;
}
public void Delete(int voucherID)
{
var voucher = Session.Get<Voucher>(voucherID);
Session.Delete(voucher);
using (var ft = new FoodTableBI(Session, false))
ft.UpdateStatus(voucher.TableID, voucherID, null);
}
public int? Update(Voucher voucher)
{
var dt = DbValues.Date;
@@ -66,7 +62,7 @@ namespace Tanshu.Accounts.Repository
if (voucher.Date == null)
{
voucher.SetValue(VoucherFields.Date, dt);
voucher.SetValue(VoucherFields.BillID, DbValues.BillID );
voucher.SetValue(VoucherFields.BillID, DbValues.BillID(voucher.VoucherType));
}
Kot addedKot = null;
@@ -79,15 +75,18 @@ namespace Tanshu.Accounts.Repository
item.User = voucher.User;
item.Code = DbValues.KotCode;
}
UpdateBill(voucher);
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
VoucherSettlementBI.UpdateSettlements(voucher.Settlements, amount);
Session.Update(voucher);
return addedKot == null ? (int?) null : addedKot.KotID;
return addedKot == null ? (int?)null : addedKot.KotID;
}
public Voucher Get(int voucherID)
public Voucher Get(Expression<Func<Voucher, bool>> query)
{
var voucher = Session.Get<Voucher>(voucherID);
var voucher = Session.QueryOver<Voucher>()
.Where(query)
.SingleOrDefault();
NHibernateUtil.Initialize(voucher.Customer);
NHibernateUtil.Initialize(voucher.Waiter);
NHibernateUtil.Initialize(voucher.User);
@@ -108,12 +107,16 @@ namespace Tanshu.Accounts.Repository
NHibernateUtil.Initialize(item);
return voucher;
}
public Voucher Get(string billID)
public void Delete(int voucherID)
{
var voucher = Session.CreateCriteria<Voucher>()
.Add(Restrictions.Eq("BillID", billID))
.UniqueResult<Voucher>();
return voucher != null ? Get(voucher.VoucherID) : null;
var voucher = Session.Get<Voucher>(voucherID);
Delete(voucher);
}
public void Delete(Voucher voucher)
{
Session.Delete(voucher);
using (var ft = new FoodTableBI(Session, false))
ft.UpdateStatus(voucher.TableID, voucher.VoucherID, null);
}
public void VoidBill(int voucherID, string reason)
@@ -132,6 +135,15 @@ namespace Tanshu.Accounts.Repository
Session.Update(voucher);
return voucher.VoucherID;
}
public int MergeTables(int voucherID, FoodTable foodTable)
{
var voucher = Session.Get<Voucher>(foodTable.VoucherID);
var oldVoucher = Session.Get<Voucher>(voucherID);
foreach (var kot in oldVoucher.Kots)
voucher.Kots.Add(kot);
Session.Update(voucher);
return voucher.VoucherID;
}
public int MergeKot(int kotID, Voucher voucher)
{
var kot = Session.Get<Kot>(kotID);
@@ -140,5 +152,31 @@ namespace Tanshu.Accounts.Repository
return voucher.VoucherID;
}
private static void UpdateBill(Voucher voucher)
{
switch (voucher.VoucherType)
{
case VoucherType.Regular:
break;
case VoucherType.NoCharge:
foreach (var item in voucher.Kots.SelectMany(kot => kot.Inventories))
{
item.ServiceCharge = 0;
item.Tax = 0;
}
break;
case VoucherType.TakeAway:
foreach (var item in voucher.Kots.SelectMany(kot => kot.Inventories))
item.ServiceCharge = 0;
break;
case VoucherType.Staff:
foreach (var item in voucher.Kots.SelectMany(kot => kot.Inventories))
{
item.ServiceCharge = 0;
item.Tax = 0;
}
break;
}
}
}
}
@@ -1,67 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using Tanshu.Accounts.Contracts;
using System.Data.SqlClient;
using Tanshu.Data.DAO;
using System.Collections.Generic;
using NHibernate;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.SqlDAO;
using NHibernate.Criterion;
namespace Tanshu.Accounts.Repository
{
public static class WaiterBI
public class WaiterBI : FluentGenericBase<Waiter>
{
public static void Insert(Waiter waiter)
{
using (var session = SessionManager.Session)
{
session.Save(waiter);
}
}
public static void Update(Waiter waiter)
{
using (var session = SessionManager.Session)
{
session.Update(waiter);
}
}
public static bool Delete(int waiterID)
{
using (var session = SessionManager.Session)
{
session.Delete(new Waiter() { WaiterID = waiterID });
return true;
}
}
public static Waiter GetWaiter(int waiterID)
public WaiterBI()
: base()
{ }
public WaiterBI(bool beginTransaction)
: base(beginTransaction)
{ }
public WaiterBI(ISession session)
: base(session)
{ }
public WaiterBI(ISession session, bool beginTransaction)
: base(session, beginTransaction)
{ }
public static IList<Waiter> List(Dictionary<string, string> filter)
{
using (var session = SessionManager.Session)
{
return session.Get<Waiter>(waiterID);
}
}
public static IList<Waiter> GetWaiters()
{
using (var session = SessionManager.Session)
{
return session.CreateCriteria<Waiter>()
.List<Waiter>();
}
}
public static IList<Waiter> GetWaiters(string name)
{
using (var session = SessionManager.Session)
{
return session.CreateCriteria<Waiter>()
.Add(Restrictions.InsensitiveLike("Name", string.Format("%{0}%", name)))
.List<Waiter>();
}
}
public static IList<Waiter> GetFilteredWaiters(Dictionary<string, string> filter)
{
return GetWaiters(filter["Name"]);
using (var bi = new WaiterBI(false))
return bi.Query()
.WhereRestrictionOn(x => x.Name).IsLike(string.Format("%{0}%", filter["Name"]))
.List();
}
}
}
+19 -5
View File
@@ -1,4 +1,5 @@
using System;
using Tanshu.Accounts.Entities;
namespace Tanshu.Accounts.Repository
{
@@ -39,25 +40,38 @@ namespace Tanshu.Accounts.Repository
}
}
}
public static string BillID
public static string BillID(VoucherType voucherType)
{
get
{
using (var session = SessionManager.Session)
{
const string query = @"
var query = "";
switch (voucherType)
{
case VoucherType.Regular:
case VoucherType.TakeAway:
query = @"
DECLARE @BillID nvarchar(10)
SELECT @BillID = ISNULL(CAST(MAX(CAST(REPLACE(BillID, '-', '') AS int)) + 1 AS nvarchar(9)), '010001') FROM Entities_Vouchers WHERE BillID LIKE '__-____'
AND BillID NOT LIKE 'NC-%' AND BillID NOT LIKE 'ST-%'
IF LEN(@BillID) = 5
SET @BillID = '0' + @BillID
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-' + SUBSTRING(@BillID, 3, 7)
IF SUBSTRING(@BillID,3,7) = '-0000'
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-0001'
SELECT @BillID";
break;
case VoucherType.NoCharge:
query = @"SELECT ISNULL('NC-' + CAST(MAX(CAST(SUBSTRING(BillID, 4,9) AS int)) + 1 AS nvarchar(9)), 'NC-1') FROM Entities_Vouchers WHERE BillID LIKE 'NC-%'";
break;
case VoucherType.Staff:
query = @"SELECT ISNULL('ST-' + CAST(MAX(CAST(SUBSTRING(BillID, 4,9) AS int)) + 1 AS nvarchar(9)), 'ST-1') FROM Entities_Vouchers WHERE BillID LIKE 'ST-%'";
break;
default:
throw new ArgumentOutOfRangeException("voucherType");
}
var sqlQuery = session.CreateSQLQuery(query);
return (string)sqlQuery.UniqueResult();
}
}
}
}
}
@@ -84,6 +84,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BusinessLayer\CheckoutBI.cs" />
<Compile Include="BusinessLayer\InventoryBI.cs" />
<Compile Include="BusinessLayer\ReprintBI.cs" />
<Compile Include="BusinessLayer\FluentBasicBaseBI.cs" />
<Compile Include="BusinessLayer\VoucherSettlementBI.cs" />