?? categoy.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 + -