From 853fad06921adfd51fac3e40513d653fc3ad60d1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Jan 2011 05:06:24 +0530 Subject: [PATCH] Partly working --- Tanshu.Accounts.BI/FoodTableBI.cs | 69 +++ Tanshu.Accounts.BI/ProductBI.cs | 4 +- Tanshu.Accounts.BI/ProductTypeBI.cs | 69 +++ Tanshu.Accounts.BI/Tanshu.Accounts.BI.csproj | 2 + .../DAOFactory/FoodTableDAO.cs | 15 + .../DAOFactory/ProductDAO.cs | 5 +- .../DAOFactory/ProductTypeDAO.cs | 17 + .../Data Contracts/FoodTableBO.cs | 11 + .../Data Contracts/SalesBillItemBO.cs | 2 +- .../Service Contracts/FoodTableBI.cs | 18 + .../Service Contracts/ProductBI.cs | 12 +- .../Service Contracts/ProductTypesBI.cs | 19 + .../Tanshu.Accounts.Contracts.csproj | 5 + Tanshu.Accounts.DAOFactory/DAOFactory.cs | 2 + .../SqlServerDAOFactory.cs | 9 + Tanshu.Accounts.Helpers/ControlFactory.cs | 107 +++- Tanshu.Accounts.PointOfSale/App.config | 2 +- .../Authentication/LoginForm.cs | 2 - Tanshu.Accounts.PointOfSale/ProductsForm.cs | 2 +- .../Sales/SalesForm.Designer.cs | 544 ++---------------- .../Sales/SalesForm.cs | 439 +++++--------- .../Sales/SalesForm.resx | 30 +- Tanshu.Accounts.SqlDAO/FoodTableDAO.cs | 43 ++ Tanshu.Accounts.SqlDAO/ProductDAO.cs | 31 +- Tanshu.Accounts.SqlDAO/ProductTypeDAO.cs | 86 +++ .../Tanshu.Accounts.SqlDAO.csproj | 2 + 26 files changed, 706 insertions(+), 841 deletions(-) create mode 100644 Tanshu.Accounts.BI/FoodTableBI.cs create mode 100644 Tanshu.Accounts.BI/ProductTypeBI.cs create mode 100644 Tanshu.Accounts.Contracts/DAOFactory/FoodTableDAO.cs create mode 100644 Tanshu.Accounts.Contracts/DAOFactory/ProductTypeDAO.cs create mode 100644 Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs create mode 100644 Tanshu.Accounts.Contracts/Service Contracts/FoodTableBI.cs create mode 100644 Tanshu.Accounts.Contracts/Service Contracts/ProductTypesBI.cs create mode 100644 Tanshu.Accounts.SqlDAO/FoodTableDAO.cs create mode 100644 Tanshu.Accounts.SqlDAO/ProductTypeDAO.cs diff --git a/Tanshu.Accounts.BI/FoodTableBI.cs b/Tanshu.Accounts.BI/FoodTableBI.cs new file mode 100644 index 0000000..84dacbd --- /dev/null +++ b/Tanshu.Accounts.BI/FoodTableBI.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Tanshu.Accounts.Contracts; +using Tanshu.Accounts.DAOFactory; +using System.Data.SqlClient; +using Tanshu.Data.DAO; + +namespace Tanshu.Accounts.BI +{ + public class FoodTableBI : IFoodTableBI + { + public void Insert(FoodTableBO foodTable) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (IFoodTableDAO dao = factory.GetFoodTableDAO(connection)) + { + dao.Insert(foodTable); + } + } + } + public void Update(FoodTableBO foodTable) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (IFoodTableDAO dao = factory.GetFoodTableDAO(connection)) + { + dao.Update(foodTable); + } + } + } + public bool Delete(int tableID) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (IFoodTableDAO dao = factory.GetFoodTableDAO(connection)) + { + return dao.Delete(tableID); + } + } + } + public FoodTableBO GetFoodTable(int tableID) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (IFoodTableDAO dao = factory.GetFoodTableDAO(connection)) + { + return dao.GetFoodTable(tableID); + } + } + } + public List GetFoodTables() + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (IFoodTableDAO dao = factory.GetFoodTableDAO(connection)) + { + return dao.GetFoodTables(); + } + } + } + } +} diff --git a/Tanshu.Accounts.BI/ProductBI.cs b/Tanshu.Accounts.BI/ProductBI.cs index 21dcea1..37a42d2 100644 --- a/Tanshu.Accounts.BI/ProductBI.cs +++ b/Tanshu.Accounts.BI/ProductBI.cs @@ -119,14 +119,14 @@ namespace Tanshu.Accounts.BI filter.Add("Type", ""); return GetFilteredProducts(filter); } - public List GetProductTypes() + public List GetProducts(Guid productTypeID) { GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); using (IConnectionDAO connection = factory.Connection) { using (IProductDAO dao = factory.GetProductDAO(connection)) { - return dao.GetProductTypes(); + return dao.GetProducts(productTypeID); } } } diff --git a/Tanshu.Accounts.BI/ProductTypeBI.cs b/Tanshu.Accounts.BI/ProductTypeBI.cs new file mode 100644 index 0000000..e13624d --- /dev/null +++ b/Tanshu.Accounts.BI/ProductTypeBI.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Tanshu.Accounts.Contracts; +using Tanshu.Accounts.DAOFactory; +using System.Data.SqlClient; +using Tanshu.Data.DAO; + +namespace Tanshu.Accounts.BI +{ + public class ProductTypeBI : IProductTypeBI + { + public ProductTypeBO GetProductType(Guid productTypeID) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (var dao = factory.GetProductTypeDAO(connection)) + { + return dao.GetProductType(productTypeID); + } + } + } + public ProductTypeBO GetProductTypeByName(string name) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (var dao = factory.GetProductTypeDAO(connection)) + { + return dao.GetProductType(name); + } + } + } + public bool Insert(ProductTypeBO productType) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (var dao = factory.GetProductTypeDAO(connection)) + { + return dao.Insert(productType); + } + } + } + public bool Update(ProductTypeBO productType) + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (var dao = factory.GetProductTypeDAO(connection)) + { + return dao.Update(productType); + } + } + } + public List GetProductTypes() + { + GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType); + using (IConnectionDAO connection = factory.Connection) + { + using (var dao = factory.GetProductTypeDAO(connection)) + { + return dao.GetProductTypes(); + } + } + } + } +} diff --git a/Tanshu.Accounts.BI/Tanshu.Accounts.BI.csproj b/Tanshu.Accounts.BI/Tanshu.Accounts.BI.csproj index 77622f1..7910111 100644 --- a/Tanshu.Accounts.BI/Tanshu.Accounts.BI.csproj +++ b/Tanshu.Accounts.BI/Tanshu.Accounts.BI.csproj @@ -64,6 +64,8 @@ + + diff --git a/Tanshu.Accounts.Contracts/DAOFactory/FoodTableDAO.cs b/Tanshu.Accounts.Contracts/DAOFactory/FoodTableDAO.cs new file mode 100644 index 0000000..a4052bb --- /dev/null +++ b/Tanshu.Accounts.Contracts/DAOFactory/FoodTableDAO.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using Tanshu.Accounts.Contracts; + +namespace Tanshu.Accounts.DAOFactory +{ + public interface IFoodTableDAO : IDisposable + { + void Insert(FoodTableBO foodTable); + void Update(FoodTableBO foodTable); + bool Delete(int tableID); + FoodTableBO GetFoodTable(int tableID); + List GetFoodTables(); + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/DAOFactory/ProductDAO.cs b/Tanshu.Accounts.Contracts/DAOFactory/ProductDAO.cs index 273764d..6399661 100644 --- a/Tanshu.Accounts.Contracts/DAOFactory/ProductDAO.cs +++ b/Tanshu.Accounts.Contracts/DAOFactory/ProductDAO.cs @@ -19,8 +19,9 @@ namespace Tanshu.Accounts.DAOFactory List GetFilteredProducts(Dictionary filter); - List GetProductTypes(); - List GetProducts(string name, int skip, int count); + + List GetProducts(Guid productTypeID); + } } diff --git a/Tanshu.Accounts.Contracts/DAOFactory/ProductTypeDAO.cs b/Tanshu.Accounts.Contracts/DAOFactory/ProductTypeDAO.cs new file mode 100644 index 0000000..590a84e --- /dev/null +++ b/Tanshu.Accounts.Contracts/DAOFactory/ProductTypeDAO.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using Tanshu.Accounts.Contracts; + +namespace Tanshu.Accounts.DAOFactory +{ + public interface IProductTypeDAO : IDisposable + { + bool Insert(ProductTypeBO productType); + ProductTypeBO GetProductType(Guid productTypeID); + ProductTypeBO GetProductType(string name); + bool Delete(Guid productTypeID); + bool Update(ProductTypeBO productType); + List GetProductTypes(); + + } +} diff --git a/Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs new file mode 100644 index 0000000..cade291 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Data Contracts/FoodTableBO.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.Serialization; + +namespace Tanshu.Accounts.Contracts +{ + public class FoodTableBO + { + public int TableID { get; set; } + public string Name { get; set; } + } +} diff --git a/Tanshu.Accounts.Contracts/Data Contracts/SalesBillItemBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/SalesBillItemBO.cs index 89d591e..7565367 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/SalesBillItemBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/SalesBillItemBO.cs @@ -18,7 +18,7 @@ namespace Tanshu.Accounts.Contracts get { return price; } set { - if (value <= 0) + if (value < 0) throw new ArgumentException("Price has to be non-negative greater than zero."); else price = value; diff --git a/Tanshu.Accounts.Contracts/Service Contracts/FoodTableBI.cs b/Tanshu.Accounts.Contracts/Service Contracts/FoodTableBI.cs new file mode 100644 index 0000000..df31a2a --- /dev/null +++ b/Tanshu.Accounts.Contracts/Service Contracts/FoodTableBI.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ServiceModel; + +using System.Data.SqlClient; + +namespace Tanshu.Accounts.Contracts +{ + public interface IFoodTableBI + { + void Insert(FoodTableBO foodTable); + void Update(FoodTableBO foodTable); + bool Delete(int tableID); + FoodTableBO GetFoodTable(int tableID); + List GetFoodTables(); + } +} diff --git a/Tanshu.Accounts.Contracts/Service Contracts/ProductBI.cs b/Tanshu.Accounts.Contracts/Service Contracts/ProductBI.cs index a8e3cb2..a0b319f 100644 --- a/Tanshu.Accounts.Contracts/Service Contracts/ProductBI.cs +++ b/Tanshu.Accounts.Contracts/Service Contracts/ProductBI.cs @@ -6,26 +6,16 @@ using System.Data.SqlClient; namespace Tanshu.Accounts.Contracts { - [ServiceContract] public interface IProductBI { - [OperationContract] bool Insert(ProductBO product); - [OperationContract] bool Update(ProductBO product); - [OperationContract] bool Delete(Guid productID); - [OperationContract] ProductBO GetProductFromName(string nameAndUnits); - [OperationContract] ProductBO GetProduct(Guid productID); - [OperationContract] decimal GetProductStock(DateTime date, Guid productID, Guid? voucherID); - [OperationContract] List GetProducts(); - [OperationContract] List GetFilteredProducts(Dictionary filter); - [OperationContract] - List GetProductTypes(); + List GetProducts(Guid productTypeID); } } diff --git a/Tanshu.Accounts.Contracts/Service Contracts/ProductTypesBI.cs b/Tanshu.Accounts.Contracts/Service Contracts/ProductTypesBI.cs new file mode 100644 index 0000000..83aa989 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Service Contracts/ProductTypesBI.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ServiceModel; + +using System.Data.SqlClient; + +namespace Tanshu.Accounts.Contracts +{ + public interface IProductTypeBI + { + ProductTypeBO GetProductType(Guid productTypeID); + + ProductTypeBO GetProductTypeByName(string name); + bool Insert(ProductTypeBO productType); + bool Update(ProductTypeBO productType); + List GetProductTypes(); + } +} diff --git a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj index 8b1abd7..8a88cdd 100644 --- a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj +++ b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj @@ -56,6 +56,8 @@ + + @@ -74,6 +76,7 @@ + @@ -109,6 +112,8 @@ + + diff --git a/Tanshu.Accounts.DAOFactory/DAOFactory.cs b/Tanshu.Accounts.DAOFactory/DAOFactory.cs index e18c37c..66d07e9 100644 --- a/Tanshu.Accounts.DAOFactory/DAOFactory.cs +++ b/Tanshu.Accounts.DAOFactory/DAOFactory.cs @@ -19,12 +19,14 @@ namespace Tanshu.Accounts.DAOFactory public abstract IAdvanceDAO GetAdvanceDAO(IConnectionDAO connection); public abstract ICheckoutDAO GetCheckoutDAO(DateTime startDate, DateTime finishDate, Guid userID, IConnectionDAO connection); public abstract ICustomerDAO GetCustomerDAO(IConnectionDAO connection); + public abstract IFoodTableDAO GetFoodTableDAO(IConnectionDAO connection); public abstract IInventoryDAO GetInventoryDAO(IConnectionDAO connection); public abstract ILedgerDAO GetLedgerDAO(IConnectionDAO connection); public abstract IManagementDAO GetManagementDAO(DateTime startDate, DateTime finishDate, IConnectionDAO connection); public abstract IMembershipDAO GetMembershipDAO(IConnectionDAO connection); public abstract IPaymentDAO GetPaymentDAO(IConnectionDAO connection); public abstract IProductDAO GetProductDAO(IConnectionDAO connection); + public abstract IProductTypeDAO GetProductTypeDAO(IConnectionDAO connection); public abstract ISalesAnalysisDAO GetSalesAnalysisDAO(IConnectionDAO connection); public abstract ISaleVoucherDAO GetSaleVoucherDAO(IConnectionDAO connection); public abstract ISaleVoucherMixDAO GetSaleVoucherMixDAO(IConnectionDAO connection); diff --git a/Tanshu.Accounts.DAOFactory/SqlServerDAOFactory.cs b/Tanshu.Accounts.DAOFactory/SqlServerDAOFactory.cs index 55a9676..7d248fd 100644 --- a/Tanshu.Accounts.DAOFactory/SqlServerDAOFactory.cs +++ b/Tanshu.Accounts.DAOFactory/SqlServerDAOFactory.cs @@ -29,6 +29,11 @@ namespace Tanshu.Accounts.DAOFactory return new CustomerDAO(connection); } + public override IFoodTableDAO GetFoodTableDAO(IConnectionDAO connection) + { + return new FoodTableDAO(connection); + } + public override IInventoryDAO GetInventoryDAO(IConnectionDAO connection) { return new InventoryDAO(connection); @@ -58,6 +63,10 @@ namespace Tanshu.Accounts.DAOFactory { return new ProductDAO(connection); } + public override IProductTypeDAO GetProductTypeDAO(IConnectionDAO connection) + { + return new ProductTypeDAO(connection); + } public override ISalesAnalysisDAO GetSalesAnalysisDAO(IConnectionDAO connection) { diff --git a/Tanshu.Accounts.Helpers/ControlFactory.cs b/Tanshu.Accounts.Helpers/ControlFactory.cs index 3392dab..7bb88ca 100644 --- a/Tanshu.Accounts.Helpers/ControlFactory.cs +++ b/Tanshu.Accounts.Helpers/ControlFactory.cs @@ -10,39 +10,122 @@ namespace Tanshu.Accounts.Helpers { public static class ControlFactory { - public static void GenerateButtons(ref Panel panel, Rectangle clientArea, int x, int y, int border, List list, ButtonClickDelegate bcDelegate) + public static void GenerateButtons(ref Panel panel, ref List