⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cart.cs

📁 人力资源管理系统
💻 CS
字号:
using System;
using System.Data ;
using COAdmin.COMMON;
using COAdmin.DAL ;

namespace COAdmin.BLL
{
	/// <summary>
	/// Cart 的摘要说明。
	/// </summary>
	public class Cart
	{
		public Cart()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		private int _cartID ;
		private int _orderID ;
		private int _custID ;
		private int _productID ;
		private double _unitPrice ;
		private int _orderNum ;
		private double _sellPrice ;
		private string _productName ;

		#region 公共属性
		public int CartID
		{
			get{ return _cartID ; }
			set{ _cartID = value ;}
		}

		public int OrderID
		{
			get{ return _orderID ; }
			set{ _orderID = value ;}
		}

		public int CustID
		{
			get{ return _custID ; }
			set{ _custID = value ;}
		}

		public int ProductID
		{
			get{ return _productID ; }
			set{ _productID = value ;}
		}

		public double UnitPrice
		{
			get{ return _unitPrice ; }
			set{ _unitPrice = value ;}
		}

		public int OrderNum
		{
			get{ return _orderNum ; }
			set{ _orderNum = value ;}
		}

		public double SellPrice
		{
			get{ return _sellPrice ; }
			set{ _sellPrice = value ;}
		}

		public string ProductName
		{
			get{ return _productName ; }
			set{ _productName = value ;}
		}
		#endregion

		/// <summary>
		/// 根据购物车ID获取购物车信息
		/// </summary>
		/// <param name="cartID">购物车ID</param>
		/// <returns></returns>
		public int GetCart(int cartID)
		{
			int ret = -1 ;

			//存储过程名
			string spName = "CO_Cart_Get" ;
			//存储过程参数
			object[] para = new object[] {cartID} ;

			DataTable dt = DataAccess.ExecuteDataTable(spName,para) ;
			if(dt.Rows.Count > 0)
			{
				DataRow dr = dt.Rows[0] ;
				AssignAttribute(dr) ;
				ret = 0 ;
			}
			return ret ;
		}

		/// <summary>
		/// 指定购物车属性
		/// </summary>
		/// <param name="dr">购物车行</param>
		private void AssignAttribute(DataRow dr)
		{
			_cartID = CommHandler.StringToInt(dr["CartID"].ToString()) ;
			_orderID = CommHandler.StringToInt(dr["OrderID"].ToString()) ;
			_custID = CommHandler.StringToInt(dr["CustID"].ToString()) ;
			_productID = CommHandler.StringToInt(dr["_productID"].ToString()) ;
			_unitPrice = CommHandler.StringToDouble(dr["UnitPrice"].ToString()) ;
			_orderNum = CommHandler.StringToInt(dr["OrderNum"].ToString()) ;
			_sellPrice = CommHandler.StringToDouble(dr["SellPrice"].ToString()) ;
			_productName = dr["ProductName"].ToString() ;
		}

		/// <summary>
		/// 根据订单ID查询购物车信息
		/// </summary>
		/// <param name="orderID">订单ID</param>
		/// <returns></returns>
		public static DataTable GetCartByOrderID(int orderID)
		{
			//存储过程名
			string spName = "CO_Cart_GetByOrderID" ;
			//存储过程参数
			object[] para = new object[] {orderID} ;

			return DataAccess.ExecuteDataTable(spName,para) ;			
		}

		/// <summary>
		/// 删除购物车
		/// </summary>
		/// <param name="cartID"></param>
		/// <returns></returns>
		public static int DeleteCart(int cartID)
		{
			//存储过程名
			string spName = "CO_Cart_Delete" ;

			//存储过程参数
			object[] para = new object[] {cartID} ;

			return DataAccess.ExecuteNonQuery(spName,false,para) ;

		}

		/// <summary>
		/// 添加购物车信息
		/// </summary>
		/// <returns></returns>
		public int AddCart()
		{
			int ret = -1 ;

			//存储过程名
			string spName = "CO_Cart_Add" ;
			//存储过程参数
			object[] para = new object[] {"",_orderID,_custID,_productID,_unitPrice,_orderNum,_sellPrice,_productName} ;

			//调用数据访问方法执行存储过程			
			ret = DataAccess.ExecuteNonQuery(spName,true,para) ;

			return ret ;
		}

		/// <summary>
		/// 修改购物车信息
		/// </summary>
		/// <returns></returns>
		public int ModifyCart()
		{
			int ret = -1 ;

			//存储过程名
			string spName = "CO_Cart_Modify" ;
			//存储过程参数
			object[] para = new object[] {_cartID,_orderID,_custID,_productID,_unitPrice,_orderNum,_sellPrice,_productName} ;

			//调用数据访问方法执行存储过程			
			ret = DataAccess.ExecuteNonQuery(spName,true,para) ;

			return ret ;
		}

		/// <summary>
		/// 根据商品代码查询商品信息
		/// </summary>
		/// <param name="code"></param>
		/// <returns></returns>
		public DataTable GetProdByCode(string code)
		{
			//存储过程名
			string spName = "CO_Product_GetByCode" ;
			//存储过程参数
			object[] para = new object[] {code} ;

			return DataAccess.ExecuteDataTable(spName,para) ;		

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -