From 4ac6f66041b7dc27b57eacb1a6f939a87d984519 Mon Sep 17 00:00:00 2001 From: tanshu Date: Tue, 29 Mar 2016 12:52:33 +0530 Subject: [PATCH] Chore: Added full name property to product Chore: Removed GetButton Function in ControlFactory. --- .../Data Contracts/ProductBO.cs | 7 ++ Tanshu.Accounts.Helpers/ControlFactory.cs | 74 ++++++++++++++----- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs index cf31593..0003c59 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs @@ -24,6 +24,13 @@ namespace Tanshu.Accounts.Entities public virtual decimal Quantity { get; set; } public virtual IList Inventories { get; set; } + public virtual string FullName + { + get + { + return Units == string.Empty ? Name : string.Format("{0} ({1})", Name, Units); + } + } } public class ProductMap : ClassMapping { diff --git a/Tanshu.Accounts.Helpers/ControlFactory.cs b/Tanshu.Accounts.Helpers/ControlFactory.cs index 30911c9..e1b2d6a 100644 --- a/Tanshu.Accounts.Helpers/ControlFactory.cs +++ b/Tanshu.Accounts.Helpers/ControlFactory.cs @@ -34,13 +34,29 @@ namespace Tanshu.Accounts.Helpers if (item.FoodTableID == Guid.Empty) { var pageLocation = item.Name == "Previous" ? start - pageLength : stop; - control = GetButton(string.Format("p{0}", i), item.Name, size, pageLocation, pageDelegate); + control = new Button() + { + Name = string.Format("p{0}", i), + Text = item.Name, + Width = size.X, + Height = size.Y, + Tag = pageLocation, + }; + control.Click += new EventHandler(pageDelegate); status = "paging"; } else { status = item.Status; - control = GetButton(string.Format("g{0}", i), item.Name, size, item, bcDelegate); + control = new Button() + { + Name = string.Format("g{0}", i), + Text = item.Name, + Width = size.X, + Height = size.Y, + Tag = item, + }; + control.Click += new EventHandler(bcDelegate); } if (status == "printed") control.BackColor = Color.Green; @@ -70,11 +86,27 @@ namespace Tanshu.Accounts.Helpers if (item.ProductID == Guid.Empty) { var pageLocation = item.Name == "Previous" ? start - pageLength : stop; - control = GetButton(string.Format("p{0}", i), item.Name, size, pageLocation, pageDelegate); + control = new Button() + { + Name = string.Format("p{0}", i), + Text = item.Name, + Width = size.X, + Height = size.Y, + Tag = pageLocation, + }; + control.Click += new EventHandler(pageDelegate); } else { - control = GetButton(string.Format("p{0}", i), item.Units == string.Empty ? item.Name : string.Format("{0} ({1})", item.Name, item.Units), size, item, bcDelegate); + control = new Button() + { + Name = string.Format("p{0}", i), + Text = item.FullName, + Width = size.X, + Height = size.Y, + Tag = item, + }; + control.Click += new EventHandler(bcDelegate); if (item.Price == 0) control.BackColor = Color.Yellow; if (item.IsNotAvailable) @@ -116,11 +148,27 @@ namespace Tanshu.Accounts.Helpers if (item.ProductGroupID == Guid.Empty) { var pageLocation = item.Name == "Previous" ? start - pageLength : stop; - control = GetButton(string.Format("p{0}", i), item.Name, size, pageLocation, pageDelegate); + control = new Button() + { + Name = string.Format("p{0}", i), + Text = item.Name, + Width = size.X, + Height = size.Y, + Tag = pageLocation, + }; + control.Click += new EventHandler(pageDelegate); } else { - control = GetButton(string.Format("g{0}", i), item.Name, size, item, bcDelegate); + control = new Button() + { + Name = string.Format("g{0}", i), + Text = item.Name, + Width = size.X, + Height = size.Y, + Tag = item, + }; + control.Click += new EventHandler(bcDelegate); } panel.Controls.Add(control); } @@ -169,20 +217,6 @@ namespace Tanshu.Accounts.Helpers stop = inList.Count; } } - private static Button GetButton(string name, string text, Point size, object tag, ButtonClickDelegate bcDelegate) - { - var control = new Button() - { - Name = name, - Text = text, - Width = size.X, - Height = size.Y, - Tag = tag, - }; - if (bcDelegate != null) - control.Click += new EventHandler(bcDelegate); - return control; - } private static UnselectableCheckbox GetUnselectableCheckbox(string name, string text, Point size, object tag, ButtonClickDelegate bcDelegate) { var control = new UnselectableCheckbox()