Chore: Added full name property to product

Chore: Removed GetButton Function in ControlFactory.
This commit is contained in:
tanshu 2016-03-29 12:52:33 +05:30
parent 2c206b059a
commit 4ac6f66041
2 changed files with 61 additions and 20 deletions

View File

@ -24,6 +24,13 @@ namespace Tanshu.Accounts.Entities
public virtual decimal Quantity { get; set; }
public virtual IList<Inventory> Inventories { get; set; }
public virtual string FullName
{
get
{
return Units == string.Empty ? Name : string.Format("{0} ({1})", Name, Units);
}
}
}
public class ProductMap : ClassMapping<Product>
{

View File

@ -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()