narsil/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs
unknown d8ecec8bb6 Added inverse Attribute to ProductGroup.
BillInventory Renamed.
Refactored Bill to be more usable.
Added Bill Detail Report.
Added Open Bill and Bill Details Roles.
Zero Rate Products have Yellow background Color.
Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI,
Cached the Products List.
Product and Product Group Form Working.
2011-06-23 18:17:48 +05:30

80 lines
2.5 KiB
C#

using System;
namespace Tanshu.Accounts.Contracts
{
public enum BillItemType
{
Product,
Kot
}
public class BillItemKey
{
private BillItemKey(int productID, int kotID, BillItemType billItemType)
{
if (kotID < 0)
throw new ArgumentException("KotID Cannot be Negative");
if (productID < 0)
throw new ArgumentException("ProductID Cannot be Negative");
BillItemType = billItemType;
ProductID = productID;
KotID = kotID;
}
public BillItemKey(int kotID)
: this(0, kotID, BillItemType.Kot)
{ }
public BillItemKey(int productID, int kotID)
: this(productID, kotID, BillItemType.Product)
{ }
private int _productID;
public int ProductID
{
get { return BillItemType == BillItemType.Product ? _productID : 0; }
private set { _productID = BillItemType == BillItemType.Product ? value : 0; }
}
public int KotID { get; private set; }
public BillItemType BillItemType { get; private set; }
public override int GetHashCode()
{
return BillItemType == BillItemType.Product ?
ProductID.GetHashCode() ^ KotID.GetHashCode() ^ BillItemType.GetHashCode()
: KotID.GetHashCode() ^ BillItemType.GetHashCode(); ;
}
public override bool Equals(object obj)
{
if (obj is BillItemKey)
return (this == (BillItemKey)obj);
else
return false;
}
public override string ToString()
{
return string.Format("{0} - {1}", ProductID, KotID);
}
public static bool operator ==(BillItemKey a, BillItemKey b)
{
if (object.ReferenceEquals(null, a))
return object.ReferenceEquals(null, b);
if (!(a is BillItemKey))
return false;
if (!(b is BillItemKey))
return false;
if (a.BillItemType != b.BillItemType)
return false;
return a.BillItemType == BillItemType.Product ?
a.ProductID == b.ProductID && a.KotID == b.KotID && a.BillItemType == b.BillItemType
: a.KotID == b.KotID && a.BillItemType == b.BillItemType;
}
public static bool operator !=(BillItemKey a, BillItemKey b)
{
return !(a == b);
}
}
}