2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Contracts
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public enum BillItemType
|
|
|
|
|
{
|
|
|
|
|
Product,
|
2014-11-02 08:03:31 +00:00
|
|
|
|
Kot
|
2011-06-23 12:47:48 +00:00
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public class BillItemKey
|
|
|
|
|
{
|
2014-10-12 09:41:45 +00:00
|
|
|
|
private BillItemKey(Guid productID, Guid kotID, BillItemType billItemType)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
BillItemType = billItemType;
|
|
|
|
|
ProductID = productID;
|
|
|
|
|
KotID = kotID;
|
|
|
|
|
}
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public BillItemKey(Guid kotID)
|
|
|
|
|
: this(Guid.Empty, kotID, BillItemType.Kot)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{ }
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public BillItemKey(Guid productID, Guid kotID)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
: this(productID, kotID, BillItemType.Product)
|
|
|
|
|
{ }
|
|
|
|
|
|
2014-10-12 09:41:45 +00:00
|
|
|
|
private Guid _productID;
|
|
|
|
|
public Guid ProductID
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{
|
2014-10-12 09:41:45 +00:00
|
|
|
|
get { return BillItemType == BillItemType.Product ? _productID : Guid.Empty; }
|
|
|
|
|
private set { _productID = BillItemType == BillItemType.Product ? value : Guid.Empty; }
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public Guid KotID { get; private set; }
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public BillItemType BillItemType { get; private set; }
|
2014-11-02 08:03:31 +00:00
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return BillItemType.GetHashCode() ^ KotID.GetHashCode() ^ ProductID.GetHashCode();
|
|
|
|
|
}
|
|
|
|
|
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.KotID == b.KotID && a.BillItemType == b.BillItemType && a.ProductID == b.ProductID;
|
|
|
|
|
}
|
|
|
|
|
public static bool operator !=(BillItemKey a, BillItemKey b)
|
|
|
|
|
{
|
|
|
|
|
return !(a == b);
|
|
|
|
|
}
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj is BillItemKey)
|
|
|
|
|
return (this == (BillItemKey)obj);
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-02 08:03:31 +00:00
|
|
|
|
|
|
|
|
|
|