📄 question.cs
字号:
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 的摘要说明
/// </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>
/// 根据参数获取试题信息
/// </summary>
/// <param name="questionID">试题编号</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);
//根据查询得到的数据,对成员赋值
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>
/// 向数据库添加试题
/// </summary>
/// <param name="topicInfo">试题信息哈希表</param>
public bool Add(Hashtable questionInfo)
{
Database db = new Database(); //实例化一个Database类
return db.Insert("[TQ_Questions]", questionInfo); //利用Database类的Inser方法,插入数据
}
/// <summary>
/// 修改试题内容
/// </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>
/// 查询试题信息
/// </summary>
/// <param name="queryItems">查询条件哈希表</param>
/// <returns>查询结果集</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
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -