From 964d0a78bfe6614725a54870ccb43ee645235a24 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Dec 2011 15:11:02 +0530 Subject: [PATCH] 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 --- .../Data Contracts Display/SalesAnalysisBO.cs | 1 + .../Data Contracts/ProductBO.cs | 4 + .../Data Contracts/SettleOption.cs | 8 +- .../Data Contracts/VoucherBO.cs | 21 +- .../Data Contracts/VoucherType.cs | 16 + .../Helper Functions/EnumHelper.cs | 5 + .../Helper Functions/StringHelper.cs | 26 + Tanshu.Accounts.Contracts/RolesConstants.cs | 2 + .../Tanshu.Accounts.Contracts.csproj | 2 + Tanshu.Accounts.Helpers/SelectCustomer.cs | 24 +- Tanshu.Accounts.Helpers/SelectProduct.cs | 19 +- Tanshu.Accounts.Helpers/SelectUser.cs | 19 +- Tanshu.Accounts.Helpers/SelectWaiter.cs | 54 +- Tanshu.Accounts.Helpers/SelectorEvent.cs | 38 + .../Tanshu.Accounts.Helpers.csproj | 1 + .../Authentication/LoginForm.cs | 4 +- .../Controllers/BillController.cs | 738 ++++++++++-------- .../Controllers/ISaleForm.cs | 4 +- Tanshu.Accounts.PointOfSale/MainForm.cs | 39 +- .../MainForm.designer.cs | 89 ++- .../Management/QuantityForm.cs | 96 ++- .../Management/QuantityForm.designer.cs | 17 +- .../Products/ProductForm.Designer.cs | 22 +- .../Products/ProductForm.cs | 15 +- .../Reports/BillDetailsForm.cs | 4 +- .../Reports/DiscountReportForm.cs | 46 ++ .../Reports/DiscountReportForm.designer.cs | 114 +++ .../Reports/DiscountReportForm.resx | 120 +++ .../Reports/SaleAnalysisForm.cs | 15 +- .../Reports/SaleDetail.cs | 12 +- .../Reports/VoidReprintedForm.cs | 2 + .../Sales/CustomersForm.cs | 60 +- .../Sales/DiscountForm.cs | 32 +- .../Sales/PaxForm.Designer.cs | 74 ++ Tanshu.Accounts.PointOfSale/Sales/PaxForm.cs | 36 + .../Sales/PaxForm.resx | 120 +++ .../Sales/SalesForm.Designer.cs | 59 +- .../Sales/SalesForm.cs | 104 +-- .../Sales/SalesForm.resx | 6 - .../Sales/SettleChoicesForm.cs | 23 +- .../Sales/VoucherTypeForm.Designer.cs | 63 ++ .../Sales/VoucherTypeForm.cs | 93 +++ .../Sales/VoucherTypeForm.resx | 120 +++ .../Tanshu.Accounts.PointOfSale.csproj | 40 +- .../Tanshu.Accounts.Print.csproj | 1 + Tanshu.Accounts.Print/Thermal.cs | 221 ++---- Tanshu.Accounts.Print/ThermalBill.cs | 139 ++++ .../BusinessLayer/InventoryBI.cs | 28 + .../BusinessLayer/ManagementBI.cs | 249 ++++-- .../BusinessLayer/SalesAnalysisBI.cs | 80 +- .../BusinessLayer/VoucherBI.cs | 86 +- .../BusinessLayer/WaiterBI.cs | 77 +- Tanshu.Accounts.Repository/DbValues.cs | 24 +- .../Tanshu.Accounts.Repository.csproj | 1 + 54 files changed, 2285 insertions(+), 1028 deletions(-) create mode 100644 Tanshu.Accounts.Contracts/Data Contracts/VoucherType.cs create mode 100644 Tanshu.Accounts.Contracts/Helper Functions/StringHelper.cs create mode 100644 Tanshu.Accounts.Helpers/SelectorEvent.cs create mode 100644 Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Sales/PaxForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Sales/PaxForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Sales/PaxForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.resx create mode 100644 Tanshu.Accounts.Print/ThermalBill.cs create mode 100644 Tanshu.Accounts.Repository/BusinessLayer/InventoryBI.cs diff --git a/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs index 725fb21..78a0dfd 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs @@ -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 { diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs index 33cda51..85aa81b 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs @@ -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; } } } diff --git a/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs b/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs index a2ab789..781cb68 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs @@ -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 } } \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs index 05a235a..6c81980 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs @@ -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 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 diff --git a/Tanshu.Accounts.Contracts/Data Contracts/VoucherType.cs b/Tanshu.Accounts.Contracts/Data Contracts/VoucherType.cs new file mode 100644 index 0000000..5df9649 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Data Contracts/VoucherType.cs @@ -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, + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs b/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs index 51f90cd..312e7e6 100644 --- a/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs +++ b/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs @@ -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; + } } } \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/Helper Functions/StringHelper.cs b/Tanshu.Accounts.Contracts/Helper Functions/StringHelper.cs new file mode 100644 index 0000000..ff12866 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Helper Functions/StringHelper.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/RolesConstants.cs b/Tanshu.Accounts.Contracts/RolesConstants.cs index cab568e..eb9355a 100644 --- a/Tanshu.Accounts.Contracts/RolesConstants.cs +++ b/Tanshu.Accounts.Contracts/RolesConstants.cs @@ -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"); diff --git a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj index 413a8f6..d4345fe 100644 --- a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj +++ b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj @@ -100,6 +100,7 @@ + @@ -120,6 +121,7 @@ + diff --git a/Tanshu.Accounts.Helpers/SelectCustomer.cs b/Tanshu.Accounts.Helpers/SelectCustomer.cs index 4d7bca5..409af58 100644 --- a/Tanshu.Accounts.Helpers/SelectCustomer.cs +++ b/Tanshu.Accounts.Helpers/SelectCustomer.cs @@ -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 { - public event CustomerEventHandler customerEvent; + public event CustomerEventHandler CustomerEvent; public SelectCustomer(GetData getData, bool autoClose) : base(getData, true, "List of Products") { - List filters = new List(); - filters.Add("Universal"); + var filters = new List {"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; diff --git a/Tanshu.Accounts.Helpers/SelectProduct.cs b/Tanshu.Accounts.Helpers/SelectProduct.cs index 6781ff2..044a65f 100644 --- a/Tanshu.Accounts.Helpers/SelectProduct.cs +++ b/Tanshu.Accounts.Helpers/SelectProduct.cs @@ -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 getData, bool autoClose) : base(getData, true, "List of Products") { - List filters = new List(); - filters.Add("Name"); - filters.Add("Type"); + var filters = new List {"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; diff --git a/Tanshu.Accounts.Helpers/SelectUser.cs b/Tanshu.Accounts.Helpers/SelectUser.cs index 8cb7f60..a971e9c 100644 --- a/Tanshu.Accounts.Helpers/SelectUser.cs +++ b/Tanshu.Accounts.Helpers/SelectUser.cs @@ -14,11 +14,10 @@ namespace Tanshu.Accounts.Helpers { public class SelectUser : Tanshu.Data.BaseSelector { - public event UserEventHandler userEvent; + public event UserEventHandler UserEvent; public SelectUser(GetData getData, bool autoClose) : base (getData, true, "Select a User") { - IList filters = new List(); - filters.Add("Name"); + var filters = new List {"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; diff --git a/Tanshu.Accounts.Helpers/SelectWaiter.cs b/Tanshu.Accounts.Helpers/SelectWaiter.cs index 08bbb88..2bcfebb 100644 --- a/Tanshu.Accounts.Helpers/SelectWaiter.cs +++ b/Tanshu.Accounts.Helpers/SelectWaiter.cs @@ -14,11 +14,10 @@ namespace Tanshu.Accounts.Helpers { public class SelectWaiter : Tanshu.Data.BaseSelector { - public event WaiterEventHandler waiterEvent; + public event WaiterEventHandler WaiterEvent; public SelectWaiter(GetData getData, bool autoClose) : base(getData, true, "Select a Waiter") { - List filters = new List(); - filters.Add("Name"); + var filters = new List {"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(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,SelectorAction.Insert); break; } case Keys.F2: { if (waiter != null) waiter.Name = base.filterColumns["Name"].Trim(); - eventArgs = new WaiterEventArgs(waiter, 2); + eventArgs = new SelectorEventArgs(waiter, SelectorAction.Update); break; } case Keys.F8: { if (waiter != null) - eventArgs = new WaiterEventArgs(waiter, 3); + eventArgs = new SelectorEventArgs(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 e); } diff --git a/Tanshu.Accounts.Helpers/SelectorEvent.cs b/Tanshu.Accounts.Helpers/SelectorEvent.cs new file mode 100644 index 0000000..02b638f --- /dev/null +++ b/Tanshu.Accounts.Helpers/SelectorEvent.cs @@ -0,0 +1,38 @@ +using System; + +namespace Tanshu.Accounts.Helpers +{ + public enum SelectorAction + { + Insert = 1, + Update = 2, + Delete = 3 + } + public class SelectorEventArgs : 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; + } + } +} diff --git a/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj b/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj index 8409ddb..dfa14ae 100644 --- a/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj +++ b/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj @@ -63,6 +63,7 @@ + Form diff --git a/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs b/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs index 8a320ae..3c8f6e1 100644 --- a/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs +++ b/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs @@ -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 diff --git a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs index cd39079..fd1848d 100644 --- a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs +++ b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs @@ -15,20 +15,28 @@ namespace Tanshu.Accounts.PointOfSale private readonly OrderedDictionary _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(); + _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 GetVoidReason(Dictionary filter) + private Waiter selectWaiter_waiterEvent(object sender, SelectorEventArgs e) { - var list = new List - { - 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 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 GetVoidReason(Dictionary filter) + { + var list = new List + { + 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 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); - } } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs b/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs index d1a2d1b..2806cbc 100644 --- a/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs +++ b/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs @@ -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 bill); void SetCustomerDisplay(string name); + void SetWaiterDisplay(string p); void CloseWindow(); void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List 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; } diff --git a/Tanshu.Accounts.PointOfSale/MainForm.cs b/Tanshu.Accounts.PointOfSale/MainForm.cs index e00cae2..fc51156 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.cs @@ -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(); + + } + } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs index 629f85c..fe179f9 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs @@ -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; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Management/QuantityForm.cs b/Tanshu.Accounts.PointOfSale/Management/QuantityForm.cs index 8d1e2cb..d951332 100644 --- a/Tanshu.Accounts.PointOfSale/Management/QuantityForm.cs +++ b/Tanshu.Accounts.PointOfSale/Management/QuantityForm.cs @@ -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 _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); + } + } + } } } } diff --git a/Tanshu.Accounts.PointOfSale/Management/QuantityForm.designer.cs b/Tanshu.Accounts.PointOfSale/Management/QuantityForm.designer.cs index 862b5ec..d7ab8f8 100644 --- a/Tanshu.Accounts.PointOfSale/Management/QuantityForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Management/QuantityForm.designer.cs @@ -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; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs index 03caceb..ae92c71 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs index 448f51b..67b90c3 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs @@ -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) diff --git a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs index bd1b154..90afa00 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs @@ -10,11 +10,9 @@ namespace Tanshu.Accounts.PointOfSale public partial class BillDetailsForm : Form { IList _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; diff --git a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs new file mode 100644 index 0000000..d656c3d --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs @@ -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 _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(); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs new file mode 100644 index 0000000..3cffd00 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs @@ -0,0 +1,114 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class DiscountReportForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.resx b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs index c9fc5f8..b5c6b7d 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs @@ -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 list; - //private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + IList _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); } } } diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs index fba19df..2c8739f 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs @@ -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); } } } diff --git a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs index ab7747b..32d6c15 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs @@ -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; diff --git a/Tanshu.Accounts.PointOfSale/Sales/CustomersForm.cs b/Tanshu.Accounts.PointOfSale/Sales/CustomersForm.cs index 5727739..7fa8f51 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/CustomersForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/CustomersForm.cs @@ -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; } } } } diff --git a/Tanshu.Accounts.PointOfSale/Sales/DiscountForm.cs b/Tanshu.Accounts.PointOfSale/Sales/DiscountForm.cs index 2ab5838..72efc78 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/DiscountForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/DiscountForm.cs @@ -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 source; - private HashSet selection; - decimal discount; + private readonly IList _source; + private readonly HashSet _selection; + decimal _discount; public DiscountForm(IList source) { InitializeComponent(); - this.source = source; - selection = new HashSet(); + this._source = source; + _selection = new HashSet(); } 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 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(); diff --git a/Tanshu.Accounts.PointOfSale/Sales/PaxForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Sales/PaxForm.Designer.cs new file mode 100644 index 0000000..89e759b --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/PaxForm.Designer.cs @@ -0,0 +1,74 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class PaxForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/PaxForm.cs b/Tanshu.Accounts.PointOfSale/Sales/PaxForm.cs new file mode 100644 index 0000000..fcc8e39 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/PaxForm.cs @@ -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(); + } + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Sales/PaxForm.resx b/Tanshu.Accounts.PointOfSale/Sales/PaxForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/PaxForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs index 4b94528..242e5e5 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs @@ -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; } } diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs index 737d7a9..ccabaea 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs @@ -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 diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx index 53e72f3..c41ea0d 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx @@ -123,12 +123,6 @@ 17, 17 - - True - - - 17, 17 - 148, 17 diff --git a/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs b/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs index aa5d6bf..fd44f09 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs @@ -13,11 +13,12 @@ namespace Tanshu.Accounts.PointOfSale { private readonly IDictionary _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(); _list = new Dictionary(); } @@ -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; } diff --git a/Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.Designer.cs new file mode 100644 index 0000000..11a724c --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.Designer.cs @@ -0,0 +1,63 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class VoucherTypeForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.cs b/Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.cs new file mode 100644 index 0000000..4486ffa --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/VoucherTypeForm.cs @@ -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