diff --git a/Include/Tanshu.Common.dll b/Include/Tanshu.Common.dll index 621f5d3..063d73d 100644 Binary files a/Include/Tanshu.Common.dll and b/Include/Tanshu.Common.dll differ diff --git a/Tanshu.Accounts.Contracts/Attributes/CascadeAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/CascadeAttribute.cs new file mode 100644 index 0000000..d6b3bb0 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Attributes/CascadeAttribute.cs @@ -0,0 +1,18 @@ +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/NotNullAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/NotNullAttribute.cs new file mode 100644 index 0000000..5c7a241 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Attributes/NotNullAttribute.cs @@ -0,0 +1,18 @@ +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/SecutiryAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/SecutiryAttribute.cs new file mode 100644 index 0000000..4f2fa58 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Attributes/SecutiryAttribute.cs @@ -0,0 +1,18 @@ +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/Data Contracts Display/BillInventoryBO.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs index c473592..87c4b48 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs @@ -11,31 +11,9 @@ namespace Tanshu.Accounts.Contracts public string Name { get; set; } - private decimal price; - public decimal Price - { - get { return price; } - set - { - if (value <= 0) - throw new ArgumentException("Price has to be non-negative greater than zero."); - else - price = value; - } - } + public decimal Price { get; set; } - private decimal quantity = 1; - public decimal Quantity - { - get { return quantity; } - set - { - if (value <= 0) - throw new ArgumentException("Quantity has to be non-negative greater than zero."); - quantity = value; - - } - } + public decimal Quantity { get; set; } private decimal discount = 0; public decimal Discount @@ -57,7 +35,7 @@ namespace Tanshu.Accounts.Contracts { get { - return quantity * price * (1 - discount) * (1 + ServiceCharge) * Tax; + return Quantity * Price * (1 - discount) * (1 + ServiceCharge) * Tax; } } @@ -66,7 +44,7 @@ namespace Tanshu.Accounts.Contracts { get { - return quantity * price * (1 - discount) * ServiceCharge; + return Quantity * Price * (1 - discount) * ServiceCharge; } } @@ -74,7 +52,7 @@ namespace Tanshu.Accounts.Contracts { get { - return quantity * price * discount; + return Quantity * Price * discount; } } @@ -82,7 +60,7 @@ namespace Tanshu.Accounts.Contracts { get { - return quantity * price * (1 - discount); + return Quantity * Price * (1 - discount); } } @@ -103,14 +81,14 @@ namespace Tanshu.Accounts.Contracts { get { - return price * quantity * (1 - discount) * (1 + ServiceCharge) * (1 + Tax); + return Price * Quantity * (1 - discount) * (1 + ServiceCharge) * (1 + Tax); } } public decimal Additional { get { - return quantity - printed; + return Quantity - printed; } } @@ -120,15 +98,29 @@ namespace Tanshu.Accounts.Contracts { get { - string output = string.Format("{0} @ Rs. {1:#.##}", Name, price); + string output = string.Format("{0} @ Rs. {1:#.##}", Name, Price); if (discount != 0) output += string.Format(" - {0:#.##%}", discount); + foreach (var item in Modifiers) + output += string.Format("\n\r -- {0}", item.Name); return output; + + //if (Price == 0) + // return string.Format(" -- {0}", Name); + //string output = string.Format("{0} @ Rs. {1:#.##}", Name, Price); + //if (discount != 0) + // output += string.Format(" - {0:#.##%}", discount); + //return output; } } + public override string ToString() + { + return string.Format("{0} - {1}", ProductID, Name); + } public IList Modifiers { get; set; } public BillInventory() { + Quantity = 1; printed = 0; isNew = true; Modifiers = new List(); diff --git a/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs index 2076513..441a5e8 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs @@ -5,10 +5,11 @@ namespace Tanshu.Accounts.Contracts { public class BillItemKey { - public BillItemKey(int productID, bool isNew) + //Old = 0, New = 1, Modifiers = 2+ + public BillItemKey(int ProductID, bool IsNew) { - ProductID = productID; - IsNew = isNew; + this.ProductID = ProductID; + this.IsNew = IsNew; } public int ProductID @@ -41,7 +42,7 @@ namespace Tanshu.Accounts.Contracts { if (object.ReferenceEquals(null, a)) return object.ReferenceEquals(null, b); - + if (!(a is BillItemKey)) return false; if (!(b is BillItemKey)) diff --git a/Tanshu.Accounts.Contracts/Data Contracts/InventoryBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/InventoryBO.cs index 6fc15b7..6ffcd5e 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/InventoryBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/InventoryBO.cs @@ -2,13 +2,16 @@ using System.Runtime.Serialization; using FluentNHibernate.Mapping; using System.Collections.Generic; +using Tanshu.Accounts.Contracts; namespace Tanshu.Accounts.Entities { public class Inventory { public virtual int InventoryID { get; set; } + [NotNull] public virtual Voucher Voucher { get; set; } + [NotNull] public virtual Product Product { get; set; } private decimal quantity; @@ -72,6 +75,7 @@ namespace Tanshu.Accounts.Entities } + [Cascade] public virtual IList InventoryModifier { get; set; } decimal? amount; diff --git a/Tanshu.Accounts.Contracts/Data Contracts/InventoryModifierBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/InventoryModifierBO.cs index 193b5b3..0ec01db 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/InventoryModifierBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/InventoryModifierBO.cs @@ -1,13 +1,16 @@ using System; using System.Runtime.Serialization; using FluentNHibernate.Mapping; +using Tanshu.Accounts.Contracts; namespace Tanshu.Accounts.Entities { public class InventoryModifier { public virtual int InventoryModifierID { get; set; } + [NotNull] public virtual Inventory Inventory { get; set; } + [NotNull] public virtual Modifier Modifier { get; set; } } } diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs index d57a716..5dc327f 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ModifierBO.cs @@ -1,6 +1,8 @@ using System; using System.Runtime.Serialization; using FluentNHibernate.Mapping; +using System.Collections.Generic; +using Tanshu.Accounts.Contracts; namespace Tanshu.Accounts.Entities { @@ -9,6 +11,9 @@ namespace Tanshu.Accounts.Entities public virtual int ModifierID { get; set; } public virtual string Name { get; set; } + [NotNull] + public virtual IList ProductGroupModifiers { get; set; } + public override int GetHashCode() { return ModifierID.GetHashCode() ^ Name.GetHashCode(); diff --git a/Tanshu.Accounts.Contracts/Data Contracts/PrintLocationBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/PrintLocationBO.cs index 102230d..1006e29 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/PrintLocationBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/PrintLocationBO.cs @@ -6,12 +6,12 @@ namespace Tanshu.Accounts.Entities { public class PrintLocation { - public int PrintLocationID { get; set; } - public ProductGroup ProductGroup { get; set; } - public string Location { get; set; } - public string Printer { get; set; } - public int Copies { get; set; } - public string CutCode { get; set; } + public virtual int PrintLocationID { get; set; } + public virtual ProductGroup ProductGroup { get; set; } + public virtual string Location { get; set; } + public virtual string Printer { get; set; } + public virtual int Copies { get; set; } + public virtual string CutCode { get; set; } public override bool Equals(System.Object obj) { diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs index 2c493c0..8ccbb05 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ProductBO.cs @@ -15,8 +15,6 @@ namespace Tanshu.Accounts.Entities public virtual decimal ServiceCharge { get; set; } public virtual decimal SalePrice { get; set; } public virtual bool Discontinued { get; set; } - public virtual decimal MinimumLevel { get; set; } - public virtual decimal MaximumLevel { get; set; } public virtual int SortOrder { get; set; } } } diff --git a/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs b/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs index 098f536..1ef7d55 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/SettleOption.cs @@ -7,8 +7,8 @@ namespace Tanshu.Accounts.Entities { public class SettleOption { - public int SettleOptionID { get; set; } - public string Name { get; set; } + public virtual int SettleOptionID { get; set; } + public virtual string Name { get; set; } public override bool Equals(System.Object obj) { diff --git a/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs index 44fe5ca..03cdb03 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/VoucherBO.cs @@ -3,6 +3,7 @@ using System.Runtime.Serialization; using FluentNHibernate.Mapping; using Tanshu.Accounts.Entities.Auth; using System.Collections.Generic; +using Tanshu.Accounts.Contracts; namespace Tanshu.Accounts.Entities { @@ -17,6 +18,7 @@ namespace Tanshu.Accounts.Entities public virtual DateTime CreationDate { get; set; } public virtual DateTime LastEditDate { get; set; } public virtual char Type { get; set; } + [Cascade] public virtual IList Inventories { get; set; } public Voucher() { diff --git a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj index 5375232..ddaef3f 100644 --- a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj +++ b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj @@ -85,6 +85,9 @@ + + + Code diff --git a/Tanshu.Accounts.Helpers/ControlFactory.cs b/Tanshu.Accounts.Helpers/ControlFactory.cs index 416c7ea..0df92ea 100644 --- a/Tanshu.Accounts.Helpers/ControlFactory.cs +++ b/Tanshu.Accounts.Helpers/ControlFactory.cs @@ -7,6 +7,8 @@ using System.Drawing; using Tanshu.Accounts.Contracts; using Tanshu.Accounts.Entities; using System.Collections; +using Tanshu.Accounts.Repository; +using Tanshu.Common.KeyboardControl; namespace Tanshu.Accounts.Helpers { @@ -31,7 +33,12 @@ namespace Tanshu.Accounts.Helpers for (int i = 0; i < list.Count; i++) { var item = list[i]; + var status = SaleVoucherBI.GetTableStatus(item.Name); var control = GetButton(string.Format("g{0}", i), item.Name, size.X, size.Y, item, bcDelegate); + if (status == "printed") + control.BackColor = Color.Green; + else if (status == "running") + control.BackColor = Color.Red; //var control = GetButton(string.Format("g{0}", i), string.Format("{0} {1}", item.ProductGroupID, item.Name), size.X, size.Y, item, bcDelegate); panel.Controls.Add(control); buttonList.Add(control); @@ -56,7 +63,7 @@ namespace Tanshu.Accounts.Helpers for (int i = 0; i < list.Count; i++) { var item = list[i]; - var control = GetButton(string.Format("p{0}", i), string.Format("{0} ({1})", item.Name, item.Units), size.X, size.Y, item, bcDelegate); + var control = GetButton(string.Format("p{0}", i), item.Units == string.Empty ? item.Name : string.Format("{0} ({1})", item.Name, item.Units), size.X, size.Y, item, bcDelegate); //var control = GetButton(string.Format("g{0}", i), string.Format("{0} {1}", item.ProductGroupID, item.Name), size.X, size.Y, item, bcDelegate); panel.Controls.Add(control); buttonList.Add(control); @@ -64,6 +71,24 @@ namespace Tanshu.Accounts.Helpers + } + public static void GenerateGroups(ref FlowLayoutPanel panel, ref IList controlList, Point size, IList list, ButtonClickDelegate bcDelegate) + { + if (controlList.Count != 0) + { + for (int i = controlList.Count - 1; i >= 0; i--) + { + controlList[i].Dispose(); + } + controlList = new List(); + } + for (int i = 0; i < list.Count; i++) + { + var item = list[i]; + var control = GetUnselectableCheckbox(i.ToString(), item.Name, size.X, size.Y, item, bcDelegate); + panel.Controls.Add(control); + controlList.Add(control); + } } public static void GenerateGroups(ref FlowLayoutPanel panel, ref List