From da929ad0366a39b9891cf92a81ebd984fc35ebe6 Mon Sep 17 00:00:00 2001 From: tanshu Date: Thu, 16 Oct 2014 16:41:55 +0530 Subject: [PATCH] Breaking Change: Changed Kot/Voucher Table Name to Guid Foreign key Breaking Change: Renamed Discontinued to IsActive and added NA field to products. Cleanup: Removed not used attributes Change: RoleConstants changed to simple string Feature: Table Create/Edit/Reorder and Modifier Create/Edit Form Feature: Bills now show the Tax name from the database and not a hack --- ...014.10.12 Step 1. Create New DB Schema.sql | Bin 20214 -> 20922 bytes Sql/2014.10.12 Step 2. Import old Data.sql | 64 ++- .../Attributes/AllowNullAttribute.cs | 16 - .../Attributes/CascadeAttribute.cs | 18 - .../Attributes/FormulaAttribute.cs | 24 -- .../Attributes/InverseAttribute.cs | 18 - .../Attributes/NotNullAttribute.cs | 18 - .../Attributes/PermissionAttribute.cs | 17 - .../Attributes/SecutiryAttribute.cs | 18 - .../Attributes/UniqueAttribute.cs | 18 - .../Data Contracts Display/PendingBillsBO.cs | 31 -- .../Data Contracts/FoodTableBO.cs | 2 + .../Data Contracts/KotBO.cs | 10 +- .../Data Contracts/ModifierBO.cs | 5 + .../Data Contracts/ProductBO.cs | 8 +- .../Data Contracts/ProductGroupBO.cs | 7 +- .../Data Contracts/VoucherBO.cs | 14 +- .../{Attributes => }/DisplayAttribute.cs | 0 Tanshu.Accounts.Contracts/RolesConstants.cs | 60 --- .../Tanshu.Accounts.Contracts.csproj | 12 +- Tanshu.Accounts.Helpers/ControlFactory.cs | 23 +- Tanshu.Accounts.Helpers/SelectBill.cs | 73 ---- .../Tanshu.Accounts.Helpers.csproj | 3 - .../Controllers/BillController.cs | 61 ++- .../Controllers/BillDict.cs | 1 - Tanshu.Accounts.PointOfSale/MainForm.cs | 87 ++-- .../MainForm.designer.cs | 52 ++- .../Products/FoodTableForm.Designer.cs | 385 ++++++++++++++++++ .../Products/FoodTableForm.cs | 154 +++++++ .../Products/FoodTableForm.resx | 132 ++++++ .../Products/FoodTableListForm.Designer.cs | 268 ++++++++++++ .../Products/FoodTableListForm.cs | 114 ++++++ .../Products/FoodTableListForm.resx | 138 +++++++ .../Products/ModifierEditForm.Designer.cs | 165 ++++++++ .../Products/ModifierEditForm.cs | 111 +++++ .../Products/ModifierEditForm.resx | 120 ++++++ .../Products/ModifierListForm.Designer.cs | 201 +++++++++ .../Products/ModifierListForm.cs | 100 +++++ .../Products/ModifierListForm.resx | 135 ++++++ .../Products/ProductForm.Designer.cs | 35 +- .../Products/ProductForm.cs | 6 +- .../Products/ProductGroupForm.Designer.cs | 22 +- .../Products/ProductGroupForm.cs | 4 +- .../Products/ProductListForm.Designer.cs | 18 +- .../Products/TableForm.Designer.cs | 137 +++++++ .../Products/TableForm.cs | 87 ++++ .../Products/TableForm.resx | 120 ++++++ .../Reports/BillDetailsForm.cs | 2 +- .../Reports/DiscountReportForm.cs | 2 +- .../Reports/SaleAnalysisForm.cs | 2 +- .../Reports/SaleDetail.cs | 2 +- .../Reports/VoidReprintedForm.cs | 2 +- .../Sales/MoveTableForm.cs | 12 +- .../Sales/ReorderTableForm.Designer.cs | 67 +++ .../Sales/ReorderTableForm.cs | 126 ++++++ .../Sales/ReorderTableForm.resx | 120 ++++++ .../Sales/SalesForm.Designer.cs | 46 +-- .../Sales/SalesForm.cs | 15 +- .../Sales/SalesForm.resx | 3 - .../Tanshu.Accounts.PointOfSale.csproj | 39 ++ .../AssignRoleGroups.Designer.cs | 132 ++---- .../User Management/AssignRoleGroups.cs | 115 ++---- .../AssignUserGroups.Designer.cs | 152 ++----- .../User Management/AssignUserGroups.cs | 106 ++--- Tanshu.Accounts.Print/Thermal.cs | 48 +-- Tanshu.Accounts.Print/ThermalBill.cs | 159 ++++---- .../BusinessLayer/FoodTableBI.cs | 20 +- .../BusinessLayer/GroupBI.cs | 47 +++ .../BusinessLayer/MembershipBI.cs | 156 ------- .../BusinessLayer/ModifierBI.cs | 73 +++- .../BusinessLayer/ProductGroupBI.cs | 3 +- .../BusinessLayer/UserBI.cs | 37 ++ .../BusinessLayer/VoucherBI.cs | 33 +- .../BusinessLayer/VoucherSettlementBI.cs | 2 +- Tanshu.Accounts.Repository/Session.cs | 10 +- .../Tanshu.Accounts.Repository.csproj | 4 +- 76 files changed, 3472 insertions(+), 1175 deletions(-) delete mode 100644 Tanshu.Accounts.Contracts/Attributes/AllowNullAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Attributes/CascadeAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Attributes/FormulaAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Attributes/InverseAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Attributes/NotNullAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Attributes/PermissionAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Attributes/SecutiryAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Attributes/UniqueAttribute.cs delete mode 100644 Tanshu.Accounts.Contracts/Data Contracts Display/PendingBillsBO.cs rename Tanshu.Accounts.Contracts/{Attributes => }/DisplayAttribute.cs (100%) delete mode 100644 Tanshu.Accounts.Contracts/RolesConstants.cs delete mode 100644 Tanshu.Accounts.Helpers/SelectBill.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/FoodTableForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/FoodTableForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/FoodTableForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Products/ModifierListForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/ModifierListForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/ModifierListForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Products/TableForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/TableForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Products/TableForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.resx create mode 100644 Tanshu.Accounts.Repository/BusinessLayer/GroupBI.cs delete mode 100644 Tanshu.Accounts.Repository/BusinessLayer/MembershipBI.cs diff --git a/Sql/2014.10.12 Step 1. Create New DB Schema.sql b/Sql/2014.10.12 Step 1. Create New DB Schema.sql index 97a3d402f927513037f8b5f4723437596175aa6c..b1800dd3d993c09b9c9c68a78b68574c685787a6 100644 GIT binary patch delta 265 zcmex1mvPr(#toC0CePq@n|y^mVzU-A3pbc!pujd+L5FQ~6;4cxJ zd_a_oH;n9#mYzI8ifeP6)*AN79!BdXzmt`k Rd``e(aey(?<_>csDFEs9E`$I8 diff --git a/Sql/2014.10.12 Step 2. Import old Data.sql b/Sql/2014.10.12 Step 2. Import old Data.sql index 0c9d020..63bc634 100644 --- a/Sql/2014.10.12 Step 2. Import old Data.sql +++ b/Sql/2014.10.12 Step 2. Import old Data.sql @@ -20,11 +20,40 @@ ALTER TABLE Entities_ProductGroupModifiers ADD ID uniqueidentifier not null DEFA ALTER TABLE Entities_PrintLocations ADD ID uniqueidentifier not null DEFAULT newid(); ALTER TABLE Entities_Reprints ADD ID uniqueidentifier not null DEFAULT newid(); ALTER TABLE Entities_VoucherSettlements ADD ID uniqueidentifier not null DEFAULT newid(); -COMMIT -BEGIN TRANSACTION +GO UPDATE Entities_Customers SET ID = '2C716F4B-0736-429A-AD51-610D7C47CB5E' WHERE CustomerID = 1; UPDATE Entities_Waiters SET ID = '3ECB3BCE-CBBA-461C-BC16-5823FC075AAA' WHERE WaiterID = 1; +DELETE FROM Auth_RoleGroups WHERE RoleID IN (1,2); +DELETE FROM Auth_Roles WHERE RoleID IN (1,2); +UPDATE Auth_Roles SET Name = 'Change Rate' WHERE RoleID = 3; +UPDATE Auth_Roles SET Name = 'Cashier Checkout' WHERE RoleID = 4; +UPDATE Auth_Roles SET Name = 'Customers' WHERE RoleID = 5; +UPDATE Auth_Roles SET Name = 'Discount' WHERE RoleID = 6; +UPDATE Auth_Roles SET Name = 'Edit Printed Bill' WHERE RoleID = 7; +UPDATE Auth_Roles SET Name = 'Edit Printed Product' WHERE RoleID = 8; +UPDATE Auth_Roles SET Name = 'Print Bill' WHERE RoleID = 9; +UPDATE Auth_Roles SET Name = 'Print Kot' WHERE RoleID = 10; +UPDATE Auth_Roles SET Name = 'Sales' WHERE RoleID = 11; +UPDATE Auth_Roles SET Name = 'Sales Detail' WHERE RoleID = 12; +UPDATE Auth_Roles SET Name = 'Void Bill' WHERE RoleID = 13; +UPDATE Auth_Roles SET Name = 'NC Product' WHERE RoleID = 14; +UPDATE Auth_Roles SET Name = 'Settle Bill' WHERE RoleID = 15; +UPDATE Auth_Roles SET Name = 'Products' WHERE RoleID = 16; +UPDATE Auth_Roles SET Name = 'Users' WHERE RoleID = 17; +UPDATE Auth_Roles SET Name = 'Roles' WHERE RoleID = 18; +DELETE FROM Auth_Rolegroups WHERE RoleID = 19; +DELETE FROM Auth_Roles WHERE RoleID = 19; +UPDATE Auth_Roles SET Name = 'Owner' WHERE RoleID = 20; +UPDATE Auth_Roles SET Name = 'Sales Analysis' WHERE RoleID = 21; +UPDATE Auth_Roles SET Name = 'Move Table' WHERE RoleID = 22; +UPDATE Auth_Roles SET Name = 'Merge Tables' WHERE RoleID = 23; +UPDATE Auth_Roles SET Name = 'Merge Kots' WHERE RoleID = 24; +UPDATE Auth_Roles SET Name = 'Move Kot to New Table' WHERE RoleID = 25; +UPDATE Auth_Roles SET Name = 'Bill Details' WHERE RoleID = 26; +UPDATE Auth_Roles SET Name = 'Open Bill' WHERE RoleID = 27; +INSERT INTO Auth_Roles (RoleID, Name) VALUES(Newid(), 'Modifiers') COMMIT +GO USE Sales BEGIN TRANSACTION INSERT INTO Waiters (WaiterID, Name) @@ -37,17 +66,22 @@ INSERT INTO Modifiers (ModifierID, Name, ShowInBill, Price) SELECT ID, Name, 0, 0 from Gets.dbo.Entities_Modifiers; INSERT INTO Auth_Roles (RoleID, Name) SELECT ID, Name from Gets.dbo.Auth_Roles; -INSERT INTO ProductGroups (ProductGroupID, Name, DiscountLimit, IsModifierCompulsory, Discontinued, SortOrder, GroupType) -SELECT ID, Name, DiscountLimit, IsModifierCompulsory, Discontinued, SortOrder, GroupType from Gets.dbo.Entities_ProductGroups; +INSERT INTO ProductGroups (ProductGroupID, Name, DiscountLimit, IsModifierCompulsory, IsActive, SortOrder, GroupType) +SELECT ID, Name, DiscountLimit, IsModifierCompulsory, CASE Discontinued WHEN 0 THEN 1 ELSE 0 END, SortOrder, GroupType from Gets.dbo.Entities_ProductGroups; INSERT INTO Taxes (TaxID, Name, Rate) SELECT ID, Name, Rate from Gets.dbo.Entities_Taxes; INSERT INTO Auth_Users (UserID, Name, MsrString, Password, LockedOut) SELECT ID, Name, MsrString, Password, LockedOut from Gets.dbo.Auth_Users; +INSERT INTO FoodTables (FoodTableID, Name, IsActive, Location, Status, VoucherID, SortOrder) +SELECT ID, Name, 1, Location, null, null, FoodTableID +from Gets.dbo.Entities_FoodTables as ft; + INSERT INTO Vouchers (VoucherID, Date, Pax, UserID, CreationDate, LastEditDate, BillID, TableID, WaiterID, CustomerID, Narration, Void, VoidReason, Printed, VoucherType, KotID) SELECT ID, Date, Pax, (SELECT u.ID FROM Gets.dbo.Auth_Users u WHERE u.UserID = v.UserID), -CreationDate, LastEditDate, BillID, TableID, +CreationDate, LastEditDate, BillID, +(SELECT t.ID FROM Gets.dbo.Entities_FoodTables t WHERE t.Name = v.TableID), (SELECT w.ID FROM Gets.dbo.Entities_Waiters w WHERE w.WaiterID = v.WaiterID), (SELECT c.ID FROM Gets.dbo.Entities_Customers c WHERE c.CustomerID = v.CustomerID), Narration, Void, VoidReason, Printed, VoucherType, KotID @@ -56,16 +90,18 @@ from Gets.dbo.Entities_Vouchers as V; INSERT INTO Kots (KotID, VoucherID, Code, TableID, Printed, Date, UserID) SELECT ID, (SELECT v.ID FROM Gets.dbo.Entities_Vouchers v WHERE v.VoucherID = k.VoucherID), -Code, TableID, Printed, Date, +Code, +(SELECT t.ID FROM Gets.dbo.Entities_FoodTables t WHERE t.Name = k.TableID), +Printed, Date, (SELECT u.ID FROM Gets.dbo.Auth_Users u WHERE u.UserID = k.UserID) from Gets.dbo.Entities_Kots AS k; -INSERT INTO Products (ProductID, Code, Name, Units, ProductGroupID, VatID, ServiceTaxID, ServiceCharge, IsScTaxable, Price, FullPrice, Discontinued, SortOrder, BaseCode, Quantity) +INSERT INTO Products (ProductID, Code, Name, Units, ProductGroupID, VatID, ServiceTaxID, ServiceCharge, IsScTaxable, Price, FullPrice, IsActive, IsNotAvailable, SortOrder, BaseCode, Quantity) SELECT ID, Code, Name, Units, (SELECT pg.ID FROM Gets.dbo.Entities_ProductGroups pg WHERE pg.ProductGroupID = p.ProductGroupID), (SELECT vat.ID FROM Gets.dbo.Entities_Taxes vat WHERE vat.TaxID = p.VatID), (SELECT st.ID FROM Gets.dbo.Entities_Taxes st WHERE st.TaxID = p.ServiceTaxID), -ServiceCharge, IsScTaxable, Price, FullPrice, Discontinued, SortOrder, BaseCode, Quantity +ServiceCharge, IsScTaxable, Price, FullPrice, CASE Discontinued WHEN 0 THEN 1 ELSE 0 END, 0, SortOrder, BaseCode, Quantity from Gets.dbo.Entities_Products AS p; INSERT INTO Inventories (InventoryID, KotID, ProductID, Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTaxRate, VatRate, ServiceTaxID, VatID, Discount) @@ -122,10 +158,12 @@ SELECT ID, Settled, Amount from Gets.dbo.Entities_VoucherSettlements as s; -INSERT INTO FoodTables (FoodTableID, Name, Location, Status, VoucherID, SortOrder) -SELECT ID, Name, Location, Status, -(SELECT v.ID FROM Gets.dbo.Entities_Vouchers v WHERE v.VoucherID = ft.VoucherID), -FoodTableID -from Gets.dbo.Entities_FoodTables as ft; +UPDATE FoodTables +SET Status = ft.Status, + VoucherID = (SELECT v.ID FROM Gets.dbo.Entities_Vouchers v WHERE v.VoucherID = ft.VoucherID) +FROM Gets.dbo.Entities_FoodTables as ft +WHERE FoodTables.FoodTableID = ft.ID; +INSERT INTO Auth_Roles (RoleID, Name) VALUES(Newid(), 'Modifiers') +INSERT INTO Auth_Roles (RoleID, Name) VALUES(Newid(), 'Tables') COMMIT \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/Attributes/AllowNullAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/AllowNullAttribute.cs deleted file mode 100644 index 9fcfeeb..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/AllowNullAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Tanshu.Accounts.Contracts.Attributes -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class AllowNullAttribute : Attribute - { - private string _message = string.Empty; - - public string Message - { - get { return _message; } - set { _message = value; } - } - } -} \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/Attributes/CascadeAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/CascadeAttribute.cs deleted file mode 100644 index d6b3bb0..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/CascadeAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class CascadeAttribute : Attribute - { - private string message = string.Empty; - public string Message - { - get { return message; } - set { message = value; } - } - } -} diff --git a/Tanshu.Accounts.Contracts/Attributes/FormulaAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/FormulaAttribute.cs deleted file mode 100644 index db08322..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/FormulaAttribute.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class FormulaAttribute : Attribute - { - private string message = string.Empty; - public string Message - { - get { return message; } - set { message = value; } - } - private string formula = string.Empty; - public string Formula - { - get { return formula; } - set { formula = value; } - } - } -} diff --git a/Tanshu.Accounts.Contracts/Attributes/InverseAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/InverseAttribute.cs deleted file mode 100644 index 4276778..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/InverseAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class InverseAttribute : Attribute - { - private string message = string.Empty; - public string Message - { - get { return message; } - set { message = value; } - } - } -} diff --git a/Tanshu.Accounts.Contracts/Attributes/NotNullAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/NotNullAttribute.cs deleted file mode 100644 index 5c7a241..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/NotNullAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class NotNullAttribute : Attribute - { - private string message = string.Empty; - public string Message - { - get { return message; } - set { message = value; } - } - } -} diff --git a/Tanshu.Accounts.Contracts/Attributes/PermissionAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/PermissionAttribute.cs deleted file mode 100644 index 8a9da00..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/PermissionAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] - public class PermissionAttribute : Attribute - { - public PermissionAttribute(RoleConstants role) - { - Role = role; - } - public RoleConstants Role { get; set; } - } -} diff --git a/Tanshu.Accounts.Contracts/Attributes/SecutiryAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/SecutiryAttribute.cs deleted file mode 100644 index 4f2fa58..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/SecutiryAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class SecurityAttribute : Attribute - { - private string message = string.Empty; - public string Message - { - get { return message; } - set { message = value; } - } - } -} diff --git a/Tanshu.Accounts.Contracts/Attributes/UniqueAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/UniqueAttribute.cs deleted file mode 100644 index b33322e..0000000 --- a/Tanshu.Accounts.Contracts/Attributes/UniqueAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class UniqueAttribute : Attribute - { - private string message = string.Empty; - public string Message - { - get { return message; } - set { message = value; } - } - } -} diff --git a/Tanshu.Accounts.Contracts/Data Contracts Display/PendingBillsBO.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/PendingBillsBO.cs deleted file mode 100644 index 3d81462..0000000 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/PendingBillsBO.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace Tanshu.Accounts.Contracts -{ - public enum PendingType - { - Today = 0, - Week = 1, - All = 2, - Important = 4, - Alarms = 8 - } - - public class PendingBills - { - public virtual Guid voucherID { get; set; } - public virtual string BillNo { get; set; } - public virtual string Kot { get; set; } - public virtual string TableID { get; set; } - public virtual decimal Amount { get; set; } - public virtual bool Important { get; set; } - public virtual bool Alarm { get; set; } - public virtual DateTime BookingTime { get; set; } - public virtual DateTime LastEdited { get; set; } - public virtual string Waiter { get; set; } - public virtual string Cashier { get; set; } - public virtual bool Printed { get; set; } - public virtual Nullable AlarmTime { get; set; } - } -} diff --git a/Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs index 0918242..5260e61 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs @@ -7,6 +7,7 @@ namespace Tanshu.Accounts.Entities { public virtual Guid FoodTableID { get; set; } public virtual string Name { get; set; } + public virtual bool IsActive { get; set; } public virtual string Location { get; set; } public virtual string Status { get; set; } public virtual int SortOrder { get; set; } @@ -21,6 +22,7 @@ namespace Tanshu.Accounts.Entities Lazy(true); Id(x => x.FoodTableID, map => map.Generator(Generators.GuidComb)); Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); }); + Property(x => x.IsActive); Property(x => x.Location); Property(x => x.Status); Property(x => x.VoucherID); diff --git a/Tanshu.Accounts.Contracts/Data Contracts/KotBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/KotBO.cs index d65b5bf..2dc74db 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/KotBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/KotBO.cs @@ -18,7 +18,7 @@ namespace Tanshu.Accounts.Entities public virtual Guid KotID { get; set; } public virtual Voucher Voucher { get; set; } public virtual string Code { get; set; } - public virtual string TableID { get; set; } + public virtual FoodTable Table { get; set; } public virtual bool Printed { get; set; } public virtual DateTime Date { get; set; } public virtual User User { get; set; } @@ -34,7 +34,6 @@ namespace Tanshu.Accounts.Entities Lazy(true); Id(x => x.KotID, map => map.Generator(Generators.GuidComb)); Property(x => x.Code, map => { map.NotNullable(true); map.Unique(true); }); - Property(x => x.TableID, map => map.NotNullable(true)); Property(x => x.Printed, map => map.NotNullable(true)); Property(x => x.Date, map => map.NotNullable(true)); ManyToOne(x => x.Voucher, map => @@ -44,6 +43,13 @@ namespace Tanshu.Accounts.Entities map.Cascade(Cascade.None); }); + ManyToOne(x => x.Table, map => + { + map.Column("TableID"); + map.NotNullable(true); + map.Cascade(Cascade.None); + }); + ManyToOne(x => x.User, map => { map.Column("UserID"); diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs index 4d04fa6..80ca129 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs @@ -9,6 +9,11 @@ namespace Tanshu.Accounts.Entities { public class Modifier { + public Modifier() + { + ProductGroupModifiers = new List(); + InventoryModifiers = new List(); + } public virtual Guid ModifierID { get; set; } public virtual string Name { get; set; } public virtual bool ShowInBill { get; set; } diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs index 1948e5e..4982038 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs @@ -19,11 +19,10 @@ namespace Tanshu.Accounts.Entities public virtual bool IsScTaxable { get; set; } public virtual decimal Price { get; set; } public virtual decimal FullPrice { get; set; } - public virtual bool Discontinued { get; set; } + public virtual bool IsActive { get; set; } + public virtual bool IsNotAvailable { get; set; } public virtual int SortOrder { get; set; } - [NotNull] public virtual int BaseCode { get; set; } - [NotNull] public virtual decimal Quantity { get; set; } public virtual IList Inventories { get; set; } @@ -44,7 +43,8 @@ namespace Tanshu.Accounts.Entities Property(x => x.IsScTaxable, map => map.NotNullable(true)); Property(x => x.Price, map => map.NotNullable(true)); Property(x => x.FullPrice, map => map.NotNullable(true)); - Property(x => x.Discontinued, map => map.NotNullable(true)); + Property(x => x.IsActive, map => map.NotNullable(true)); + Property(x => x.IsNotAvailable, map => map.NotNullable(true)); Property(x => x.SortOrder, map => map.NotNullable(true)); Property(x => x.BaseCode, map => map.NotNullable(true)); Property(x => x.Quantity, map => map.NotNullable(true)); diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs index a555c69..541e543 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs @@ -15,14 +15,11 @@ namespace Tanshu.Accounts.Entities public virtual Guid ProductGroupID { get; set; } - [NotNull, Unique] public virtual string Name { get; set; } - public virtual decimal DiscountLimit { get; set; } public virtual bool IsModifierCompulsory { get; set; } - public virtual bool Discontinued { get; set; } + public virtual bool IsActive { get; set; } public virtual int SortOrder { get; set; } - public virtual string GroupType { get; set; } public virtual IList Products { get; set; } public virtual IList PrintLocations { get; set; } @@ -38,7 +35,7 @@ namespace Tanshu.Accounts.Entities Lazy(true); Id(x => x.ProductGroupID, map => map.Generator(Generators.GuidComb)); Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); }); - Property(x => x.Discontinued, map => map.NotNullable(true)); + Property(x => x.IsActive, map => map.NotNullable(true)); Property(x => x.SortOrder, map => map.NotNullable(true)); Property(x => x.DiscountLimit, map => map.NotNullable(true)); Property(x => x.IsModifierCompulsory, map => map.NotNullable(true)); diff --git a/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs index a856f6d..ab3e922 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using Tanshu.Accounts.Contracts; -using Tanshu.Accounts.Contracts.Attributes; using Tanshu.Accounts.Entities.Auth; using NHibernate.Mapping.ByCode.Conformist; using NHibernate.Mapping.ByCode; @@ -24,11 +23,11 @@ namespace Tanshu.Accounts.Entities VoucherType = VoucherType.Regular; } - public Voucher(User user, Customer customer, string table, Waiter waiter, bool printed, bool isVoid, string narration) + public Voucher(User user, Customer customer, FoodTable table, Waiter waiter, bool printed, bool isVoid, string narration) : this(user) { Customer = customer; - TableID = table; + Table = table; Waiter = waiter; Printed = printed; Void = isVoid; @@ -45,7 +44,7 @@ namespace Tanshu.Accounts.Entities public virtual DateTime CreationDate { get; set; } public virtual DateTime LastEditDate { get; set; } public virtual string BillID { get; set; } - public virtual string TableID { get; set; } + public virtual FoodTable Table { get; set; } public virtual Waiter Waiter { get; set; } public virtual Customer Customer { get; set; } public virtual IList Settlements { get; set; } @@ -75,7 +74,6 @@ namespace Tanshu.Accounts.Entities Property(x => x.CreationDate, map => map.NotNullable(true)); Property(x => x.LastEditDate, map => map.NotNullable(true)); Property(x => x.BillID, map => map.NotNullable(true)); - Property(x => x.TableID, map => map.NotNullable(true)); Property(x => x.Void, map => map.NotNullable(true)); Property(x => x.VoidReason); Property(x => x.Printed, map => map.NotNullable(true)); @@ -86,6 +84,12 @@ namespace Tanshu.Accounts.Entities map.NotNullable(true); map.Cascade(Cascade.None); }); + ManyToOne(x => x.Table, map => + { + map.Column("TableID"); + map.NotNullable(true); + map.Cascade(Cascade.None); + }); ManyToOne(x => x.Waiter, map => { diff --git a/Tanshu.Accounts.Contracts/Attributes/DisplayAttribute.cs b/Tanshu.Accounts.Contracts/DisplayAttribute.cs similarity index 100% rename from Tanshu.Accounts.Contracts/Attributes/DisplayAttribute.cs rename to Tanshu.Accounts.Contracts/DisplayAttribute.cs diff --git a/Tanshu.Accounts.Contracts/RolesConstants.cs b/Tanshu.Accounts.Contracts/RolesConstants.cs deleted file mode 100644 index eb9355a..0000000 --- a/Tanshu.Accounts.Contracts/RolesConstants.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tanshu.Accounts.Contracts -{ - public sealed class RoleConstants - { - private readonly string role; - private RoleConstants(string role) - { - this.role = role; - } - public override string ToString() - { - return role; - } - public string Role - { - get { return role; } - } - public static RoleConstants ADJUST_ADVANCE = new RoleConstants("Sales/AdjustAdvance"); - public static RoleConstants RECEIVE_ADVANCE = new RoleConstants("Sales/ReceiveAdvance"); - public static RoleConstants CHANGE_RATE = new RoleConstants("Sales/ChangeRate"); - public static RoleConstants CASHIER_CHECKOUT = new RoleConstants("Sales/CashierCheckout"); - public static RoleConstants CUSTOMERS = new RoleConstants("Sales/Customers"); - public static RoleConstants DISCOUNT = new RoleConstants("Sales/Discount"); - public static RoleConstants EDIT_PRINTED_BILL = new RoleConstants("Sales/EditBill"); - public static RoleConstants EDIT_PRINTED_PRODUCT = new RoleConstants("Sales/EditPrintedProduct"); - public static RoleConstants MERGE_TABLE = new RoleConstants("Sales/MergeTable"); - public static RoleConstants MOVE_TABLE = new RoleConstants("Sales/MoveTable"); - public static RoleConstants MERGE_KOT = new RoleConstants("Sales/MergeKot"); - public static RoleConstants MOVE_KOT = new RoleConstants("Sales/MoveKot"); - public static RoleConstants OPEN_BILL = new RoleConstants("Sales/OpenBill"); - public static RoleConstants PRINT_BILL = new RoleConstants("Sales/PrintBill"); - 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"); - public static RoleConstants ZERO_RATE = new RoleConstants("Sales/ZeroRate"); - public static RoleConstants SETTLE_BILL = new RoleConstants("Sales/SettleBill"); - - public static RoleConstants PRODUCTS = new RoleConstants("Master/Products"); - - public static RoleConstants SECURITY_MANAGE_USERS = new RoleConstants("Security/ManageUsers"); - public static RoleConstants SECURITY_MANAGE_ROLES = new RoleConstants("Security/ManageRoles"); - public static RoleConstants LOG_VIEW = new RoleConstants("Log/View"); - public static RoleConstants MASTER_OWNER = new RoleConstants("Master/Owner"); - - } -} diff --git a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj index f748b6b..10ac661 100644 --- a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj +++ b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj @@ -65,15 +65,7 @@ - - - - - - - - - + Code @@ -100,7 +92,6 @@ - @@ -110,7 +101,6 @@ - diff --git a/Tanshu.Accounts.Helpers/ControlFactory.cs b/Tanshu.Accounts.Helpers/ControlFactory.cs index 0e5becd..30911c9 100644 --- a/Tanshu.Accounts.Helpers/ControlFactory.cs +++ b/Tanshu.Accounts.Helpers/ControlFactory.cs @@ -77,6 +77,8 @@ namespace Tanshu.Accounts.Helpers control = GetButton(string.Format("p{0}", i), item.Units == string.Empty ? item.Name : string.Format("{0} ({1})", item.Name, item.Units), size, item, bcDelegate); if (item.Price == 0) control.BackColor = Color.Yellow; + if (item.IsNotAvailable) + control.BackColor = Color.Red; } panel.Controls.Add(control); } @@ -150,17 +152,22 @@ namespace Tanshu.Accounts.Helpers panel.Controls.Clear(); var marginWidth = panel.Margin.Right + panel.Margin.Left; var marginHeight = panel.Margin.Top + panel.Margin.Bottom; - pageLength = (panel.ClientSize.Height / (marginHeight + size.Y)); - pageLength *= (panel.ClientSize.Width / (marginWidth + size.X)); - pageLength -= 2; + pageLength = panel.ClientSize.Height / (marginHeight + size.Y); + pageLength *= panel.ClientSize.Width / (marginWidth + size.X); if (inList.Count <= pageLength) + { start = 0; - if (start == 0) - pageLength += 1; - stop = start + pageLength; - if (stop > inList.Count) stop = inList.Count; - + } + else + { + pageLength -= 2; + if (start == 0) + pageLength += 1; + stop = start + pageLength; + if (stop > inList.Count) + stop = inList.Count; + } } private static Button GetButton(string name, string text, Point size, object tag, ButtonClickDelegate bcDelegate) { diff --git a/Tanshu.Accounts.Helpers/SelectBill.cs b/Tanshu.Accounts.Helpers/SelectBill.cs deleted file mode 100644 index 4474bde..0000000 --- a/Tanshu.Accounts.Helpers/SelectBill.cs +++ /dev/null @@ -1,73 +0,0 @@ -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.Data; - -namespace Tanshu.Accounts.Helpers -{ - public class SelectBill : Tanshu.Data.BaseSelector - { - public SelectBill(GetData getData, bool autoClose) - : base(getData, true, "List of Bills") - { - //grid.Columns["CustomerID"].Visible = false; - //grid.Columns["LedgerID"].Visible = false; - } - - protected override void FilterChanged(Dictionary filter) - { - //data = CustomerProxy.GetCustomers(filter["Universal"].Split(' ')).ToList(); - //bindingSource.DataSource = data; - } - protected override void UpdateDisplay(PendingBills item) - { - //if (item == null) - // DisplayLabel = ""; - //else - // DisplayLabel = string.Format("Chosen Customer is {0} with phone number {1}", item.Name, item.Phone); - } - protected override PendingBills HandleKeydown(object sender, ExtendedKeyEventArgs e) - { - e.Handled = false; - return null; - } - #region Designer Code - /// - /// 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.components = new System.ComponentModel.Container(); - } - - #endregion - #endregion - } -} diff --git a/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj b/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj index dfa14ae..27fe647 100644 --- a/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj +++ b/Tanshu.Accounts.Helpers/Tanshu.Accounts.Helpers.csproj @@ -70,9 +70,6 @@ Code - - Form - Form diff --git a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs index 1e6fe82..3feb308 100644 --- a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs +++ b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs @@ -109,7 +109,7 @@ namespace Tanshu.Accounts.PointOfSale } public void SetDiscount() { - if (!Session.IsAllowed(RoleConstants.DISCOUNT)) + if (!Session.IsAllowed("Discount")) throw new PermissionException("Not Allowed to give Discount"); using (var bi = new ProductGroupBI()) @@ -149,7 +149,7 @@ namespace Tanshu.Accounts.PointOfSale return; if (!prompt) quantity += item.Quantity; - if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT)) + if (quantity < 0 && !Session.IsAllowed("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) @@ -162,13 +162,13 @@ namespace Tanshu.Accounts.PointOfSale var item = CurrentProduct; if (item == null) throw new ValidationException("No Product Selected"); - if (!Session.IsAllowed(RoleConstants.CHANGE_RATE)) + if (!Session.IsAllowed("Change Rate")) throw new PermissionException("Rate Change not Allowed"); var rate = item.Price; if (!GetInput("Price", ref rate)) return; - if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE)) - throw new PermissionException("Zero Rate not Allowed"); + if (rate == 0 && !Session.IsAllowed("NC Product")) + throw new PermissionException("NC of Product is not Allowed"); foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.ProductID)) sub.Value.Price = rate; @@ -275,10 +275,6 @@ namespace Tanshu.Accounts.PointOfSale _saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount, _bill.Values.ToList()); } - private static bool Allowed(BillItemValue item, RoleConstants role) - { - return item != null && Session.IsAllowed(role); - } private static bool Allowed(BillItemValue item) { return item != null; @@ -323,7 +319,7 @@ namespace Tanshu.Accounts.PointOfSale return null; } - if (isPrinted && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL))) + if (isPrinted && (!Session.IsAllowed("Edit Printed Bill"))) return null; amount = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty).Sum(x => x.Value.GrossAmount); @@ -362,7 +358,7 @@ namespace Tanshu.Accounts.PointOfSale using (var frm = new PaxForm()) { frm.ShowDialog(); - _billInfo.TableID = tableName; + _billInfo.Table = table; _billInfo.Pax = frm.Pax; _saleForm.ShowInfo(_billInfo); } @@ -404,7 +400,7 @@ namespace Tanshu.Accounts.PointOfSale return; if (!_billInfo.Printed) return; - if (!Session.IsAllowed(RoleConstants.SETTLE_BILL)) + if (!Session.IsAllowed("Settle Bill")) return; IDictionary options; var amount = -1 * _billInfo.Kots.Sum(x => x.Inventories.Sum(y => y.Amount)); @@ -419,6 +415,7 @@ namespace Tanshu.Accounts.PointOfSale using (var bi = new VoucherSettlementBI()) { bi.SettleVoucher(Session.User, _billInfo.VoucherID, options); + bi.SaveChanges(); } ClearBill(); } @@ -428,7 +425,7 @@ namespace Tanshu.Accounts.PointOfSale { using (var bi = new FoodTableBI()) { - using (var frm = new MoveTableForm(bi.List(), allowMerge)) + using (var frm = new MoveTableForm(bi.List(x=>x.IsActive), allowMerge)) { frm.ShowDialog(); if (frm.Selection != null) @@ -449,7 +446,7 @@ namespace Tanshu.Accounts.PointOfSale var table = GetTableForMove(true); if (table == null) return; - if (table.Name == _billInfo.TableID) + if (table.FoodTableID == _billInfo.Table.FoodTableID) return; if (table.VoucherID != null) if (IsPrintedOrVoid(table.VoucherID.Value)) @@ -464,7 +461,7 @@ namespace Tanshu.Accounts.PointOfSale voucherID = MergeKot(kot, table); else if (table.VoucherID == null && kotCount == 1) //Move Table - voucherID = MoveTable(table.Name); + voucherID = MoveTable(table.FoodTableID); else if (table.VoucherID != null && kotCount == 1) //Merge Table voucherID = MergeTable(table); @@ -473,7 +470,7 @@ namespace Tanshu.Accounts.PointOfSale } internal void MoveTable() { - if (_billInfo.VoucherID == null) + if (_billInfo.VoucherID == Guid.Empty) return; var allowMerge = !IsPrintedOrVoid(_billInfo); @@ -481,28 +478,28 @@ namespace Tanshu.Accounts.PointOfSale var table = GetTableForMove(allowMerge); if (table == null) return; - if (table.Name == _billInfo.TableID) + if (table.FoodTableID == _billInfo.Table.FoodTableID) return; if (table.VoucherID.HasValue) if (IsPrintedOrVoid(table.VoucherID.Value)) return; - LoadBill(table.VoucherID.HasValue ? MergeTable(table) : MoveTable(table.Name)); + LoadBill(table.VoucherID.HasValue ? MergeTable(table) : MoveTable(table.FoodTableID)); } private Guid MoveKot(BillItemKey kot, FoodTable table) { - if (!Session.IsAllowed(RoleConstants.MOVE_KOT)) + if (!Session.IsAllowed("Move Kot to New Table")) return Guid.Empty; using (var bi = new VoucherBI()) { - var newVoucherID = bi.MoveKot(kot.KotID, table.Name); + var newVoucherID = bi.MoveKot(kot.KotID, table.FoodTableID); bi.SaveChanges(); return newVoucherID; } } private static Guid MergeKot(BillItemKey kot, FoodTable table) { - if (!Session.IsAllowed(RoleConstants.MERGE_KOT)) + if (!Session.IsAllowed("Merge Kots")) return Guid.Empty; using (var bi = new VoucherBI()) { @@ -511,20 +508,20 @@ namespace Tanshu.Accounts.PointOfSale return newVoucherID; } } - private Guid MoveTable(string tableName) + private Guid MoveTable(Guid tableID) { - if (!Session.IsAllowed(RoleConstants.MOVE_TABLE)) + if (!Session.IsAllowed("Move Table")) return Guid.Empty; using (var bi = new VoucherBI()) { - var newVoucherID = bi.Move(_billInfo.TableID, tableName); + var newVoucherID = bi.Move(_billInfo.Table.FoodTableID, tableID); bi.SaveChanges(); return newVoucherID; } } private Guid MergeTable(FoodTable table) { - if (!Session.IsAllowed(RoleConstants.MERGE_TABLE)) + if (!Session.IsAllowed("Merge Tables")) return Guid.Empty; using (var bi = new VoucherBI()) { @@ -539,7 +536,7 @@ namespace Tanshu.Accounts.PointOfSale public void SaveKot() { #region Check if Allowed - if (!Session.IsAllowed(RoleConstants.PRINT_KOT)) + if (!Session.IsAllowed("Print Kot")) return; if (_billInfo.VoucherID != Guid.Empty && IsPrintedOrVoid(_billInfo)) return; @@ -563,7 +560,7 @@ namespace Tanshu.Accounts.PointOfSale public void SaveBill() { #region Check if Allowed - if (!Session.IsAllowed(RoleConstants.PRINT_BILL)) + if (!Session.IsAllowed("Print Bill")) throw new PermissionException("Printing not allowed"); if (_bill.Count == 1) //new kot only return; @@ -625,7 +622,7 @@ namespace Tanshu.Accounts.PointOfSale if (_billInfo.VoucherID == Guid.Empty || isVoid) return; // must be existing non void bill - if (!Session.IsAllowed(RoleConstants.SPLIT_BILL)) + if (!Session.IsAllowed("Split Bill")) return; #endregion @@ -655,7 +652,7 @@ namespace Tanshu.Accounts.PointOfSale var voucherFirst = new Voucher(Session.User) { Customer = _billInfo.Customer, - TableID = table.Name, + Table = table, Waiter = _billInfo.Waiter, Printed = isPrinted, Void = false, @@ -672,7 +669,7 @@ namespace Tanshu.Accounts.PointOfSale var voucherSecond = new Voucher(Session.User) { Customer = _billInfo.Customer, - TableID = _billInfo.TableID, + Table = _billInfo.Table, Waiter = _billInfo.Waiter, Printed = isPrinted, Void = false, @@ -705,7 +702,7 @@ namespace Tanshu.Accounts.PointOfSale // return; if (_billInfo.Void) return; - if (!Session.IsAllowed(RoleConstants.VOID_BILL)) + if (!Session.IsAllowed("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; @@ -752,7 +749,7 @@ namespace Tanshu.Accounts.PointOfSale var newVoucher = new Voucher(Session.User) { Customer = _billInfo.Customer, - TableID = _billInfo.TableID, + Table = _billInfo.Table, Waiter = _billInfo.Waiter, Printed = true, Void = false, diff --git a/Tanshu.Accounts.PointOfSale/Controllers/BillDict.cs b/Tanshu.Accounts.PointOfSale/Controllers/BillDict.cs index d866bd5..3e993e3 100644 --- a/Tanshu.Accounts.PointOfSale/Controllers/BillDict.cs +++ b/Tanshu.Accounts.PointOfSale/Controllers/BillDict.cs @@ -7,7 +7,6 @@ namespace Tanshu.Accounts.PointOfSale public class BillDict : OrderedDictionary { public delegate void ItemChangedHandler(); - public event ItemChangedHandler ItemChanged; public void Load(Voucher voucher) { foreach (var kot in voucher.Kots) { diff --git a/Tanshu.Accounts.PointOfSale/MainForm.cs b/Tanshu.Accounts.PointOfSale/MainForm.cs index d64e294..e5d47c4 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.cs @@ -11,6 +11,7 @@ using Tanshu.Accounts.Repository; using Tanshu.Common; using Tanshu.Common.KeyboardControl; using NHibernate.Tool.hbm2ddl; +using System.Collections.Generic; namespace Tanshu.Accounts.PointOfSale { @@ -53,21 +54,21 @@ namespace Tanshu.Accounts.PointOfSale private void btnSale_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.SALES)) + if (Session.IsAllowed("Sales")) using (var frmSale = new SalesForm(new BillController(null, true))) frmSale.ShowDialog(); } private void btnProduct_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.PRODUCTS)) + if (Session.IsAllowed("Products")) using (var frm = new ProductListForm()) frm.ShowDialog(); } private void btnProductGroup_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.PRODUCTS)) + if (Session.IsAllowed("Products")) using (var frm = new ProductGroupListForm()) frm.ShowDialog(); } @@ -85,7 +86,7 @@ namespace Tanshu.Accounts.PointOfSale private void btnCreateUser_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES)) + if (Session.IsAllowed("Roles")) using (var bi = new UserBI()) { using (var form = new SelectUser(bi.GetFilteredUsers, true)) @@ -98,7 +99,7 @@ namespace Tanshu.Accounts.PointOfSale private void btnUserRoles_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES)) + if (Session.IsAllowed("Roles")) using (var frm = new AssignUserGroups()) frm.ShowDialog(); } @@ -111,21 +112,21 @@ namespace Tanshu.Accounts.PointOfSale private void btnCashierCheckout_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.CASHIER_CHECKOUT)) + if (Session.IsAllowed("Cashier Checkout")) using (var frm = new CashierCheckoutForm()) frm.ShowDialog(); } private void btnSaleAnalysis_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.SALE_ANALYSIS)) + if (Session.IsAllowed("Sales Analysis")) using (var frm = new frmSaleAnalysisForm()) frm.ShowDialog(); } private void btnSaleDetail_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.SALE_DETAIL)) + if (Session.IsAllowed("Sales Detail")) using (var frm = new FrmSaleDetail()) frm.ShowDialog(); } @@ -133,34 +134,36 @@ namespace Tanshu.Accounts.PointOfSale private void MainForm_Load(object sender, EventArgs e) { #if (DEBUG) - MessageBox.Show("This software does not print kots!!!","Debug Mode", MessageBoxButtons.OK , MessageBoxIcon.Exclamation); + MessageBox.Show("This software does not print kots!!!", "Debug Mode", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); #endif CheckRoles(); } private void CheckRoles() { - btnSale.Visible = Session.IsAllowed(RoleConstants.SALES); + btnSale.Visible = Session.IsAllowed("Sales"); - btnProduct.Visible = Session.IsAllowed(RoleConstants.PRODUCTS); - btnProductGroup.Visible = Session.IsAllowed(RoleConstants.PRODUCTS); + btnProduct.Visible = Session.IsAllowed("Products"); + btnProductGroup.Visible = Session.IsAllowed("Products"); + btnModifiers.Visible = Session.IsAllowed("Modifiers"); + btnReorderTables.Visible = Session.IsAllowed("Tables"); - btnOpenBill.Visible = Session.IsAllowed(RoleConstants.OPEN_BILL); + btnOpenBill.Visible = Session.IsAllowed("Open Bill"); - btnCustomer.Visible = Session.IsAllowed(RoleConstants.CUSTOMERS); + btnCustomer.Visible = Session.IsAllowed("Customers"); - btnCreateUser.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_USERS); - btnUserRoles.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_USERS); + btnCreateUser.Visible = Session.IsAllowed("Users"); + btnUserRoles.Visible = Session.IsAllowed("Users"); - btnGroupRoles.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES); + btnGroupRoles.Visible = Session.IsAllowed("Roles"); - btnCashierCheckout.Visible = Session.IsAllowed(RoleConstants.CASHIER_CHECKOUT); - btnSaleAnalysis.Visible = Session.IsAllowed(RoleConstants.SALE_ANALYSIS); - btnSaleDetail.Visible = Session.IsAllowed(RoleConstants.SALE_DETAIL); + btnCashierCheckout.Visible = Session.IsAllowed("Cashier Checkout"); + btnSaleAnalysis.Visible = Session.IsAllowed("Sales Analysis"); + btnSaleDetail.Visible = Session.IsAllowed("Sales Detail"); - 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); + btnBillDetails.Visible = Session.IsAllowed("Bill Details"); + btnVoidOrReprints.Visible = Session.IsAllowed("Void or Reprinted Bill Report"); + btnDiscountReport.Visible = Session.IsAllowed("Discount Report"); btnChangePassword.Visible = Session.IsAuthenticated; #if (DEBUG) @@ -172,7 +175,7 @@ namespace Tanshu.Accounts.PointOfSale private void btnGroupRoles_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES)) + if (Session.IsAllowed("Roles")) using (var frm = new AssignGroupRoles()) frm.ShowDialog(); } @@ -218,7 +221,7 @@ namespace Tanshu.Accounts.PointOfSale private void btnOpenBill_Click(object sender, EventArgs e) { - if (!Session.IsAllowed(RoleConstants.OPEN_BILL)) + if (!Session.IsAllowed("Open Bill")) return; var result = InputBox.Show("Bill Number", "0", InputBox_Validating); if (!result.OK) @@ -226,7 +229,7 @@ namespace Tanshu.Accounts.PointOfSale Voucher voucher; using (var bi = new VoucherBI()) voucher = bi.Get(x => x.BillID == result.Text); - if (Session.IsAllowed(RoleConstants.SALES)) + if (Session.IsAllowed("Sales")) using (var frmSale = new SalesForm(new BillController(voucher.VoucherID, true))) frmSale.ShowDialog(); } @@ -240,29 +243,49 @@ namespace Tanshu.Accounts.PointOfSale private void btnBillDetails_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.BILL_DETAILS)) + if (Session.IsAllowed("Bill Details")) using (var frm = new BillDetailsForm()) frm.ShowDialog(); } private void btnVoidOrReprints_Click(object sender, EventArgs e) { - if (Session.IsAllowed(RoleConstants.VOID_OR_REPRINTED_BILL_REPORT)) + if (Session.IsAllowed("Void or Reprinted Bill Report")) using (var frm = new VoidReprintedForm()) frm.ShowDialog(); } private void btnDiscountReport_Click(object sender, EventArgs e) { - using (var frm = new DiscountReportForm()) - frm.ShowDialog(); + if (Session.IsAllowed("Discount Report")) + using (var frm = new DiscountReportForm()) + frm.ShowDialog(); } private void btnManagement_Click(object sender, EventArgs e) { - using (var frm = new ManagementForm()) - frm.ShowDialog(); + if (Session.IsAllowed("Owner")) + using (var frm = new ManagementForm()) + frm.ShowDialog(); + } + + private void btnReorderTables_Click(object sender, EventArgs e) + { + if (Session.IsAllowed("Tables")) + using (var frm = new ReorderTableForm()) + { + frm.ShowDialog(); + } + } + + private void btnModifiers_Click(object sender, EventArgs e) + { + if (Session.IsAllowed("Modifiers")) + using (var frm = new ModifierListForm()) + { + 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 6a72425..fad3219 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs @@ -48,6 +48,8 @@ this.btnChangePassword = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button(); this.btnManagement = new System.Windows.Forms.Button(); + this.btnReorderTables = new System.Windows.Forms.Button(); + this.btnModifiers = new System.Windows.Forms.Button(); this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -79,6 +81,8 @@ this.flowLayoutPanel1.Controls.Add(this.btnCustomer); this.flowLayoutPanel1.Controls.Add(this.btnProduct); this.flowLayoutPanel1.Controls.Add(this.btnProductGroup); + this.flowLayoutPanel1.Controls.Add(this.btnReorderTables); + this.flowLayoutPanel1.Controls.Add(this.btnModifiers); this.flowLayoutPanel1.Controls.Add(this.btnOpenBill); this.flowLayoutPanel1.Controls.Add(this.btnCreateUser); this.flowLayoutPanel1.Controls.Add(this.btnUserRoles); @@ -140,7 +144,7 @@ // // btnOpenBill // - this.btnOpenBill.Location = new System.Drawing.Point(159, 109); + this.btnOpenBill.Location = new System.Drawing.Point(471, 109); this.btnOpenBill.Name = "btnOpenBill"; this.btnOpenBill.Size = new System.Drawing.Size(150, 100); this.btnOpenBill.TabIndex = 7; @@ -150,7 +154,7 @@ // // btnCreateUser // - this.btnCreateUser.Location = new System.Drawing.Point(315, 109); + 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; @@ -160,7 +164,7 @@ // // btnUserRoles // - this.btnUserRoles.Location = new System.Drawing.Point(471, 109); + 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; @@ -170,7 +174,7 @@ // // btnGroupRoles // - this.btnGroupRoles.Location = new System.Drawing.Point(627, 109); + 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; @@ -180,7 +184,7 @@ // // btnCashierCheckout // - this.btnCashierCheckout.Location = new System.Drawing.Point(3, 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; @@ -190,7 +194,7 @@ // // btnSaleAnalysis // - this.btnSaleAnalysis.Location = new System.Drawing.Point(159, 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; @@ -200,7 +204,7 @@ // // btnSaleDetail // - this.btnSaleDetail.Location = new System.Drawing.Point(315, 215); + 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; @@ -210,7 +214,7 @@ // // btnBillDetails // - this.btnBillDetails.Location = new System.Drawing.Point(471, 215); + 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; @@ -220,7 +224,7 @@ // // btnVoidOrReprints // - this.btnVoidOrReprints.Location = new System.Drawing.Point(627, 215); + 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; @@ -230,7 +234,7 @@ // // btnDiscountReport // - this.btnDiscountReport.Location = new System.Drawing.Point(3, 321); + 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; @@ -240,7 +244,7 @@ // // btnChangePassword // - this.btnChangePassword.Location = new System.Drawing.Point(159, 321); + this.btnChangePassword.Location = new System.Drawing.Point(471, 321); this.btnChangePassword.Name = "btnChangePassword"; this.btnChangePassword.Size = new System.Drawing.Size(150, 100); this.btnChangePassword.TabIndex = 17; @@ -250,7 +254,7 @@ // // btnExit // - this.btnExit.Location = new System.Drawing.Point(315, 321); + this.btnExit.Location = new System.Drawing.Point(627, 321); this.btnExit.Name = "btnExit"; this.btnExit.Size = new System.Drawing.Size(150, 100); this.btnExit.TabIndex = 18; @@ -260,7 +264,7 @@ // // btnManagement // - this.btnManagement.Location = new System.Drawing.Point(471, 321); + 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; @@ -268,6 +272,26 @@ this.btnManagement.UseVisualStyleBackColor = true; this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click); // + // btnReorderTables + // + this.btnReorderTables.Location = new System.Drawing.Point(159, 109); + this.btnReorderTables.Name = "btnReorderTables"; + this.btnReorderTables.Size = new System.Drawing.Size(150, 100); + this.btnReorderTables.TabIndex = 22; + this.btnReorderTables.Text = "Reorder Tables"; + this.btnReorderTables.UseVisualStyleBackColor = true; + this.btnReorderTables.Click += new System.EventHandler(this.btnReorderTables_Click); + // + // btnModifiers + // + this.btnModifiers.Location = new System.Drawing.Point(315, 109); + this.btnModifiers.Name = "btnModifiers"; + this.btnModifiers.Size = new System.Drawing.Size(150, 100); + this.btnModifiers.TabIndex = 23; + this.btnModifiers.Text = "Product Modifiers"; + this.btnModifiers.UseVisualStyleBackColor = true; + this.btnModifiers.Click += new System.EventHandler(this.btnModifiers_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -307,5 +331,7 @@ private System.Windows.Forms.Button btnVoidOrReprints; private System.Windows.Forms.Button btnManagement; private System.Windows.Forms.Button btnDiscountReport; + private System.Windows.Forms.Button btnReorderTables; + private System.Windows.Forms.Button btnModifiers; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.Designer.cs new file mode 100644 index 0000000..f96746a --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.Designer.cs @@ -0,0 +1,385 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class FoodTableForm + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.Label4 = new System.Windows.Forms.Label(); + this.bsProductGroups = new System.Windows.Forms.BindingSource(this.components); + this.Label7 = new System.Windows.Forms.Label(); + this.bsServiceTax = new System.Windows.Forms.BindingSource(this.components); + this.label5 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.txtProductID = new System.Windows.Forms.TextBox(); + this.txtCode = new System.Windows.Forms.TextBox(); + this.Label2 = new System.Windows.Forms.Label(); + this.txtUnits = new System.Windows.Forms.TextBox(); + this.txtName = new System.Windows.Forms.TextBox(); + this.txtPrice = new System.Windows.Forms.TextBox(); + this.cmbVat = new System.Windows.Forms.ComboBox(); + this.chkDiscontinued = new System.Windows.Forms.CheckBox(); + this.txtServiceCharge = new System.Windows.Forms.TextBox(); + this.btnAddProductGroup = new System.Windows.Forms.Button(); + this.cmbProductGroup = new System.Windows.Forms.ComboBox(); + this.btnCancel = new System.Windows.Forms.Button(); + 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(); + this.cmbServiceTax = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.chkIsScTaxable = new System.Windows.Forms.CheckBox(); + this.bsVat = new System.Windows.Forms.BindingSource(this.components); + ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsVat)).BeginInit(); + this.SuspendLayout(); + // + // Label4 + // + this.Label4.AutoSize = true; + this.Label4.Location = new System.Drawing.Point(25, 82); + this.Label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.Label4.Name = "Label4"; + this.Label4.Size = new System.Drawing.Size(110, 17); + this.Label4.TabIndex = 15; + this.Label4.Text = "Price / Full Price"; + // + // bsProductGroups + // + this.bsProductGroups.DataSource = typeof(Tanshu.Accounts.Entities.ProductGroup); + // + // Label7 + // + this.Label7.AutoSize = true; + this.Label7.Location = new System.Drawing.Point(93, 174); + this.Label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.Label7.Name = "Label7"; + this.Label7.Size = new System.Drawing.Size(48, 17); + this.Label7.TabIndex = 17; + this.Label7.Text = "Group"; + // + // bsServiceTax + // + this.bsServiceTax.DataSource = typeof(Tanshu.Accounts.Entities.Tax); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(35, 142); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(105, 17); + this.label5.TabIndex = 16; + this.label5.Text = "Service Charge"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(16, 18); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(119, 17); + this.label3.TabIndex = 13; + this.label3.Text = "Product ID / Code"; + // + // txtProductID + // + this.txtProductID.Location = new System.Drawing.Point(149, 15); + this.txtProductID.Margin = new System.Windows.Forms.Padding(4); + this.txtProductID.Name = "txtProductID"; + this.txtProductID.ReadOnly = true; + this.txtProductID.Size = new System.Drawing.Size(251, 22); + this.txtProductID.TabIndex = 12; + // + // txtCode + // + this.txtCode.AccessibleName = ""; + this.txtCode.Location = new System.Drawing.Point(409, 15); + this.txtCode.Margin = new System.Windows.Forms.Padding(4); + this.txtCode.Name = "txtCode"; + this.txtCode.Size = new System.Drawing.Size(127, 22); + this.txtCode.TabIndex = 0; + this.txtCode.WordWrap = false; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(48, 50); + this.Label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(89, 17); + this.Label2.TabIndex = 14; + this.Label2.Text = "Name / Units"; + // + // txtUnits + // + this.txtUnits.AccessibleName = ""; + this.txtUnits.Location = new System.Drawing.Point(409, 47); + this.txtUnits.Margin = new System.Windows.Forms.Padding(4); + this.txtUnits.Name = "txtUnits"; + this.txtUnits.Size = new System.Drawing.Size(127, 22); + this.txtUnits.TabIndex = 2; + // + // txtName + // + this.txtName.AccessibleName = ""; + this.txtName.Location = new System.Drawing.Point(149, 47); + this.txtName.Margin = new System.Windows.Forms.Padding(4); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(251, 22); + this.txtName.TabIndex = 1; + // + // txtPrice + // + this.txtPrice.AccessibleName = ""; + this.txtPrice.Location = new System.Drawing.Point(149, 79); + this.txtPrice.Margin = new System.Windows.Forms.Padding(4); + this.txtPrice.Name = "txtPrice"; + this.txtPrice.Size = new System.Drawing.Size(111, 22); + this.txtPrice.TabIndex = 3; + this.txtPrice.Text = "0"; + // + // cmbVat + // + this.cmbVat.DataSource = this.bsVat; + this.cmbVat.DisplayMember = "Name"; + this.cmbVat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbVat.Location = new System.Drawing.Point(284, 107); + this.cmbVat.Margin = new System.Windows.Forms.Padding(4); + this.cmbVat.Name = "cmbVat"; + this.cmbVat.Size = new System.Drawing.Size(116, 24); + this.cmbVat.TabIndex = 4; + this.cmbVat.ValueMember = "TaxID"; + // + // chkDiscontinued + // + this.chkDiscontinued.AutoSize = true; + this.chkDiscontinued.Location = new System.Drawing.Point(409, 141); + this.chkDiscontinued.Margin = new System.Windows.Forms.Padding(4); + this.chkDiscontinued.Name = "chkDiscontinued"; + this.chkDiscontinued.Size = new System.Drawing.Size(112, 21); + this.chkDiscontinued.TabIndex = 7; + this.chkDiscontinued.Text = "Discontinued"; + this.chkDiscontinued.UseVisualStyleBackColor = true; + // + // txtServiceCharge + // + this.txtServiceCharge.AccessibleName = "Phone 1"; + this.txtServiceCharge.Location = new System.Drawing.Point(149, 139); + this.txtServiceCharge.Margin = new System.Windows.Forms.Padding(4); + this.txtServiceCharge.Name = "txtServiceCharge"; + this.txtServiceCharge.Size = new System.Drawing.Size(96, 22); + this.txtServiceCharge.TabIndex = 5; + this.txtServiceCharge.Text = "0"; + // + // btnAddProductGroup + // + this.btnAddProductGroup.Location = new System.Drawing.Point(409, 171); + this.btnAddProductGroup.Margin = new System.Windows.Forms.Padding(4); + this.btnAddProductGroup.Name = "btnAddProductGroup"; + this.btnAddProductGroup.Size = new System.Drawing.Size(128, 26); + this.btnAddProductGroup.TabIndex = 9; + this.btnAddProductGroup.Text = "Add Group"; + // + // cmbProductGroup + // + this.cmbProductGroup.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProductGroups, "ProductGroupID", true)); + this.cmbProductGroup.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProductGroups, "Name", true)); + this.cmbProductGroup.DataSource = this.bsProductGroups; + this.cmbProductGroup.DisplayMember = "Name"; + this.cmbProductGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbProductGroup.Location = new System.Drawing.Point(149, 171); + this.cmbProductGroup.Margin = new System.Windows.Forms.Padding(4); + this.cmbProductGroup.Name = "cmbProductGroup"; + this.cmbProductGroup.Size = new System.Drawing.Size(251, 24); + this.cmbProductGroup.TabIndex = 8; + this.cmbProductGroup.ValueMember = "ProductGroupID"; + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(437, 204); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(100, 92); + this.btnCancel.TabIndex = 11; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(329, 204); + this.btnOk.Margin = new System.Windows.Forms.Padding(4); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(100, 92); + this.btnOk.TabIndex = 10; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(261, 142); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(34, 17); + this.label1.TabIndex = 18; + this.label1.Text = "Sort"; + // + // txtSortOrder + // + this.txtSortOrder.AccessibleName = ""; + this.txtSortOrder.Location = new System.Drawing.Point(304, 139); + this.txtSortOrder.Margin = new System.Windows.Forms.Padding(4); + this.txtSortOrder.Name = "txtSortOrder"; + this.txtSortOrder.Size = new System.Drawing.Size(96, 22); + this.txtSortOrder.TabIndex = 6; + this.txtSortOrder.Text = "0"; + // + // txtFullPrice + // + this.txtFullPrice.AccessibleName = ""; + this.txtFullPrice.Location = new System.Drawing.Point(268, 79); + this.txtFullPrice.Margin = new System.Windows.Forms.Padding(4); + this.txtFullPrice.Name = "txtFullPrice"; + this.txtFullPrice.Size = new System.Drawing.Size(104, 22); + this.txtFullPrice.TabIndex = 19; + this.txtFullPrice.Text = "0"; + // + // cmbServiceTax + // + this.cmbServiceTax.DataSource = this.bsServiceTax; + this.cmbServiceTax.DisplayMember = "Name"; + this.cmbServiceTax.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbServiceTax.Location = new System.Drawing.Point(149, 107); + this.cmbServiceTax.Margin = new System.Windows.Forms.Padding(4); + this.cmbServiceTax.Name = "cmbServiceTax"; + this.cmbServiceTax.Size = new System.Drawing.Size(127, 24); + this.cmbServiceTax.TabIndex = 20; + this.cmbServiceTax.ValueMember = "TaxID"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(25, 110); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(115, 17); + this.label6.TabIndex = 21; + this.label6.Text = "Service Tax / Vat"; + // + // chkIsScTaxable + // + this.chkIsScTaxable.AutoSize = true; + this.chkIsScTaxable.Location = new System.Drawing.Point(409, 109); + this.chkIsScTaxable.Margin = new System.Windows.Forms.Padding(4); + this.chkIsScTaxable.Name = "chkIsScTaxable"; + this.chkIsScTaxable.Size = new System.Drawing.Size(114, 21); + this.chkIsScTaxable.TabIndex = 22; + this.chkIsScTaxable.Text = "Is Sc Taxable"; + this.chkIsScTaxable.UseVisualStyleBackColor = true; + // + // bsVat + // + this.bsVat.DataSource = typeof(Tanshu.Accounts.Entities.Tax); + // + // ProductForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(553, 340); + this.Controls.Add(this.chkIsScTaxable); + this.Controls.Add(this.label6); + this.Controls.Add(this.cmbServiceTax); + this.Controls.Add(this.txtFullPrice); + this.Controls.Add(this.txtSortOrder); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.btnAddProductGroup); + this.Controls.Add(this.cmbProductGroup); + this.Controls.Add(this.chkDiscontinued); + this.Controls.Add(this.txtServiceCharge); + this.Controls.Add(this.Label7); + this.Controls.Add(this.txtPrice); + this.Controls.Add(this.label5); + this.Controls.Add(this.cmbVat); + this.Controls.Add(this.txtUnits); + this.Controls.Add(this.txtName); + this.Controls.Add(this.Label2); + this.Controls.Add(this.txtCode); + this.Controls.Add(this.txtProductID); + this.Controls.Add(this.label3); + this.Controls.Add(this.Label4); + this.Margin = new System.Windows.Forms.Padding(4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProductForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Products"; + this.Load += new System.EventHandler(this.Products_Load); + ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsVat)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Label Label4; + internal System.Windows.Forms.Label Label7; + private System.Windows.Forms.BindingSource bsProductGroups; + private System.Windows.Forms.BindingSource bsServiceTax; + internal System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtProductID; + internal System.Windows.Forms.TextBox txtCode; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.TextBox txtUnits; + internal System.Windows.Forms.TextBox txtName; + internal System.Windows.Forms.TextBox txtPrice; + internal System.Windows.Forms.ComboBox cmbVat; + private System.Windows.Forms.CheckBox chkDiscontinued; + internal System.Windows.Forms.TextBox txtServiceCharge; + internal System.Windows.Forms.Button btnAddProductGroup; + internal System.Windows.Forms.ComboBox cmbProductGroup; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOk; + internal System.Windows.Forms.Label label1; + internal System.Windows.Forms.TextBox txtSortOrder; + internal System.Windows.Forms.TextBox txtFullPrice; + internal System.Windows.Forms.ComboBox cmbServiceTax; + internal System.Windows.Forms.Label label6; + private System.Windows.Forms.CheckBox chkIsScTaxable; + private System.Windows.Forms.BindingSource bsVat; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.cs b/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.cs new file mode 100644 index 0000000..4a0543d --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.cs @@ -0,0 +1,154 @@ +using System; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Entities; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class FoodTableForm : Form + { + private Guid? _productID; + public FoodTableForm(Guid? productID) + { + _productID = productID; + InitializeComponent(); + } + + private void Products_Load(object sender, EventArgs e) + { + FillCombos(); + if (_productID.HasValue) + { + Product product; + using (var bi = new ProductBI()) + product = bi.Get(x => x.ProductID == _productID.Value); + txtProductID.Text = _productID.Value.ToString(); + txtCode.Text = product.Code.ToString(); + txtName.Text = product.Name; + txtUnits.Text = product.Units; + txtPrice.Text = product.Price.ToString("#.##"); + txtFullPrice.Text = product.FullPrice.ToString("#.##"); + cmbVat.SelectedValue = product.Vat.TaxID; + cmbServiceTax.SelectedValue = product.ServiceTax.TaxID; + txtServiceCharge.Text = product.ServiceCharge.ToString("#.##"); + chkDiscontinued.Checked = product.Discontinued; + chkIsScTaxable.Checked = product.IsScTaxable; + cmbProductGroup.SelectedValue = product.ProductGroup.ProductGroupID; + txtSortOrder.Text = product.SortOrder.ToString(); + } + else + { + txtProductID.Text = "(Auto)"; + txtName.Focus(); + } + } + + private void FillCombos() + { + using (var bi = new ProductGroupBI()) + bsProductGroups.DataSource = bi.List(); + using (var bi = new TaxBI()) + { + bsServiceTax.DataSource = bi.List(); + bsVat.DataSource = bi.List(); + } + } + + private void btnAddCategory_Click(object sender, EventArgs e) + { + using (var frm = new ProductGroupListForm()) + frm.ShowDialog(); + FillCombos(); + cmbProductGroup.SelectedIndex = -1; + } + + private Product IsFormValid() + { + var product = new Product(); + + if (_productID.HasValue) + product.ProductID = _productID.Value; + + int code; + if (!int.TryParse(txtCode.Text, out code)) + return null; + if (code < 0) + return null; + product.Code = code; + + if (string.IsNullOrEmpty(txtName.Text.Trim())) + return null; + product.Name = txtName.Text.Trim(); + //if (string.IsNullOrEmpty(txtUnits.Text.Trim())) + // return null; + product.Units = txtUnits.Text.Trim(); + + decimal price; + if (!decimal.TryParse(txtPrice.Text, out price)) + return null; + if (price < 0) + return null; + 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 (cmbVat.SelectedItem == null) + return null; + product.Vat = (Tax)cmbVat.SelectedItem; + + if (cmbServiceTax.SelectedItem == null) + return null; + product.ServiceTax = (Tax)cmbServiceTax.SelectedItem; + + decimal serviceCharge; + if (!decimal.TryParse(txtServiceCharge.Text, out serviceCharge)) + return null; + if (serviceCharge < 0 || serviceCharge > 1) + return null; + product.ServiceCharge = serviceCharge; + + product.IsScTaxable = chkIsScTaxable.Checked; + product.Discontinued = chkDiscontinued.Checked; + int sortOrder; + if (!int.TryParse(txtSortOrder.Text, out sortOrder)) + return null; + product.SortOrder = sortOrder; + + //Group + if (cmbProductGroup.SelectedItem == null) + return null; + product.ProductGroup = (ProductGroup)cmbProductGroup.SelectedItem; + return product; + } + + private void btnOk_Click(object sender, EventArgs e) + { + var product = IsFormValid(); + if (product != null) + { + using (var bi = new ProductBI()) + { + if (_productID.HasValue) + bi.Update(product); + else + bi.Insert(product); + bi.SaveChanges(); + } + MessageBox.Show("Update / Save Successful"); + this.Close(); + } + else + MessageBox.Show("The form is not valid"); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.resx b/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.resx new file mode 100644 index 0000000..89bd3df --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/FoodTableForm.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 211, 17 + + + 56, 25 + + + 382, 17 + + + 102 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.Designer.cs new file mode 100644 index 0000000..c74b589 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.Designer.cs @@ -0,0 +1,268 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class FoodTableListForm + { + /// + /// 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.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnEdit = new System.Windows.Forms.Button(); + this.btnExit = new System.Windows.Forms.Button(); + this.dgvProducts = new System.Windows.Forms.DataGridView(); + this.bsList = new System.Windows.Forms.BindingSource(this.components); + this.btnSave = new System.Windows.Forms.Button(); + this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.unitsDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.moveUp = new System.Windows.Forms.DataGridViewButtonColumn(); + this.moveDown = new System.Windows.Forms.DataGridViewButtonColumn(); + this.Vat = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ServiceTax = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Group = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.serviceChargeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.salePriceDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.discontinuedDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit(); + this.SuspendLayout(); + // + // btnAdd + // + this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnAdd.Location = new System.Drawing.Point(12, 255); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(75, 75); + this.btnAdd.TabIndex = 68; + this.btnAdd.Text = "&Add"; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnEdit + // + this.btnEdit.AccessibleName = "Done"; + this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnEdit.Location = new System.Drawing.Point(93, 255); + this.btnEdit.Name = "btnEdit"; + this.btnEdit.Size = new System.Drawing.Size(75, 75); + this.btnEdit.TabIndex = 62; + this.btnEdit.Text = "&Edit"; + this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); + // + // btnExit + // + this.btnExit.AccessibleName = "Done"; + this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnExit.Location = new System.Drawing.Point(575, 255); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(75, 75); + this.btnExit.TabIndex = 61; + this.btnExit.Text = "E&xit"; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); + // + // dgvProducts + // + this.dgvProducts.AllowUserToAddRows = false; + this.dgvProducts.AllowUserToDeleteRows = false; + this.dgvProducts.AllowUserToResizeRows = false; + this.dgvProducts.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.dgvProducts.AutoGenerateColumns = false; + this.dgvProducts.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + this.dgvProducts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvProducts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.nameDataGridViewTextBoxColumn, + this.unitsDataGridViewTextBoxColumn, + this.moveUp, + this.moveDown, + this.Vat, + this.ServiceTax, + this.Group, + this.serviceChargeDataGridViewTextBoxColumn, + this.salePriceDataGridViewTextBoxColumn, + this.discontinuedDataGridViewCheckBoxColumn}); + this.dgvProducts.DataSource = this.bsList; + this.dgvProducts.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.dgvProducts.Location = new System.Drawing.Point(12, 12); + this.dgvProducts.MultiSelect = false; + this.dgvProducts.Name = "dgvProducts"; + this.dgvProducts.ReadOnly = true; + this.dgvProducts.RowHeadersVisible = false; + this.dgvProducts.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.dgvProducts.RowTemplate.Height = 24; + this.dgvProducts.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvProducts.Size = new System.Drawing.Size(638, 237); + this.dgvProducts.TabIndex = 74; + this.dgvProducts.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvProductTypes_CellFormatting); + // + // bsList + // + this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.Product); + // + // btnSave + // + this.btnSave.AccessibleName = "Done"; + this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnSave.Location = new System.Drawing.Point(174, 255); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(75, 75); + this.btnSave.TabIndex = 75; + this.btnSave.Text = "&Save"; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // nameDataGridViewTextBoxColumn + // + this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; + this.nameDataGridViewTextBoxColumn.HeaderText = "Name"; + this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; + this.nameDataGridViewTextBoxColumn.ReadOnly = true; + this.nameDataGridViewTextBoxColumn.Width = 60; + // + // unitsDataGridViewTextBoxColumn + // + this.unitsDataGridViewTextBoxColumn.DataPropertyName = "Units"; + this.unitsDataGridViewTextBoxColumn.HeaderText = "Units"; + this.unitsDataGridViewTextBoxColumn.Name = "unitsDataGridViewTextBoxColumn"; + this.unitsDataGridViewTextBoxColumn.ReadOnly = true; + this.unitsDataGridViewTextBoxColumn.Width = 56; + // + // moveUp + // + this.moveUp.HeaderText = "Up"; + this.moveUp.Name = "moveUp"; + this.moveUp.ReadOnly = true; + this.moveUp.Text = "Up"; + this.moveUp.UseColumnTextForButtonValue = true; + this.moveUp.Width = 27; + // + // moveDown + // + this.moveDown.HeaderText = "Down"; + this.moveDown.Name = "moveDown"; + this.moveDown.ReadOnly = true; + this.moveDown.Text = "Down"; + this.moveDown.UseColumnTextForButtonValue = true; + this.moveDown.Width = 41; + // + // Vat + // + this.Vat.DataPropertyName = "Vat"; + this.Vat.HeaderText = "Vat"; + this.Vat.Name = "Vat"; + this.Vat.ReadOnly = true; + this.Vat.Width = 48; + // + // ServiceTax + // + this.ServiceTax.DataPropertyName = "ServiceTax"; + this.ServiceTax.HeaderText = "ServiceTax"; + this.ServiceTax.Name = "ServiceTax"; + this.ServiceTax.ReadOnly = true; + this.ServiceTax.Width = 86; + // + // Group + // + this.Group.DataPropertyName = "ProductGroup"; + this.Group.HeaderText = "ProductGroup"; + this.Group.Name = "Group"; + this.Group.ReadOnly = true; + this.Group.Width = 98; + // + // serviceChargeDataGridViewTextBoxColumn + // + this.serviceChargeDataGridViewTextBoxColumn.DataPropertyName = "ServiceCharge"; + dataGridViewCellStyle1.Format = "P0"; + this.serviceChargeDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1; + this.serviceChargeDataGridViewTextBoxColumn.HeaderText = "SC"; + this.serviceChargeDataGridViewTextBoxColumn.Name = "serviceChargeDataGridViewTextBoxColumn"; + this.serviceChargeDataGridViewTextBoxColumn.ReadOnly = true; + this.serviceChargeDataGridViewTextBoxColumn.Width = 46; + // + // salePriceDataGridViewTextBoxColumn + // + this.salePriceDataGridViewTextBoxColumn.DataPropertyName = "Price"; + dataGridViewCellStyle2.Format = "N0"; + this.salePriceDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2; + this.salePriceDataGridViewTextBoxColumn.HeaderText = "Price"; + this.salePriceDataGridViewTextBoxColumn.Name = "salePriceDataGridViewTextBoxColumn"; + this.salePriceDataGridViewTextBoxColumn.ReadOnly = true; + this.salePriceDataGridViewTextBoxColumn.Width = 56; + // + // discontinuedDataGridViewCheckBoxColumn + // + this.discontinuedDataGridViewCheckBoxColumn.DataPropertyName = "Discontinued"; + this.discontinuedDataGridViewCheckBoxColumn.HeaderText = "Discontinued"; + this.discontinuedDataGridViewCheckBoxColumn.Name = "discontinuedDataGridViewCheckBoxColumn"; + this.discontinuedDataGridViewCheckBoxColumn.ReadOnly = true; + this.discontinuedDataGridViewCheckBoxColumn.Width = 75; + // + // ProductListForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(662, 342); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.dgvProducts); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.btnEdit); + this.Controls.Add(this.btnExit); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProductListForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Products"; + this.Load += new System.EventHandler(this.ProductGroupListForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Button btnAdd; + internal System.Windows.Forms.Button btnEdit; + internal System.Windows.Forms.Button btnExit; + private System.Windows.Forms.DataGridView dgvProducts; + private System.Windows.Forms.BindingSource bsList; + internal System.Windows.Forms.Button btnSave; + private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn unitsDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewButtonColumn moveUp; + private System.Windows.Forms.DataGridViewButtonColumn moveDown; + private System.Windows.Forms.DataGridViewTextBoxColumn Vat; + private System.Windows.Forms.DataGridViewTextBoxColumn ServiceTax; + private System.Windows.Forms.DataGridViewTextBoxColumn Group; + private System.Windows.Forms.DataGridViewTextBoxColumn serviceChargeDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn salePriceDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn discontinuedDataGridViewCheckBoxColumn; + //private System.Windows.Forms.DataGridViewTextBoxColumn discountLimitDataGridViewTextBoxColumn; + //private System.Windows.Forms.DataGridViewTextBoxColumn groupTypeDataGridViewTextBoxColumn; + //private System.Windows.Forms.DataGridViewTextBoxColumn productGroupDataGridViewTextBoxColumn; + //private System.Windows.Forms.DataGridViewTextBoxColumn taxDataGridViewTextBoxColumn; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.cs b/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.cs new file mode 100644 index 0000000..8070652 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.cs @@ -0,0 +1,114 @@ +using System; +using System.Windows.Forms; +using Tanshu.Accounts.Entities; +using Tanshu.Accounts.Repository; +using System.Collections.Generic; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class FoodTableListForm : Form + { + private IList _list; + public FoodTableListForm() + { + InitializeComponent(); + dgvProducts.CellClick += new DataGridViewCellEventHandler(dgvProducts_CellClick); + } + + private void btnAdd_Click(object sender, EventArgs e) + { + using (var frm = new ProductForm(null)) + frm.ShowDialog(); + using (var bi = new ProductBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void ProductGroupListForm_Load(object sender, EventArgs e) + { + using (var bi = new ProductBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void btnEdit_Click(object sender, EventArgs e) + { + var id = ((Product)bsList.Current).ProductID; + using (var frm = new ProductForm(id)) + frm.ShowDialog(); + using (var bi = new ProductBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void btnExit_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void dgvProductTypes_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + var data = dgvProducts.Rows[e.RowIndex].DataBoundItem as Product; + if (data == null) + return; + var tax = e.Value as Tax; + if (tax != null) + { + e.Value = string.Format("{1:P} - {0}", tax.Name, tax.Rate); ; + return; + } + var productGroup = e.Value as ProductGroup; + if (productGroup != null) + { + e.Value = productGroup.Name; + } + } + private void dgvProducts_CellClick(object sender, DataGridViewCellEventArgs e) + { + // Ignore clicks that are not on button cells. + if (e.RowIndex < 0) + return; + + // Ignore clicks that are not on button cells. + if (e.ColumnIndex == dgvProducts.Columns["moveUp"].Index) + { + var product = dgvProducts.Rows[e.RowIndex].DataBoundItem as Product; + var index = _list.IndexOf(product); + if (index == 0) + return; + var previousProduct = _list[index - 1]; + if (previousProduct.ProductGroup.ProductGroupID != product.ProductGroup.ProductGroupID) + return; + _list.RemoveAt(index); + _list.Insert(index -1, product); + bsList.DataSource = _list; + bsList.ResetBindings(false); + bsList.CurrencyManager.Position -= 1; + } + if (e.ColumnIndex == dgvProducts.Columns["moveDown"].Index) + { + var product = dgvProducts.Rows[e.RowIndex].DataBoundItem as Product; + var index = _list.IndexOf(product); + if (index == _list.Count + 1) + return; + var nextProduct = _list[index + 1]; + if (product.ProductGroup.ProductGroupID != nextProduct.ProductGroup.ProductGroupID) + return; + _list.RemoveAt(index); + _list.Insert(index + 1, product); + bsList.DataSource = _list; + bsList.ResetBindings(false); + bsList.CurrencyManager.Position += 1; + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + using (var bi = new ProductBI()) + { + bi.UpdateSortOrder(_list); + bi.SaveChanges(); + } + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.resx b/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.resx new file mode 100644 index 0000000..4537dcc --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/FoodTableListForm.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.Designer.cs new file mode 100644 index 0000000..abe9370 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.Designer.cs @@ -0,0 +1,165 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class ModifierEditForm + { + /// + /// 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.txtName = new System.Windows.Forms.TextBox(); + this.Label2 = new System.Windows.Forms.Label(); + this.txtPrice = new System.Windows.Forms.TextBox(); + this.Label5 = new System.Windows.Forms.Label(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.chkShowInBill = new System.Windows.Forms.CheckBox(); + this.chkShowForAll = new System.Windows.Forms.CheckBox(); + this.clbGroups = new System.Windows.Forms.CheckedListBox(); + this.SuspendLayout(); + // + // txtName + // + this.txtName.AccessibleName = ""; + this.txtName.Location = new System.Drawing.Point(94, 12); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(276, 20); + this.txtName.TabIndex = 0; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(53, 15); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(35, 13); + this.Label2.TabIndex = 10; + this.Label2.Text = "Name"; + // + // txtPrice + // + this.txtPrice.AccessibleName = "Phone 1"; + this.txtPrice.Location = new System.Drawing.Point(94, 64); + this.txtPrice.Name = "txtPrice"; + this.txtPrice.Size = new System.Drawing.Size(65, 20); + this.txtPrice.TabIndex = 1; + this.txtPrice.Text = "0"; + this.txtPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // Label5 + // + this.Label5.AutoSize = true; + this.Label5.Location = new System.Drawing.Point(57, 67); + this.Label5.Name = "Label5"; + this.Label5.Size = new System.Drawing.Size(31, 13); + this.Label5.TabIndex = 11; + this.Label5.Text = "Price"; + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(214, 317); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 75); + this.btnOk.TabIndex = 6; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(295, 317); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 75); + this.btnCancel.TabIndex = 7; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // chkShowInBill + // + this.chkShowInBill.AutoSize = true; + this.chkShowInBill.Location = new System.Drawing.Point(94, 38); + this.chkShowInBill.Name = "chkShowInBill"; + this.chkShowInBill.Size = new System.Drawing.Size(81, 17); + this.chkShowInBill.TabIndex = 4; + this.chkShowInBill.Text = "Show In Bill"; + this.chkShowInBill.UseVisualStyleBackColor = true; + // + // chkShowForAll + // + this.chkShowForAll.AutoSize = true; + this.chkShowForAll.Location = new System.Drawing.Point(94, 90); + this.chkShowForAll.Name = "chkShowForAll"; + this.chkShowForAll.Size = new System.Drawing.Size(119, 17); + this.chkShowForAll.TabIndex = 3; + this.chkShowForAll.Text = "Show for All Groups"; + this.chkShowForAll.UseVisualStyleBackColor = true; + this.chkShowForAll.CheckedChanged += new System.EventHandler(this.chkShowForAll_CheckedChanged); + // + // clbGroups + // + this.clbGroups.FormattingEnabled = true; + this.clbGroups.Location = new System.Drawing.Point(94, 113); + this.clbGroups.Name = "clbGroups"; + this.clbGroups.Size = new System.Drawing.Size(276, 184); + this.clbGroups.TabIndex = 20; + this.clbGroups.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbGroups_Format); + // + // ModifierEditForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(382, 404); + this.Controls.Add(this.clbGroups); + this.Controls.Add(this.chkShowInBill); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.chkShowForAll); + this.Controls.Add(this.txtPrice); + this.Controls.Add(this.Label5); + this.Controls.Add(this.txtName); + this.Controls.Add(this.Label2); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ModifierEditForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Product Types"; + this.Load += new System.EventHandler(this.ModifierEditForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.TextBox txtName; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.TextBox txtPrice; + internal System.Windows.Forms.Label Label5; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.CheckBox chkShowInBill; + private System.Windows.Forms.CheckBox chkShowForAll; + private System.Windows.Forms.CheckedListBox clbGroups; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.cs b/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.cs new file mode 100644 index 0000000..6a40384 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.cs @@ -0,0 +1,111 @@ +using System; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Entities; +using System.Linq; +using System.Collections.Generic; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class ModifierEditForm : Form + { + private Guid? _modifierID; + public ModifierEditForm(Guid modifierID) + : this() + { + _modifierID = modifierID; + } + + public ModifierEditForm() + { + InitializeComponent(); + } + + private void ModifierEditForm_Load(object sender, EventArgs e) + { + Modifier modifier; + using (var bi = new ModifierBI()) + { + var groups = bi.ProductGroupList(); + clbGroups.DataSource = groups; + if (_modifierID.HasValue) + { + + modifier = bi.Get(x => x.ModifierID == _modifierID.Value); + + txtName.Text = modifier.Name; + chkShowInBill.Checked = modifier.ShowInBill; + txtPrice.Text = modifier.Price.ToString(); + if (modifier.ProductGroupModifiers.Any(x => x.ProductGroup == null)) + { + chkShowForAll.Checked = true; + clbGroups.Hide(); + } + else + { + chkShowForAll.Checked = false; + } + for (int i = 0; i < clbGroups.Items.Count; i++) + { + var item = (ProductGroup)clbGroups.Items[i]; + if (item.ProductGroupModifiers.Any(x => x.Modifier == modifier)) + { + clbGroups.SetItemChecked(i, true); + } + } + } + else + { + txtName.Focus(); + } + } + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnOk_Click(object sender, EventArgs e) + { + Modifier modifier; + using (var bi = new ModifierBI()) + { + if (_modifierID.HasValue) + modifier = bi.Get(x => x.ModifierID == _modifierID.Value); + else + modifier = new Modifier(); + + if (string.IsNullOrEmpty(txtName.Text.Trim())) + return; + modifier.Name = txtName.Text.Trim(); + decimal price; + if (!decimal.TryParse(txtPrice.Text, out price)) + return; + if (price < 0) + return; + modifier.Price = price; + modifier.ShowInBill = chkShowInBill.Checked; + if (_modifierID.HasValue) + bi.Update(modifier, chkShowForAll.Checked, clbGroups.CheckedItems.OfType()); + else + bi.Insert(modifier, chkShowForAll.Checked, clbGroups.CheckedItems.OfType()); + bi.SaveChanges(); + } + MessageBox.Show("Update / Save Successful"); + this.Close(); + } + private void clbGroups_Format(object sender, ListControlConvertEventArgs e) + { + e.Value = ((ProductGroup)e.ListItem).Name; + } + + private void chkShowForAll_CheckedChanged(object sender, EventArgs e) + { + if (chkShowForAll.Checked) + clbGroups.Hide(); + else + clbGroups.Show(); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.resx b/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ModifierEditForm.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/Products/ModifierListForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.Designer.cs new file mode 100644 index 0000000..a752e77 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.Designer.cs @@ -0,0 +1,201 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class ModifierListForm + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnEdit = new System.Windows.Forms.Button(); + this.btnExit = new System.Windows.Forms.Button(); + this.dgvProductGroups = new System.Windows.Forms.DataGridView(); + this.bsList = new System.Windows.Forms.BindingSource(this.components); + this.btnSave = new System.Windows.Forms.Button(); + this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ShowInBill = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.moveUp = new System.Windows.Forms.DataGridViewButtonColumn(); + this.moveDown = new System.Windows.Forms.DataGridViewButtonColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvProductGroups)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit(); + this.SuspendLayout(); + // + // btnAdd + // + this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnAdd.Location = new System.Drawing.Point(12, 255); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(75, 75); + this.btnAdd.TabIndex = 68; + this.btnAdd.Text = "&Add"; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnEdit + // + this.btnEdit.AccessibleName = "Done"; + this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnEdit.Location = new System.Drawing.Point(93, 255); + this.btnEdit.Name = "btnEdit"; + this.btnEdit.Size = new System.Drawing.Size(75, 75); + this.btnEdit.TabIndex = 62; + this.btnEdit.Text = "&Edit"; + this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); + // + // btnExit + // + this.btnExit.AccessibleName = "Done"; + this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnExit.Location = new System.Drawing.Point(514, 255); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(75, 75); + this.btnExit.TabIndex = 61; + this.btnExit.Text = "E&xit"; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); + // + // dgvProductGroups + // + this.dgvProductGroups.AllowUserToAddRows = false; + this.dgvProductGroups.AllowUserToDeleteRows = false; + this.dgvProductGroups.AllowUserToResizeRows = false; + this.dgvProductGroups.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.dgvProductGroups.AutoGenerateColumns = false; + this.dgvProductGroups.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + this.dgvProductGroups.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvProductGroups.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.nameDataGridViewTextBoxColumn, + this.ShowInBill, + this.Price, + this.moveUp, + this.moveDown}); + this.dgvProductGroups.DataSource = this.bsList; + this.dgvProductGroups.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.dgvProductGroups.Location = new System.Drawing.Point(12, 12); + this.dgvProductGroups.MultiSelect = false; + this.dgvProductGroups.Name = "dgvProductGroups"; + this.dgvProductGroups.ReadOnly = true; + this.dgvProductGroups.RowHeadersVisible = false; + this.dgvProductGroups.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.dgvProductGroups.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvProductGroups.Size = new System.Drawing.Size(577, 237); + this.dgvProductGroups.TabIndex = 74; + // + // bsList + // + this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.Modifier); + // + // btnSave + // + this.btnSave.AccessibleName = "Done"; + this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnSave.Location = new System.Drawing.Point(174, 255); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(75, 75); + this.btnSave.TabIndex = 75; + this.btnSave.Text = "&Save"; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // nameDataGridViewTextBoxColumn + // + this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; + this.nameDataGridViewTextBoxColumn.HeaderText = "Name"; + this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; + this.nameDataGridViewTextBoxColumn.ReadOnly = true; + this.nameDataGridViewTextBoxColumn.Width = 60; + // + // ShowInBill + // + this.ShowInBill.DataPropertyName = "ShowInBill"; + this.ShowInBill.HeaderText = "ShowInBill"; + this.ShowInBill.Name = "ShowInBill"; + this.ShowInBill.ReadOnly = true; + this.ShowInBill.Width = 62; + // + // Price + // + this.Price.DataPropertyName = "Price"; + this.Price.HeaderText = "Price"; + this.Price.Name = "Price"; + this.Price.ReadOnly = true; + this.Price.Width = 56; + // + // moveUp + // + this.moveUp.HeaderText = "Up"; + this.moveUp.Name = "moveUp"; + this.moveUp.ReadOnly = true; + this.moveUp.Text = "Up"; + this.moveUp.UseColumnTextForButtonValue = true; + this.moveUp.Width = 27; + // + // moveDown + // + this.moveDown.HeaderText = "Down"; + this.moveDown.Name = "moveDown"; + this.moveDown.ReadOnly = true; + this.moveDown.Text = "Down"; + this.moveDown.UseColumnTextForButtonValue = true; + this.moveDown.Width = 41; + // + // ModifierListForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(601, 342); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.dgvProductGroups); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.btnEdit); + this.Controls.Add(this.btnExit); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ModifierListForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Product Types"; + this.Load += new System.EventHandler(this.ProductGroupListForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvProductGroups)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Button btnAdd; + internal System.Windows.Forms.Button btnEdit; + internal System.Windows.Forms.Button btnExit; + private System.Windows.Forms.DataGridView dgvProductGroups; + private System.Windows.Forms.BindingSource bsList; + internal System.Windows.Forms.Button btnSave; + private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn ShowInBill; + private System.Windows.Forms.DataGridViewTextBoxColumn Price; + private System.Windows.Forms.DataGridViewButtonColumn moveUp; + private System.Windows.Forms.DataGridViewButtonColumn moveDown; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.cs b/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.cs new file mode 100644 index 0000000..9cfa29a --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.cs @@ -0,0 +1,100 @@ +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.Repository; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class ModifierListForm : Form + { + private IList _list; + public ModifierListForm() + { + InitializeComponent(); + dgvProductGroups.CellClick += new DataGridViewCellEventHandler(dgvProductGroups_CellClick); + } + + private void btnAdd_Click(object sender, EventArgs e) + { + using (var frm = new ModifierEditForm()) + frm.ShowDialog(); + using (var bi = new ModifierBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void ProductGroupListForm_Load(object sender, EventArgs e) + { + using (var bi = new ModifierBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void btnEdit_Click(object sender, EventArgs e) + { + var id = ((Modifier)bsList.Current).ModifierID; + using (var frm = new ModifierEditForm(id)) + frm.ShowDialog(); + using (var bi = new ModifierBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void btnExit_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void dgvProductGroups_CellClick(object sender, DataGridViewCellEventArgs e) + { + // Ignore clicks that are not on button cells. + if (e.RowIndex < 0) + return; + + // Ignore clicks that are not on button cells. + if (e.ColumnIndex == dgvProductGroups.Columns["moveUp"].Index) + { + var modifier = dgvProductGroups.Rows[e.RowIndex].DataBoundItem as Modifier; + var index = _list.IndexOf(modifier); + if (index == 0) + return; + var previousProduct = _list[index - 1]; + _list.RemoveAt(index); + _list.Insert(index - 1, modifier); + bsList.DataSource = _list; + bsList.ResetBindings(false); + bsList.CurrencyManager.Position -= 1; + } + if (e.ColumnIndex == dgvProductGroups.Columns["moveDown"].Index) + { + var modifier = dgvProductGroups.Rows[e.RowIndex].DataBoundItem as Modifier; + var index = _list.IndexOf(modifier); + if (index == _list.Count + 1) + return; + var nextProduct = _list[index + 1]; + _list.RemoveAt(index); + _list.Insert(index + 1, modifier); + bsList.DataSource = _list; + bsList.ResetBindings(false); + bsList.CurrencyManager.Position += 1; + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + //using (var bi = new ModifierBI()) + //{ + // bi.UpdateSortOrder(_list); + // bi.SaveChanges(); + // _list = bi.List(); + // bsList.DataSource = _list; + //} + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.resx b/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.resx new file mode 100644 index 0000000..b672b26 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ModifierListForm.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + + 17, 17 + + \ 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 3a05cd9..cfa7948 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs @@ -43,7 +43,7 @@ this.txtPrice = new System.Windows.Forms.TextBox(); this.cmbVat = new System.Windows.Forms.ComboBox(); this.bsVat = new System.Windows.Forms.BindingSource(this.components); - this.chkDiscontinued = new System.Windows.Forms.CheckBox(); + this.chkIsActive = new System.Windows.Forms.CheckBox(); this.txtServiceCharge = new System.Windows.Forms.TextBox(); this.btnAddProductGroup = new System.Windows.Forms.Button(); this.cmbProductGroup = new System.Windows.Forms.ComboBox(); @@ -53,6 +53,7 @@ this.cmbServiceTax = new System.Windows.Forms.ComboBox(); this.label6 = new System.Windows.Forms.Label(); this.chkIsScTaxable = new System.Windows.Forms.CheckBox(); + this.chkIsNotAvailable = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bsVat)).BeginInit(); @@ -168,15 +169,15 @@ // this.bsVat.DataSource = typeof(Tanshu.Accounts.Entities.Tax); // - // chkDiscontinued + // chkIsActive // - this.chkDiscontinued.AutoSize = true; - this.chkDiscontinued.Location = new System.Drawing.Point(307, 115); - this.chkDiscontinued.Name = "chkDiscontinued"; - this.chkDiscontinued.Size = new System.Drawing.Size(88, 17); - this.chkDiscontinued.TabIndex = 7; - this.chkDiscontinued.Text = "Discontinued"; - this.chkDiscontinued.UseVisualStyleBackColor = true; + this.chkIsActive.AutoSize = true; + this.chkIsActive.Location = new System.Drawing.Point(191, 115); + this.chkIsActive.Name = "chkIsActive"; + this.chkIsActive.Size = new System.Drawing.Size(67, 17); + this.chkIsActive.TabIndex = 7; + this.chkIsActive.Text = "Is Active"; + this.chkIsActive.UseVisualStyleBackColor = true; // // txtServiceCharge // @@ -267,11 +268,22 @@ this.chkIsScTaxable.Text = "Is Sc Taxable"; this.chkIsScTaxable.UseVisualStyleBackColor = true; // + // chkIsNotAvailable + // + this.chkIsNotAvailable.AutoSize = true; + this.chkIsNotAvailable.Location = new System.Drawing.Point(255, 114); + this.chkIsNotAvailable.Name = "chkIsNotAvailable"; + this.chkIsNotAvailable.Size = new System.Drawing.Size(57, 17); + this.chkIsNotAvailable.TabIndex = 23; + this.chkIsNotAvailable.Text = "Is N/A"; + this.chkIsNotAvailable.UseVisualStyleBackColor = true; + // // ProductForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(415, 276); + this.Controls.Add(this.chkIsNotAvailable); this.Controls.Add(this.chkIsScTaxable); this.Controls.Add(this.label6); this.Controls.Add(this.cmbServiceTax); @@ -280,7 +292,7 @@ this.Controls.Add(this.btnOk); this.Controls.Add(this.btnAddProductGroup); this.Controls.Add(this.cmbProductGroup); - this.Controls.Add(this.chkDiscontinued); + this.Controls.Add(this.chkIsActive); this.Controls.Add(this.txtServiceCharge); this.Controls.Add(this.Label7); this.Controls.Add(this.txtPrice); @@ -322,7 +334,7 @@ internal System.Windows.Forms.TextBox txtName; internal System.Windows.Forms.TextBox txtPrice; internal System.Windows.Forms.ComboBox cmbVat; - private System.Windows.Forms.CheckBox chkDiscontinued; + private System.Windows.Forms.CheckBox chkIsActive; internal System.Windows.Forms.TextBox txtServiceCharge; internal System.Windows.Forms.Button btnAddProductGroup; internal System.Windows.Forms.ComboBox cmbProductGroup; @@ -333,5 +345,6 @@ internal System.Windows.Forms.Label label6; private System.Windows.Forms.CheckBox chkIsScTaxable; private System.Windows.Forms.BindingSource bsVat; + private System.Windows.Forms.CheckBox chkIsNotAvailable; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs index 5dcce29..9dadc93 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs @@ -31,8 +31,9 @@ namespace Tanshu.Accounts.PointOfSale cmbVat.SelectedValue = product.Vat.TaxID; cmbServiceTax.SelectedValue = product.ServiceTax.TaxID; txtServiceCharge.Text = product.ServiceCharge.ToString("#.##"); - chkDiscontinued.Checked = product.Discontinued; + chkIsActive.Checked = product.IsActive; chkIsScTaxable.Checked = product.IsScTaxable; + chkIsNotAvailable.Checked = product.IsNotAvailable; cmbProductGroup.SelectedValue = product.ProductGroup.ProductGroupID; } else @@ -112,7 +113,8 @@ namespace Tanshu.Accounts.PointOfSale product.ServiceCharge = serviceCharge; product.IsScTaxable = chkIsScTaxable.Checked; - product.Discontinued = chkDiscontinued.Checked; + product.IsActive = chkIsActive.Checked; + product.IsNotAvailable = chkIsNotAvailable.Checked; //Group if (cmbProductGroup.SelectedItem == null) diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.Designer.cs index 6f97041..6bdd85c 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.Designer.cs @@ -39,7 +39,7 @@ this.label3 = new System.Windows.Forms.Label(); this.btnOk = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); - this.chkDiscontinued = new System.Windows.Forms.CheckBox(); + this.chkIsActive = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // txtName @@ -146,22 +146,22 @@ this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // - // chkDiscontinued + // chkIsActive // - this.chkDiscontinued.AutoSize = true; - this.chkDiscontinued.Location = new System.Drawing.Point(237, 90); - this.chkDiscontinued.Name = "chkDiscontinued"; - this.chkDiscontinued.Size = new System.Drawing.Size(88, 17); - this.chkDiscontinued.TabIndex = 4; - this.chkDiscontinued.Text = "Discontinued"; - this.chkDiscontinued.UseVisualStyleBackColor = true; + this.chkIsActive.AutoSize = true; + this.chkIsActive.Location = new System.Drawing.Point(237, 90); + this.chkIsActive.Name = "chkIsActive"; + this.chkIsActive.Size = new System.Drawing.Size(67, 17); + this.chkIsActive.TabIndex = 4; + this.chkIsActive.Text = "Is Active"; + this.chkIsActive.UseVisualStyleBackColor = true; // // ProductGroupForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(373, 226); - this.Controls.Add(this.chkDiscontinued); + this.Controls.Add(this.chkIsActive); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnOk); this.Controls.Add(this.txtGroupType); @@ -197,6 +197,6 @@ internal System.Windows.Forms.Label label3; private System.Windows.Forms.Button btnOk; private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.CheckBox chkDiscontinued; + private System.Windows.Forms.CheckBox chkIsActive; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.cs index 278bfef..9ef6671 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.cs @@ -28,7 +28,7 @@ namespace Tanshu.Accounts.PointOfSale txtDiscountLimit.Text = productGroup.DiscountLimit.ToString(); chkModifierCompulsory.Checked = productGroup.IsModifierCompulsory; txtGroupType.Text = productGroup.GroupType; - chkDiscontinued.Checked = productGroup.Discontinued; + chkIsActive.Checked = productGroup.IsActive; } else { @@ -76,7 +76,7 @@ namespace Tanshu.Accounts.PointOfSale return null; productGroup.DiscountLimit = discount; productGroup.IsModifierCompulsory = chkModifierCompulsory.Checked; - productGroup.Discontinued = chkDiscontinued.Checked; + productGroup.IsActive = chkIsActive.Checked; if (string.IsNullOrEmpty(txtGroupType.Text.Trim())) return null; productGroup.GroupType = txtGroupType.Text.Trim(); diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs index b3c65e7..a2fa386 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs @@ -46,7 +46,7 @@ this.Group = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.serviceChargeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.salePriceDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.discontinuedDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.isActiveDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit(); this.SuspendLayout(); @@ -104,7 +104,7 @@ this.Group, this.serviceChargeDataGridViewTextBoxColumn, this.salePriceDataGridViewTextBoxColumn, - this.discontinuedDataGridViewCheckBoxColumn}); + this.isActiveDataGridViewCheckBoxColumn}); this.dgvProducts.DataSource = this.bsList; this.dgvProducts.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgvProducts.Location = new System.Drawing.Point(12, 12); @@ -212,13 +212,13 @@ this.salePriceDataGridViewTextBoxColumn.ReadOnly = true; this.salePriceDataGridViewTextBoxColumn.Width = 56; // - // discontinuedDataGridViewCheckBoxColumn + // isActiveDataGridViewCheckBoxColumn // - this.discontinuedDataGridViewCheckBoxColumn.DataPropertyName = "Discontinued"; - this.discontinuedDataGridViewCheckBoxColumn.HeaderText = "Discontinued"; - this.discontinuedDataGridViewCheckBoxColumn.Name = "discontinuedDataGridViewCheckBoxColumn"; - this.discontinuedDataGridViewCheckBoxColumn.ReadOnly = true; - this.discontinuedDataGridViewCheckBoxColumn.Width = 75; + this.isActiveDataGridViewCheckBoxColumn.DataPropertyName = "IsActive"; + this.isActiveDataGridViewCheckBoxColumn.HeaderText = "Is Active"; + this.isActiveDataGridViewCheckBoxColumn.Name = "isActiveDataGridViewCheckBoxColumn"; + this.isActiveDataGridViewCheckBoxColumn.ReadOnly = true; + this.isActiveDataGridViewCheckBoxColumn.Width = 75; // // ProductListForm // @@ -259,7 +259,7 @@ private System.Windows.Forms.DataGridViewTextBoxColumn Group; private System.Windows.Forms.DataGridViewTextBoxColumn serviceChargeDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn salePriceDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewCheckBoxColumn discontinuedDataGridViewCheckBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn isActiveDataGridViewCheckBoxColumn; //private System.Windows.Forms.DataGridViewTextBoxColumn discountLimitDataGridViewTextBoxColumn; //private System.Windows.Forms.DataGridViewTextBoxColumn groupTypeDataGridViewTextBoxColumn; //private System.Windows.Forms.DataGridViewTextBoxColumn productGroupDataGridViewTextBoxColumn; diff --git a/Tanshu.Accounts.PointOfSale/Products/TableForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/TableForm.Designer.cs new file mode 100644 index 0000000..e08a7ae --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/TableForm.Designer.cs @@ -0,0 +1,137 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class TableForm + { + /// + /// 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.txtName = new System.Windows.Forms.TextBox(); + this.Label2 = new System.Windows.Forms.Label(); + this.txtLocation = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.chkIsActive = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // txtName + // + this.txtName.AccessibleName = ""; + this.txtName.Location = new System.Drawing.Point(94, 12); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(267, 20); + this.txtName.TabIndex = 0; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(53, 15); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(35, 13); + this.Label2.TabIndex = 10; + this.Label2.Text = "Name"; + // + // txtLocation + // + this.txtLocation.AccessibleName = ""; + this.txtLocation.Location = new System.Drawing.Point(94, 38); + this.txtLocation.Name = "txtLocation"; + this.txtLocation.Size = new System.Drawing.Size(267, 20); + this.txtLocation.TabIndex = 5; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(40, 41); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(48, 13); + this.label3.TabIndex = 12; + this.label3.Text = "Location"; + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(205, 114); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 75); + this.btnOk.TabIndex = 6; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(286, 114); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 75); + this.btnCancel.TabIndex = 7; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // chkIsActive + // + this.chkIsActive.AutoSize = true; + this.chkIsActive.Location = new System.Drawing.Point(94, 64); + this.chkIsActive.Name = "chkIsActive"; + this.chkIsActive.Size = new System.Drawing.Size(67, 17); + this.chkIsActive.TabIndex = 4; + this.chkIsActive.Text = "Is Active"; + this.chkIsActive.UseVisualStyleBackColor = true; + // + // TableForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(373, 201); + this.Controls.Add(this.chkIsActive); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.txtLocation); + this.Controls.Add(this.label3); + this.Controls.Add(this.txtName); + this.Controls.Add(this.Label2); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TableForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Tables"; + this.Load += new System.EventHandler(this.TableForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.TextBox txtName; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.TextBox txtLocation; + internal System.Windows.Forms.Label label3; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.CheckBox chkIsActive; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/TableForm.cs b/Tanshu.Accounts.PointOfSale/Products/TableForm.cs new file mode 100644 index 0000000..b45091a --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/TableForm.cs @@ -0,0 +1,87 @@ +using System; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Entities; +using System.Linq; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class TableForm : Form + { + private Guid? _tableID; + public TableForm() + { + InitializeComponent(); + } + + public TableForm(Guid tableID) + : this() + { + _tableID = tableID; + } + + private void TableForm_Load(object sender, EventArgs e) + { + if (_tableID.HasValue) + { + FoodTable foodTable; + using (var bi = new FoodTableBI()) + foodTable = bi.Get(x => x.FoodTableID == _tableID.Value); + + txtName.Text = foodTable.Name; + txtLocation.Text = foodTable.Location; + chkIsActive.Checked = foodTable.IsActive; + } + else + { + txtName.Focus(); + } + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnOk_Click(object sender, EventArgs e) + { + if (IsFormValid()) + { + using (var bi = new FoodTableBI()) + { + FoodTable foodTable; + if (_tableID.HasValue) + { + foodTable = bi.Get(x => x.FoodTableID == _tableID.Value); + if (foodTable.IsActive && chkIsActive.Checked == false && (foodTable.Status != null || foodTable.VoucherID.HasValue)) + { + MessageBox.Show("Cannot deactivate a table with running bill"); + return; + } + } + else + foodTable = new FoodTable(); + foodTable.Name = txtName.Text.Trim(); + foodTable.IsActive = chkIsActive.Checked; + foodTable.Location = txtLocation.Text.Trim(); + + if (_tableID.HasValue) + bi.Update(foodTable); + else + bi.Insert(foodTable); + bi.SaveChanges(); + } + MessageBox.Show("Update / Save Successful"); + this.Close(); + } + else + MessageBox.Show("The form is not valid"); + } + private bool IsFormValid() + { + if (string.IsNullOrEmpty(txtName.Text.Trim())) + return false; + return true; + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Products/TableForm.resx b/Tanshu.Accounts.PointOfSale/Products/TableForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/TableForm.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/BillDetailsForm.cs b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs index 90afa00..5535473 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs @@ -22,7 +22,7 @@ namespace Tanshu.Accounts.PointOfSale private void ShowStatement() { - if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT)) + if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit")) return; _list = new SalesAnalysisBI().GetBillDetails(dtpStart.Value, dtpFinish.Value); dgvSale.AutoGenerateColumns = true; diff --git a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs index d656c3d..30bf0c8 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs @@ -21,7 +21,7 @@ namespace Tanshu.Accounts.PointOfSale private void ShowStatement() { - if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT)) + if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit")) return; _list = new SalesAnalysisBI().DiscountReport(dtpStart.Value, dtpFinish.Value); dgvSale.AutoGenerateColumns = true; diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs index 1c3773b..cbdbc91 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleAnalysisForm.cs @@ -22,7 +22,7 @@ namespace Tanshu.Accounts.PointOfSale private void ShowStatement() { if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && - !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT)) + !Session.IsAllowed("Accounts Audit")) return; _list = new SalesAnalysisBI().GetSale(dtpStart.Value, dtpFinish.Value); diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs index 804bc37..c1fabfd 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs @@ -21,7 +21,7 @@ namespace Tanshu.Accounts.PointOfSale private void ShowStatement() { - if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT)) + if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit")) return; _list = new SalesAnalysisBI().GetSaleDetail(dtpStart.Value, dtpFinish.Value); dgvSale.AutoGenerateColumns = true; diff --git a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs index 32d6c15..a30fd06 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs @@ -22,7 +22,7 @@ namespace Tanshu.Accounts.PointOfSale private void ShowStatement() { - if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed(RoleConstants.ACCOUNTS_AUDIT)) + if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit")) return; _list = new SalesAnalysisBI().VoidOrReprintedBillsList(dtpStart.Value, dtpFinish.Value); dgvSale.AutoGenerateColumns = true; diff --git a/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.cs b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.cs index 4357296..4e30cd0 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.cs @@ -4,26 +4,26 @@ using System.Drawing; using System.Windows.Forms; using Tanshu.Accounts.Entities; using Tanshu.Accounts.Helpers; +using System.Diagnostics; namespace Tanshu.Accounts.PointOfSale { public partial class MoveTableForm : Form { - private readonly IList _source; + private readonly IList _tableList; private readonly bool _allowMerge; - public MoveTableForm(IList source, bool allowMerge) + public MoveTableForm(IList tableList, bool allowMerge) { InitializeComponent(); - _source = source; + _tableList = tableList; Selection = null; _allowMerge = allowMerge; } - public FoodTable Selection { get; private set; } private void MoveTableForm_Load(object sender, EventArgs e) { - ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, _source, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click)); + ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, _tableList, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click)); } private void tableButton_Click(object sender, EventArgs e) { @@ -47,7 +47,7 @@ namespace Tanshu.Accounts.PointOfSale var start = (int)button.Tag; if (start < 0) start = 0; - ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _source, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click)); + ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _tableList, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click)); } } } diff --git a/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.Designer.cs new file mode 100644 index 0000000..2da28c3 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.Designer.cs @@ -0,0 +1,67 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class ReorderTableForm + { + /// + /// 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.flpTables = new System.Windows.Forms.FlowLayoutPanel(); + this.SuspendLayout(); + // + // flpTables + // + this.flpTables.AllowDrop = true; + this.flpTables.AutoScroll = true; + this.flpTables.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flpTables.Dock = System.Windows.Forms.DockStyle.Fill; + this.flpTables.Location = new System.Drawing.Point(0, 0); + this.flpTables.Name = "flpTables"; + this.flpTables.Size = new System.Drawing.Size(847, 492); + this.flpTables.TabIndex = 7; + this.flpTables.DragDrop += new System.Windows.Forms.DragEventHandler(this.flpTables_DragDrop); + this.flpTables.DragEnter += new System.Windows.Forms.DragEventHandler(this.flpTables_DragEnter); + // + // ReorderTableForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(847, 492); + this.Controls.Add(this.flpTables); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.Name = "ReorderTableForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Move Table / Kot"; + this.Load += new System.EventHandler(this.MoveTableForm_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flpTables; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.cs b/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.cs new file mode 100644 index 0000000..ad4fdc2 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using Tanshu.Accounts.Entities; +using Tanshu.Accounts.Helpers; +using System.Diagnostics; +using Tanshu.Accounts.Repository; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class ReorderTableForm : Form + { + private readonly IList _tableList; + public ReorderTableForm() + { + InitializeComponent(); + using (var bi = new FoodTableBI()) + { + _tableList = bi.List(); + } + Selection = null; + } + private void button_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left && e.Clicks == 1) + { + var button = (Button)sender; + button.DoDragDrop(button, DragDropEffects.Move); + } + } + + private void flpTables_DragEnter(object sender, DragEventArgs e) + { + e.Effect = DragDropEffects.All; + } + private void flpTables_DragDrop(object sender, DragEventArgs e) + { + Button button = (Button)e.Data.GetData(typeof(Button)); + Point p = flpTables.PointToClient(new Point(e.X, e.Y)); + var item = flpTables.GetChildAtPoint(p); + int index = flpTables.Controls.GetChildIndex(item, false); + flpTables.Controls.SetChildIndex(button, index); + flpTables.Invalidate(); + + var foodTable = (FoodTable)button.Tag; + var listIndex = _tableList.IndexOf(foodTable); + var newIndex = _tableList.IndexOf((FoodTable)((Button)item).Tag); + _tableList.Remove(foodTable); + _tableList.Insert(index - 1, foodTable); + + + } + public FoodTable Selection { get; private set; } + + private void MoveTableForm_Load(object sender, EventArgs e) + { + GenerateTables(new Point(75, 75)); + } + private void tableButton_Click(object sender, EventArgs e) + { + var button = sender as Button; + if (button == null) + return; + var item = button.Tag as FoodTable; + Selection = item; + using (var frm = new TableForm(item.FoodTableID)) + { + frm.ShowDialog(); + } + } + private void GenerateTables(Point size) + { + var saveButton = new Button() + { + Name = "saveButton", + Text = "Save", + Width = size.X, + Height = size.Y, + }; + saveButton.Click += saveButton_Click; + flpTables.Controls.Add(saveButton); + for (int i = 0; i < _tableList.Count; i++) + { + var item = _tableList[i]; + var control = new Button() + { + Name = string.Format("g{0}", i), + Text = item.Name, + Width = size.X, + Height = size.Y, + Tag = item, + BackColor = item.IsActive ? Color.Green : Color.Red + }; + control.MouseDown += button_MouseDown; + control.Click += tableButton_Click; + flpTables.Controls.Add(control); + } + var addButton = new Button() + { + Name = "addButton", + Text = "Add Table", + Width = size.X, + Height = size.Y, + }; + addButton.Click += addButton_Click; + flpTables.Controls.Add(addButton); + } + private void addButton_Click(object sender, EventArgs e) + { + using (var frm = new TableForm()) + { + frm.ShowDialog(); + } + } + private void saveButton_Click(object sender, EventArgs e) + { + using (var bi = new FoodTableBI()) + { + bi.UpdateSortOrder(_tableList); + bi.SaveChanges(); + } + MessageBox.Show("Order Updated"); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.resx b/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/ReorderTableForm.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 242e5e5..b590e8c 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs @@ -47,6 +47,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.bindingSource = new System.Windows.Forms.BindingSource(this.components); this.pnlBilling = new System.Windows.Forms.Panel(); + this.label10 = new System.Windows.Forms.Label(); + this.txtPax = new System.Windows.Forms.TextBox(); this.flpMain = new System.Windows.Forms.FlowLayoutPanel(); this.flpGroup = new System.Windows.Forms.FlowLayoutPanel(); this.flpActions = new System.Windows.Forms.FlowLayoutPanel(); @@ -81,15 +83,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales this.txtKotID = new System.Windows.Forms.TextBox(); 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.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(); this.flpActions.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.bsPending)).BeginInit(); this.SuspendLayout(); // // label7 @@ -276,6 +274,23 @@ namespace Tanshu.Accounts.PointOfSale.Sales this.pnlBilling.Size = new System.Drawing.Size(982, 688); this.pnlBilling.TabIndex = 121; // + // label10 + // + 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; + // // flpMain // this.flpMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -605,27 +620,6 @@ namespace Tanshu.Accounts.PointOfSale.Sales // this.bsWaiter.DataSource = typeof(Tanshu.Accounts.Entities.Waiter); // - // bsPending - // - this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBills); - // - // label10 - // - 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -646,7 +640,6 @@ namespace Tanshu.Accounts.PointOfSale.Sales this.pnlBilling.PerformLayout(); this.flpActions.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.bsPending)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -656,7 +649,6 @@ namespace Tanshu.Accounts.PointOfSale.Sales private System.Windows.Forms.BindingSource bindingSource; private System.Windows.Forms.BindingSource bsWaiter; - private System.Windows.Forms.BindingSource bsPending; internal System.Windows.Forms.Label label7; internal System.Windows.Forms.TextBox txtDiscount; internal System.Windows.Forms.Label Label12; diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs index dcb6dce..ddfaaad 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs @@ -23,10 +23,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales this._billController = billController; billController.InitGui(this); using (var bi = new ProductGroupBI()) - _productGroupList = bi.List(x => x.Discontinued == false); + _productGroupList = bi.List(x => x.IsActive); using (var bi = new ProductBI()) foreach (var item in _productGroupList) - _productDictionary.Add(item.ProductGroupID, bi.List(x => x.ProductGroup.ProductGroupID == item.ProductGroupID && x.Discontinued == false)); + _productDictionary.Add(item.ProductGroupID, bi.List(x => x.ProductGroup.ProductGroupID == item.ProductGroupID && x.IsActive)); } #region ISaleForm Members @@ -50,7 +50,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales { if (voucher.VoucherID == Guid.Empty) { - txtTableID.Text = voucher.TableID; + txtTableID.Text = voucher.Table.Name; txtPax.Text = voucher.Pax.ToString(); } else @@ -61,7 +61,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales 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; + txtTableID.Text = voucher.Table.Name; txtPax.Text = voucher.Pax.ToString(); btnWaiter.Text = string.Format("{0} - F5", voucher.Waiter.Name); } @@ -337,11 +337,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, _productGroupList, productTypeButton_Click, productTypePage_Click); else using (var bi = new FoodTableBI()) - ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(), tableButton_Click, tablePage_Click); + ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(x => x.IsActive), tableButton_Click, tablePage_Click); } } - private void productTypeButton_Click(object sender, EventArgs e) { var button = sender as Button; @@ -372,6 +371,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales if (button == null) return; var item = button.Tag as Product; + if (item.IsNotAvailable) + return; _billController.AddProduct(item); } @@ -407,7 +408,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales if (start < 0) start = 0; using (var bi = new FoodTableBI()) - ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, bi.List(), tableButton_Click, tablePage_Click); + ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, bi.List(x => x.IsActive), tableButton_Click, tablePage_Click); } private void btnPrintBill_Click(object sender, EventArgs e) { diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx index c41ea0d..4230359 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx @@ -126,9 +126,6 @@ 148, 17 - - 248, 17 - 81 diff --git a/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj b/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj index edcdf7d..8837531 100644 --- a/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj +++ b/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj @@ -116,6 +116,24 @@ ManagementForm.cs + + Form + + + ModifierEditForm.cs + + + Form + + + ModifierListForm.cs + + + Form + + + TableForm.cs + Form @@ -158,6 +176,12 @@ SaleDetail.cs + + Form + + + ReorderTableForm.cs + Form @@ -273,6 +297,18 @@ ManagementForm.cs + + ModifierEditForm.cs + Designer + + + ModifierListForm.cs + Designer + + + TableForm.cs + Designer + ProductListForm.cs Designer @@ -301,6 +337,9 @@ SaleDetail.cs Designer + + ReorderTableForm.cs + VoucherTypeForm.cs diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs index 56adf02..7d14834 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs @@ -28,36 +28,13 @@ /// private void InitializeComponent() { - this.lstRoles = new System.Windows.Forms.ListBox(); - this.lstGroupRoles = new System.Windows.Forms.ListBox(); this.cmbGroup = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.btnAddSelected = new System.Windows.Forms.Button(); - this.btnAddAll = new System.Windows.Forms.Button(); - this.btnRemoveSelected = new System.Windows.Forms.Button(); - this.btnRemoveAll = new System.Windows.Forms.Button(); + this.clbRoles = new System.Windows.Forms.CheckedListBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOk = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // lstGroups - // - this.lstRoles.FormattingEnabled = true; - this.lstRoles.Location = new System.Drawing.Point(12, 59); - this.lstRoles.Name = "lstGroups"; - this.lstRoles.ScrollAlwaysVisible = true; - this.lstRoles.Size = new System.Drawing.Size(183, 225); - this.lstRoles.TabIndex = 0; - // - // lstUserGroups - // - this.lstGroupRoles.FormattingEnabled = true; - this.lstGroupRoles.Location = new System.Drawing.Point(274, 59); - this.lstGroupRoles.Name = "lstUserGroups"; - this.lstGroupRoles.ScrollAlwaysVisible = true; - this.lstGroupRoles.Size = new System.Drawing.Size(183, 225); - this.lstGroupRoles.TabIndex = 1; - // // cmbGroup // this.cmbGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -66,7 +43,7 @@ this.cmbGroup.Name = "cmbGroup"; this.cmbGroup.Size = new System.Drawing.Size(375, 21); this.cmbGroup.TabIndex = 2; - this.cmbGroup.SelectedIndexChanged += new System.EventHandler(this.cmbUsers_SelectedIndexChanged); + this.cmbGroup.SelectedIndexChanged += new System.EventHandler(this.cmbGroup_SelectedIndexChanged); // // label1 // @@ -77,83 +54,45 @@ this.label1.TabIndex = 4; this.label1.Text = "Group Name"; // - // label2 + // clbRoles // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 43); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(76, 13); - this.label2.TabIndex = 5; - this.label2.Text = "Pending Roles"; + this.clbRoles.FormattingEnabled = true; + this.clbRoles.Location = new System.Drawing.Point(12, 39); + this.clbRoles.Name = "clbRoles"; + this.clbRoles.Size = new System.Drawing.Size(445, 184); + this.clbRoles.TabIndex = 21; + this.clbRoles.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbRoles_Format); // - // label3 + // btnCancel // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(271, 43); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(80, 13); - this.label3.TabIndex = 6; - this.label3.Text = "Assigned Roles"; + this.btnCancel.Location = new System.Drawing.Point(382, 236); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 75); + this.btnCancel.TabIndex = 23; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // - // btnAddSelected + // btnOk // - this.btnAddSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnAddSelected.Location = new System.Drawing.Point(201, 105); - this.btnAddSelected.Name = "btnAddSelected"; - this.btnAddSelected.Size = new System.Drawing.Size(67, 25); - this.btnAddSelected.TabIndex = 7; - this.btnAddSelected.Text = ">"; - this.btnAddSelected.UseVisualStyleBackColor = true; - this.btnAddSelected.Click += new System.EventHandler(this.btnAddSelected_Click); - // - // btnAddAll - // - this.btnAddAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnAddAll.Location = new System.Drawing.Point(201, 136); - this.btnAddAll.Name = "btnAddAll"; - this.btnAddAll.Size = new System.Drawing.Size(67, 25); - this.btnAddAll.TabIndex = 8; - this.btnAddAll.Text = ">>"; - this.btnAddAll.UseVisualStyleBackColor = true; - this.btnAddAll.Click += new System.EventHandler(this.btnAddAll_Click); - // - // btnRemoveSelected - // - this.btnRemoveSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnRemoveSelected.Location = new System.Drawing.Point(201, 167); - this.btnRemoveSelected.Name = "btnRemoveSelected"; - this.btnRemoveSelected.Size = new System.Drawing.Size(67, 25); - this.btnRemoveSelected.TabIndex = 9; - this.btnRemoveSelected.Text = "<"; - this.btnRemoveSelected.UseVisualStyleBackColor = true; - this.btnRemoveSelected.Click += new System.EventHandler(this.btnRemoveSelected_Click); - // - // btnRemoveAll - // - this.btnRemoveAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnRemoveAll.Location = new System.Drawing.Point(201, 198); - this.btnRemoveAll.Name = "btnRemoveAll"; - this.btnRemoveAll.Size = new System.Drawing.Size(67, 25); - this.btnRemoveAll.TabIndex = 10; - this.btnRemoveAll.Text = "<<"; - this.btnRemoveAll.UseVisualStyleBackColor = true; - this.btnRemoveAll.Click += new System.EventHandler(this.btnRemoveAll_Click); + this.btnOk.Location = new System.Drawing.Point(301, 236); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 75); + this.btnOk.TabIndex = 22; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); // // AssignGroupRoles // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(469, 323); - this.Controls.Add(this.btnRemoveAll); - this.Controls.Add(this.btnRemoveSelected); - this.Controls.Add(this.btnAddAll); - this.Controls.Add(this.btnAddSelected); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.clbRoles); this.Controls.Add(this.label1); this.Controls.Add(this.cmbGroup); - this.Controls.Add(this.lstGroupRoles); - this.Controls.Add(this.lstRoles); this.MaximizeBox = false; this.Name = "AssignGroupRoles"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; @@ -166,15 +105,10 @@ #endregion - private System.Windows.Forms.ListBox lstRoles; - private System.Windows.Forms.ListBox lstGroupRoles; private System.Windows.Forms.ComboBox cmbGroup; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Button btnAddSelected; - private System.Windows.Forms.Button btnAddAll; - private System.Windows.Forms.Button btnRemoveSelected; - private System.Windows.Forms.Button btnRemoveAll; + private System.Windows.Forms.CheckedListBox clbRoles; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOk; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs index 2f179fa..553a8b4 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs @@ -1,15 +1,9 @@ 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.Helpers; -using System.Threading; -using Tanshu.Accounts.Repository; +using System.Linq; using Tanshu.Accounts.Entities.Auth; +using Tanshu.Accounts.Repository; namespace Tanshu.Accounts.PointOfSale { @@ -22,98 +16,71 @@ namespace Tanshu.Accounts.PointOfSale private void AssignGroupRoles_Load(object sender, EventArgs e) { - FillUsers(); + FillGroups(); } - private void FillUsers() + private void FillGroups() { cmbGroup.DisplayMember = "Name"; cmbGroup.ValueMember = "GroupID"; - cmbGroup.DataSource = MembershipBI.GetGroups(); + using (var bi = new GroupBI()) + cmbGroup.DataSource = bi.List(); } - private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e) + private void cmbGroup_SelectedIndexChanged(object sender, EventArgs e) { - GetLists(); - } - - private void GetLists() - { - IList roles; - IList roleGroups; if (cmbGroup.SelectedValue == null) - { - roles = MembershipBI.GetRoles(); - roleGroups = new List(); - - } + GetRoles(null); else - { - int groupID = (int)cmbGroup.SelectedValue; - roles = MembershipBI.GetRolesNotOfGroup(groupID); - roleGroups = MembershipBI.GetRolesOfGroup(groupID); - } - - RefreshRoles(roles, roleGroups); - } - private void RefreshRoles(IList roles, IList roleGroups) - { - lstRoles.DisplayMember = "Name"; - lstRoles.ValueMember = "RoleID"; - lstRoles.DataSource = roles; - - lstGroupRoles.DisplayMember = "Name"; - lstGroupRoles.ValueMember = "RoleID"; - lstGroupRoles.DataSource = roleGroups; - - btnAddAll.Enabled = btnAddSelected.Enabled = roles.Count > 0; - btnRemoveAll.Enabled = btnRemoveSelected.Enabled = roleGroups.Count > 0; + GetRoles((Guid)cmbGroup.SelectedValue); } - private void btnAddSelected_Click(object sender, EventArgs e) + private void GetRoles(Guid? groupID) { - if (lstRoles.SelectedItem != null) + using (var bi = new GroupBI()) { - var groupID = (Guid)cmbGroup.SelectedValue; - var roleID = (Guid)lstRoles.SelectedValue; - MembershipBI.AddRoleToGroup(roleID, groupID); - GetLists(); + var roles = bi.RoleList(); + clbRoles.DataSource = roles; + + if (groupID.HasValue) + { + var group = bi.Get(x => x.GroupID == groupID.Value); + for (int i = 0; i < clbRoles.Items.Count; i++) + { + var item = (Role)clbRoles.Items[i]; + if (item.Groups.Any(x => x.Group == group)) + { + clbRoles.SetItemChecked(i, true); + } + } + } } } - private void btnRemoveSelected_Click(object sender, EventArgs e) + private void btnCancel_Click(object sender, EventArgs e) { - if (lstGroupRoles.SelectedItem != null) - { - var groupID = (Guid)cmbGroup.SelectedValue; - var roleID = (Guid)lstGroupRoles.SelectedValue; - MembershipBI.RemoveRoleFromGroup(roleID, groupID); - GetLists(); - } + this.Close(); } - private void btnAddAll_Click(object sender, EventArgs e) + private void btnOk_Click(object sender, EventArgs e) { - var groupID = (Guid)cmbGroup.SelectedValue; - Guid roleID; - for (var i = 0; i <= lstRoles.Items.Count - 1; i++) + if (cmbGroup.SelectedValue != null) + Save((Guid)cmbGroup.SelectedValue); + } + private void Save(Guid groupID) + { + using (var bi = new GroupBI()) { - roleID = ((Role)lstRoles.Items[i]).RoleID; - MembershipBI.AddRoleToGroup(roleID, groupID); + var group = bi.Get(x => x.GroupID == groupID); + bi.Update(group, clbRoles.CheckedItems.OfType()); + bi.SaveChanges(); } - GetLists(); + MessageBox.Show("Update / Save Successful"); } - private void btnRemoveAll_Click(object sender, EventArgs e) + private void clbRoles_Format(object sender, ListControlConvertEventArgs e) { - var groupID = (Guid)cmbGroup.SelectedValue; - Guid roleID; - for (var i = 0; i <= lstGroupRoles.Items.Count - 1; i++) - { - roleID = ((Role)lstGroupRoles.Items[i]).RoleID; - MembershipBI.RemoveRoleFromGroup(roleID, groupID); - } - GetLists(); + e.Value = ((Role)e.ListItem).Name; } } } diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs index acf753a..42f09c0 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs @@ -28,45 +28,22 @@ /// private void InitializeComponent() { - this.lstGroups = new System.Windows.Forms.ListBox(); - this.lstUserGroups = new System.Windows.Forms.ListBox(); - this.cmbUsers = new System.Windows.Forms.ComboBox(); + this.cmbUser = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.btnAddSelected = new System.Windows.Forms.Button(); - this.btnAddAll = new System.Windows.Forms.Button(); - this.btnRemoveSelected = new System.Windows.Forms.Button(); - this.btnRemoveAll = new System.Windows.Forms.Button(); + this.clbGroups = new System.Windows.Forms.CheckedListBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOk = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // lstGroups + // cmbUser // - this.lstGroups.FormattingEnabled = true; - this.lstGroups.Location = new System.Drawing.Point(12, 59); - this.lstGroups.Name = "lstGroups"; - this.lstGroups.ScrollAlwaysVisible = true; - this.lstGroups.Size = new System.Drawing.Size(183, 225); - this.lstGroups.TabIndex = 0; - // - // lstUserGroups - // - this.lstUserGroups.FormattingEnabled = true; - this.lstUserGroups.Location = new System.Drawing.Point(274, 59); - this.lstUserGroups.Name = "lstUserGroups"; - this.lstUserGroups.ScrollAlwaysVisible = true; - this.lstUserGroups.Size = new System.Drawing.Size(183, 225); - this.lstUserGroups.TabIndex = 1; - // - // cmbGroup - // - this.cmbUsers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cmbUsers.FormattingEnabled = true; - this.cmbUsers.Location = new System.Drawing.Point(72, 12); - this.cmbUsers.Name = "cmbGroup"; - this.cmbUsers.Size = new System.Drawing.Size(276, 21); - this.cmbUsers.TabIndex = 2; - this.cmbUsers.SelectedIndexChanged += new System.EventHandler(this.cmbUsers_SelectedIndexChanged); + this.cmbUser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbUser.FormattingEnabled = true; + this.cmbUser.Location = new System.Drawing.Point(72, 12); + this.cmbUser.Name = "cmbUser"; + this.cmbUser.Size = new System.Drawing.Size(385, 21); + this.cmbUser.TabIndex = 2; + this.cmbUser.SelectedIndexChanged += new System.EventHandler(this.cmbUsers_SelectedIndexChanged); // // label1 // @@ -77,83 +54,45 @@ this.label1.TabIndex = 4; this.label1.Text = "User Name"; // - // label2 + // clbGroups // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 43); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(83, 13); - this.label2.TabIndex = 5; - this.label2.Text = "Pending Groups"; + this.clbGroups.FormattingEnabled = true; + this.clbGroups.Location = new System.Drawing.Point(12, 39); + this.clbGroups.Name = "clbGroups"; + this.clbGroups.Size = new System.Drawing.Size(445, 184); + this.clbGroups.TabIndex = 22; + this.clbGroups.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbGroups_Format); // - // label3 + // btnCancel // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(271, 43); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(87, 13); - this.label3.TabIndex = 6; - this.label3.Text = "Assigned Groups"; + this.btnCancel.Location = new System.Drawing.Point(382, 236); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 75); + this.btnCancel.TabIndex = 25; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // - // btnAddSelected + // btnOk // - this.btnAddSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnAddSelected.Location = new System.Drawing.Point(201, 105); - this.btnAddSelected.Name = "btnAddSelected"; - this.btnAddSelected.Size = new System.Drawing.Size(67, 25); - this.btnAddSelected.TabIndex = 7; - this.btnAddSelected.Text = ">"; - this.btnAddSelected.UseVisualStyleBackColor = true; - this.btnAddSelected.Click += new System.EventHandler(this.btnAddSelected_Click); - // - // btnAddAll - // - this.btnAddAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnAddAll.Location = new System.Drawing.Point(201, 136); - this.btnAddAll.Name = "btnAddAll"; - this.btnAddAll.Size = new System.Drawing.Size(67, 25); - this.btnAddAll.TabIndex = 8; - this.btnAddAll.Text = ">>"; - this.btnAddAll.UseVisualStyleBackColor = true; - this.btnAddAll.Click += new System.EventHandler(this.btnAddAll_Click); - // - // btnRemoveSelected - // - this.btnRemoveSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnRemoveSelected.Location = new System.Drawing.Point(201, 167); - this.btnRemoveSelected.Name = "btnRemoveSelected"; - this.btnRemoveSelected.Size = new System.Drawing.Size(67, 25); - this.btnRemoveSelected.TabIndex = 9; - this.btnRemoveSelected.Text = "<"; - this.btnRemoveSelected.UseVisualStyleBackColor = true; - this.btnRemoveSelected.Click += new System.EventHandler(this.btnRemoveSelected_Click); - // - // btnRemoveAll - // - this.btnRemoveAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnRemoveAll.Location = new System.Drawing.Point(201, 198); - this.btnRemoveAll.Name = "btnRemoveAll"; - this.btnRemoveAll.Size = new System.Drawing.Size(67, 25); - this.btnRemoveAll.TabIndex = 10; - this.btnRemoveAll.Text = "<<"; - this.btnRemoveAll.UseVisualStyleBackColor = true; - this.btnRemoveAll.Click += new System.EventHandler(this.btnRemoveAll_Click); + this.btnOk.Location = new System.Drawing.Point(301, 236); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 75); + this.btnOk.TabIndex = 24; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); // // AssignUserGroups // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(469, 323); - this.Controls.Add(this.btnRemoveAll); - this.Controls.Add(this.btnRemoveSelected); - this.Controls.Add(this.btnAddAll); - this.Controls.Add(this.btnAddSelected); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.clbGroups); this.Controls.Add(this.label1); - this.Controls.Add(this.cmbUsers); - this.Controls.Add(this.lstUserGroups); - this.Controls.Add(this.lstGroups); + this.Controls.Add(this.cmbUser); this.MaximizeBox = false; this.Name = "AssignUserGroups"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; @@ -166,15 +105,10 @@ #endregion - private System.Windows.Forms.ListBox lstGroups; - private System.Windows.Forms.ListBox lstUserGroups; - private System.Windows.Forms.ComboBox cmbUsers; + private System.Windows.Forms.ComboBox cmbUser; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Button btnAddSelected; - private System.Windows.Forms.Button btnAddAll; - private System.Windows.Forms.Button btnRemoveSelected; - private System.Windows.Forms.Button btnRemoveAll; + private System.Windows.Forms.CheckedListBox clbGroups; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOk; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs index 866a080..c14ff2b 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs @@ -27,94 +27,66 @@ namespace Tanshu.Accounts.PointOfSale private void FillUsers() { - cmbUsers.DisplayMember = "Name"; - cmbUsers.ValueMember = "UserID"; + cmbUser.DisplayMember = "Name"; + cmbUser.ValueMember = "UserID"; using (var bi = new UserBI()) - cmbUsers.DataSource = bi.List(); + cmbUser.DataSource = bi.List(); } private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e) { - GetLists(); - } - - private void GetLists() - { - IList groups; - IList userGroups; - if (cmbUsers.SelectedValue == null) - { - groups = MembershipBI.GetGroups(); - userGroups = new List(); - - } + if (cmbUser.SelectedValue == null) + GetGroups(null); else - { - var userid = (Guid)cmbUsers.SelectedValue; - groups = MembershipBI.GetGroupsNotOfUser(userid); - userGroups = MembershipBI.GetGroupsOfUser(userid); - } - - RefreshRoles(groups, userGroups); - } - private void RefreshRoles(IList groups, IList userGroups) - { - lstGroups.DisplayMember = "Name"; - lstGroups.ValueMember = "GroupID"; - lstGroups.DataSource = groups; - - lstUserGroups.DisplayMember = "Name"; - lstUserGroups.ValueMember = "GroupID"; - lstUserGroups.DataSource = userGroups; - - btnAddAll.Enabled = btnAddSelected.Enabled = groups.Count > 0; - btnRemoveAll.Enabled = btnRemoveSelected.Enabled = userGroups.Count > 0; + GetGroups((Guid)cmbUser.SelectedValue); } - private void btnAddSelected_Click(object sender, EventArgs e) + private void GetGroups(Guid? userID) { - if (lstGroups.SelectedItem != null) + using (var bi = new UserBI()) { - var userID = (Guid)cmbUsers.SelectedValue; - var groupID = (Guid)lstGroups.SelectedValue; - MembershipBI.AddUserToGroup(userID, groupID); - GetLists(); + var groups = bi.GroupList(); + clbGroups.DataSource = groups; + + if (userID.HasValue) + { + var user = bi.Get(x => x.UserID == userID.Value); + for (int i = 0; i < clbGroups.Items.Count; i++) + { + var item = (Group)clbGroups.Items[i]; + if (item.UserGroups.Any(x => x.User == user)) + { + clbGroups.SetItemChecked(i, true); + } + } + } } } - - private void btnRemoveSelected_Click(object sender, EventArgs e) + private void btnOk_Click(object sender, EventArgs e) { - if (lstUserGroups.SelectedItem != null) - { - Guid userID = (Guid)cmbUsers.SelectedValue; - Guid groupID = (Guid)lstUserGroups.SelectedValue; - MembershipBI.RemoveUserFromGroup(userID, groupID); - GetLists(); - } + if (cmbUser.SelectedValue != null) + Save((Guid)cmbUser.SelectedValue); } - private void btnAddAll_Click(object sender, EventArgs e) + private void Save(Guid userID) { - var userID = (Guid)cmbUsers.SelectedValue; - Guid groupID; - for (var i = 0; i <= lstGroups.Items.Count - 1; i++) + using (var bi = new UserBI()) { - groupID = ((Group)lstGroups.Items[i]).GroupID; - MembershipBI.AddUserToGroup(userID, groupID); + var user = bi.Get(x => x.UserID == userID); + bi.Update(user, clbGroups.CheckedItems.OfType()); + bi.SaveChanges(); } - GetLists(); + MessageBox.Show("Update / Save Successful"); } - private void btnRemoveAll_Click(object sender, EventArgs e) + private void btnCancel_Click(object sender, EventArgs e) { - var userID = (Guid)cmbUsers.SelectedValue; - Guid groupID; - for (var i = 0; i <= lstUserGroups.Items.Count - 1; i++) - { - groupID = ((Group)lstUserGroups.Items[i]).GroupID; - MembershipBI.RemoveUserFromGroup(userID, groupID); - } - GetLists(); + this.Close(); + } + + private void clbGroups_Format(object sender, ListControlConvertEventArgs e) + { + e.Value = ((Group)e.ListItem).Name; } } } diff --git a/Tanshu.Accounts.Print/Thermal.cs b/Tanshu.Accounts.Print/Thermal.cs index 0eccc5a..7b63e0b 100644 --- a/Tanshu.Accounts.Print/Thermal.cs +++ b/Tanshu.Accounts.Print/Thermal.cs @@ -23,7 +23,7 @@ namespace Tanshu.Accounts.Print billText += "\n\r" + string.Format("Copy No. {0}", copyNumber).Center42(); billText += DrawLine; billText += string.Format("\n\rKOT ID : {0,-7}/{1,-7} {2:dd-MMM-yyyy HH:mm}", voucher.KotID, kot.Code, kot.Date); - billText += string.Format("\n\rTable No.: {0} / {1}", voucher.TableID, waiter.Name); + billText += string.Format("\n\rTable No.: {0} / {1}", voucher.Table.Name, waiter.Name); billText += DrawLine; billText += "\n\r Qty. x Name "; billText += DrawLine; @@ -42,21 +42,6 @@ namespace Tanshu.Accounts.Print return billText; } - private static decimal Amount(IEnumerable list) - { - return list.Sum(item => item.Amount); - } - - private static decimal ServiceTax(IEnumerable list) - { - return list.Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + (item.IsScTaxable ? item.ServiceCharge : 0)) * item.ServiceTaxRate); - } - - private static decimal SplitTax(IEnumerable list, decimal rate) - { - return list.Where(x => x.VatRate == rate).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + (item.IsScTaxable ? item.ServiceCharge : 0)) * item.VatRate); - } - private static string Name(Product product) { return string.IsNullOrEmpty(product.Units) @@ -101,32 +86,6 @@ namespace Tanshu.Accounts.Print #endif } - public static Boolean PrintAdvance(string user, string advance, string narration) - { - var billText = "\n\r" + FormatText("Hops n Grains", 42, Align.Centre); - billText += "\n\r" + FormatText("The Microbrewery", 42, Align.Centre); - billText += "\n\r" + FormatText("SCO 358, Sector 9, Panchkula", 42, Align.Centre); - billText += "\n\r" + FormatText("A Unit of Peitho Foods Pvt. Ltd.", 42, Align.Centre); - billText += "\n\r" + FormatText("CIN: U15139CH2010PTC032202", 42, Align.Centre); - billText += DrawLine; - billText += "\n\r" + - FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, Align.Centre); - billText += "\n\r" + FormatText("Received Rs. " + advance + " as advance.", 42, Align.Centre); - billText += DrawLine; - if (narration != "") billText += "\n\r" + FormatText(narration, 42, Align.Centre); - billText += DrawLine; - billText += "\n\r" + FormatText("Thanking you " + user, 42, Align.Left); - billText += "\n\r"; - billText += "\n\r"; - billText += "\n\r"; - billText += "\n\r"; - billText += "\n\r"; - billText += "Signed" + "\n\r"; - billText += "\n\r"; - PrintRaw(PrintLocationBI.BasePrinter, billText, "Advance for " + user); - return PrintRaw(PrintLocationBI.BasePrinter, billText, "Advance for " + user); - } - public static Boolean PrintClosing(CheckoutBI details) { var billText = FormatText(string.Format("{0} Checkout By {1}", details.Cashier.Name, details.Manager), 42, Align.Centre); @@ -182,10 +141,7 @@ namespace Tanshu.Accounts.Print public static void PrintBill(Guid voucherID) { - Voucher voucher; - using (var bi = new VoucherBI()) - voucher = bi.Get(x => x.VoucherID == voucherID); - PrintRaw(PrintLocationBI.BasePrinter, DesignBill(voucher), "Bill"); + PrintRaw(PrintLocationBI.BasePrinter, DesignBill(voucherID), "Bill"); } public static void PrintKot(Guid voucherID, Guid kotID) diff --git a/Tanshu.Accounts.Print/ThermalBill.cs b/Tanshu.Accounts.Print/ThermalBill.cs index b087a55..b908079 100644 --- a/Tanshu.Accounts.Print/ThermalBill.cs +++ b/Tanshu.Accounts.Print/ThermalBill.cs @@ -4,111 +4,130 @@ using System.Linq; using Tanshu.Accounts.Entities; using Tanshu.Common.Helpers; using Tanshu.Accounts.Contracts; +using Tanshu.Accounts.Repository; namespace Tanshu.Accounts.Print { public static partial class Thermal { - private static string DesignBill(Voucher voucher) + private static string DesignBill(Guid voucherID) { - var list = new Dictionary(); - foreach (var item in voucher.Kots.SelectMany(kot => kot.Inventories)) + using (var bi = new VoucherBI()) { - if (list.ContainsKey(item.Product.ProductID)) - list[item.Product.ProductID].Quantity += item.Quantity; - else - list.Add(item.Product.ProductID, item); - } + Voucher voucher = bi.Get(x => x.VoucherID == voucherID); + var list = new Dictionary(); + foreach (var item in voucher.Kots.SelectMany(kot => kot.Inventories)) + { + int hash = item.Product.ProductID.GetHashCode(); + foreach (var mod in item.InventoryModifier.Where(x => x.Modifier.ShowInBill)) + { + hash = hash ^ mod.Modifier.ModifierID.GetHashCode(); + } + if (list.ContainsKey(hash)) + list[hash].Quantity += item.Quantity; + else + list.Add(hash, item); + } - var billText = ""; - billText += Header(voucher); - billText += Products(voucher, list); + var billText = ""; + billText += Header(voucher); + billText += Products(voucher, list.Values.ToList()); - decimal amount; - amount = list.Values.Sum(item => item.Quantity * item.FullPrice); - if (amount != 0) - billText += "\n\r" + FormatText("Total : ", 33, Align.Right) + FormatBillNum(amount, 9); + decimal amount; + amount = list.Values.Sum(item => item.Quantity * item.FullPrice); + if (amount != 0) + billText += "\n\r" + FormatText("Total : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = list.Values.Sum(item => item.Quantity * (item.FullPrice - item.Price)); - if (amount != 0) - billText += "\n\r" + FormatText("Happy Hour Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); + amount = list.Values.Sum(item => item.Quantity * (item.FullPrice - item.Price)); + if (amount != 0) + billText += "\n\r" + FormatText("Happy Hour Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = list.Values.Sum(item => item.Quantity * item.Price * item.Discount); - if (amount != 0) - billText += "\n\r" + FormatText("Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); + amount = list.Values.Sum(item => item.Quantity * item.Price * item.Discount); + if (amount != 0) + billText += "\n\r" + FormatText("Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = list.Values.Sum(item => item.Quantity * item.Price * (1 - item.Discount)); - if (amount != 0) - { - billText += "\n\r" + FormatText(" : ", 33, Align.Right) + "---------"; - billText += "\n\r" + FormatText("Net : ", 33, Align.Right) + FormatBillNum(amount, 9); - - } + amount = list.Values.Sum(item => item.Quantity * item.Price * (1 - item.Discount)); + if (amount != 0) + { + billText += "\n\r" + FormatText(" : ", 33, Align.Right) + "---------"; + billText += "\n\r" + FormatText("Net : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = list.Values.Sum(item => item.Quantity * item.Price * (1 - item.Discount) * item.ServiceCharge); - if (amount != 0) - billText += "\n\r" + FormatText("Service Charge : ", 33, Align.Right) + FormatBillNum(amount, 9); + } - // Begin Service Tax and VAT Hack + amount = list.Values.Sum(item => item.Quantity * item.Price * (1 - item.Discount) * item.ServiceCharge); + if (amount != 0) + billText += "\n\r" + FormatText("Service Charge : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = SplitTax(list.Values, .13125M); - if (amount != 0) - billText += "\n\r" + FormatText("VAT on Food : ", 33, Align.Right) + - FormatBillNum(amount, 9); + var vatList = from i in list.Values + group i by i.Vat into vat + select new + { + Tax = vat.Key, + Amount = vat.Sum(x => x.Quantity * x.Price * (1 - x.Discount) * (1 + x.ServiceCharge) * x.VatRate) + }; + foreach (var item in vatList) + if (item.Amount != 0) + billText += "\n\r" + FormatText(item.Tax.Name, 33, Align.Right) + FormatBillNum(item.Amount, 9); - amount = SplitTax(list.Values, .1575M); - if (amount != 0) - billText += "\n\r" + FormatText("VAT on Liqour : ", 33, Align.Right) + - FormatBillNum(amount, 9); + var stList = from i in list.Values + group i by i.ServiceTax into serviceTax + select new + { + Tax = serviceTax.Key, + Amount = serviceTax.Sum(x => x.Quantity * x.Price * (1 - x.Discount) * (1 + x.ServiceCharge) * x.ServiceTaxRate) + }; + foreach (var item in stList) + if (item.Amount != 0) + billText += "\n\r" + FormatText(item.Tax.Name, 33, Align.Right) + FormatBillNum(item.Amount, 9); - amount = ServiceTax(list.Values); - if (amount != 0) - billText += "\n\r" + FormatText("Cental Govt. ST : ", 33, Align.Right) + - FormatBillNum(amount, 9); + amount = list.Values.Sum(item => item.Amount); + if (amount != 0) + billText += string.Format("\n\r{0,33}{1,9:#,##0.00;(#,##0.00);0}", "Final Amount : ", Math.Round(amount, 0)); - amount = Amount(list.Values); - if (amount != 0) - billText += string.Format("\n\r{0,33}{1,9:#,##0.00;(#,##0.00);0}", "Final Amount : ", Math.Round(amount, 0)); - - billText += DrawLine; - - if (voucher.VoucherType == VoucherType.NoCharge || voucher.VoucherType == VoucherType.Staff) - { - billText += "\n\r" + "THIS IS NOT A BILL - DON'T PAY".Center42(); billText += DrawLine; + + if (voucher.VoucherType == VoucherType.NoCharge || voucher.VoucherType == VoucherType.Staff) + { + billText += "\n\r" + "THIS IS NOT A BILL - DON'T PAY".Center42(); + billText += DrawLine; + } + if (voucher.Narration != "") + { + billText += "\n\r" + FormatText(voucher.Narration, 42, Align.Centre); + billText += DrawLine; + } + if (voucher.Customer.CustomerID != Constants.CASH_CUSTOMER) + { + billText += "\n\r" + voucher.Customer.Name; + billText += string.Format("\n\r{0}\n\r{1}", voucher.Customer.Phone, voucher.Customer.Address); + billText += DrawLine; + } + billText += "\n\r" + "Cashier : " + voucher.User.Name + " / " + voucher.Waiter.Name; + billText += "\n\r" + "Call: 0172-4026666, 8054923853, 8054923856"; + return billText; } - if (voucher.Narration != "") - { - billText += "\n\r" + FormatText(voucher.Narration, 42, Align.Centre); - billText += DrawLine; - } - if (voucher.Customer.CustomerID != Constants.CASH_CUSTOMER) - { - billText += "\n\r" + voucher.Customer.Name; - billText += string.Format("\n\r{0}\n\r{1}", voucher.Customer.Phone, voucher.Customer.Address); - billText += DrawLine; - } - billText += "\n\r" + "Cashier : " + voucher.User.Name + " / " + voucher.Waiter.Name; - billText += "\n\r" + "Call: 0172-4026666, 8054923853, 8054923856"; - return billText; } - private static string Products(Voucher voucher, IDictionary list) + private static string Products(Voucher voucher, IList list) { var billNo = voucher.BillID.Substring(voucher.BillID.IndexOf("-") + 1); var billText = ""; billText += "\n\r" + string.Format("Bill No: {0,-12} {1:dd-MMM-yyyy HH:mm:ss}", billNo, voucher.Date); - billText += "\n\r" + "Table No.: " + voucher.TableID; + billText += "\n\r" + "Table No.: " + voucher.Table.Name; billText += "\n\r" + "------------------------------------------"; billText += "\n\r" + "Qty. Particulars Price Amount"; billText += "\n\r" + "------------------------------------------"; - foreach (var item in list.Values.Where(item => item.Quantity != 0)) + foreach (var item in list.Where(item => item.Quantity != 0)) { billText += "\n\r" + FormatBillNum(item.Quantity, 5) + " "; billText += FormatText(Name(item.Product), 22, Align.Left) + " "; billText += FormatBillNum(item.FullPrice, 6) + " "; billText += FormatBillNum(item.FullPrice * item.Quantity, 6); + foreach (var mod in item.InventoryModifier.Where(x => x.Modifier.ShowInBill)) + { + billText += "\n\r -- " + FormatText(mod.Modifier.Name, 38, Align.Left); + } } billText += "\n\r" + "------------------------------------------"; return billText; diff --git a/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs index e6d3bb9..9e0e4c9 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs @@ -3,6 +3,7 @@ using Tanshu.Accounts.Entities; using System.Linq; using System; using System.Collections.Generic; +using System.Linq.Expressions; namespace Tanshu.Accounts.Repository { @@ -14,7 +15,22 @@ namespace Tanshu.Accounts.Repository .OrderBy(x => x.SortOrder).Asc .List(); } - - + public new IList List(Expression> query) + { + return _session.QueryOver() + .Where(query) + .OrderBy(x => x.SortOrder).Asc + .List(); + } + public void UpdateSortOrder(IList list) + { + for (int i = 0; i < list.Count; i++) + { + var item = list[i]; + var foodTable = _session.Get(item.FoodTableID); + foodTable.SortOrder = i; + _session.Update(foodTable); + } + } } } \ No newline at end of file diff --git a/Tanshu.Accounts.Repository/BusinessLayer/GroupBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/GroupBI.cs new file mode 100644 index 0000000..549ccbb --- /dev/null +++ b/Tanshu.Accounts.Repository/BusinessLayer/GroupBI.cs @@ -0,0 +1,47 @@ +using System; +using System.Linq; +using Tanshu.Accounts.Entities.Auth; +using System.Collections.Generic; + +namespace Tanshu.Accounts.Repository +{ + public class GroupBI : UnitOfWork + { + public new IList List() + { + return _session.QueryOver() + .OrderBy(x => x.Name).Asc + .List(); + + } + public IList RoleList() + { + return _session.QueryOver() + .OrderBy(x => x.Name).Asc + .List(); + } + public void Update(Group group, IEnumerable selectedRoles) + { + var roles = new Dictionary(); + foreach (var item in RoleList()) + { + roles.Add(item, selectedRoles.Any(x => x.RoleID == item.RoleID)); + } + foreach (var item in roles) + { + var id = item.Key.RoleID; + var ug = group.RoleGroups.SingleOrDefault(x => x.Role.RoleID == id); + if (item.Value && ug == null) + { + var rg = new RoleGroup() { Group = group, Role = item.Key }; + _session.Save(rg); + } + else if (!item.Value && ug != null) + { + group.RoleGroups.Remove(ug); + _session.Delete(ug); + } + } + } + } +} diff --git a/Tanshu.Accounts.Repository/BusinessLayer/MembershipBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/MembershipBI.cs deleted file mode 100644 index 3d5487d..0000000 --- a/Tanshu.Accounts.Repository/BusinessLayer/MembershipBI.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System.Collections.Generic; -using Tanshu.Accounts.Entities.Auth; -using NHibernate; -using System; - -namespace Tanshu.Accounts.Repository -{ - public class MembershipBI : UnitOfWork - { - public static bool IsUserInRole(Guid userID, string roleName) - { - string query = @" -SELECT COUNT(*) AS Role_Count FROM -Auth_UserGroups ug INNER JOIN Auth_RoleGroups rg ON ug.GroupID = rg.GroupID -INNER JOIN Auth_Roles r ON rg.RoleID = r.RoleID -WHERE ug.UserID = :UserID AND r.Name = :Role;"; - using (var session = SessionManager.Session) - { - return session - .CreateSQLQuery(query) - .AddScalar("Role_Count", NHibernateUtil.Int32) - .SetGuid("UserID", userID) - .SetString("Role", roleName) - .UniqueResult() > 0; - } - } - #region UserGroup - public static IList GetGroups() - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .List(); - } - } - public static IList GetGroupsOfUser(Guid userID) - { - using (var session = SessionManager.Session) - { - string query = "select ug.Group from UserGroup ug where ug.User.UserID = :userID"; - var list = session.CreateQuery(query) - .SetParameter("userID", userID) - .List(); - foreach (var item in list) - NHibernateUtil.Initialize(item); - return list; - } - } - public static IList GetGroupsNotOfUser(Guid userID) - { - using (var session = SessionManager.Session) - { - string query = "select g from Group g where g not in (select ug.Group from UserGroup ug where ug.User.UserID = :userID)"; - var list = session.CreateQuery(query) - .SetParameter("userID", userID) - .List(); - foreach (var item in list) - NHibernateUtil.Initialize(item); - return list; - } - } - public static void AddUserToGroup(Guid userID, Guid groupID) - { - using (var session = SessionManager.Session) - { - var userGroup = session.CreateQuery("select count(*) from UserGroup ug where ug.User.UserID = :userID and ug.Group.GroupID = :groupID") - .SetParameter("userID", userID) - .SetParameter("groupID", groupID) - .UniqueResult(); - if (userGroup == 0) - { - var user = session.Get(userID); - var group = session.Get(groupID); - session.Save(new UserGroup() { User = user, Group = group }); - } - } - } - public static void RemoveUserFromGroup(Guid userID, Guid groupID) - { - using (var session = SessionManager.Session) - { - string query = "delete UserGroup ug where ug.User.UserID = :userID and ug.Group.GroupID = :groupID"; - session.CreateQuery(query) - .SetParameter("userID", userID) - .SetParameter("groupID", groupID) - .ExecuteUpdate(); - } - } - #endregion - #region RoleGroup - public static IList GetRoles() - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .List(); - } - } - public static IList GetRolesOfGroup(int groupID) - { - using (var session = SessionManager.Session) - { - string query = "select rg.Role from RoleGroup rg where rg.Group.GroupID = :groupID"; - var list = session.CreateQuery(query) - .SetParameter("groupID", groupID) - .List(); - foreach (var item in list) - NHibernateUtil.Initialize(item); - return list; - } - } - public static IList GetRolesNotOfGroup(int groupID) - { - using (var session = SessionManager.Session) - { - string query = "select r from Role r where r not in (select rg.Role from RoleGroup rg where rg.Group.GroupID = :groupID)"; - var list = session.CreateQuery(query) - .SetParameter("groupID", groupID) - .List(); - foreach (var item in list) - NHibernateUtil.Initialize(item); - return list; - } - } - public static void AddRoleToGroup(Guid roleID, Guid groupID) - { - using (var session = SessionManager.Session) - { - var roleGroup = session.CreateQuery("select count(*) from RoleGroup rg where rg.Role.RoleID = :roleID and rg.Group.GroupID = :groupID") - .SetParameter("roleID", roleID) - .SetParameter("groupID", groupID) - .UniqueResult(); - if (roleGroup == 0) - { - var role = session.Get(roleID); - var group = session.Get(groupID); - session.Save(new RoleGroup() { Role = role, Group = group }); - } - } - } - public static void RemoveRoleFromGroup(Guid roleID, Guid groupID) - { - using (var session = SessionManager.Session) - { - string query = "delete RoleGroup rg where rg.Role.RoleID = :roleID and rg.Group.GroupID = :groupID"; - session.CreateQuery(query) - .SetParameter("roleID", roleID) - .SetParameter("groupID", groupID) - .ExecuteUpdate(); - } - } - #endregion - - - } -} diff --git a/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs index 21c74df..ba426cb 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs @@ -1,9 +1,80 @@ -using NHibernate; +using System.Collections.Generic; +using System.Linq; using Tanshu.Accounts.Entities; namespace Tanshu.Accounts.Repository { public class ModifierBI : UnitOfWork { + public IList ProductGroupList() + { + return _session.QueryOver() + .OrderBy(x => x.SortOrder).Asc + .List(); + } + public void Insert(Modifier modifier, bool showForAll, IEnumerable selectedGroups) + { + if (showForAll) + selectedGroups = null; + SetGroups(modifier, selectedGroups); + _session.Save(modifier); + } + + public void Update(Modifier modifier, bool showForAll, IEnumerable selectedGroups) + { + if (showForAll) + selectedGroups = null; + SetGroups(modifier, selectedGroups); + _session.Update(modifier); + } + private void SetGroups(Modifier modifier, IEnumerable selectedGroups) + { + if (selectedGroups == null) + { + var ug = modifier.ProductGroupModifiers.SingleOrDefault(x => x.ProductGroup == null); + var others = modifier.ProductGroupModifiers.Where(x => x.ProductGroup != null).ToList(); + for (var i = others.Count() -1; i >= 0; i--) + { + var item = others[i]; + modifier.ProductGroupModifiers.Remove(item); + _session.Delete(item); + } + if (ug == null) + { + var pgm = new ProductGroupModifier() { Modifier = modifier, ProductGroup = null, ShowAutomatically = false }; + _session.Save(pgm); + } + } + else + { + var groups = new Dictionary(); + foreach (var item in ProductGroupList()) + { + groups.Add(item, selectedGroups.Any(x => x.ProductGroupID == item.ProductGroupID)); + } + foreach (var item in groups) + { + var id = item.Key.ProductGroupID; + var ug = modifier.ProductGroupModifiers.SingleOrDefault(x =>x.ProductGroup != null && x.ProductGroup.ProductGroupID == id); + if (item.Value && ug == null) + { + var pgm = new ProductGroupModifier() { Modifier = modifier, ProductGroup = item.Key, ShowAutomatically = false }; + _session.Save(pgm); + } + else if (!item.Value && ug != null) + { + modifier.ProductGroupModifiers.Remove(ug); + _session.Delete(ug); + } + } + var blank = modifier.ProductGroupModifiers.SingleOrDefault(x => x.ProductGroup == null); + if (blank != null) + { + modifier.ProductGroupModifiers.Remove(blank); + _session.Delete(blank); + } + + } + } } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs index 18a26da..5c937a7 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs @@ -42,12 +42,11 @@ namespace Tanshu.Accounts.Repository } public void UpdateSortOrder(IList list) { - int order = 0; for (int i = 0; i < list.Count; i++) { var item = list[i]; var productGroup = _session.Get(item.ProductGroupID); - productGroup.SortOrder = order; + productGroup.SortOrder = i; _session.Update(productGroup); } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs index ddb4fc7..08d1775 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using NHibernate; using Tanshu.Accounts.Entities.Auth; @@ -8,6 +9,12 @@ namespace Tanshu.Accounts.Repository { public class UserBI : UnitOfWork { + public IList GroupList() + { + return _session.QueryOver() + .OrderBy(x => x.Name).Asc + .List(); + } public IList GetFilteredUsers(Dictionary filter) { return _session.QueryOver() @@ -43,5 +50,35 @@ order by u.Name"; .SetParameter("finishDate", finishDate) .List(); } + public void Update(User user, IEnumerable selectedGroups) + { + var roles = new Dictionary(); + foreach (var item in GroupList()) + { + roles.Add(item, selectedGroups.Any(x => x.GroupID == item.GroupID)); + } + foreach (var item in roles) + { + var id = item.Key.GroupID; + var ug = user.UserGroups.SingleOrDefault(x => x.Group.GroupID == id); + if (item.Value && ug == null) + { + var rg = new UserGroup() { User = user, Group = item.Key }; + _session.Save(rg); + } + else if (!item.Value && ug != null) + { + user.UserGroups.Remove(ug); + _session.Delete(ug); + } + } + } + public bool IsUserInRole(Guid userID, string roleName) + { + var user = _session.QueryOver() + .Where(x => x.UserID == userID) + .SingleOrDefault(); + return user.UserGroups.SelectMany(x => x.Group.RoleGroups).Any(y=>y.Role.Name == roleName); + } } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs index 2baa990..bbc33da 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs @@ -28,7 +28,7 @@ namespace Tanshu.Accounts.Repository item.Voucher = voucher; item.Date = dt; item.Printed = true; - item.TableID = voucher.TableID; + item.Table = voucher.Table; item.User = voucher.User; item.Code = DbValues.KotCode; UpdateBillType(voucher); @@ -58,7 +58,7 @@ namespace Tanshu.Accounts.Repository var kotID = Insert(voucher); if (updateTable) { - var table = _session.QueryOver().Where(x => x.Name == voucher.TableID).SingleOrDefault(); + var table = _session.QueryOver().Where(x => x.FoodTableID == voucher.Table.FoodTableID).SingleOrDefault(); if (table.VoucherID.HasValue) throw new ValidationException("A bill exists on this table, cannot overwrite"); var status = !voucher.Printed ? "running" : "printed"; @@ -86,7 +86,7 @@ namespace Tanshu.Accounts.Repository item.Voucher = voucher; item.Date = dt; item.Printed = true; - item.TableID = voucher.TableID; + item.Table = voucher.Table; item.User = voucher.User; item.Code = DbValues.KotCode; _session.Save(item); @@ -124,7 +124,7 @@ namespace Tanshu.Accounts.Repository var kotID = Update(voucher); if (updateTable) { - var table = _session.QueryOver().Where(x => x.Name == voucher.TableID).SingleOrDefault(); + var table = _session.QueryOver().Where(x => x.FoodTableID == voucher.Table.FoodTableID).SingleOrDefault(); var status = !voucher.Printed ? "running" : "printed"; table.VoucherID = voucher.VoucherID; table.Status = status; @@ -140,6 +140,7 @@ namespace Tanshu.Accounts.Repository NHibernateUtil.Initialize(voucher.Customer); NHibernateUtil.Initialize(voucher.Waiter); NHibernateUtil.Initialize(voucher.User); + NHibernateUtil.Initialize(voucher.Table); foreach (var kot in voucher.Kots) { NHibernateUtil.Initialize(kot); @@ -166,7 +167,7 @@ namespace Tanshu.Accounts.Repository if (updateTable) { - var table = _session.QueryOver().Where(x => x.Name == voucher.TableID).SingleOrDefault(); + var table = _session.QueryOver().Where(x => x.FoodTableID == voucher.Table.FoodTableID).SingleOrDefault(); table.VoucherID = null; table.Status = null; _session.Update(table); @@ -206,7 +207,7 @@ namespace Tanshu.Accounts.Repository _session.Update(newVoucher); - var oldTable = _session.QueryOver().Where(x => x.Name == oldVoucher.TableID).SingleOrDefault(); + var oldTable = _session.QueryOver().Where(x => x.FoodTableID == oldVoucher.Table.FoodTableID).SingleOrDefault(); foreach (var item in oldVoucher.Settlements) { _session.Delete(item); @@ -249,13 +250,13 @@ namespace Tanshu.Accounts.Repository } } - public Guid MoveKot(Guid kotID, string tableName) + public Guid MoveKot(Guid kotID, Guid tableID) { var kot = _session.Get(kotID); var oldVoucher = _session.Get(kot.Voucher.VoucherID); - var newVoucher = new Voucher(Session.User, oldVoucher.Customer, tableName, oldVoucher.Waiter, false, false, ""); + var table = _session.QueryOver().Where(x => x.FoodTableID == tableID).SingleOrDefault(); + var newVoucher = new Voucher(Session.User, oldVoucher.Customer, table, oldVoucher.Waiter, false, false, ""); Insert(newVoucher); - var table = _session.QueryOver().Where(x => x.Name == tableName).SingleOrDefault(); table.VoucherID = newVoucher.VoucherID; table.Status = "running"; _session.Update(table); @@ -284,14 +285,14 @@ namespace Tanshu.Accounts.Repository Update(oldVoucher); var status = oldVoucher.Printed ? "printed" : "running"; - var tableFirst = _session.QueryOver().Where(x => x.Name == first.TableID).SingleOrDefault(); + var tableFirst = _session.QueryOver().Where(x => x.FoodTableID == first.Table.FoodTableID).SingleOrDefault(); if (tableFirst.VoucherID.HasValue) throw new ValidationException("A bill exists on this table, cannot overwrite"); tableFirst.VoucherID = first.VoucherID; tableFirst.Status = status; _session.Update(tableFirst); - var tableSecond = _session.QueryOver().Where(x => x.Name == second.TableID).SingleOrDefault(); + var tableSecond = _session.QueryOver().Where(x => x.FoodTableID == second.Table.FoodTableID).SingleOrDefault(); tableSecond.VoucherID = first.VoucherID; tableSecond.Status = status; _session.Update(tableFirst); @@ -307,15 +308,15 @@ namespace Tanshu.Accounts.Repository Insert(newVoucher); Update(oldVoucher); - var table = _session.QueryOver().Where(x => x.Name == oldVoucher.TableID).SingleOrDefault(); + var table = _session.QueryOver().Where(x => x.FoodTableID == oldVoucher.Table.FoodTableID).SingleOrDefault(); table.VoucherID = newVoucher.VoucherID; table.Status = "printed"; _session.Update(table); } - public Guid Move(string oldTableName, string newTableName) + public Guid Move(Guid oldTableID, Guid newTableID) { - var oldTable = _session.QueryOver().Where(x => x.Name == oldTableName).SingleOrDefault(); - var newTable = _session.QueryOver().Where(x => x.Name == newTableName).SingleOrDefault(); + var oldTable = _session.QueryOver().Where(x => x.FoodTableID == oldTableID).SingleOrDefault(); + var newTable = _session.QueryOver().Where(x => x.FoodTableID == newTableID).SingleOrDefault(); var voucher = _session.Get(oldTable.VoucherID); newTable.Status = oldTable.Status; @@ -324,7 +325,7 @@ namespace Tanshu.Accounts.Repository oldTable.Status = null; oldTable.VoucherID = null; - voucher.TableID = newTable.Name; + voucher.Table = newTable; _session.Update(newTable); _session.Update(oldTable); diff --git a/Tanshu.Accounts.Repository/BusinessLayer/VoucherSettlementBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/VoucherSettlementBI.cs index 7106f9d..8ec786c 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/VoucherSettlementBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/VoucherSettlementBI.cs @@ -70,7 +70,7 @@ namespace Tanshu.Accounts.Repository if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) == 0 || voucher.Void) { var table = _session.QueryOver() - .Where(x => x.Name == voucher.TableID && x.VoucherID == voucher.VoucherID) + .Where(x => x.FoodTableID == voucher.Table.FoodTableID && x.VoucherID == voucher.VoucherID) .SingleOrDefault(); if (table != null) { diff --git a/Tanshu.Accounts.Repository/Session.cs b/Tanshu.Accounts.Repository/Session.cs index 06dcd68..f688c96 100644 --- a/Tanshu.Accounts.Repository/Session.cs +++ b/Tanshu.Accounts.Repository/Session.cs @@ -30,17 +30,15 @@ namespace Tanshu.Accounts.Contracts } } } - public static bool IsAllowed(RoleConstants role) + public static bool IsAllowed(string role) { if (_currentUser == null) return false; if (_roles == null) _roles = new Dictionary(); - if (!_roles.ContainsKey(role.Role)) - _roles.Add(role.Role, MembershipBI.IsUserInRole(_currentUser.UserID, role.Role)); - return _roles[role.Role]; - - + if (!_roles.ContainsKey(role)) + _roles.Add(role, new UserBI().IsUserInRole(_currentUser.UserID, role)); + return _roles[role]; } } } diff --git a/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj b/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj index b0a4ef2..3239c83 100644 --- a/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj +++ b/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj @@ -64,15 +64,13 @@ + Code - - Code -