1
using System;
2
using System.Data;
3
using System.Collections;
4
using System.Data.SqlClient;
5
using OnLineExam.DataAccessLayer;
6
using OnLineExam.DataAccessHelper;
7
8
9
namespace OnLineExam.BusinessLogicLayer
10
...{
11
//判断题类
12
public class JudgeProblem
13
...{
14
私有成员#region 私有成员
15
private int _ID; //题目编号
16
private int _CourseID; //所属科目
17
private string _Title; //题目
18
private bool _Answer; //答案
19
20
#endregion 私有成员
21
22
属性#region 属性
23
24
public int ID
25
...{
26
set
27
...{
28
this._ID = value;
29
}
30
get
31
...{
32
return this._ID;
33
}
34
}
35
public int CourseID
36
...{
37
set
38
...{
39
this._CourseID = value;
40
}
41
get
42
...{
43
return this._CourseID;
44
}
45
}
46
public string Title
47
...{
48
set
49
...{
50
this._Title = value;
51
}
52
get
53
...{
54
return this._Title;
55
}
56
}
57
public Boolean Answer
58
...{
59
set
60
...{
61
this._Answer = value;
62
}
63
get
64
...{
65
return this._Answer;
66
}
67
}
68
#endregion 属性
69
70
方法#region 方法
71
72
//根据题目ID 初始化题目
73
//输入:
74
// TID - 题目编号;
75
//输出:
76
// 题目存在:返回True;
77
// 题目不在:返回False;
78
public bool LoadData(int TID)
79
...{
80
SqlParameter[] Params = new SqlParameter[1];
81
DataBase DB = new DataBase();
82
83
Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //用户编号
84
85
DataSet ds = DB.GetDataSet("Proc_JudgeProblemDetail", Params);
86
ds.CaseSensitive = false;
87
DataRow DR;
88
if (ds.Tables[0].Rows.Count > 0)
89
...{
90
DR = ds.Tables[0].Rows[0];
91
this._CourseID = GetSafeData.ValidateDataRow_N(DR, "CourseID"); //科目编号
92
this._Title = GetSafeData.ValidateDataRow_S(DR, "Title"); //题目
93
this._Answer = GetSafeData.ValidateDataRow_B(DR, "Answer"); //答案
94
return true;
95
}
96
else
97
...{
98
return false;
99
}
100
}
101
102
103
//向SingleProblem表中添加题目信息(采用存储过程)
104
//输出:
105
// 插入成功:返回True;
106
// 插入失败:返回False;
107
public bool InsertByProc()
108
...{
109
SqlParameter[] Params = new SqlParameter[3];
110
111
DataBase DB = new DataBase();
112
113
Params[0] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, CourseID); //科目编号
114
Params[1] = DB.MakeInParam("@Title", SqlDbType.VarChar, 1000, Title); //题目
115
Params[2] = DB.MakeInParam("@Answer", SqlDbType.Bit,1, Answer); //答案A
116
117
int Count = -1;
118
Count = DB.RunProc("Proc_JudgeProblemAdd", Params);
119
if (Count > 0)
120
return true;
121
else return false;
122
}
123
124
//更新判断题的信息
125
public bool UpdateByProc(int TID)
126
...{
127
SqlParameter[] Params = new SqlParameter[4];
128
129
DataBase DB = new DataBase();
130
131
Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //题目编号
132
Params[1] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, CourseID); //科目编号
133
Params[2] = DB.MakeInParam("@Title", SqlDbType.VarChar, 1000, Title); //题目
134
Params[3] = DB.MakeInParam("@Answer", SqlDbType.Bit, 1, Answer); //答案
135
136
int Count = -1;
137
Count = DB.RunProc("Proc_JudgeProblemModify", Params);
138
if (Count > 0)
139
return true;
140
else return false;
141
}
142
143
144
//删除题目
145
//输入:
146
// TID - 题目编号;
147
//输出:
148
// 删除成功:返回True;
149
// 删除失败:返回False;
150
public bool DeleteByProc(int TID)
151
...{
152
SqlParameter[] Params = new SqlParameter[1];
153
154
DataBase DB = new DataBase();
155
156
Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //题目编号
157
158
int Count = -1;
159
Count = DB.RunProc("Proc_JudgeProblemDelete", Params);
160
if (Count > 0)
161
return true;
162
else return false;
163
}
164
165
//查询判断题
166
//课程编号
167
public DataSet QueryJudgeProblem(int TCourseID)
168
...{
169
SqlParameter[] Params = new SqlParameter[1];
170
171
DataBase DB = new DataBase();
172
173
Params[0] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, TCourseID); //题目编号
174
return DB.GetDataSet("Proc_JudgeProblemList", Params);
175
}
176
177
#endregion 方法
178
}
179
}