📄 candidatepaper.cs
字号:
using System;
using System.Data;
using System.Configuration;
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 System.Data.Common;
#region CandidatePaper
/// <summary>
/// This object represents the properties and methods of a CandidatePaper.
/// </summary>
public class CandidatePaper
{
protected int _id;
protected string _teacherID = String.Empty;
protected string _title = String.Empty;
protected string _description = String.Empty;
protected string _reference = String.Empty;
protected DateTime _dateTime;
protected bool _isBeSelected;
public CandidatePaper()
{
}
public CandidatePaper(int id)
{
DbDataReader reader = DataAccess.ExecuteDataReader("usp_SelectCandidatePaper", false, new object[] { id });
if (reader.Read())
{
this.LoadFromReader(reader);
reader.Close();
}
else
{
if (!reader.IsClosed) reader.Close();
throw new ApplicationException("CandidatePaper does not exist.");
}
}
public CandidatePaper(DbDataReader reader)
{
this.LoadFromReader(reader);
}
protected void LoadFromReader(DbDataReader reader)
{
if (reader != null && !reader.IsClosed)
{
_id = reader.GetInt32(0);
if (!reader.IsDBNull(1)) _teacherID = reader.GetString(1);
if (!reader.IsDBNull(2)) _title = reader.GetString(2);
if (!reader.IsDBNull(3)) _description = reader.GetString(3);
if (!reader.IsDBNull(4)) _reference = reader.GetString(4);
if (!reader.IsDBNull(5)) _dateTime = reader.GetDateTime(5);
if (!reader.IsDBNull(6)) _isBeSelected = reader.GetBoolean(6);
}
}
#region Public Properties
public int Id
{
get {return _id;}
}
public string TeacherID
{
get {return _teacherID;}
set {_teacherID = value;}
}
public string Title
{
get {return _title;}
set {_title = value;}
}
public string Description
{
get {return _description;}
set {_description = value;}
}
public string Reference
{
get {return _reference;}
set {_reference = value;}
}
public DateTime DateTime
{
get {return _dateTime;}
set {_dateTime = value;}
}
public bool IsBeSelected
{
get {return _isBeSelected;}
set {_isBeSelected = value;}
}
#endregion
public static CandidatePaper GetCandidatePaper(int id)
{
return new CandidatePaper(id);
}
public static DataTable GetCandidatePapers(string teacherid)
{
string sql = "select * from CandidatePaper where teacherid='" + teacherid + "'";
return DataAccess.ExecuteDataTable(sql);
}
//获得可选论文列表
public static DataTable GetCanSelectedCandidatePapers(string teacherid)
{
string sql = "select * from CandidatePaper where teacherid='" + teacherid + "' and IsBeSelected=0";
return DataAccess.ExecuteDataTable(sql);
}
//通过论文ID获得老师ID
public static string GetTeacherIDByCandidatePaperID(int cpid)
{
string tid = "";
string sql = "select teacher.teacherid from teacher,CandidatePaper where " +
" teacher.teacherid=CandidatePaper.Teacherid and CandidatePaperID=" + cpid;
DbDataReader ddr = DataAccess.ExecuteDataReader(sql);
if (ddr.Read())
{
tid = ddr.GetString(0);
}
ddr.Close();
return tid;
}
//获得老师、学生、论文之间的关联关系
public static DataTable GetTeacherStudentPaperInfo(string studentid)
{
string sql = @"SELECT * from View_StudentTeacherPaper where StudentID = '" + studentid + "'";
return DataAccess.ExecuteDataTable(sql);
}
//老师插入备选论文。
public static int Insert(CandidatePaper cp)
{
return DataAccess.ExecuteNonQuery("usp_InsertCandidatePaper",false,new object[]
{ cp.TeacherID,cp.Title,cp.Description,cp.Reference,cp.DateTime,cp.IsBeSelected
});
}
}
#endregion
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -