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

📄 categoy.cs

📁 C#2005 实例源代码
💻 CS
字号:
/**********************************************************
 * 示例:Web系统的三层体系结构之
 * 业务逻辑层
 *********************************************************/

using System;
using System.Data;

using NorthWind.DataAccessLayer;

namespace NorthWind.BusinessLayer
{
	/// <summary>
	/// 获取种类类,一个Category对象表示一种货物种类
	/// </summary>
	public class Category
	{
		#region 私有成员

		private int _categoryID;		//编号
		private string _categoryName;	//名称
		private string _description;	//说明

		#endregion 私有成员

		#region 属性

		public int CategoryID
		{
			set
			{
				this._categoryID=value;
			}
			get
			{
				return this._categoryID;
			}
		}
		public string CategoryName
		{
			set
			{
				this._categoryName=value;
			}
			get
			{
				return this._categoryName;
			}
		}
		public string Description
		{
			set
			{
				this._description=value;
			}
			get
			{
				return this._description;
			}
		}

		#endregion 属性

		#region 方法
		/// <summary>
		/// 根据参数categoryID,获取货物详细信息
		/// </summary>
		/// <param name="categoryID">货物种类编号</param>
		public void LoadData(int categoryID)
		{
			Database db=new Database();		//实例化一个Database类

			string sql="Select * from Categories where CategoryID = "+categoryID;
			DataSet ds=db.GetDataSet(sql);	//利用Database类的GetSet方法查询数据

			//根据查询得到的数据,对私有成员赋值
			if(ds.Tables[0].Rows.Count>0)
			{
				this._categoryID=Convert.ToInt32(ds.Tables[0].Rows[0]["CategoryID"]);
				this._categoryName=ds.Tables[0].Rows[0]["CategoryName"].ToString();
				this._description=ds.Tables[0].Rows[0]["Description"].ToString();
			}
		}

		#endregion 方法
	}
}

⌨️ 快捷键说明

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