购物车 物品操作 things

public class thing
{
    
public thing()
    {
    }
    
string strId;    //商品ID
    string strTitle;   //商品名称
    decimal price;  //普通会员价格
    decimal vipPrice;  //高级会员价格
    int num;   //购物数量
    decimal sum = 0m;   //总金额
    decimal vipsum = 0m;  //VIP总金额

    
public string StrId
    {
        
get
        {
            
return strId;
        }
        
set
        {
            strId 
= value;
        }
    }
    
public string StrTitle
    {
        
get
        {
            
return strTitle;
        }
        
set
        {
            strTitle 
= value;
        }
    }
    
public decimal Price
    {
        
get
        {
            
return price;
        }
        
set
        {
            price 
= value;
            sum 
= price * num;
        }
    }
    
public decimal VIPPrice
    {
        
get
        {
            
return vipPrice;
        }
        
set
        {
            vipPrice 
= value;
            vipsum 
= vipPrice * num;
        }
    }
    
public int Num
    {
        
get
        {
            
return num;
        }
        
set
        {
            num 
= value;
            sum 
= price * num;
            vipsum 
= vipPrice * num;
        }
    }
    
public decimal Sum
    {
        
get
        {
            
return sum;
        }
        
set
        {
            sum 
= value;
        }
    }
    
public decimal VIPSum
    {
        
get
        {
            
return vipsum;
        }
        
set
        {
            vipsum 
= value;
        }
    }




    
public class things : IEnumerable
    {
        Hashtable ht 
= null;
        
public things()
        {
            ht 
= new Hashtable();

        }
        
public things(int count)
        {
            ht 
= new Hashtable(count);
        }

        
//添加 数量
        public void Add(thing t)
        {
            
if (ht.ContainsKey(t.StrId))
            {
                ((thing)ht[t.StrId]).Num 
= ((thing)ht[t.StrId]).Num + t.Num;
            }
            
else
            {
                ht.Add(t.StrId, t);
            }
        }

        
//删除
        public void Remove(string strId)
        {
            
if (ht.ContainsKey(strId))
            {
                ht.Remove(strId);
            }
        }

        
//清空所有
        public void Clear()
        {
            ht.Clear();
        }

        
//总件数
        public int Count
        {
            
get
            {
                
return ht.Count;
            }
        }

        
//更新 数量
        public void Update(string strId, int i)
        {
            
if (ht.ContainsKey(strId))
            {
                ((thing)ht[strId]).Num 
= i;
            }
        }

        
//返回一个物品的所有
        public thing this[string strId]
        {
            
get
            {
                
if (ht.ContainsKey(strId))
                {
                    
return ((thing)ht[strId]);
                }
                
else
                {
                    
return null;
                }
            }
        }
        
//总价
        public decimal sumprice()
        {
            
decimal price = 0m;
            
foreach (DictionaryEntry de in ht)
            {
                price 
+= ((thing)(de.Value)).Sum;
            }
            
return price;
        }

        
//高级会员价格统计
        public decimal vipsumprice()
        {
            
decimal price = 0m;
            
foreach (DictionaryEntry de in ht)
            {
                price 
+= ((thing)(de.Value)).VIPSum;
            }
            
return price;
        }

        
//注册接口
        public IEnumerator GetEnumerator()
        {
            
// TODO:  添加 Books.GetEnumerator 实现
            return ht.Values.GetEnumerator();
        }

    }





    
public class order
    {
        
//string odid;   //记录订单主键
        string oDName;   //订单名
        decimal oDPrice;
        
string bName;  //买家姓名
        string bEmail;   //买家email
        string bTel;  //买家联系电话
        string shipInfo;  //送货信息
        string shipMethod;  //送货方式
        string payMethod;   //支付方式
        things ts;   //用于接收商品列表
        public order()
        {
        }

        
public decimal ODPrice
        {
            
get
            {
                
return oDPrice;
            }
            
set
            {
                oDPrice 
= value;
            }
        }
        
public string ODName
        {
            
get
            {
                
return oDName;
            }
            
set
            {
                oDName 
= value;
            }
        }

        
public things Things
        {
            
get
            {
                
return ts;
            }
            
set
            {
                ts 
= value;
            }
        }

        
public string BName
        {
            
get
            {
                
return bName;
            }
            
set
            {
                bName 
= value;
            }
        }
        
public string BEmail
        {
            
get
            {
                
return bEmail;
            }
            
set
            {
                bEmail 
= value;
            }
        }
        
public string BTel
        {
            
get
            {
                
return bTel;
            }
            
set
            {
                bTel 
= value;
            }
        }
        
public string ShipInfo
        {
            
get
            {
                
return shipInfo;
            }
            
set
            {
                shipInfo 
= value;
            }
        }
        
public string ShipMethod
        {
            
get
            {
                
return shipMethod;
            }
            
set
            {
                shipMethod 
= value;
            }
        }
        
public string PayMethod
        {
            
get
            {
                
return payMethod;
            }
            
set
            {
                payMethod 
= value;
            }
        }
    }
posted @ 2009-09-12 15:26  曾祥展  阅读(439)  评论(0编辑  收藏  举报