?? question.cs
字號(hào):
?using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TQMS.DataAccessLayer;
using TQMS.DataAccessHelper;
namespace TQMS.BusinessLogicLayer
{
/// <summary>
/// Question 的摘要說(shuō)明
/// </summary>
public class Question
{
#region 私有成員
private int _questionID;
private string _questionContent;
private string _rightAnser;
private string _imageUrl;
private int _chapterID;
private int _type;
private int _diffcultLevel;
private int _UserID;
private DateTime _addTime;
private DateTime _editTime;
private bool _exist;
#endregion
#region 屬性
public int QuestionID
{
set
{
this._questionID = value;
}
get
{
return this._questionID;
}
}
public string QuestionContent
{
set
{
this._questionContent = value;
}
get
{
return this._questionContent;
}
}
public string RightAnser
{
set
{
this._rightAnser = value;
}
get
{
return this._rightAnser;
}
}
public string ImageUrl
{
set
{
this._imageUrl = value;
}
get
{
return this._imageUrl;
}
}
public int ChapterID
{
set
{
this._chapterID = value;
}
get
{
return this._chapterID;
}
}
public int Type
{
set
{
this._type = value;
}
get
{
return this._type;
}
}
public int DifficultLevel
{
set
{
this._diffcultLevel = value;
}
get
{
return this._diffcultLevel;
}
}
public int UserID
{
set
{
this._UserID = value;
}
get
{
return this._UserID;
}
}
public DateTime AddTime
{
set
{
this._addTime = value;
}
get
{
return this._addTime;
}
}
public DateTime EditTime
{
set
{
this._editTime = value;
}
get
{
return this._editTime;
}
}
public bool Exist
{
set
{
this._exist = value;
}
get
{
return this._exist;
}
}
#endregion
#region 方法
/// <summary>
/// 根據(jù)參數(shù)獲取試題信息
/// </summary>
/// <param name="questionID">試題編號(hào)</param>
public void LoadData(int questionID)
{
Database db = new Database();
string sql = "Select * from TQ_Questions where TQ_QuestionID=" + questionID;
DataRow dr = db.GetDataRow(sql);
//根據(jù)查詢得到的數(shù)據(jù),對(duì)成員賦值
if (dr != null)
{
this._questionID = GetSafeData.ValidateDataRow_N(dr, "TQ_QuestionID");
this._questionContent = GetSafeData.ValidateDataRow_S(dr, "TQ_QuestionContent");
this._rightAnser= GetSafeData.ValidateDataRow_S(dr, "TQ_RightAnser");
this._imageUrl = GetSafeData.ValidateDataRow_S(dr, "TQ_ImageUrl");
this._chapterID = GetSafeData.ValidateDataRow_N(dr, "TQ_ChapterID");
this._type = GetSafeData.ValidateDataRow_N(dr, "TQ_Type");
this._diffcultLevel = GetSafeData.ValidateDataRow_N(dr, "TQ_DifficultyLevel");
this._UserID= GetSafeData.ValidateDataRow_N(dr, "TQ_UserID");
this._addTime = GetSafeData.ValidateDataRow_T(dr, "TQ_AddTime");
this._editTime = GetSafeData.ValidateDataRow_T(dr, "TQ_LastEditTime");
this._exist = true;
}
else
{
this._exist = false;
}
}
/// <summary>
/// 向數(shù)據(jù)庫(kù)添加試題
/// </summary>
/// <param name="topicInfo">試題信息哈希表</param>
public bool Add(Hashtable questionInfo)
{
Database db = new Database(); //實(shí)例化一個(gè)Database類
return db.Insert("[TQ_Questions]", questionInfo); //利用Database類的Inser方法,插入數(shù)據(jù)
}
/// <summary>
/// 修改試題內(nèi)容
/// </summary>
/// <param name="newBookInfo">新的試題信息哈希表</param>
/// <param name="condition">Update的Where子句</param>
public bool Update(Hashtable newQuestionInfo)
{
Database db = new Database();
string condition = "Where TQ_QuestionID = " + this._questionID;
return db.Update("[TQ_Questions]", newQuestionInfo, condition);
}
/// <summary>
/// 刪除試題
/// </summary>
public bool Delete()
{
Database db = new Database();
string strSql = "Delete From [TQ_Questions] Where TQ_QuestionID = " + this._questionID;
int i=db.ExecuteSQL(strSql);
if (i > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 查詢?cè)囶}信息
/// </summary>
/// <param name="queryItems">查詢條件哈希表</param>
/// <returns>查詢結(jié)果集</returns>
public static DataTable QueryQuestion(Hashtable queryItems)
{
string where = SqlStringConstructor.GetConditionClause(queryItems);
string sql = "Select * From [TQ_Questions] " + where +" ORDER BY [TQ_Type]";
Database db = new Database();
return db.GetDataTable(sql);
}
#endregion
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -